{"query_id": "bigcodebench_00022", "query": "Combine two lists by alternating their elements, even if they are of different lengths. Elements from the longer list without a counterpart in the shorter one will be included on their own. Then, create a random sample of size K from the combined list, and calculate the frequency of each element in the sample.\nThe function should output with:\n collections.Counter: An object that counts the frequency of each element in the sample.\nYou should write self-contained code starting with:\n```\nimport collections\nfrom itertools import zip_longest\nfrom random import choices\ndef task_func(l1, l2, K=10):\n```"} {"query_id": "bigcodebench_00091", "query": "Perform a linear regression on two columns of a dataset and record the result. Additionally, generates a plot representing the original data and the fitted line.\nThe function should raise the exception for: ValueError: If the specified columns do not exist in the DataFrame.\nThe function should output with:\n tuple: The slope, intercept, r-value, p-value, and standard error of the regression.\n Axes: The matplotlib Axes object containing the plot.\nYou should write self-contained code starting with:\n```\nfrom scipy.stats import linregress\nimport matplotlib.pyplot as plt\ndef task_func(data, column1, column2):\n```"} {"query_id": "bigcodebench_00247", "query": "Generate a random dataset of floating point numbers, truncate each value to 3 decimal places and normalize the data using standard scaling (mean = 0, std = 1).\nNote that: The function use \"Normalized Value\" for the column name in the DataFrame that being returned.\nThe function should raise the exception for: If max_value is less than min_value, a ValueError is raised.\nThe function should output with:\n DataFrame: A pandas DataFrame with the normalized data.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nimport random\nfrom sklearn.preprocessing import StandardScaler\n# Constants\nN_DATA_POINTS = 5000\nMIN_VALUE = 0.0\nMAX_VALUE = 10.0\ndef task_func(n_data_points=5000, min_value=0.0, max_value=10.0):\n```"} {"query_id": "bigcodebench_00268", "query": "Create a Python dictionary with a specified number of keys and values.\nNote that: Keys are randomly selected from a predefined list of letters, and values are consecutive integers starting from 1. Due to the randomness in key selection, the actual keys in the dictionary may vary in each execution.\nThe function should output with:\n dict: A Python dictionary with keys as strings and values as lists of integers.\nYou should write self-contained code starting with:\n```\nimport collections\nimport random\n# Constants\nLETTERS = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']\ndef task_func(n_keys, n_values):\n```"} {"query_id": "bigcodebench_00314", "query": "Makes an HTTPS GET request to a specified server and path, and retrieves the response.\nThe function should raise the exception for: ssl.SSLError: If there is an SSL handshake error.\nThe function should output with:\n str: The response body from the server as a string.\nYou should write self-contained code starting with:\n```\nimport socket\nimport ssl\nimport http.client\ndef task_func(SERVER_NAME, SERVER_PORT, path):\n```"} {"query_id": "bigcodebench_00372", "query": "Processes all Word (.docx) files in the provided directory, searching for double quotes in the text and adding a backslash before each double quote to \"protect\" it.\nThe function should output with:\n int: Number of .docx files processed.\nYou should write self-contained code starting with:\n```\nimport re\nimport glob\nfrom docx import Document\ndef task_func(directory_path: str) -> int:\n```"} {"query_id": "bigcodebench_00701", "query": "Perform a linear regression analysis on a given DataFrame.\nThe function should output with:\n score (float): The R-squared score of the model.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nfrom sklearn.linear_model import LinearRegression\ndef task_func(df, target):\n```"} {"query_id": "bigcodebench_00876", "query": "Modifies a dictionary, sorts it by the frequency of its values, and backs up files from a source directory. This function performs three main tasks: 1. Updates the input dictionary by adding a key 'a' with the value 1. 2. Sorts the dictionary by the frequency of its values in descending order. 3. Backs up all files from the specified source directory to a backup directory. >>> data_dict = {'avc': '1', 'hello': 'world', 'test': 'world', 'cat': 'meow'} >>> updated_dict, value_frequencies, backup_status = task_func(data_dict, 'to_backup', 'backup') >>> print(updated_dict) {'a': 1, 'avc': '1', 'hello': 'world', 'test': 'world', 'cat': 'meow'} >>> print(value_frequencies) [('avc', 1), ('world', 2), ('meow', 1), (1, 2)] >>> print(backup_status) True\nThe function should output with:\n tuple:\n dict: The modified dictionary with the added key and value.\n list: A list of tuples representing the sorted items of the dictionary by their frequency.\n bool: A boolean indicating whether the backup was successful (True) or not (False).\nYou should write self-contained code starting with:\n```\nimport collections\nimport operator\nimport os\nimport shutil\ndef task_func(data_dict, source_directory, backup_directory):\n```"} {"query_id": "bigcodebench_00936", "query": "Draws a bar chart representing the positions of each letter in the given word within the English alphabet using numpy and matplotlib.pyplot. Constants: - ALPHABET: A list containing all lowercase letters of the English alphabet.\nNote that: The function uses the index of each letter in the English alphabet to represent its position. For example, 'a' will be represented by 1, 'b' by 2, and so on.\nThe function should output with:\n Axes: A matplotlib.axes._axes.Axes object representing the generated plot.\nYou should write self-contained code starting with:\n```\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport string\n# Constants\nALPHABET = list(string.ascii_lowercase)\ndef task_func(word):\n```"} {"query_id": "bigcodebench_01086", "query": "Generates a DataFrame with two columns: a string field and a float field. The string field contains randomly generated strings of 10 ASCII letters. The float field contains randomly generated numbers between 0 and 10000, formatted with two decimal places and a comma as the thousands separator.\nNote that: The exact values in the dataset will vary as they are randomly generated.\nThe function should output with:\n DataFrame: A pandas DataFrame with NUM_SAMPLES rows. Each row contains a\n random string in the 'String Field' column and a formatted float in the\n 'Float Field' column.\nYou should write self-contained code starting with:\n```\nimport string\nimport random\nimport pandas as pd\nimport numpy as np\n# Constants\nNUM_SAMPLES = 1000 # Number of samples\ndef task_func():\n```"}