diff --git "a/validation.jsonl" "b/validation.jsonl" new file mode 100644--- /dev/null +++ "b/validation.jsonl" @@ -0,0 +1,1000 @@ +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_medium_0308de8d", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nresult = very_long_function_call_v1781(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v1781(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_hard_676cb176", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nresult = very_long_function_call_v1546(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v1546(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_medium_6618547c", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef function_v602():\n # Buggy: range(1, n)\n x = 10\n result = x range(1, n) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is range: using 'range(1, n)' instead of 'range(n)'.\n\n**Improved code:**\n```python\ndef function_v602():\n # Fixed: range(n)\n x = 10\n result = x range(n) 2\n return result\n```", "sample_id": "python_medium_38435872", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_easy_6369782a", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_hard_7153cec6", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_easy_33d47fde", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef add_v258(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v258(a: int, b: int) -> int:\n```", "sample_id": "python_medium_f3d75ed5", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef function_v1977():\n # Buggy: /\n x = 10\n result = x / 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is division: using '/' instead of '//'.\n\n**Improved code:**\n```python\ndef function_v1977():\n # Fixed: //\n x = 10\n result = x // 2\n return result\n```", "sample_id": "python_easy_5a4f6f79", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v874):\n```", "sample_id": "python_medium_bd50ec1d", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_hard_7673ea8a", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_medium_6f2ce38b", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_medium_17de1f3f", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\nfor i in range(n_v415):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v415):\n if condition:\n break\n```", "sample_id": "python_medium_be37c9ce", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_easy_1485a906", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v1785):\n```", "sample_id": "python_medium_036186ba", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef process_v1121():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v1121():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_hard_7728ac74", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_medium_3988ac6d", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef check_value(x, y):\n if x = y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '=' instead of '=='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x == y:\n return True\n return False\n```", "sample_id": "python_easy_122aafb5", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef function_v1428():\n # Buggy: '{}'.format(x)\n x = 10\n result = x '{}'.format(x) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is string format: using ''{}'.format(x)' instead of 'f'{x}''.\n\n**Improved code:**\n```python\ndef function_v1428():\n # Fixed: f'{x}'\n x = 10\n result = x f'{x}' 2\n return result\n```", "sample_id": "python_medium_91aeda7e", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef function_v234():\n # Buggy: '{}'.format(x)\n x = 10\n result = x '{}'.format(x) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is string format: using ''{}'.format(x)' instead of 'f'{x}''.\n\n**Improved code:**\n```python\ndef function_v234():\n # Fixed: f'{x}'\n x = 10\n result = x f'{x}' 2\n return result\n```", "sample_id": "python_easy_c2bdc4de", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_medium_1bfd9e5d", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_hard_17de1f3f", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef add_v616(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v616(a: int, b: int) -> int:\n```", "sample_id": "python_easy_7b4d4e5a", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef add_v905(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v905(a: int, b: int) -> int:\n```", "sample_id": "python_easy_8778efa4", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef check_value(x, y):\n if x = y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '=' instead of '=='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x == y:\n return True\n return False\n```", "sample_id": "python_easy_d5b7f2b1", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef process_v763():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v763():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_easy_85c72700", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_hard_5861437c", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_easy_4497e4c9", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nfor i in range(n_v1288):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v1288):\n if condition:\n break\n```", "sample_id": "python_medium_6dbfed9e", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef process_v1950():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v1950():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_medium_7c9eb81e", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_hard_7153cec6", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef calc_v854(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v854(first_number, second_number):\n```", "sample_id": "python_medium_91c0bfa7", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef calc_v1204(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v1204(first_number, second_number):\n```", "sample_id": "python_easy_fc7a5f6a", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef process_v404():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v404():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_medium_d22a8b9c", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef function_v758():\n # Buggy: '{}'.format(x)\n x = 10\n result = x '{}'.format(x) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is string format: using ''{}'.format(x)' instead of 'f'{x}''.\n\n**Improved code:**\n```python\ndef function_v758():\n # Fixed: f'{x}'\n x = 10\n result = x f'{x}' 2\n return result\n```", "sample_id": "python_medium_44c477a2", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\nresult = very_long_function_call_v159(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v159(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_hard_662063a3", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef process_v175():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v175():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_medium_cf7b061c", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef check_value(x, y):\n if x > y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '>' instead of '>='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x >= y:\n return True\n return False\n```", "sample_id": "python_medium_625692f9", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef calc_v826(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v826(first_number, second_number):\n```", "sample_id": "python_medium_37d62ea3", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_medium_3988ac6d", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_medium_63b3af67", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef check_value(x, y):\n if x > y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '>' instead of '>='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x >= y:\n return True\n return False\n```", "sample_id": "python_easy_625692f9", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_medium_1485a906", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_medium_1485a906", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef process(obj):\n if obj:\n return obj.value\n return None\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is null check: using 'if obj:' instead of 'if obj is not None:'.\n\n**Improved code:**\n```python\ndef process(obj):\n if obj is not None:\n return obj.value\n return None\n```", "sample_id": "python_medium_819ae0ca", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_medium_7673ea8a", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_medium_f1ad7498", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_hard_50a18830", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef add_v503(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v503(a: int, b: int) -> int:\n```", "sample_id": "python_medium_ca8df843", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_hard_de2f3509", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef function_v1944():\n # Buggy: '{}'.format(x)\n x = 10\n result = x '{}'.format(x) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is string format: using ''{}'.format(x)' instead of 'f'{x}''.\n\n**Improved code:**\n```python\ndef function_v1944():\n # Fixed: f'{x}'\n x = 10\n result = x f'{x}' 2\n return result\n```", "sample_id": "python_easy_38a0da7f", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_easy_0faa9843", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_medium_5861437c", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_easy_0faa9843", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nfor i in range(n_v1813):\n for j in range(n_v1813):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v1813):\n for j in range(i+1, n):\n```", "sample_id": "python_medium_e905e709", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef function_v1634():\n # Buggy: ==\n x = 10\n result = x == 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is assignment: using '==' instead of '='.\n\n**Improved code:**\n```python\ndef function_v1634():\n # Fixed: =\n x = 10\n result = x = 2\n return result\n```", "sample_id": "python_medium_64601db1", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nfor i in range(n_v617):\n for j in range(n_v617):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v617):\n for j in range(i+1, n):\n```", "sample_id": "python_hard_ae562440", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef function_v369():\n # Buggy: list = list + [x]\n x = 10\n result = x list = list + [x] 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is list append: using 'list = list + [x]' instead of 'list.append(x)'.\n\n**Improved code:**\n```python\ndef function_v369():\n # Fixed: list.append(x)\n x = 10\n result = x list.append(x) 2\n return result\n```", "sample_id": "python_easy_c9fe8c0a", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef function_v1392():\n # Buggy: /\n x = 10\n result = x / 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is division: using '/' instead of '//'.\n\n**Improved code:**\n```python\ndef function_v1392():\n # Fixed: //\n x = 10\n result = x // 2\n return result\n```", "sample_id": "python_easy_88583cfe", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef get_last_element(arr):\n return arr[len(arr)]\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is index: using 'arr[len(arr)]' instead of 'arr[len(arr)-1]'.\n\n**Improved code:**\n```python\ndef get_last_element(arr):\n return arr[len(arr)-1]\n```", "sample_id": "python_easy_81c17ab2", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_easy_0faa9843", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_hard_1485a906", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef process_v169():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v169():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_hard_7fd9910b", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_easy_7153cec6", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_easy_6f2ce38b", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_medium_cb24a338", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef check_value(x, y):\n if x = y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '=' instead of '=='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x == y:\n return True\n return False\n```", "sample_id": "python_medium_5f2fc867", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_hard_3988ac6d", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef process_v497():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v497():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_easy_5eec6dcf", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_easy_7153cec6", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_hard_1485a906", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_hard_a92c2d8e", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef add_v1408(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v1408(a: int, b: int) -> int:\n```", "sample_id": "python_easy_29278ca1", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v1606):\n```", "sample_id": "python_medium_9425c75a", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_medium_cb24a338", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_medium_17de1f3f", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_hard_3ca9041c", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_medium_8d441813", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_medium_3b59d906", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_hard_bfafafb6", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nresult = very_long_function_call_v1553(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v1553(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_hard_2dce10ff", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_medium_6369782a", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_hard_f1ad7498", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef check_value(x, y):\n if x = y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '=' instead of '=='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x == y:\n return True\n return False\n```", "sample_id": "python_easy_122aafb5", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_medium_0faa9843", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef function_v386():\n # Buggy: '{}'.format(x)\n x = 10\n result = x '{}'.format(x) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is string format: using ''{}'.format(x)' instead of 'f'{x}''.\n\n**Improved code:**\n```python\ndef function_v386():\n # Fixed: f'{x}'\n x = 10\n result = x f'{x}' 2\n return result\n```", "sample_id": "python_medium_53d29f67", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef check_value(x, y):\n if x = y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '=' instead of '=='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x == y:\n return True\n return False\n```", "sample_id": "python_medium_5f2fc867", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_hard_1bfd9e5d", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v1363):\n```", "sample_id": "python_hard_6bcf6a53", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nfor i in range(n_v1144):\n for j in range(n_v1144):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v1144):\n for j in range(i+1, n):\n```", "sample_id": "python_medium_23ce360f", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_easy_a92c2d8e", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_easy_a92c2d8e", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_medium_7673ea8a", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef check_value(x, y):\n if x = y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '=' instead of '=='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x == y:\n return True\n return False\n```", "sample_id": "python_medium_d5b7f2b1", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef function_v1304():\n # Buggy: range(1, n)\n x = 10\n result = x range(1, n) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is range: using 'range(1, n)' instead of 'range(n)'.\n\n**Improved code:**\n```python\ndef function_v1304():\n # Fixed: range(n)\n x = 10\n result = x range(n) 2\n return result\n```", "sample_id": "python_easy_c0236470", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_easy_3988ac6d", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_medium_cb24a338", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_medium_6f2ce38b", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_hard_7673ea8a", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_easy_0faa9843", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef add_v330(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v330(a: int, b: int) -> int:\n```", "sample_id": "python_medium_667c316b", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_easy_a92c2d8e", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef function_v355():\n # Buggy: list = list + [x]\n x = 10\n result = x list = list + [x] 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is list append: using 'list = list + [x]' instead of 'list.append(x)'.\n\n**Improved code:**\n```python\ndef function_v355():\n # Fixed: list.append(x)\n x = 10\n result = x list.append(x) 2\n return result\n```", "sample_id": "python_medium_a8197b72", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef process_v1713():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v1713():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_hard_9a826f2b", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef function_v806():\n # Buggy: /\n x = 10\n result = x / 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is division: using '/' instead of '//'.\n\n**Improved code:**\n```python\ndef function_v806():\n # Fixed: //\n x = 10\n result = x // 2\n return result\n```", "sample_id": "python_medium_0a2255dd", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_hard_cb24a338", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nresult = very_long_function_call_v127(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v127(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_easy_72c9cb65", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_hard_0faa9843", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef function_v1390():\n # Buggy: /\n x = 10\n result = x / 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is division: using '/' instead of '//'.\n\n**Improved code:**\n```python\ndef function_v1390():\n # Fixed: //\n x = 10\n result = x // 2\n return result\n```", "sample_id": "python_easy_22045dba", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_medium_1485a906", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_medium_3b59d906", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_medium_6369782a", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef function_v188():\n # Buggy: '{}'.format(x)\n x = 10\n result = x '{}'.format(x) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is string format: using ''{}'.format(x)' instead of 'f'{x}''.\n\n**Improved code:**\n```python\ndef function_v188():\n # Fixed: f'{x}'\n x = 10\n result = x f'{x}' 2\n return result\n```", "sample_id": "python_medium_5e27a40a", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef calc_v460(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v460(first_number, second_number):\n```", "sample_id": "python_hard_a88b44e4", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(n_v1133):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v1133):\n if condition:\n break\n```", "sample_id": "python_medium_8f372094", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_medium_3988ac6d", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef function_v988():\n # Buggy: ==\n x = 10\n result = x == 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is assignment: using '==' instead of '='.\n\n**Improved code:**\n```python\ndef function_v988():\n # Fixed: =\n x = 10\n result = x = 2\n return result\n```", "sample_id": "python_medium_6e28ce96", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_hard_3988ac6d", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef function_v179():\n # Buggy: list = list + [x]\n x = 10\n result = x list = list + [x] 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is list append: using 'list = list + [x]' instead of 'list.append(x)'.\n\n**Improved code:**\n```python\ndef function_v179():\n # Fixed: list.append(x)\n x = 10\n result = x list.append(x) 2\n return result\n```", "sample_id": "python_easy_00824eba", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef add_v738(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v738(a: int, b: int) -> int:\n```", "sample_id": "python_medium_2cbe24a7", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef check_value(x, y):\n if x > y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '>' instead of '>='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x >= y:\n return True\n return False\n```", "sample_id": "python_medium_e2da8820", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef add_v814(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v814(a: int, b: int) -> int:\n```", "sample_id": "python_hard_e31e115b", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_hard_de2f3509", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef add_v1810(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v1810(a: int, b: int) -> int:\n```", "sample_id": "python_hard_65c5b02c", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nfor i in range(n_v1691):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v1691):\n if condition:\n break\n```", "sample_id": "python_medium_fc828a7b", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_medium_3b59d906", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_hard_e96dfa9a", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nresult = very_long_function_call_v1926(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v1926(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_hard_b47d1837", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef calc_v521(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v521(first_number, second_number):\n```", "sample_id": "python_hard_8d6d6d49", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_medium_723519b4", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef get_last_element(arr):\n return arr[len(arr)]\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is index: using 'arr[len(arr)]' instead of 'arr[len(arr)-1]'.\n\n**Improved code:**\n```python\ndef get_last_element(arr):\n return arr[len(arr)-1]\n```", "sample_id": "python_easy_3560e64c", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef get_last_element(arr):\n return arr[len(arr)]\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is index: using 'arr[len(arr)]' instead of 'arr[len(arr)-1]'.\n\n**Improved code:**\n```python\ndef get_last_element(arr):\n return arr[len(arr)-1]\n```", "sample_id": "python_medium_7c94bab7", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef check_value(x, y):\n if x = y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '=' instead of '=='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x == y:\n return True\n return False\n```", "sample_id": "python_easy_d5b7f2b1", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef check_value(x, y):\n if x = y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '=' instead of '=='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x == y:\n return True\n return False\n```", "sample_id": "python_medium_122aafb5", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef check_value(x, y):\n if x > y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '>' instead of '>='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x >= y:\n return True\n return False\n```", "sample_id": "python_medium_90db5188", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nfor i in range(n_v1627):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v1627):\n if condition:\n break\n```", "sample_id": "python_hard_5571687b", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef function_v1180():\n # Buggy: ==\n x = 10\n result = x == 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is assignment: using '==' instead of '='.\n\n**Improved code:**\n```python\ndef function_v1180():\n # Fixed: =\n x = 10\n result = x = 2\n return result\n```", "sample_id": "python_easy_81987e08", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_medium_3988ac6d", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef calc_v736(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v736(first_number, second_number):\n```", "sample_id": "python_easy_f876121c", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_easy_a92c2d8e", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_medium_a92c2d8e", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_medium_3b59d906", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_easy_17de1f3f", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_easy_1485a906", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_easy_0faa9843", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_hard_ce9f3f46", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\nresult = very_long_function_call_v868(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v868(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_easy_78ad2184", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_medium_7153cec6", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_medium_7673ea8a", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_hard_0faa9843", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef get_last_element(arr):\n return arr[len(arr)]\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is index: using 'arr[len(arr)]' instead of 'arr[len(arr)-1]'.\n\n**Improved code:**\n```python\ndef get_last_element(arr):\n return arr[len(arr)-1]\n```", "sample_id": "python_easy_65909c9b", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_medium_7673ea8a", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_easy_3988ac6d", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef function_v120():\n # Buggy: range(1, n)\n x = 10\n result = x range(1, n) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is range: using 'range(1, n)' instead of 'range(n)'.\n\n**Improved code:**\n```python\ndef function_v120():\n # Fixed: range(n)\n x = 10\n result = x range(n) 2\n return result\n```", "sample_id": "python_easy_6f993c5e", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef process_v1982():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v1982():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_easy_db28807f", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_easy_de2f3509", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_hard_a92c2d8e", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_hard_6f2ce38b", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(n_v598):\n for j in range(n_v598):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v598):\n for j in range(i+1, n):\n```", "sample_id": "python_hard_4ce3fc52", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef check_value(x, y):\n if x > y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '>' instead of '>='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x >= y:\n return True\n return False\n```", "sample_id": "python_medium_90db5188", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef calc_v1665(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v1665(first_number, second_number):\n```", "sample_id": "python_easy_1e2dfdf6", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef function_v1412():\n # Buggy: list = list + [x]\n x = 10\n result = x list = list + [x] 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is list append: using 'list = list + [x]' instead of 'list.append(x)'.\n\n**Improved code:**\n```python\ndef function_v1412():\n # Fixed: list.append(x)\n x = 10\n result = x list.append(x) 2\n return result\n```", "sample_id": "python_easy_337dd013", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef process_v1618():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v1618():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_medium_accaf14c", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef function_v1431():\n # Buggy: list = list + [x]\n x = 10\n result = x list = list + [x] 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is list append: using 'list = list + [x]' instead of 'list.append(x)'.\n\n**Improved code:**\n```python\ndef function_v1431():\n # Fixed: list.append(x)\n x = 10\n result = x list.append(x) 2\n return result\n```", "sample_id": "python_easy_a2b214f0", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v1644):\n```", "sample_id": "python_hard_8fdb40df", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_hard_50a18830", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_medium_f1ad7498", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_hard_de2f3509", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef function_v881():\n # Buggy: /\n x = 10\n result = x / 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is division: using '/' instead of '//'.\n\n**Improved code:**\n```python\ndef function_v881():\n # Fixed: //\n x = 10\n result = x // 2\n return result\n```", "sample_id": "python_easy_10a4d380", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_hard_63b3af67", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_hard_7153cec6", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef function_v441():\n # Buggy: ==\n x = 10\n result = x == 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is assignment: using '==' instead of '='.\n\n**Improved code:**\n```python\ndef function_v441():\n # Fixed: =\n x = 10\n result = x = 2\n return result\n```", "sample_id": "python_easy_c20501a2", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_medium_0faa9843", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef process_v1935():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v1935():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_medium_734340d0", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nresult = very_long_function_call_v732(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v732(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_medium_fd70148f", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nfor i in range(n_v757):\n for j in range(n_v757):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v757):\n for j in range(i+1, n):\n```", "sample_id": "python_medium_2ca220e1", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef function_v1529():\n # Buggy: /\n x = 10\n result = x / 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is division: using '/' instead of '//'.\n\n**Improved code:**\n```python\ndef function_v1529():\n # Fixed: //\n x = 10\n result = x // 2\n return result\n```", "sample_id": "python_medium_52977e61", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nresult = very_long_function_call_v788(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v788(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_easy_bc95b29f", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v888):\n```", "sample_id": "python_medium_3ab65050", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_hard_de2f3509", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_easy_1485a906", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef check_value(x, y):\n if x = y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '=' instead of '=='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x == y:\n return True\n return False\n```", "sample_id": "python_easy_122aafb5", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nfor i in range(n_v464):\n for j in range(n_v464):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v464):\n for j in range(i+1, n):\n```", "sample_id": "python_medium_4ea49879", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef check_value(x, y):\n if x = y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '=' instead of '=='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x == y:\n return True\n return False\n```", "sample_id": "python_medium_9cfea75d", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_medium_6f2ce38b", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_hard_7153cec6", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_easy_0308de8d", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef add_v499(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v499(a: int, b: int) -> int:\n```", "sample_id": "python_easy_a13557f8", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_medium_1485a906", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_medium_17de1f3f", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_easy_3988ac6d", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef process(obj):\n if obj:\n return obj.value\n return None\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is null check: using 'if obj:' instead of 'if obj is not None:'.\n\n**Improved code:**\n```python\ndef process(obj):\n if obj is not None:\n return obj.value\n return None\n```", "sample_id": "python_easy_eac796f4", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef process(obj):\n if obj:\n return obj.value\n return None\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is null check: using 'if obj:' instead of 'if obj is not None:'.\n\n**Improved code:**\n```python\ndef process(obj):\n if obj is not None:\n return obj.value\n return None\n```", "sample_id": "python_medium_0946810e", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_medium_17de1f3f", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_medium_de2f3509", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nfor i in range(n_v1073):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v1073):\n if condition:\n break\n```", "sample_id": "python_hard_9782f28b", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef function_v1488():\n # Buggy: '{}'.format(x)\n x = 10\n result = x '{}'.format(x) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is string format: using ''{}'.format(x)' instead of 'f'{x}''.\n\n**Improved code:**\n```python\ndef function_v1488():\n # Fixed: f'{x}'\n x = 10\n result = x f'{x}' 2\n return result\n```", "sample_id": "python_medium_a768851b", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_medium_50a18830", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_hard_de2f3509", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(n_v1469):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v1469):\n if condition:\n break\n```", "sample_id": "python_medium_a948f42e", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_hard_cb24a338", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nresult = very_long_function_call_v955(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v955(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_medium_740746c0", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_hard_8d441813", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_hard_cb24a338", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_hard_50a18830", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_easy_6369782a", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_hard_17de1f3f", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_hard_a92c2d8e", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_hard_6f2ce38b", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v167):\n```", "sample_id": "python_medium_6bd558c0", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_medium_ce9f3f46", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_medium_1485a906", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_medium_1485a906", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_hard_a92c2d8e", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nfor i in range(n_v1417):\n for j in range(n_v1417):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v1417):\n for j in range(i+1, n):\n```", "sample_id": "python_medium_becac17b", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef get_last_element(arr):\n return arr[len(arr)]\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is index: using 'arr[len(arr)]' instead of 'arr[len(arr)-1]'.\n\n**Improved code:**\n```python\ndef get_last_element(arr):\n return arr[len(arr)-1]\n```", "sample_id": "python_easy_81c17ab2", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_easy_1485a906", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_medium_cb24a338", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_medium_6f2ce38b", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef function_v1540():\n # Buggy: list = list + [x]\n x = 10\n result = x list = list + [x] 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is list append: using 'list = list + [x]' instead of 'list.append(x)'.\n\n**Improved code:**\n```python\ndef function_v1540():\n # Fixed: list.append(x)\n x = 10\n result = x list.append(x) 2\n return result\n```", "sample_id": "python_medium_7208735c", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_hard_7153cec6", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_hard_de2f3509", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef function_v1603():\n # Buggy: /\n x = 10\n result = x / 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is division: using '/' instead of '//'.\n\n**Improved code:**\n```python\ndef function_v1603():\n # Fixed: //\n x = 10\n result = x // 2\n return result\n```", "sample_id": "python_medium_070261d3", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_easy_6369782a", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_easy_7673ea8a", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nresult = very_long_function_call_v647(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v647(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_hard_27bd0731", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_easy_de2f3509", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef function_v1235():\n # Buggy: ==\n x = 10\n result = x == 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is assignment: using '==' instead of '='.\n\n**Improved code:**\n```python\ndef function_v1235():\n # Fixed: =\n x = 10\n result = x = 2\n return result\n```", "sample_id": "python_medium_c66566b5", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_medium_cb24a338", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef check_value(x, y):\n if x > y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '>' instead of '>='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x >= y:\n return True\n return False\n```", "sample_id": "python_medium_e2da8820", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_hard_7153cec6", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_easy_17de1f3f", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nfor i in range(n_v1525):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v1525):\n if condition:\n break\n```", "sample_id": "python_medium_4e3d0fa5", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef function_v1308():\n # Buggy: /\n x = 10\n result = x / 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is division: using '/' instead of '//'.\n\n**Improved code:**\n```python\ndef function_v1308():\n # Fixed: //\n x = 10\n result = x // 2\n return result\n```", "sample_id": "python_easy_004b736f", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nfor i in range(n_v1092):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v1092):\n if condition:\n break\n```", "sample_id": "python_hard_29130a28", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_medium_cb24a338", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_hard_7153cec6", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_hard_bfafafb6", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_easy_a92c2d8e", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v553):\n```", "sample_id": "python_medium_e747ebd0", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(n_v1656):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v1656):\n if condition:\n break\n```", "sample_id": "python_hard_4e957b49", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_easy_17de1f3f", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef function_v35():\n # Buggy: /\n x = 10\n result = x / 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is division: using '/' instead of '//'.\n\n**Improved code:**\n```python\ndef function_v35():\n # Fixed: //\n x = 10\n result = x // 2\n return result\n```", "sample_id": "python_easy_7c6026be", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_medium_3a902dbf", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_medium_0faa9843", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_medium_a92c2d8e", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_medium_50a18830", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_easy_0308de8d", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef get_last_element(arr):\n return arr[len(arr)]\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is index: using 'arr[len(arr)]' instead of 'arr[len(arr)-1]'.\n\n**Improved code:**\n```python\ndef get_last_element(arr):\n return arr[len(arr)-1]\n```", "sample_id": "python_easy_65909c9b", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef check_value(x, y):\n if x > y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '>' instead of '>='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x >= y:\n return True\n return False\n```", "sample_id": "python_easy_e2da8820", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_medium_cb24a338", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_hard_e96dfa9a", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef add_v168(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v168(a: int, b: int) -> int:\n```", "sample_id": "python_medium_01f8ce65", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_easy_17de1f3f", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(n_v1712):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v1712):\n if condition:\n break\n```", "sample_id": "python_medium_9cba6a67", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nresult = very_long_function_call_v1355(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v1355(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_easy_6cfe0ac1", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_hard_1485a906", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_medium_6f2ce38b", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_hard_a92c2d8e", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef function_v1381():\n # Buggy: range(1, n)\n x = 10\n result = x range(1, n) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is range: using 'range(1, n)' instead of 'range(n)'.\n\n**Improved code:**\n```python\ndef function_v1381():\n # Fixed: range(n)\n x = 10\n result = x range(n) 2\n return result\n```", "sample_id": "python_easy_3bf33cb9", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_hard_50a18830", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_medium_cb24a338", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_medium_de2f3509", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_medium_7673ea8a", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nfor i in range(n_v274):\n for j in range(n_v274):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v274):\n for j in range(i+1, n):\n```", "sample_id": "python_medium_7d905db5", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_easy_3988ac6d", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nfor i in range(n_v0):\n for j in range(n_v0):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v0):\n for j in range(i+1, n):\n```", "sample_id": "python_medium_1b0a67ed", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nresult = very_long_function_call_v1725(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v1725(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_medium_76ba255f", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_easy_de2f3509", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_easy_de2f3509", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_easy_a51375cc", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_medium_0faa9843", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v793):\n```", "sample_id": "python_medium_8a5e73f8", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_hard_3988ac6d", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nresult = very_long_function_call_v57(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v57(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_hard_fd296a16", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_medium_3988ac6d", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_medium_1485a906", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_easy_17de1f3f", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\nresult = very_long_function_call_v48(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v48(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_medium_2b940e71", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_medium_6369782a", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nresult = very_long_function_call_v189(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v189(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_hard_3645a0be", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_easy_de2f3509", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef calc_v1159(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v1159(first_number, second_number):\n```", "sample_id": "python_easy_d5929fb9", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef function_v915():\n # Buggy: /\n x = 10\n result = x / 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is division: using '/' instead of '//'.\n\n**Improved code:**\n```python\ndef function_v915():\n # Fixed: //\n x = 10\n result = x // 2\n return result\n```", "sample_id": "python_easy_13b92850", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v898):\n```", "sample_id": "python_hard_da308840", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_medium_cb24a338", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_easy_a92c2d8e", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_easy_17de1f3f", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef calc_v1485(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v1485(first_number, second_number):\n```", "sample_id": "python_easy_30fdfff8", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\nfor i in range(n_v1394):\n for j in range(n_v1394):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v1394):\n for j in range(i+1, n):\n```", "sample_id": "python_medium_c23fb32f", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef add_v425(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v425(a: int, b: int) -> int:\n```", "sample_id": "python_medium_a5a0cb5b", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nfor i in range(n_v1618):\n for j in range(n_v1618):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v1618):\n for j in range(i+1, n):\n```", "sample_id": "python_medium_792026de", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_easy_17de1f3f", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(n_v1148):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v1148):\n if condition:\n break\n```", "sample_id": "python_hard_c1d30cb7", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nfor i in range(n_v1737):\n for j in range(n_v1737):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v1737):\n for j in range(i+1, n):\n```", "sample_id": "python_hard_d23756c7", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_hard_ce9f3f46", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_easy_7153cec6", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_medium_8d441813", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef add_v1257(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v1257(a: int, b: int) -> int:\n```", "sample_id": "python_hard_3872a516", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef function_v457():\n # Buggy: /\n x = 10\n result = x / 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is division: using '/' instead of '//'.\n\n**Improved code:**\n```python\ndef function_v457():\n # Fixed: //\n x = 10\n result = x // 2\n return result\n```", "sample_id": "python_easy_1784ea21", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_hard_50a18830", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef check_value(x, y):\n if x = y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '=' instead of '=='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x == y:\n return True\n return False\n```", "sample_id": "python_easy_5f2fc867", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nfor i in range(n_v493):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v493):\n if condition:\n break\n```", "sample_id": "python_hard_fc7b20cc", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_hard_50a18830", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nfor i in range(n_v1327):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v1327):\n if condition:\n break\n```", "sample_id": "python_hard_71ee12c4", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_medium_cb24a338", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\nfor i in range(n_v1652):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v1652):\n if condition:\n break\n```", "sample_id": "python_hard_3c0b0dee", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_medium_1485a906", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef process(obj):\n if obj:\n return obj.value\n return None\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is null check: using 'if obj:' instead of 'if obj is not None:'.\n\n**Improved code:**\n```python\ndef process(obj):\n if obj is not None:\n return obj.value\n return None\n```", "sample_id": "python_medium_eac796f4", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_easy_0faa9843", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef function_v891():\n # Buggy: ==\n x = 10\n result = x == 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is assignment: using '==' instead of '='.\n\n**Improved code:**\n```python\ndef function_v891():\n # Fixed: =\n x = 10\n result = x = 2\n return result\n```", "sample_id": "python_easy_72032b48", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_easy_7153cec6", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nresult = very_long_function_call_v485(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v485(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_medium_d1a83a95", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_hard_cb24a338", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nfor i in range(n_v1397):\n for j in range(n_v1397):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v1397):\n for j in range(i+1, n):\n```", "sample_id": "python_medium_41572f6a", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef check_value(x, y):\n if x > y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '>' instead of '>='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x >= y:\n return True\n return False\n```", "sample_id": "python_medium_c4572eac", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_hard_1485a906", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_medium_0faa9843", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_medium_6f2ce38b", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_hard_7153cec6", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nfor i in range(n_v783):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v783):\n if condition:\n break\n```", "sample_id": "python_hard_88485a7f", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nfor i in range(n_v176):\n for j in range(n_v176):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v176):\n for j in range(i+1, n):\n```", "sample_id": "python_medium_68bb39d7", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_medium_de2f3509", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_hard_de2f3509", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_easy_0faa9843", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_hard_1485a906", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\nresult = very_long_function_call_v1255(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v1255(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_medium_efd38b9b", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_easy_1485a906", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_easy_a92c2d8e", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef function_v822():\n # Buggy: list = list + [x]\n x = 10\n result = x list = list + [x] 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is list append: using 'list = list + [x]' instead of 'list.append(x)'.\n\n**Improved code:**\n```python\ndef function_v822():\n # Fixed: list.append(x)\n x = 10\n result = x list.append(x) 2\n return result\n```", "sample_id": "python_easy_83320799", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef function_v1583():\n # Buggy: range(1, n)\n x = 10\n result = x range(1, n) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is range: using 'range(1, n)' instead of 'range(n)'.\n\n**Improved code:**\n```python\ndef function_v1583():\n # Fixed: range(n)\n x = 10\n result = x range(n) 2\n return result\n```", "sample_id": "python_medium_6ecba824", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_medium_8d441813", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_hard_ce9f3f46", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_easy_7153cec6", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v1919):\n```", "sample_id": "python_hard_a6d5c7cc", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_medium_5861437c", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_hard_1485a906", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef add_v976(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v976(a: int, b: int) -> int:\n```", "sample_id": "python_hard_5497480b", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_medium_17de1f3f", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef function_v944():\n # Buggy: list = list + [x]\n x = 10\n result = x list = list + [x] 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is list append: using 'list = list + [x]' instead of 'list.append(x)'.\n\n**Improved code:**\n```python\ndef function_v944():\n # Fixed: list.append(x)\n x = 10\n result = x list.append(x) 2\n return result\n```", "sample_id": "python_easy_d60af4c5", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nresult = very_long_function_call_v986(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v986(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_hard_d7774351", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_hard_7153cec6", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef add_v1288(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v1288(a: int, b: int) -> int:\n```", "sample_id": "python_easy_1e8c8547", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_medium_6f2ce38b", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_easy_6f2ce38b", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_hard_6f2ce38b", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_hard_6f2ce38b", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_hard_7673ea8a", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_easy_7673ea8a", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef process(obj):\n if obj:\n return obj.value\n return None\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is null check: using 'if obj:' instead of 'if obj is not None:'.\n\n**Improved code:**\n```python\ndef process(obj):\n if obj is not None:\n return obj.value\n return None\n```", "sample_id": "python_medium_819ae0ca", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_medium_1485a906", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\nresult = very_long_function_call_v261(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v261(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_hard_6542432a", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef function_v449():\n # Buggy: '{}'.format(x)\n x = 10\n result = x '{}'.format(x) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is string format: using ''{}'.format(x)' instead of 'f'{x}''.\n\n**Improved code:**\n```python\ndef function_v449():\n # Fixed: f'{x}'\n x = 10\n result = x f'{x}' 2\n return result\n```", "sample_id": "python_easy_09298451", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef function_v531():\n # Buggy: range(1, n)\n x = 10\n result = x range(1, n) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is range: using 'range(1, n)' instead of 'range(n)'.\n\n**Improved code:**\n```python\ndef function_v531():\n # Fixed: range(n)\n x = 10\n result = x range(n) 2\n return result\n```", "sample_id": "python_medium_5bbde308", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_medium_e96dfa9a", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef function_v604():\n # Buggy: '{}'.format(x)\n x = 10\n result = x '{}'.format(x) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is string format: using ''{}'.format(x)' instead of 'f'{x}''.\n\n**Improved code:**\n```python\ndef function_v604():\n # Fixed: f'{x}'\n x = 10\n result = x f'{x}' 2\n return result\n```", "sample_id": "python_easy_dded2714", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v876):\n```", "sample_id": "python_medium_641b3698", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_medium_3ca9041c", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_medium_6f2ce38b", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_easy_de2f3509", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_hard_0faa9843", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_easy_0faa9843", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef process_v1410():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v1410():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_hard_54480ddc", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef function_v774():\n # Buggy: list = list + [x]\n x = 10\n result = x list = list + [x] 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is list append: using 'list = list + [x]' instead of 'list.append(x)'.\n\n**Improved code:**\n```python\ndef function_v774():\n # Fixed: list.append(x)\n x = 10\n result = x list.append(x) 2\n return result\n```", "sample_id": "python_easy_7e836c00", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef check_value(x, y):\n if x > y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '>' instead of '>='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x >= y:\n return True\n return False\n```", "sample_id": "python_easy_90db5188", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_easy_4497e4c9", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_easy_6369782a", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef check_value(x, y):\n if x > y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '>' instead of '>='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x >= y:\n return True\n return False\n```", "sample_id": "python_easy_4790b0e9", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nresult = very_long_function_call_v1134(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v1134(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_hard_43ee2d1d", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_medium_6f2ce38b", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_hard_63b3af67", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_easy_a92c2d8e", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\nfor i in range(n_v1756):\n for j in range(n_v1756):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v1756):\n for j in range(i+1, n):\n```", "sample_id": "python_medium_59011717", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\nfor i in range(n_v291):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v291):\n if condition:\n break\n```", "sample_id": "python_hard_efb919d3", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_hard_1485a906", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_easy_0faa9843", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_medium_cb24a338", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_hard_723519b4", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_easy_de2f3509", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_easy_33d47fde", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef calc_v1971(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v1971(first_number, second_number):\n```", "sample_id": "python_hard_3843edab", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_medium_3988ac6d", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef add_v1493(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v1493(a: int, b: int) -> int:\n```", "sample_id": "python_hard_3750edcd", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v1320):\n```", "sample_id": "python_hard_4f357669", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef process(obj):\n if obj:\n return obj.value\n return None\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is null check: using 'if obj:' instead of 'if obj is not None:'.\n\n**Improved code:**\n```python\ndef process(obj):\n if obj is not None:\n return obj.value\n return None\n```", "sample_id": "python_medium_819ae0ca", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v396):\n```", "sample_id": "python_hard_0048a8bc", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_easy_7153cec6", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v906):\n```", "sample_id": "python_medium_ce14fc7b", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_hard_17de1f3f", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_easy_6f2ce38b", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_easy_de2f3509", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef add_v911(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v911(a: int, b: int) -> int:\n```", "sample_id": "python_hard_d149f559", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_hard_ce9f3f46", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_hard_cb24a338", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef function_v1087():\n # Buggy: '{}'.format(x)\n x = 10\n result = x '{}'.format(x) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is string format: using ''{}'.format(x)' instead of 'f'{x}''.\n\n**Improved code:**\n```python\ndef function_v1087():\n # Fixed: f'{x}'\n x = 10\n result = x f'{x}' 2\n return result\n```", "sample_id": "python_medium_e0cef055", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_easy_0faa9843", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_medium_a92c2d8e", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef add_v1454(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v1454(a: int, b: int) -> int:\n```", "sample_id": "python_easy_c6868d46", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nfor i in range(n_v1241):\n for j in range(n_v1241):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v1241):\n for j in range(i+1, n):\n```", "sample_id": "python_hard_b2b5eda0", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef process_v912():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v912():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_medium_008bafe5", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef check_value(x, y):\n if x > y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '>' instead of '>='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x >= y:\n return True\n return False\n```", "sample_id": "python_easy_4790b0e9", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef process(obj):\n if obj:\n return obj.value\n return None\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is null check: using 'if obj:' instead of 'if obj is not None:'.\n\n**Improved code:**\n```python\ndef process(obj):\n if obj is not None:\n return obj.value\n return None\n```", "sample_id": "python_medium_eac796f4", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef function_v818():\n # Buggy: range(1, n)\n x = 10\n result = x range(1, n) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is range: using 'range(1, n)' instead of 'range(n)'.\n\n**Improved code:**\n```python\ndef function_v818():\n # Fixed: range(n)\n x = 10\n result = x range(n) 2\n return result\n```", "sample_id": "python_medium_a0d866a7", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef function_v324():\n # Buggy: '{}'.format(x)\n x = 10\n result = x '{}'.format(x) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is string format: using ''{}'.format(x)' instead of 'f'{x}''.\n\n**Improved code:**\n```python\ndef function_v324():\n # Fixed: f'{x}'\n x = 10\n result = x f'{x}' 2\n return result\n```", "sample_id": "python_medium_e9200e20", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nresult = very_long_function_call_v884(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v884(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_easy_d2c578ac", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_medium_cb24a338", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_easy_6f2ce38b", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_medium_3b59d906", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v318):\n```", "sample_id": "python_medium_d8d21b60", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef check_value(x, y):\n if x > y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '>' instead of '>='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x >= y:\n return True\n return False\n```", "sample_id": "python_easy_625692f9", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_medium_bfafafb6", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_medium_1bfd9e5d", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_medium_f1ad7498", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef calc_v577(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v577(first_number, second_number):\n```", "sample_id": "python_hard_e5772b6b", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef add_v1689(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v1689(a: int, b: int) -> int:\n```", "sample_id": "python_hard_159c1830", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_easy_3988ac6d", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\nfor i in range(n_v1929):\n for j in range(n_v1929):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v1929):\n for j in range(i+1, n):\n```", "sample_id": "python_medium_e5d6fbd5", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_medium_1485a906", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v1762):\n```", "sample_id": "python_medium_88d820e5", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_easy_6f2ce38b", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_medium_de2f3509", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef add_v693(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v693(a: int, b: int) -> int:\n```", "sample_id": "python_medium_73233ada", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_hard_7153cec6", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef function_v244():\n # Buggy: list = list + [x]\n x = 10\n result = x list = list + [x] 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is list append: using 'list = list + [x]' instead of 'list.append(x)'.\n\n**Improved code:**\n```python\ndef function_v244():\n # Fixed: list.append(x)\n x = 10\n result = x list.append(x) 2\n return result\n```", "sample_id": "python_easy_0e95e949", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef process_v1827():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v1827():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_hard_fb0821e1", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef check_value(x, y):\n if x = y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '=' instead of '=='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x == y:\n return True\n return False\n```", "sample_id": "python_medium_07b0f465", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\nresult = very_long_function_call_v680(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v680(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_easy_7a96e8c0", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v490):\n```", "sample_id": "python_hard_ce476dd1", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v975):\n```", "sample_id": "python_hard_262e52ac", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_medium_a51375cc", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_hard_a92c2d8e", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\nfor i in range(n_v1393):\n for j in range(n_v1393):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v1393):\n for j in range(i+1, n):\n```", "sample_id": "python_medium_2b24f23c", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_medium_1bfd9e5d", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_hard_3988ac6d", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_medium_de2f3509", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef function_v880():\n # Buggy: list = list + [x]\n x = 10\n result = x list = list + [x] 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is list append: using 'list = list + [x]' instead of 'list.append(x)'.\n\n**Improved code:**\n```python\ndef function_v880():\n # Fixed: list.append(x)\n x = 10\n result = x list.append(x) 2\n return result\n```", "sample_id": "python_medium_44ede4b4", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_medium_6f2ce38b", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef function_v1332():\n # Buggy: ==\n x = 10\n result = x == 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is assignment: using '==' instead of '='.\n\n**Improved code:**\n```python\ndef function_v1332():\n # Fixed: =\n x = 10\n result = x = 2\n return result\n```", "sample_id": "python_easy_2b6edbd8", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_hard_cb24a338", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_easy_4497e4c9", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef function_v1310():\n # Buggy: list = list + [x]\n x = 10\n result = x list = list + [x] 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is list append: using 'list = list + [x]' instead of 'list.append(x)'.\n\n**Improved code:**\n```python\ndef function_v1310():\n # Fixed: list.append(x)\n x = 10\n result = x list.append(x) 2\n return result\n```", "sample_id": "python_medium_9ed2d638", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\nfor i in range(n_v1163):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v1163):\n if condition:\n break\n```", "sample_id": "python_medium_873d0d48", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_medium_3ca9041c", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_hard_0308de8d", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_medium_de2f3509", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_hard_a92c2d8e", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef check_value(x, y):\n if x = y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '=' instead of '=='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x == y:\n return True\n return False\n```", "sample_id": "python_easy_122aafb5", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_medium_6f2ce38b", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_hard_de2f3509", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_easy_63b3af67", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nfor i in range(n_v264):\n for j in range(n_v264):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v264):\n for j in range(i+1, n):\n```", "sample_id": "python_medium_942dbd0f", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef function_v1587():\n # Buggy: list = list + [x]\n x = 10\n result = x list = list + [x] 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is list append: using 'list = list + [x]' instead of 'list.append(x)'.\n\n**Improved code:**\n```python\ndef function_v1587():\n # Fixed: list.append(x)\n x = 10\n result = x list.append(x) 2\n return result\n```", "sample_id": "python_medium_d1b624f1", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_easy_0faa9843", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef calc_v1222(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v1222(first_number, second_number):\n```", "sample_id": "python_medium_13a10dc1", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_hard_7673ea8a", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v1793):\n```", "sample_id": "python_medium_23e9f822", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_hard_7673ea8a", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\nresult = very_long_function_call_v602(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v602(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_easy_50bfaa4e", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef check_value(x, y):\n if x > y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '>' instead of '>='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x >= y:\n return True\n return False\n```", "sample_id": "python_medium_90db5188", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef add_v1871(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v1871(a: int, b: int) -> int:\n```", "sample_id": "python_easy_a1a0d0e3", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef calc_v1258(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v1258(first_number, second_number):\n```", "sample_id": "python_medium_33b2a8b6", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nresult = very_long_function_call_v433(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v433(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_hard_a9158807", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_hard_e96dfa9a", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_hard_17de1f3f", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_hard_0faa9843", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_hard_f1ad7498", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_hard_6f2ce38b", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_easy_63b3af67", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nfor i in range(n_v467):\n for j in range(n_v467):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v467):\n for j in range(i+1, n):\n```", "sample_id": "python_medium_b75774bb", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_easy_0faa9843", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_hard_f1ad7498", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_easy_17de1f3f", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef function_v363():\n # Buggy: list = list + [x]\n x = 10\n result = x list = list + [x] 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is list append: using 'list = list + [x]' instead of 'list.append(x)'.\n\n**Improved code:**\n```python\ndef function_v363():\n # Fixed: list.append(x)\n x = 10\n result = x list.append(x) 2\n return result\n```", "sample_id": "python_easy_e72dbb37", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef check_value(x, y):\n if x > y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '>' instead of '>='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x >= y:\n return True\n return False\n```", "sample_id": "python_medium_e2da8820", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nfor i in range(n_v517):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v517):\n if condition:\n break\n```", "sample_id": "python_hard_4915f75c", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef function_v768():\n # Buggy: '{}'.format(x)\n x = 10\n result = x '{}'.format(x) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is string format: using ''{}'.format(x)' instead of 'f'{x}''.\n\n**Improved code:**\n```python\ndef function_v768():\n # Fixed: f'{x}'\n x = 10\n result = x f'{x}' 2\n return result\n```", "sample_id": "python_medium_497309a8", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef process_v907():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v907():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_easy_1f62b0ac", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_easy_6f2ce38b", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_hard_a92c2d8e", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef function_v79():\n # Buggy: ==\n x = 10\n result = x == 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is assignment: using '==' instead of '='.\n\n**Improved code:**\n```python\ndef function_v79():\n # Fixed: =\n x = 10\n result = x = 2\n return result\n```", "sample_id": "python_medium_5f50a526", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_medium_3a902dbf", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef process_v260():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v260():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_medium_af04a176", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef check_value(x, y):\n if x = y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '=' instead of '=='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x == y:\n return True\n return False\n```", "sample_id": "python_easy_5f2fc867", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nfor i in range(n_v47):\n for j in range(n_v47):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v47):\n for j in range(i+1, n):\n```", "sample_id": "python_medium_23d78d26", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_medium_7673ea8a", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef function_v1429():\n # Buggy: '{}'.format(x)\n x = 10\n result = x '{}'.format(x) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is string format: using ''{}'.format(x)' instead of 'f'{x}''.\n\n**Improved code:**\n```python\ndef function_v1429():\n # Fixed: f'{x}'\n x = 10\n result = x f'{x}' 2\n return result\n```", "sample_id": "python_medium_fe7ccaa1", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_easy_8d441813", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_medium_a92c2d8e", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef process_v708():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v708():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_hard_6195c889", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v707):\n```", "sample_id": "python_hard_3a4b8160", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_medium_7153cec6", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_medium_a51375cc", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef check_value(x, y):\n if x = y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '=' instead of '=='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x == y:\n return True\n return False\n```", "sample_id": "python_medium_d5b7f2b1", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef function_v1361():\n # Buggy: ==\n x = 10\n result = x == 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is assignment: using '==' instead of '='.\n\n**Improved code:**\n```python\ndef function_v1361():\n # Fixed: =\n x = 10\n result = x = 2\n return result\n```", "sample_id": "python_medium_f93aeb59", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_easy_6f2ce38b", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_hard_e96dfa9a", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef calc_v417(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v417(first_number, second_number):\n```", "sample_id": "python_easy_29e6ff13", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_medium_5861437c", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_easy_6f2ce38b", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_hard_17de1f3f", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef function_v828():\n # Buggy: '{}'.format(x)\n x = 10\n result = x '{}'.format(x) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is string format: using ''{}'.format(x)' instead of 'f'{x}''.\n\n**Improved code:**\n```python\ndef function_v828():\n # Fixed: f'{x}'\n x = 10\n result = x f'{x}' 2\n return result\n```", "sample_id": "python_medium_4ea4e8f8", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef calc_v1130(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v1130(first_number, second_number):\n```", "sample_id": "python_easy_761075e4", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_medium_a92c2d8e", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(n_v734):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v734):\n if condition:\n break\n```", "sample_id": "python_medium_1546f595", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef process(obj):\n if obj:\n return obj.value\n return None\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is null check: using 'if obj:' instead of 'if obj is not None:'.\n\n**Improved code:**\n```python\ndef process(obj):\n if obj is not None:\n return obj.value\n return None\n```", "sample_id": "python_medium_819ae0ca", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_hard_a92c2d8e", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_hard_6f2ce38b", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef function_v1897():\n # Buggy: range(1, n)\n x = 10\n result = x range(1, n) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is range: using 'range(1, n)' instead of 'range(n)'.\n\n**Improved code:**\n```python\ndef function_v1897():\n # Fixed: range(n)\n x = 10\n result = x range(n) 2\n return result\n```", "sample_id": "python_easy_c4d9bfb7", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef process_v1068():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v1068():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_easy_f94e0fba", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_hard_723519b4", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_hard_0faa9843", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_medium_de2f3509", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_medium_a92c2d8e", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef calc_v1147(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v1147(first_number, second_number):\n```", "sample_id": "python_medium_0df61d8a", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef process_v1842():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v1842():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_medium_63703efc", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_medium_3988ac6d", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nresult = very_long_function_call_v644(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v644(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_medium_a707f3e2", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\nresult = very_long_function_call_v1954(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v1954(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_medium_320f7e6d", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_medium_7153cec6", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_hard_0faa9843", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef calc_v1060(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v1060(first_number, second_number):\n```", "sample_id": "python_medium_4349201f", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(n_v837):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v837):\n if condition:\n break\n```", "sample_id": "python_medium_6fb95bcc", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef function_v1325():\n # Buggy: list = list + [x]\n x = 10\n result = x list = list + [x] 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is list append: using 'list = list + [x]' instead of 'list.append(x)'.\n\n**Improved code:**\n```python\ndef function_v1325():\n # Fixed: list.append(x)\n x = 10\n result = x list.append(x) 2\n return result\n```", "sample_id": "python_medium_b9035830", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef function_v1550():\n # Buggy: /\n x = 10\n result = x / 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is division: using '/' instead of '//'.\n\n**Improved code:**\n```python\ndef function_v1550():\n # Fixed: //\n x = 10\n result = x // 2\n return result\n```", "sample_id": "python_easy_f8032e9d", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef function_v30():\n # Buggy: ==\n x = 10\n result = x == 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is assignment: using '==' instead of '='.\n\n**Improved code:**\n```python\ndef function_v30():\n # Fixed: =\n x = 10\n result = x = 2\n return result\n```", "sample_id": "python_easy_69bdcc9d", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef check_value(x, y):\n if x > y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '>' instead of '>='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x >= y:\n return True\n return False\n```", "sample_id": "python_medium_90db5188", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_hard_a92c2d8e", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_medium_6f2ce38b", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_easy_7153cec6", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef process_v1742():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v1742():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_hard_aa0da087", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_medium_6f2ce38b", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_medium_5861437c", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef check_value(x, y):\n if x = y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '=' instead of '=='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x == y:\n return True\n return False\n```", "sample_id": "python_medium_5f2fc867", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_hard_de2f3509", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef process_v390():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v390():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_hard_2aec3db5", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_hard_7153cec6", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_hard_a92c2d8e", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_hard_0faa9843", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef add_v1558(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v1558(a: int, b: int) -> int:\n```", "sample_id": "python_medium_4685bdce", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_easy_7153cec6", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_medium_7673ea8a", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v465):\n```", "sample_id": "python_medium_09f32bdf", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef add_v1601(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v1601(a: int, b: int) -> int:\n```", "sample_id": "python_hard_a2f6981e", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v1975):\n```", "sample_id": "python_hard_51594408", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_easy_de2f3509", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_easy_6f2ce38b", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_hard_17de1f3f", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef check_value(x, y):\n if x > y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '>' instead of '>='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x >= y:\n return True\n return False\n```", "sample_id": "python_medium_90db5188", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_hard_3b59d906", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nresult = very_long_function_call_v873(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v873(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_hard_cd2e4e53", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_easy_de2f3509", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_easy_4497e4c9", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nfor i in range(n_v519):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v519):\n if condition:\n break\n```", "sample_id": "python_hard_6d9f2b9a", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_hard_0faa9843", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef function_v1364():\n # Buggy: ==\n x = 10\n result = x == 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is assignment: using '==' instead of '='.\n\n**Improved code:**\n```python\ndef function_v1364():\n # Fixed: =\n x = 10\n result = x = 2\n return result\n```", "sample_id": "python_easy_7c6840d0", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_easy_3988ac6d", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef function_v1906():\n # Buggy: '{}'.format(x)\n x = 10\n result = x '{}'.format(x) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is string format: using ''{}'.format(x)' instead of 'f'{x}''.\n\n**Improved code:**\n```python\ndef function_v1906():\n # Fixed: f'{x}'\n x = 10\n result = x f'{x}' 2\n return result\n```", "sample_id": "python_medium_dbc2812c", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v636):\n```", "sample_id": "python_hard_925c2541", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef process(obj):\n if obj:\n return obj.value\n return None\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is null check: using 'if obj:' instead of 'if obj is not None:'.\n\n**Improved code:**\n```python\ndef process(obj):\n if obj is not None:\n return obj.value\n return None\n```", "sample_id": "python_medium_0946810e", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\nfor i in range(n_v873):\n for j in range(n_v873):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v873):\n for j in range(i+1, n):\n```", "sample_id": "python_medium_0814eb79", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_medium_8d441813", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef process_v622():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v622():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_medium_fefc63b7", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef check_value(x, y):\n if x = y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '=' instead of '=='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x == y:\n return True\n return False\n```", "sample_id": "python_medium_122aafb5", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_hard_a92c2d8e", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef calc_v429(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v429(first_number, second_number):\n```", "sample_id": "python_easy_99f1f47e", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_medium_0faa9843", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_medium_17de1f3f", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_medium_50a18830", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_hard_50a18830", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_hard_f1ad7498", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_easy_4497e4c9", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_hard_e96dfa9a", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef function_v1382():\n # Buggy: range(1, n)\n x = 10\n result = x range(1, n) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is range: using 'range(1, n)' instead of 'range(n)'.\n\n**Improved code:**\n```python\ndef function_v1382():\n # Fixed: range(n)\n x = 10\n result = x range(n) 2\n return result\n```", "sample_id": "python_easy_73995b27", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef add_v1841(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v1841(a: int, b: int) -> int:\n```", "sample_id": "python_easy_9bf91455", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_hard_0faa9843", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_medium_7673ea8a", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef add_v1691(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v1691(a: int, b: int) -> int:\n```", "sample_id": "python_hard_8e91ddee", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nresult = very_long_function_call_v859(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v859(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_hard_4d6646ad", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_hard_1bfd9e5d", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_easy_de2f3509", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef function_v869():\n # Buggy: range(1, n)\n x = 10\n result = x range(1, n) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is range: using 'range(1, n)' instead of 'range(n)'.\n\n**Improved code:**\n```python\ndef function_v869():\n # Fixed: range(n)\n x = 10\n result = x range(n) 2\n return result\n```", "sample_id": "python_medium_e90dafdc", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_hard_6f2ce38b", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_hard_17de1f3f", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_hard_0faa9843", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef process_v322():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v322():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_medium_66ea1537", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef get_last_element(arr):\n return arr[len(arr)]\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is index: using 'arr[len(arr)]' instead of 'arr[len(arr)-1]'.\n\n**Improved code:**\n```python\ndef get_last_element(arr):\n return arr[len(arr)-1]\n```", "sample_id": "python_easy_c0fdeaee", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v184):\n```", "sample_id": "python_medium_6fc366d7", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef process(obj):\n if obj:\n return obj.value\n return None\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is null check: using 'if obj:' instead of 'if obj is not None:'.\n\n**Improved code:**\n```python\ndef process(obj):\n if obj is not None:\n return obj.value\n return None\n```", "sample_id": "python_medium_27f89ed6", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_hard_17de1f3f", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_hard_0faa9843", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_easy_de2f3509", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_hard_0308de8d", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_hard_7673ea8a", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(n_v1357):\n for j in range(n_v1357):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v1357):\n for j in range(i+1, n):\n```", "sample_id": "python_hard_bd8ff3af", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nfor i in range(n_v764):\n for j in range(n_v764):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v764):\n for j in range(i+1, n):\n```", "sample_id": "python_hard_8e70c766", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nfor i in range(n_v1727):\n for j in range(n_v1727):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v1727):\n for j in range(i+1, n):\n```", "sample_id": "python_hard_f7add391", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef add_v12(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v12(a: int, b: int) -> int:\n```", "sample_id": "python_easy_427752cb", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_easy_0308de8d", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef calc_v474(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v474(first_number, second_number):\n```", "sample_id": "python_medium_e39c5eb1", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef process_v1218():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v1218():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_easy_2f8dadba", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_hard_0faa9843", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_easy_17de1f3f", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_easy_a92c2d8e", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef function_v662():\n # Buggy: list = list + [x]\n x = 10\n result = x list = list + [x] 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is list append: using 'list = list + [x]' instead of 'list.append(x)'.\n\n**Improved code:**\n```python\ndef function_v662():\n # Fixed: list.append(x)\n x = 10\n result = x list.append(x) 2\n return result\n```", "sample_id": "python_medium_9e20b12b", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef get_last_element(arr):\n return arr[len(arr)]\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is index: using 'arr[len(arr)]' instead of 'arr[len(arr)-1]'.\n\n**Improved code:**\n```python\ndef get_last_element(arr):\n return arr[len(arr)-1]\n```", "sample_id": "python_medium_65909c9b", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_easy_1485a906", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_medium_3988ac6d", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef function_v1881():\n # Buggy: range(1, n)\n x = 10\n result = x range(1, n) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is range: using 'range(1, n)' instead of 'range(n)'.\n\n**Improved code:**\n```python\ndef function_v1881():\n # Fixed: range(n)\n x = 10\n result = x range(n) 2\n return result\n```", "sample_id": "python_easy_22310002", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nresult = very_long_function_call_v143(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v143(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_medium_7e84ff38", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\nfor i in range(n_v1686):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v1686):\n if condition:\n break\n```", "sample_id": "python_hard_87c930bb", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_medium_6369782a", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef process_v24():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v24():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_easy_2c477729", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_easy_0faa9843", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_hard_5861437c", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_hard_a92c2d8e", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef check_value(x, y):\n if x > y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '>' instead of '>='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x >= y:\n return True\n return False\n```", "sample_id": "python_easy_4790b0e9", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_easy_6f2ce38b", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_hard_cb24a338", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v1830):\n```", "sample_id": "python_hard_066a4901", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_hard_6f2ce38b", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_medium_8d441813", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_hard_de2f3509", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_hard_0faa9843", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_easy_6f2ce38b", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_medium_7673ea8a", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_easy_de2f3509", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef function_v1980():\n # Buggy: ==\n x = 10\n result = x == 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is assignment: using '==' instead of '='.\n\n**Improved code:**\n```python\ndef function_v1980():\n # Fixed: =\n x = 10\n result = x = 2\n return result\n```", "sample_id": "python_easy_510cb9fb", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_medium_3b59d906", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v450):\n```", "sample_id": "python_medium_0b87a548", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef function_v1458():\n # Buggy: list = list + [x]\n x = 10\n result = x list = list + [x] 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is list append: using 'list = list + [x]' instead of 'list.append(x)'.\n\n**Improved code:**\n```python\ndef function_v1458():\n # Fixed: list.append(x)\n x = 10\n result = x list.append(x) 2\n return result\n```", "sample_id": "python_medium_e970ad4a", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v366):\n```", "sample_id": "python_medium_cb591255", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_medium_7153cec6", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_easy_7673ea8a", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef function_v565():\n # Buggy: ==\n x = 10\n result = x == 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is assignment: using '==' instead of '='.\n\n**Improved code:**\n```python\ndef function_v565():\n # Fixed: =\n x = 10\n result = x = 2\n return result\n```", "sample_id": "python_easy_157763a2", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_hard_7673ea8a", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef process(obj):\n if obj:\n return obj.value\n return None\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is null check: using 'if obj:' instead of 'if obj is not None:'.\n\n**Improved code:**\n```python\ndef process(obj):\n if obj is not None:\n return obj.value\n return None\n```", "sample_id": "python_easy_b277e062", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nfor i in range(n_v1433):\n for j in range(n_v1433):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v1433):\n for j in range(i+1, n):\n```", "sample_id": "python_medium_417ba95f", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_easy_4497e4c9", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_easy_de2f3509", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_medium_17de1f3f", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef add_v830(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v830(a: int, b: int) -> int:\n```", "sample_id": "python_medium_d8fe8fda", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_medium_de2f3509", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef get_last_element(arr):\n return arr[len(arr)]\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is index: using 'arr[len(arr)]' instead of 'arr[len(arr)-1]'.\n\n**Improved code:**\n```python\ndef get_last_element(arr):\n return arr[len(arr)-1]\n```", "sample_id": "python_easy_3560e64c", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef process(obj):\n if obj:\n return obj.value\n return None\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is null check: using 'if obj:' instead of 'if obj is not None:'.\n\n**Improved code:**\n```python\ndef process(obj):\n if obj is not None:\n return obj.value\n return None\n```", "sample_id": "python_easy_b277e062", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nresult = very_long_function_call_v351(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v351(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_medium_27cc9454", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_medium_e96dfa9a", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(n_v703):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v703):\n if condition:\n break\n```", "sample_id": "python_hard_a5f93bdb", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef calc_v1400(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v1400(first_number, second_number):\n```", "sample_id": "python_hard_941167ee", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef function_v1800():\n # Buggy: '{}'.format(x)\n x = 10\n result = x '{}'.format(x) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is string format: using ''{}'.format(x)' instead of 'f'{x}''.\n\n**Improved code:**\n```python\ndef function_v1800():\n # Fixed: f'{x}'\n x = 10\n result = x f'{x}' 2\n return result\n```", "sample_id": "python_medium_842955c2", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_medium_1bfd9e5d", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v1029):\n```", "sample_id": "python_hard_448f95d5", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_hard_f1ad7498", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef function_v913():\n # Buggy: ==\n x = 10\n result = x == 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is assignment: using '==' instead of '='.\n\n**Improved code:**\n```python\ndef function_v913():\n # Fixed: =\n x = 10\n result = x = 2\n return result\n```", "sample_id": "python_medium_c6c0430c", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef process_v821():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v821():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_medium_8fac0145", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_hard_1485a906", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_medium_cb24a338", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v1046):\n```", "sample_id": "python_hard_2ffe212d", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_medium_f1ad7498", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef function_v1459():\n # Buggy: /\n x = 10\n result = x / 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is division: using '/' instead of '//'.\n\n**Improved code:**\n```python\ndef function_v1459():\n # Fixed: //\n x = 10\n result = x // 2\n return result\n```", "sample_id": "python_easy_acff5cf8", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nresult = very_long_function_call_v1076(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v1076(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_easy_a982234f", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v702):\n```", "sample_id": "python_medium_f0235bd7", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_hard_f1ad7498", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_easy_6f2ce38b", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef calc_v963(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v963(first_number, second_number):\n```", "sample_id": "python_hard_4b232bf6", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef function_v1660():\n # Buggy: ==\n x = 10\n result = x == 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is assignment: using '==' instead of '='.\n\n**Improved code:**\n```python\ndef function_v1660():\n # Fixed: =\n x = 10\n result = x = 2\n return result\n```", "sample_id": "python_medium_730cec6c", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v449):\n```", "sample_id": "python_medium_ef693d06", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_medium_5861437c", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef function_v54():\n # Buggy: range(1, n)\n x = 10\n result = x range(1, n) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is range: using 'range(1, n)' instead of 'range(n)'.\n\n**Improved code:**\n```python\ndef function_v54():\n # Fixed: range(n)\n x = 10\n result = x range(n) 2\n return result\n```", "sample_id": "python_medium_feb59960", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_medium_cb24a338", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_easy_a92c2d8e", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef process_v1776():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v1776():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_hard_7eb87e4f", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_hard_3988ac6d", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef process_v1022():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v1022():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_medium_8c3de05e", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef process_v1693():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v1693():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_easy_56fbd881", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_easy_1485a906", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_easy_6f2ce38b", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef process_v172():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v172():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_hard_dc05c903", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v950):\n```", "sample_id": "python_hard_e367bf92", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_hard_a92c2d8e", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef add_v1506(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v1506(a: int, b: int) -> int:\n```", "sample_id": "python_medium_1449dbfd", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef add_v422(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v422(a: int, b: int) -> int:\n```", "sample_id": "python_medium_d31531b2", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_medium_7153cec6", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_hard_cb24a338", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nfor i in range(n_v4):\n for j in range(n_v4):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v4):\n for j in range(i+1, n):\n```", "sample_id": "python_medium_74b499ce", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef function_v1590():\n # Buggy: '{}'.format(x)\n x = 10\n result = x '{}'.format(x) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is string format: using ''{}'.format(x)' instead of 'f'{x}''.\n\n**Improved code:**\n```python\ndef function_v1590():\n # Fixed: f'{x}'\n x = 10\n result = x f'{x}' 2\n return result\n```", "sample_id": "python_medium_7a6abdbd", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_hard_7153cec6", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef process_v582():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v582():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_easy_e453c360", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(n_v288):\n for j in range(n_v288):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v288):\n for j in range(i+1, n):\n```", "sample_id": "python_hard_772e3512", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_easy_0308de8d", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef function_v1956():\n # Buggy: list = list + [x]\n x = 10\n result = x list = list + [x] 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is list append: using 'list = list + [x]' instead of 'list.append(x)'.\n\n**Improved code:**\n```python\ndef function_v1956():\n # Fixed: list.append(x)\n x = 10\n result = x list.append(x) 2\n return result\n```", "sample_id": "python_medium_fab6edfc", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef function_v337():\n # Buggy: /\n x = 10\n result = x / 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is division: using '/' instead of '//'.\n\n**Improved code:**\n```python\ndef function_v337():\n # Fixed: //\n x = 10\n result = x // 2\n return result\n```", "sample_id": "python_easy_0811d7cd", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_medium_7673ea8a", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef process_v1253():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v1253():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_hard_77ecb8e4", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef process(obj):\n if obj:\n return obj.value\n return None\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is null check: using 'if obj:' instead of 'if obj is not None:'.\n\n**Improved code:**\n```python\ndef process(obj):\n if obj is not None:\n return obj.value\n return None\n```", "sample_id": "python_medium_b277e062", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_medium_7673ea8a", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef get_last_element(arr):\n return arr[len(arr)]\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is index: using 'arr[len(arr)]' instead of 'arr[len(arr)-1]'.\n\n**Improved code:**\n```python\ndef get_last_element(arr):\n return arr[len(arr)-1]\n```", "sample_id": "python_easy_65909c9b", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef function_v15():\n # Buggy: /\n x = 10\n result = x / 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is division: using '/' instead of '//'.\n\n**Improved code:**\n```python\ndef function_v15():\n # Fixed: //\n x = 10\n result = x // 2\n return result\n```", "sample_id": "python_easy_1feff4fb", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_hard_7153cec6", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_easy_a92c2d8e", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef function_v356():\n # Buggy: /\n x = 10\n result = x / 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is division: using '/' instead of '//'.\n\n**Improved code:**\n```python\ndef function_v356():\n # Fixed: //\n x = 10\n result = x // 2\n return result\n```", "sample_id": "python_easy_97b0b570", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_hard_0faa9843", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef process_v1661():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v1661():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_easy_8305748f", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_medium_6f2ce38b", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v679):\n```", "sample_id": "python_medium_9f077253", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef calc_v1968(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v1968(first_number, second_number):\n```", "sample_id": "python_easy_02757018", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_medium_0faa9843", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_medium_1485a906", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_easy_6f2ce38b", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_hard_a92c2d8e", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_hard_17de1f3f", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef function_v581():\n # Buggy: range(1, n)\n x = 10\n result = x range(1, n) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is range: using 'range(1, n)' instead of 'range(n)'.\n\n**Improved code:**\n```python\ndef function_v581():\n # Fixed: range(n)\n x = 10\n result = x range(n) 2\n return result\n```", "sample_id": "python_medium_1d3da7dd", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef function_v471():\n # Buggy: list = list + [x]\n x = 10\n result = x list = list + [x] 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is list append: using 'list = list + [x]' instead of 'list.append(x)'.\n\n**Improved code:**\n```python\ndef function_v471():\n # Fixed: list.append(x)\n x = 10\n result = x list.append(x) 2\n return result\n```", "sample_id": "python_easy_d4344143", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_medium_17de1f3f", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_hard_1485a906", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_medium_6f2ce38b", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_easy_0faa9843", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nresult = very_long_function_call_v533(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v533(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_medium_c7328d95", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_medium_4497e4c9", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\nresult = very_long_function_call_v16(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v16(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_medium_86281c96", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v611):\n```", "sample_id": "python_medium_1a5c1665", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef function_v1570():\n # Buggy: '{}'.format(x)\n x = 10\n result = x '{}'.format(x) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is string format: using ''{}'.format(x)' instead of 'f'{x}''.\n\n**Improved code:**\n```python\ndef function_v1570():\n # Fixed: f'{x}'\n x = 10\n result = x f'{x}' 2\n return result\n```", "sample_id": "python_easy_516c9218", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef calc_v427(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v427(first_number, second_number):\n```", "sample_id": "python_medium_03e79190", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_medium_7153cec6", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef function_v153():\n # Buggy: ==\n x = 10\n result = x == 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is assignment: using '==' instead of '='.\n\n**Improved code:**\n```python\ndef function_v153():\n # Fixed: =\n x = 10\n result = x = 2\n return result\n```", "sample_id": "python_medium_cd35c6ba", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_hard_7153cec6", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nfor i in range(n_v427):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v427):\n if condition:\n break\n```", "sample_id": "python_medium_987245f4", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef get_last_element(arr):\n return arr[len(arr)]\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is index: using 'arr[len(arr)]' instead of 'arr[len(arr)-1]'.\n\n**Improved code:**\n```python\ndef get_last_element(arr):\n return arr[len(arr)-1]\n```", "sample_id": "python_medium_81c17ab2", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef function_v183():\n # Buggy: '{}'.format(x)\n x = 10\n result = x '{}'.format(x) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is string format: using ''{}'.format(x)' instead of 'f'{x}''.\n\n**Improved code:**\n```python\ndef function_v183():\n # Fixed: f'{x}'\n x = 10\n result = x f'{x}' 2\n return result\n```", "sample_id": "python_medium_f7211a1f", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v1924):\n```", "sample_id": "python_medium_a36c2faf", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_hard_cb24a338", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_hard_6f2ce38b", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_easy_3988ac6d", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_hard_7673ea8a", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef function_v778():\n # Buggy: /\n x = 10\n result = x / 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is division: using '/' instead of '//'.\n\n**Improved code:**\n```python\ndef function_v778():\n # Fixed: //\n x = 10\n result = x // 2\n return result\n```", "sample_id": "python_medium_fa5ed58a", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nresult = very_long_function_call_v236(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v236(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_medium_f1eaba7b", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_medium_7153cec6", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_medium_cb24a338", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef function_v1413():\n # Buggy: list = list + [x]\n x = 10\n result = x list = list + [x] 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is list append: using 'list = list + [x]' instead of 'list.append(x)'.\n\n**Improved code:**\n```python\ndef function_v1413():\n # Fixed: list.append(x)\n x = 10\n result = x list.append(x) 2\n return result\n```", "sample_id": "python_medium_6a22915f", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_easy_3988ac6d", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_medium_cb24a338", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_medium_de2f3509", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef calc_v1791(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v1791(first_number, second_number):\n```", "sample_id": "python_medium_3b3e64dd", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v1527):\n```", "sample_id": "python_medium_c0a30397", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_medium_17de1f3f", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_hard_0308de8d", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_medium_63b3af67", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_medium_7673ea8a", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_easy_0faa9843", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_easy_6369782a", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_hard_6f2ce38b", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nresult = very_long_function_call_v1180(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v1180(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_medium_b98e4256", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_medium_4497e4c9", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_hard_1bfd9e5d", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_medium_de2f3509", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_medium_a51375cc", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nresult = very_long_function_call_v716(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v716(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_medium_f391fc55", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef add_v1119(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v1119(a: int, b: int) -> int:\n```", "sample_id": "python_medium_e5283a3f", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_easy_17de1f3f", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef process_v780():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v780():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_easy_1bdd838f", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nfor i in range(n_v1239):\n for j in range(n_v1239):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v1239):\n for j in range(i+1, n):\n```", "sample_id": "python_hard_91ccd7b4", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef process_v1034():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v1034():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_hard_06f75214", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_medium_bfafafb6", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef get_last_element(arr):\n return arr[len(arr)]\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is index: using 'arr[len(arr)]' instead of 'arr[len(arr)-1]'.\n\n**Improved code:**\n```python\ndef get_last_element(arr):\n return arr[len(arr)-1]\n```", "sample_id": "python_easy_65909c9b", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_easy_7673ea8a", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nresult = very_long_function_call_v1789(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v1789(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_easy_e541bc74", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef calc_v88(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v88(first_number, second_number):\n```", "sample_id": "python_hard_f592ac05", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_hard_7153cec6", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef function_v499():\n # Buggy: list = list + [x]\n x = 10\n result = x list = list + [x] 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is list append: using 'list = list + [x]' instead of 'list.append(x)'.\n\n**Improved code:**\n```python\ndef function_v499():\n # Fixed: list.append(x)\n x = 10\n result = x list.append(x) 2\n return result\n```", "sample_id": "python_medium_ea3f031f", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_hard_7673ea8a", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(n_v1366):\n for j in range(n_v1366):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v1366):\n for j in range(i+1, n):\n```", "sample_id": "python_medium_47a3119f", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nresult = very_long_function_call_v151(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v151(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_hard_4915e8f3", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_medium_50a18830", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nfor i in range(n_v948):\n for j in range(n_v948):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v948):\n for j in range(i+1, n):\n```", "sample_id": "python_hard_3591ed41", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef function_v1830():\n # Buggy: ==\n x = 10\n result = x == 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is assignment: using '==' instead of '='.\n\n**Improved code:**\n```python\ndef function_v1830():\n # Fixed: =\n x = 10\n result = x = 2\n return result\n```", "sample_id": "python_easy_1d843581", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nfor i in range(n_v1348):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v1348):\n if condition:\n break\n```", "sample_id": "python_medium_cb901a39", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef function_v1312():\n # Buggy: ==\n x = 10\n result = x == 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is assignment: using '==' instead of '='.\n\n**Improved code:**\n```python\ndef function_v1312():\n # Fixed: =\n x = 10\n result = x = 2\n return result\n```", "sample_id": "python_medium_538f4303", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_hard_1485a906", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_hard_0faa9843", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef calc_v941(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v941(first_number, second_number):\n```", "sample_id": "python_easy_b4e45745", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v1024):\n```", "sample_id": "python_hard_b1506d25", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_hard_6f2ce38b", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nfor i in range(n_v1869):\n for j in range(n_v1869):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v1869):\n for j in range(i+1, n):\n```", "sample_id": "python_hard_2557b0f3", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nresult = very_long_function_call_v1919(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v1919(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_hard_651ef23f", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_easy_8d441813", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef function_v1945():\n # Buggy: /\n x = 10\n result = x / 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is division: using '/' instead of '//'.\n\n**Improved code:**\n```python\ndef function_v1945():\n # Fixed: //\n x = 10\n result = x // 2\n return result\n```", "sample_id": "python_easy_355753bb", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_medium_63b3af67", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nfor i in range(n_v1544):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v1544):\n if condition:\n break\n```", "sample_id": "python_hard_b6d7a87a", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_medium_a92c2d8e", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_medium_17de1f3f", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef add_v645(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v645(a: int, b: int) -> int:\n```", "sample_id": "python_hard_c9de7b50", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nresult = very_long_function_call_v501(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v501(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_medium_f01d6b66", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_hard_7673ea8a", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_easy_3988ac6d", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_medium_de2f3509", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_hard_1485a906", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_medium_0308de8d", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nresult = very_long_function_call_v971(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v971(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_medium_77d7ee46", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_easy_6f2ce38b", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_easy_0faa9843", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\nresult = very_long_function_call_v575(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v575(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_hard_51ec2609", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef process_v1914():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v1914():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_easy_54706936", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef function_v738():\n # Buggy: /\n x = 10\n result = x / 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is division: using '/' instead of '//'.\n\n**Improved code:**\n```python\ndef function_v738():\n # Fixed: //\n x = 10\n result = x // 2\n return result\n```", "sample_id": "python_medium_fd924ab6", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_easy_6f2ce38b", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_easy_17de1f3f", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_easy_3988ac6d", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_hard_1485a906", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_medium_e96dfa9a", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v525):\n```", "sample_id": "python_hard_c313f34c", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef function_v600():\n # Buggy: range(1, n)\n x = 10\n result = x range(1, n) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is range: using 'range(1, n)' instead of 'range(n)'.\n\n**Improved code:**\n```python\ndef function_v600():\n # Fixed: range(n)\n x = 10\n result = x range(n) 2\n return result\n```", "sample_id": "python_easy_cfdca9eb", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_easy_0308de8d", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_easy_a92c2d8e", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_medium_f1ad7498", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_medium_0faa9843", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_hard_a92c2d8e", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\nresult = very_long_function_call_v1321(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v1321(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_easy_a9894dad", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef calc_v1150(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v1150(first_number, second_number):\n```", "sample_id": "python_hard_cac4bfb9", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v1447):\n```", "sample_id": "python_hard_c0305873", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\nresult = very_long_function_call_v1706(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v1706(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_hard_5e3aaf0a", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\nresult = very_long_function_call_v104(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v104(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_easy_c21818cd", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef function_v410():\n # Buggy: ==\n x = 10\n result = x == 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is assignment: using '==' instead of '='.\n\n**Improved code:**\n```python\ndef function_v410():\n # Fixed: =\n x = 10\n result = x = 2\n return result\n```", "sample_id": "python_medium_bcf7090a", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef add_v1602(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v1602(a: int, b: int) -> int:\n```", "sample_id": "python_easy_2ad9551c", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_medium_cb24a338", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef function_v689():\n # Buggy: /\n x = 10\n result = x / 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is division: using '/' instead of '//'.\n\n**Improved code:**\n```python\ndef function_v689():\n # Fixed: //\n x = 10\n result = x // 2\n return result\n```", "sample_id": "python_easy_f56edab7", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_easy_0faa9843", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_medium_a92c2d8e", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_easy_4497e4c9", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_hard_3b59d906", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_medium_a92c2d8e", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef process_v547():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v547():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_medium_a0ac30c9", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_easy_7673ea8a", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_easy_1485a906", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_hard_7153cec6", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef function_v1610():\n # Buggy: range(1, n)\n x = 10\n result = x range(1, n) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is range: using 'range(1, n)' instead of 'range(n)'.\n\n**Improved code:**\n```python\ndef function_v1610():\n # Fixed: range(n)\n x = 10\n result = x range(n) 2\n return result\n```", "sample_id": "python_medium_2650fe46", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_medium_3988ac6d", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nfor i in range(n_v1333):\n for j in range(n_v1333):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v1333):\n for j in range(i+1, n):\n```", "sample_id": "python_medium_f0c315d6", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_easy_3988ac6d", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef calc_v840(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v840(first_number, second_number):\n```", "sample_id": "python_medium_1122496b", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef get_last_element(arr):\n return arr[len(arr)]\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is index: using 'arr[len(arr)]' instead of 'arr[len(arr)-1]'.\n\n**Improved code:**\n```python\ndef get_last_element(arr):\n return arr[len(arr)-1]\n```", "sample_id": "python_medium_65909c9b", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef calc_v132(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v132(first_number, second_number):\n```", "sample_id": "python_easy_b3773012", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nresult = very_long_function_call_v1952(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v1952(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_medium_4689d4ee", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\nfor i in range(n_v237):\n for j in range(n_v237):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v237):\n for j in range(i+1, n):\n```", "sample_id": "python_hard_542d94d7", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_easy_de2f3509", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_hard_cb24a338", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef check_value(x, y):\n if x = y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '=' instead of '=='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x == y:\n return True\n return False\n```", "sample_id": "python_medium_122aafb5", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef process_v335():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v335():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_easy_e2566f0d", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef add_v1629(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v1629(a: int, b: int) -> int:\n```", "sample_id": "python_hard_4283ebbc", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_medium_a92c2d8e", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef calc_v8(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v8(first_number, second_number):\n```", "sample_id": "python_easy_5f484d05", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_medium_3988ac6d", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nresult = very_long_function_call_v1264(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v1264(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_hard_fa4b5b3b", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nfor i in range(n_v1555):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v1555):\n if condition:\n break\n```", "sample_id": "python_hard_85a690eb", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_easy_3988ac6d", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef check_value(x, y):\n if x = y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '=' instead of '=='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x == y:\n return True\n return False\n```", "sample_id": "python_easy_9cfea75d", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_hard_0faa9843", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_medium_3988ac6d", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_medium_a51375cc", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_medium_0308de8d", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(n_v1604):\n for j in range(n_v1604):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v1604):\n for j in range(i+1, n):\n```", "sample_id": "python_hard_908421f2", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_medium_5861437c", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_hard_7673ea8a", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_medium_723519b4", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_easy_6f2ce38b", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_hard_a92c2d8e", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef calc_v1774(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v1774(first_number, second_number):\n```", "sample_id": "python_easy_4d09750f", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef calc_v1527(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v1527(first_number, second_number):\n```", "sample_id": "python_easy_49e71b11", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_medium_33d47fde", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_medium_1485a906", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_medium_e96dfa9a", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef process_v910():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v910():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_medium_b31d002f", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef check_value(x, y):\n if x = y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '=' instead of '=='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x == y:\n return True\n return False\n```", "sample_id": "python_medium_9cfea75d", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(n_v854):\n for j in range(n_v854):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v854):\n for j in range(i+1, n):\n```", "sample_id": "python_hard_f6b9789c", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_hard_de2f3509", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_hard_1485a906", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_easy_17de1f3f", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_easy_a92c2d8e", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nfor i in range(n_v977):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v977):\n if condition:\n break\n```", "sample_id": "python_medium_392913e4", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nfor i in range(n_v1025):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v1025):\n if condition:\n break\n```", "sample_id": "python_medium_bd649a8b", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_medium_7153cec6", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef add_v1164(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v1164(a: int, b: int) -> int:\n```", "sample_id": "python_hard_73d27154", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_easy_17de1f3f", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_easy_3988ac6d", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_hard_3988ac6d", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_easy_cb24a338", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef process_v1051():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v1051():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_hard_baa21715", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef calc_v541(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v541(first_number, second_number):\n```", "sample_id": "python_easy_e291409d", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use list comprehension\n\nInput code:\n```python\nresult = []\nfor i in range(10):\n if i % 2 == 0:\n result.append(i ** 2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use list comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = [i ** 2 for i in range(10) if i % 2 == 0]\n```", "sample_id": "python_medium_cb24a338", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_hard_3988ac6d", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef check_value(x, y):\n if x < y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '<' instead of '<='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x <= y:\n return True\n return False\n```", "sample_id": "python_easy_4497e4c9", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef process_v482():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v482():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_medium_635e5f48", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef check_value(x, y):\n if x > y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '>' instead of '>='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x >= y:\n return True\n return False\n```", "sample_id": "python_medium_90db5188", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_easy_6f2ce38b", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_medium_0faa9843", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(n_v1065):\n for j in range(n_v1065):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v1065):\n for j in range(i+1, n):\n```", "sample_id": "python_hard_a9db9d56", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\nresult = very_long_function_call_v1252(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v1252(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_medium_efa0fa38", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nresult = very_long_function_call_v1353(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v1353(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_medium_4e2b92a8", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_hard_3988ac6d", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python class\n\nInput code:\n```python\ndef process(obj):\n if obj:\n return obj.value\n return None\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is null check: using 'if obj:' instead of 'if obj is not None:'.\n\n**Improved code:**\n```python\ndef process(obj):\n if obj is not None:\n return obj.value\n return None\n```", "sample_id": "python_easy_27f89ed6", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_medium_7153cec6", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nresult = very_long_function_call_v334(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v334(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_medium_b88e6d88", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef calc_v1617(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v1617(first_number, second_number):\n```", "sample_id": "python_hard_a73e6b7d", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_easy_1485a906", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef function_v1816():\n # Buggy: list = list + [x]\n x = 10\n result = x list = list + [x] 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is list append: using 'list = list + [x]' instead of 'list.append(x)'.\n\n**Improved code:**\n```python\ndef function_v1816():\n # Fixed: list.append(x)\n x = 10\n result = x list.append(x) 2\n return result\n```", "sample_id": "python_medium_ab9a2ca3", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement DFS in Python\n\nInput code:\n```python\ndef dfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented DFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef dfs(graph, start, visited=None):\n if visited is None:\n visited = set()\n \n visited.add(start)\n print(start)\n \n for neighbor in graph[start]:\n if neighbor not in visited:\n dfs(graph, neighbor, visited)\n \n return visited\n```", "sample_id": "python_medium_17de1f3f", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: cache results\n\n**Improved code:**\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 1:\n return n\n return fib(n-1) + fib(n-2)\n```", "sample_id": "python_hard_50a18830", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v696):\n```", "sample_id": "python_medium_a2d8130f", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef process_v809():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v809():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_hard_2643a4a1", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef calc_v1864(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v1864(first_number, second_number):\n```", "sample_id": "python_medium_eb51984b", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v1706):\n```", "sample_id": "python_medium_160d5902", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\nresult = very_long_function_call_v968(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v968(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_medium_4605c118", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef calc_v581(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v581(first_number, second_number):\n```", "sample_id": "python_hard_c1b87fdb", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_medium_a92c2d8e", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef function_v1781():\n # Buggy: range(1, n)\n x = 10\n result = x range(1, n) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is range: using 'range(1, n)' instead of 'range(n)'.\n\n**Improved code:**\n```python\ndef function_v1781():\n # Fixed: range(n)\n x = 10\n result = x range(n) 2\n return result\n```", "sample_id": "python_medium_cb3a0ee1", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_medium_7673ea8a", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_medium_723519b4", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_medium_a92c2d8e", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_easy_a92c2d8e", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\nfor i in range(n_v1934):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v1934):\n if condition:\n break\n```", "sample_id": "python_medium_06a3510e", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\ndef add_v641(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v641(a: int, b: int) -> int:\n```", "sample_id": "python_hard_7ad652d8", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement binary search in Python\n\nInput code:\n```python\ndef binary_search(arr, target):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented binary search algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n```", "sample_id": "python_easy_7673ea8a", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_medium_0308de8d", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef function_v1193():\n # Buggy: ==\n x = 10\n result = x == 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is assignment: using '==' instead of '='.\n\n**Improved code:**\n```python\ndef function_v1193():\n # Fixed: =\n x = 10\n result = x = 2\n return result\n```", "sample_id": "python_medium_f48590a9", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v269):\n```", "sample_id": "python_medium_c2342ae0", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_hard_3988ac6d", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v1890):\n```", "sample_id": "python_medium_7b1ffe10", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v1359):\n```", "sample_id": "python_hard_5ca12f9a", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_easy_0308de8d", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nresult = []\nfor x in list:\n result.append(x*2)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: use built-in\n\n**Improved code:**\n```python\nresult = [x*2 for x in list]\n```", "sample_id": "python_medium_e96dfa9a", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v1769):\n```", "sample_id": "python_hard_9d1bd693", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef function_v1302():\n # Buggy: ==\n x = 10\n result = x == 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is assignment: using '==' instead of '='.\n\n**Improved code:**\n```python\ndef function_v1302():\n # Fixed: =\n x = 10\n result = x = 2\n return result\n```", "sample_id": "python_easy_747cde24", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_easy_8d441813", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_easy_a92c2d8e", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef function_v333():\n # Buggy: '{}'.format(x)\n x = 10\n result = x '{}'.format(x) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is string format: using ''{}'.format(x)' instead of 'f'{x}''.\n\n**Improved code:**\n```python\ndef function_v333():\n # Fixed: f'{x}'\n x = 10\n result = x f'{x}' 2\n return result\n```", "sample_id": "python_medium_ae070443", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_hard_0faa9843", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef process(obj):\n if obj:\n return obj.value\n return None\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is null check: using 'if obj:' instead of 'if obj is not None:'.\n\n**Improved code:**\n```python\ndef process(obj):\n if obj is not None:\n return obj.value\n return None\n```", "sample_id": "python_medium_eac796f4", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_easy_1485a906", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef add_v167(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v167(a: int, b: int) -> int:\n```", "sample_id": "python_hard_57e481f8", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_hard_7153cec6", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef process_v807():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v807():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_easy_22a80ab9", "language": "python", "difficulty": "easy"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_easy_a92c2d8e", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(n_v1322):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v1322):\n if condition:\n break\n```", "sample_id": "python_medium_93e5d53e", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef process_v21():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v21():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_easy_9815b02c", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef function_v1938():\n # Buggy: /\n x = 10\n result = x / 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is division: using '/' instead of '//'.\n\n**Improved code:**\n```python\ndef function_v1938():\n # Fixed: //\n x = 10\n result = x // 2\n return result\n```", "sample_id": "python_easy_71aade8e", "language": "python", "difficulty": "easy"} +{"text": "user\nFix the bug in this Python function\n\nInput code:\n```python\ndef process(obj):\n if obj:\n return obj.value\n return None\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is null check: using 'if obj:' instead of 'if obj is not None:'.\n\n**Improved code:**\n```python\ndef process(obj):\n if obj is not None:\n return obj.value\n return None\n```", "sample_id": "python_easy_0946810e", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef process_v709():\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add docstring\n\n**Improved code:**\n```python\ndef process_v709():\n \"\"\"Process the data and return results.\"\"\"\n```", "sample_id": "python_easy_4ce28a0e", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_medium_6f2ce38b", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef calc_v1183(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v1183(first_number, second_number):\n```", "sample_id": "python_hard_70eb4529", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\nif status == 1:\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: use constants\n\n**Improved code:**\n```python\nSTATUS_ACTIVE = 1\n\nif status == STATUS_ACTIVE:\n```", "sample_id": "python_hard_8d441813", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement merge sort in Python\n\nInput code:\n```python\ndef merge_sort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented merge sort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n \n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n \n result.extend(left[i:])\n result.extend(right[j:])\n return result\n```", "sample_id": "python_easy_0faa9843", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this search function implementation\n\nInput code:\n```python\nfor i in range(n_v289):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: add early termination\n\n**Improved code:**\n```python\nfor i in range(n_v289):\n if condition:\n break\n```", "sample_id": "python_hard_233fc7ac", "language": "python", "difficulty": "hard"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_medium_1485a906", "language": "python", "difficulty": "medium"} +{"text": "user\nRefactor this code to simplify boolean expression\n\nInput code:\n```python\nif condition == True:\n return True\nelse:\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to simplify boolean expression for better readability and performance.\n\n**Improved code:**\n```python\nreturn condition\n```", "sample_id": "python_medium_3988ac6d", "language": "python", "difficulty": "medium"} +{"text": "user\nFix the bug in this Python loop\n\nInput code:\n```python\ndef function_v45():\n # Buggy: range(1, n)\n x = 10\n result = x range(1, n) 2\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is range: using 'range(1, n)' instead of 'range(n)'.\n\n**Improved code:**\n```python\ndef function_v45():\n # Fixed: range(n)\n x = 10\n result = x range(n) 2\n return result\n```", "sample_id": "python_easy_7aa562cc", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nresult = very_long_function_call_v893(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v893(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_hard_a15cb59c", "language": "python", "difficulty": "hard"} +{"text": "user\nImprove the code style and readability of this class\n\nInput code:\n```python\nresult = very_long_function_call_v1211(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v1211(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_easy_24b20b57", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use enumerate\n\nInput code:\n```python\nfor i in range(len(items)):\n print(i, items[i])\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use enumerate for better readability and performance.\n\n**Improved code:**\n```python\nfor i, item in enumerate(items):\n print(i, item)\n```", "sample_id": "python_hard_de2f3509", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python conditional\n\nInput code:\n```python\ndef process(obj):\n if obj:\n return obj.value\n return None\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is null check: using 'if obj:' instead of 'if obj is not None:'.\n\n**Improved code:**\n```python\ndef process(obj):\n if obj is not None:\n return obj.value\n return None\n```", "sample_id": "python_medium_819ae0ca", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\nresult = very_long_function_call_v122(param1, param2, param3, param4, param5)\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: split long lines\n\n**Improved code:**\n```python\nresult = very_long_function_call_v122(\n param1, param2, param3,\n param4, param5\n)\n```", "sample_id": "python_medium_f69b8e97", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this data structure implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v1736):\n```", "sample_id": "python_hard_e65da3ec", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this sorting algorithm implementation\n\nInput code:\n```python\nfor i in range(len(arr)):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: avoid repeated calculations\n\n**Improved code:**\n```python\nn = len(arr)\nfor i in range(n_v1888):\n```", "sample_id": "python_hard_b79c9bbe", "language": "python", "difficulty": "hard"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nfor i in range(n_v148):\n for j in range(n_v148):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v148):\n for j in range(i+1, n):\n```", "sample_id": "python_hard_31ea93f5", "language": "python", "difficulty": "hard"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_easy_7153cec6", "language": "python", "difficulty": "easy"} +{"text": "user\nOptimize this loop implementation\n\nInput code:\n```python\nfor i in range(n_v380):\n for j in range(n_v380):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v380):\n for j in range(i+1, n):\n```", "sample_id": "python_medium_c89ef435", "language": "python", "difficulty": "medium"} +{"text": "user\nOptimize this recursion implementation\n\nInput code:\n```python\nfor i in range(n_v16):\n for j in range(n_v16):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Optimized by: reduce complexity\n\n**Improved code:**\n```python\nfor i in range(n_v16):\n for j in range(i+1, n):\n```", "sample_id": "python_hard_2b44e9ce", "language": "python", "difficulty": "hard"} +{"text": "user\nFix the bug in this Python method\n\nInput code:\n```python\ndef check_value(x, y):\n if x > y:\n return True\n return False\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** The bug is comparison: using '>' instead of '>='.\n\n**Improved code:**\n```python\ndef check_value(x, y):\n if x >= y:\n return True\n return False\n```", "sample_id": "python_medium_625692f9", "language": "python", "difficulty": "medium"} +{"text": "user\nImprove the code style and readability of this module\n\nInput code:\n```python\ndef add_v213(a, b):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: add type hints\n\n**Improved code:**\n```python\ndef add_v213(a: int, b: int) -> int:\n```", "sample_id": "python_easy_32f9f050", "language": "python", "difficulty": "easy"} +{"text": "user\nImprove the code style and readability of this function\n\nInput code:\n```python\ndef calc_v131(x, y):\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Improved by: better variable names\n\n**Improved code:**\n```python\ndef calculate_sum_v131(first_number, second_number):\n```", "sample_id": "python_medium_f38da2fa", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement quicksort in Python\n\nInput code:\n```python\ndef quicksort(arr):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented quicksort algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n \n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)\n```", "sample_id": "python_easy_7153cec6", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to extract method\n\nInput code:\n```python\ndef process_data(data):\n # validation\n if not data:\n return None\n if len(data) < 10:\n return None\n # processing\n result = []\n for item in data:\n result.append(item * 2)\n return result\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to extract method for better readability and performance.\n\n**Improved code:**\n```python\ndef process_data(data):\n if not _is_valid_data(data):\n return None\n return _transform_data(data)\n\ndef _is_valid_data(data):\n return data and len(data) >= 10\n\ndef _transform_data(data):\n return [item * 2 for item in data]\n```", "sample_id": "python_easy_1485a906", "language": "python", "difficulty": "easy"} +{"text": "user\nRefactor this code to use dictionary comprehension\n\nInput code:\n```python\nresult = {}\nfor key, value in items:\n result[key] = value * 2\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Refactored to use dictionary comprehension for better readability and performance.\n\n**Improved code:**\n```python\nresult = {key: value * 2 for key, value in items}\n```", "sample_id": "python_medium_6f2ce38b", "language": "python", "difficulty": "medium"} +{"text": "user\nImplement BFS in Python\n\nInput code:\n```python\ndef bfs(graph, start):\n # TODO: implement\n pass\n```\nmodel\nI'll analyze this code and provide an improved version.\n\n**Analysis:** Implemented BFS algorithm with proper logic and edge case handling.\n\n**Improved code:**\n```python\ndef bfs(graph, start):\n visited = {start}\n queue = [start]\n \n while queue:\n vertex = queue.pop(0)\n print(vertex)\n \n for neighbor in graph[vertex]:\n if neighbor not in visited:\n visited.add(neighbor)\n queue.append(neighbor)\n \n return visited\n```", "sample_id": "python_hard_a92c2d8e", "language": "python", "difficulty": "hard"}