commit 500e2db71e4f1749f808d1700a4c685acb69c97a Author: p14698207 Date: Tue Nov 12 02:40:53 2024 +0000 last diff --git a/.gitattributes b/.gitattributes new file mode 100755 index 0000000..01c5811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +*.safetensors filter=lfs diff=lfs merge=lfs -text +llm_conda.tar.gz filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..e8511ad --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +model_final/* +!model_final/*.txt +checkpoints/* \ No newline at end of file diff --git a/datasets/eval.parquet b/datasets/eval.parquet new file mode 100644 index 0000000..71cd5d1 Binary files /dev/null and b/datasets/eval.parquet differ diff --git a/datasets/readme.txt b/datasets/readme.txt new file mode 100644 index 0000000..1fc53c3 --- /dev/null +++ b/datasets/readme.txt @@ -0,0 +1,4 @@ +数据总结 + +jtatman/python-code-dataset-500k数据格式化 +总共为58915条数据 diff --git a/datasets/数据.parquet b/datasets/数据.parquet new file mode 100644 index 0000000..993568a Binary files /dev/null and b/datasets/数据.parquet differ diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..c3c7c03 --- /dev/null +++ b/dockerfile @@ -0,0 +1,21 @@ +FROM pytorch/pytorch:2.4.0-cuda12.1-cudnn9-devel + +WORKDIR /app + +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +RUN apt-get clean && \ + rm -rf /var/lib/apt/lists/* && \ + rm -rf /root/.cache/pip + +RUN chmod +x training/train_py.sh + +RUN echo '#!/bin/bash\n\ +cd /app/training && ./train_py.sh\n\ +cd /app && python inference.py\n\ +' > /app/run.sh && chmod +x /app/run.sh + +ENTRYPOINT ["/app/run.sh"] \ No newline at end of file diff --git a/inference.py b/inference.py new file mode 100755 index 0000000..9360e51 --- /dev/null +++ b/inference.py @@ -0,0 +1,74 @@ +from typing import List, Dict, Any +import json +import torch +from tqdm import tqdm +from transformers import AutoModelForCausalLM, AutoTokenizer + +def generate_responses(model: AutoModelForCausalLM, + tokenizer: AutoTokenizer, + texts: List[str]) -> List[str]: + """批量生成模型响应""" + inputs = tokenizer(texts, return_tensors="pt", padding=True).to(model.device) + outputs = model.generate(inputs['input_ids'], + max_new_tokens=256, + pad_token_id=0) + return tokenizer.batch_decode(outputs, skip_special_tokens=True) + +def format_prompt(sample: Dict[str, Any]) -> str: + """根据输入样本格式化提示文本""" + if 'choices' in sample: + return f"<用户>{sample['question']}\n{''.join(sample['choices'])}" + + if sample['question'].strip().startswith("Write"): + return f"<用户>{sample['question']} def" + + return f"{sample['question']}\n " + +def process_response(response: str, question: str) -> str: + """处理模型输出的响应""" + return response.split('')[1].strip() + +def run_inference(model_path: str, input_path: str, output_path: str): + """执行推理流程""" + # 初始化模型和分词器 + model = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True) + model = model.to("cuda").to(dtype=torch.bfloat16) + model.eval() + + tokenizer = AutoTokenizer.from_pretrained(model_path) + tokenizer.pad_token = tokenizer.unk_token + tokenizer.pad_token_id = tokenizer.unk_token_id + tokenizer.add_eos_token = False + + # 读取数据 + with open(input_path) as f: + samples = [json.loads(line) for line in f] + + # 批量处理 + batch_size = 8 + for start_idx in tqdm(range(0, len(samples), batch_size)): + batch = samples[start_idx:start_idx + batch_size] + + # 准备输入 + prompts = [format_prompt(sample) for sample in batch] + + # 生成响应 + raw_outputs = generate_responses(model, tokenizer, prompts) + + # 处理输出 + for i, (sample, output) in enumerate(zip(batch, raw_outputs)): + processed_response = process_response(output, sample['question']) + samples[start_idx + i]['raw_outputs'] = [processed_response] + + # 保存结果 + with open(output_path, 'w', encoding='utf-8') as f: + for sample in samples: + json.dump(sample, f, ensure_ascii=False) + f.write('\n') + +if __name__ == '__main__': + MODEL_PATH = 'checkpoints/py/checkpoint-15000' + INPUT_FILE = 'test_set/代码生成_round4.jsonl' + OUTPUT_FILE = 'test_set/code_generation_result.jsonl' + + run_inference(MODEL_PATH, INPUT_FILE, OUTPUT_FILE) \ No newline at end of file diff --git a/logs/logs.txt b/logs/logs.txt new file mode 100644 index 0000000..f9c7153 --- /dev/null +++ b/logs/logs.txt @@ -0,0 +1,12476 @@ +/data02/users/lz/miniconda3/envs/cpm/lib/python3.10/site-packages/torch/_utils.py:831: UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly. To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage() + return self.fget.__get__(instance, owner)() +/data02/users/lz/miniconda3/envs/cpm/lib/python3.10/site-packages/torch/_utils.py:831: UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly. To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage() + return self.fget.__get__(instance, owner)() +/data02/users/lz/miniconda3/envs/cpm/lib/python3.10/site-packages/torch/_utils.py:831: UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly. To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage() + return self.fget.__get__(instance, owner)() +/data02/users/lz/miniconda3/envs/cpm/lib/python3.10/site-packages/torch/_utils.py:831: UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly. To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage() + return self.fget.__get__(instance, owner)() + Generating train split: 0 examples [00:00, ? examples/s] Generating train split: 61458 examples [00:00, 385951.50 examples/s] Generating train split: 61458 examples [00:00, 381522.15 examples/s] + Generating train split: 0 examples [00:00, ? examples/s] Generating train split: 200 examples [00:00, 82467.64 examples/s] + Map (num_proc=16): 0%| | 0/61458 [00:00 int:\n \"\"\"\n You are given a 0-indexed string s typed by a user. Changing a key is defined as using a key different from the last used key. For example, s = \"ab\" has a change of a key while s = \"bBBb\" does not have any.\n\n Return the number of times the user had to change the key.\n\n Note: Modifiers like shift or caps lock won't be counted in changing the key that is if a user typed the letter 'a' and then the letter 'A' then it will not be considered as a changing of key.\n\n Examples:\n >>> s = \"aAbBcC\"\n 2\n >>> s = \"AaAaAaaA\"\n 0\n\n Constraints:\n 1 <= s.length <= 100\n s consists of only upper case and lower case English letters.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b0702", "question": "Write a python function to check whether the given number is a perfect square or not.\nassert is_Perfect_Square(10) == False\nassert is_Perfect_Square(36) == True\nassert is_Perfect_Square(14) == False\n", "raw_outputs": ""} +{"task_id": "b6212", "question": "Write a function to add a dictionary to the tuple.\nassert add_dict_to_tuple((4, 5, 6), {\"MSAM\" : 1, \"is\" : 2, \"best\" : 3} ) == (4, 5, 6, {'MSAM': 1, 'is': 2, 'best': 3})\nassert add_dict_to_tuple((1, 2, 3), {\"UTS\" : 2, \"is\" : 3, \"Worst\" : 4} ) == (1, 2, 3, {'UTS': 2, 'is': 3, 'Worst': 4})\nassert add_dict_to_tuple((8, 9, 10), {\"POS\" : 3, \"is\" : 4, \"Okay\" : 5} ) == (8, 9, 10, {'POS': 3, 'is': 4, 'Okay': 5})\n", "raw_outputs": ""} +{"task_id": "a7114", "question": "\n\ndef sum_to_n(n: int):\n \"\"\"sum_to_n is a function that sums numbers from 1 to n.\n >>> sum_to_n(30)\n 465\n >>> sum_to_n(100)\n 5050\n >>> sum_to_n(5)\n 15\n >>> sum_to_n(10)\n 55\n >>> sum_to_n(1)\n 1\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b8330", "question": "Write a function to find the length of the shortest string that has both str1 and str2 as subsequences.\nassert super_seq(\"AGGTAB\", \"GXTXAYB\", 6, 7) == 9\nassert super_seq(\"feek\", \"eke\", 4, 3) == 5\nassert super_seq(\"PARRT\", \"RTA\", 5, 3) == 6\n", "raw_outputs": ""} +{"task_id": "a2073", "question": "\ndef will_it_fly(q,w):\n '''\n Write a function that returns True if the object q will fly, and False otherwise.\n The object q will fly if it's balanced (it is a palindromic list) and the sum of its elements is less than or equal the maximum possible weight w.\n\n Example:\n will_it_fly([1, 2], 5) ➞ False \n # 1+2 is less than the maximum possible weight, but it's unbalanced.\n\n will_it_fly([3, 2, 3], 1) ➞ False\n # it's balanced, but 3+2+3 is more than the maximum possible weight.\n\n will_it_fly([3, 2, 3], 9) ➞ True\n # 3+2+3 is less than the maximum possible weight, and it's balanced.\n\n will_it_fly([3], 5) ➞ True\n # 3 is less than the maximum possible weight, and it's balanced.\n '''\n", "raw_outputs": ""} +{"task_id": "a1057", "question": "from typing import List\n\ndef generate_non_consecutive_zero_binary(n: int) -> List[str]:\n \"\"\"\n You are given a positive integer n.\n\n A binary string x is valid if all substrings of x of length 2 contain at least one \"1\".\n\n Return all valid strings with length n, in any order.\n\n Examples:\n >>> n = 3\n ['010','011','101','110','111']\n >>> n = 1\n ['0','1']\n\n Constraints:\n 1 <= n <= 18\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b6766", "question": "Write a function to filter the given list of any Python values, only keeping the integers.\nassert filter_integers([]) == []\nassert filter_integers([4, {}, [], 23.2, 9, 'adasd']) == [4, 9]\nassert filter_integers([3, 'c', 3, 3, 'a', 'b']) == [3, 3, 3]\n", "raw_outputs": ""} +{"task_id": "b1075", "question": "Write a function to assign frequency to each tuple in the given tuple list.\nassert assign_freq([(6, 5, 8), (2, 7), (6, 5, 8), (6, 5, 8), (9, ), (2, 7)] ) == '[(6, 5, 8, 3), (2, 7, 2), (9, 1)]'\nassert assign_freq([(4, 2, 4), (7, 1), (4, 8), (4, 2, 4), (9, 2), (7, 1)] ) == '[(4, 2, 4, 2), (7, 1, 2), (4, 8, 1), (9, 2, 1)]'\nassert assign_freq([(11, 13, 10), (17, 21), (4, 2, 3), (17, 21), (9, 2), (4, 2, 3)] ) == '[(11, 13, 10, 1), (17, 21, 2), (4, 2, 3, 2), (9, 2, 1)]'\n", "raw_outputs": ""} +{"task_id": "a9881", "question": "from typing import List\n\n\ndef has_close_elements(numbers: List[float], threshold: float) -> bool:\n \"\"\" Check if in given list of numbers, are any two numbers closer to each other than\n given threshold.\n >>> has_close_elements([1.0, 2.0, 3.0], 0.5)\n False\n >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)\n True\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a9044", "question": "from typing import List\nfrom collections import Counter\nfrom heapq import heapify, heapreplace\nfrom string import ascii_lowercase\n\ndef minimize_string_value(s: str) -> str:\n \"\"\"\n You are given a string s. s[i] is either a lowercase English letter or '?'.\n\n For a string t having length m containing only lowercase English letters, we define the function cost(i) for an index i as the number of characters equal to t[i] that appeared before it, i.e. in the range [0, i - 1].\n\n The value of t is the sum of cost(i) for all indices i.\n\n For example, for the string t = \"aab\":\n\n cost(0) = 0\n cost(1) = 1\n cost(2) = 0\n Hence, the value of \"aab\" is 0 + 1 + 0 = 1.\n Your task is to replace all occurrences of '?' in s with any lowercase English letter so that the value of s is minimized.\n\n Return a string denoting the modified string with replaced occurrences of '?'. If there are multiple strings resulting in the minimum value, return the lexicographically smallest one.\n\n Examples:\n >>> s = \"???\"\n abc\n >>> s = \"a?a?\"\n abac\n\n Constraints:\n 1 <= s.length <= 10^5\n s[i] is either a lowercase English letter or '?'.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a2892", "question": "from typing import List\nfrom collections import defaultdict\nfrom math import isqrt\ndef number_of_quality_pairs(nums1: List[int], nums2: List[int], k: int) -> int:\n \"\"\"\n You are given 2 integer arrays nums1 and nums2 of lengths n and m respectively. You are also given a positive integer k.\n\n A pair (i, j) is called good if nums1[i] is divisible by nums2[j] * k (0 <= i <= n - 1, 0 <= j <= m - 1).\n\n Return the total number of good pairs.\n\n Examples:\n >>> nums1 = [1,3,4], nums2 = [1,3,4], k = 1\n 5\n >>> nums1 = [1,2,4,12], nums2 = [2,4], k = 3\n 2\n\n Constraints:\n 1 <= n, m <= 50\n 1 <= nums1[i], nums2[j] <= 50\n 1 <= k <= 50\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b4446", "question": "Write a python function to find the missing number in a sorted array.\nassert find_missing([1,2,3,5],4) == 4\nassert find_missing([1,3,4,5],4) == 2\nassert find_missing([1,2,3,5,6,7],5) == 4\n", "raw_outputs": ""} +{"task_id": "a1054", "question": "\n\ndef sort_even(l: list):\n \"\"\"This function takes a list l and returns a list l' such that\n l' is identical to l in the odd indicies, while its values at the even indicies are equal\n to the values of the even indicies of l, but sorted.\n >>> sort_even([1, 2, 3])\n [1, 2, 3]\n >>> sort_even([5, 6, 3, 4])\n [3, 6, 5, 4]\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a6676", "question": "from typing import List\nfrom math import inf\n\ndef minimum_moves(nums: List[int], k: int, maxChanges: int) -> int:\n \"\"\"\n You are given a binary array nums of length n, a positive integer k and a non-negative integer maxChanges.\n\n Alice plays a game, where the goal is for Alice to pick up k ones from nums using the minimum number of moves. When the game starts, Alice picks up any index aliceIndex in the range [0, n - 1] and stands there. If nums[aliceIndex] == 1 , Alice picks up the one and nums[aliceIndex] becomes 0(this does not count as a move). After this, Alice can make any number of moves (including zero) where in each move Alice must perform exactly one of the following actions:\n\n Select any index j != aliceIndex such that nums[j] == 0 and set nums[j] = 1. This action can be performed at most maxChanges times.\n Select any two adjacent indices x and y (|x - y| == 1) such that nums[x] == 1, nums[y] == 0, then swap their values (set nums[y] = 1 and nums[x] = 0). If y == aliceIndex, Alice picks up the one after this move and nums[y] becomes 0.\n Return the minimum number of moves required by Alice to pick exactly k ones.\n\n Examples:\n >>> nums = [1,1,0,0,0,1,1,0,0,1], k = 3, maxChanges = 1\n 3\n >>> nums = [0,0,0,0], k = 2, maxChanges = 3\n 4\n\n Constraints:\n 2 <= n <= 10^5\n 0 <= nums[i] <= 1\n 1 <= k <= 10^5\n 0 <= maxChanges <= 10^5\n maxChanges + sum(nums) >= k\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a8485", "question": "from typing import List\nfrom math import inf\nfrom heapq import nlargest, nsmallest\n\ndef min_distance_after_removing_point(points: List[List[int]]) -> int:\n \"\"\"\n You are given a array points representing integer coordinates of some points on a 2D plane, where points[i] = [x_i, y_i].\n\n The distance between two points is defined as their Manhattan distance.\n Return the minimum possible value for maximum distance between any two points by removing exactly one point.\n\n Examples:\n >>> points = [[3,10],[5,15],[10,2],[4,4]]\n 12\n >>> points = [[1,1],[1,1],[1,1]]\n 0\n\n Constraints:\n 3 <= points.length <= 10^5\n points[i].length == 2\n 1 <= points[i][0], points[i][1] <= 10^8\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a0375", "question": "\n\ndef how_many_times(string: str, substring: str) -> int:\n \"\"\" Find how many times a given substring can be found in the original string. Count overlaping cases.\n >>> how_many_times('', 'a')\n 0\n >>> how_many_times('aaa', 'a')\n 3\n >>> how_many_times('aaaa', 'aa')\n 3\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b0098", "question": "Write a function to return a sorted list of all elements from a given list of positive integers, where each element doesn't have any even digit.\nassert unique_digits([15, 33, 1422, 1]) == [1, 15, 33]\nassert unique_digits([152, 323, 1422, 10]) == []\nassert unique_digits([12345, 2033, 111, 151]) == [111, 151]\nassert unique_digits([135, 103, 31]) == [31, 135]\n", "raw_outputs": ""} +{"task_id": "b9625", "question": "Write a function to calculate the perimeter of a regular polygon.\nassert perimeter_polygon(4,20)==80\nassert perimeter_polygon(10,15)==150\nassert perimeter_polygon(9,7)==63\n", "raw_outputs": ""} +{"task_id": "b5391", "question": "Write a function to find the maximum product formed by multiplying numbers of an increasing subsequence of that array.\nassert max_product([3, 100, 4, 5, 150, 6], 6) == 45000 \nassert max_product([4, 42, 55, 68, 80], 5) == 50265600\nassert max_product([10, 22, 9, 33, 21, 50, 41, 60], 8) == 21780000 \n", "raw_outputs": ""} +{"task_id": "b6525", "question": "Write a function to search some literals strings in a string by using regex.\nassert check_literals('The quick brown fox jumps over the lazy dog.',['fox']) == 'Matched!'\nassert check_literals('The quick brown fox jumps over the lazy dog.',['horse']) == 'Not Matched!'\nassert check_literals('The quick brown fox jumps over the lazy dog.',['lazy']) == 'Matched!'\n", "raw_outputs": ""} +{"task_id": "b0739", "question": "Write a function to sort the given array by using heap sort.\nassert heap_sort([12, 2, 4, 5, 2, 3]) == [2, 2, 3, 4, 5, 12]\nassert heap_sort([32, 14, 5, 6, 7, 19]) == [5, 6, 7, 14, 19, 32]\nassert heap_sort([21, 15, 29, 78, 65]) == [15, 21, 29, 65, 78]\n", "raw_outputs": ""} +{"task_id": "a2546", "question": "\ndef any_int(x, y, z):\n '''\n Create a function that takes 3 numbers.\n Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers.\n Returns false in any other cases.\n \n Examples\n any_int(5, 2, 7) ➞ True\n \n any_int(3, 2, 2) ➞ False\n\n any_int(3, -2, 1) ➞ True\n \n any_int(3.6, -2.2, 2) ➞ False\n \n\n \n '''\n", "raw_outputs": ""} +{"task_id": "a0451", "question": "\n\ndef fib(n: int):\n \"\"\"Return n-th Fibonacci number.\n >>> fib(10)\n 55\n >>> fib(1)\n 1\n >>> fib(8)\n 21\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b8363", "question": "Write a function to find the maximum sum we can make by dividing number in three parts recursively and summing them up together for the given number.\nassert breakSum(12) == 13\nassert breakSum(24) == 27\nassert breakSum(23) == 23\n", "raw_outputs": ""} +{"task_id": "a1550", "question": "from typing import List\n\ndef count_alternating_subarrays(nums: List[int]) -> int:\n \"\"\"\n You are given a binary array nums.\n\n We call a subarray alternating if no two adjacent elements in the subarray have the same value.\n\n Return the number of alternating subarrays in nums.\n\n Examples:\n >>> nums = [0,1,1,1]\n 5\n >>> nums = [1,0,1,0]\n 10\n\n Constraints:\n 1 <= nums.length <= 10^5\n nums[i] is either 0 or 1.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b8837", "question": "Write a function to get the n largest items from a dataset.\nassert larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],2)==[100,90]\nassert larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],5)==[100,90,80,70,60]\nassert larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],3)==[100,90,80]\n", "raw_outputs": ""} +{"task_id": "b7614", "question": "Write a function to obtain the Roman numeral equivalent of a given positive integer, and return it in lowercase. The integer restricts from 1 to 1000.\nassert int_to_mini_roman(19) == 'xix'\nassert int_to_mini_roman(152) == 'clii'\nassert int_to_mini_roman(251) == 'ccli'\nassert int_to_mini_roman(426) == 'cdxxvi'\nassert int_to_mini_roman(500) == 'd'\nassert int_to_mini_roman(1) == 'i'\nassert int_to_mini_roman(4) == 'iv'\nassert int_to_mini_roman(43) == 'xliii'\nassert int_to_mini_roman(90) == 'xc'\nassert int_to_mini_roman(94) == 'xciv'\nassert int_to_mini_roman(532) == 'dxxxii'\nassert int_to_mini_roman(900) == 'cm'\nassert int_to_mini_roman(994) == 'cmxciv'\nassert int_to_mini_roman(1000) == 'm'\n", "raw_outputs": ""} +{"task_id": "a7473", "question": "from typing import List\n\ndef get_child_with_ball_after_k_seconds(n: int, k: int) -> int:\n \"\"\"\n You are given two positive integers n and k. There are n children numbered from 0 to n - 1 standing in a queue in order from left to right.\n\n Initially, child 0 holds a ball and the direction of passing the ball is towards the right direction. After each second, the child holding the ball passes it to the child next to them. Once the ball reaches either end of the line, i.e. child 0 or child n - 1, the direction of passing is reversed.\n\n Return the number of the child who receives the ball after k seconds.\n\n Examples:\n >>> n = 3, k = 5\n 1\n >>> n = 5, k = 6\n 2\n\n Constraints:\n 2 <= n <= 50\n 1 <= k <= 50\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a6589", "question": "\n\n\ndef sum_squares(lst):\n \"\"\"\"\n This function will take a list of integers. For all entries in the list, the function shall square the integer entry if its index is a \n multiple of 3 and will cube the integer entry if its index is a multiple of 4 and not a multiple of 3. The function will not \n change the entries in the list whose indexes are not a multiple of 3 or 4. The function shall then return the sum of all entries. \n \n Examples:\n For lst = [1,2,3] the output should be 6\n For lst = [] the output should be 0\n For lst = [-1,-5,2,-1,-5] the output should be -126\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b8744", "question": "Write a function to remove lowercase substrings from a given string.\nassert remove_lowercase(\"PYTHon\")==('PYTH')\nassert remove_lowercase(\"FInD\")==('FID')\nassert remove_lowercase(\"STRinG\")==('STRG')\n", "raw_outputs": ""} +{"task_id": "a7730", "question": "from typing import List\nfrom itertools import pairwise\n\ndef is_array_special(nums: List[int]) -> bool:\n \"\"\"\n An array is considered special if every pair of its adjacent elements contains two numbers with different parity.\n\n You are given an array of integers nums. Return true if nums is a special array, otherwise, return false.\n\n Examples:\n >>> nums = [1]\n true\n >>> nums = [2,1,4]\n true\n\n Constraints:\n 1 <= nums.length <= 100\n 1 <= nums[i] <= 100\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a2337", "question": "from typing import List, Tuple\n\n\ndef rolling_max(numbers: List[int]) -> List[int]:\n \"\"\" From a given list of integers, generate a list of rolling maximum element found until given moment\n in the sequence.\n >>> rolling_max([1, 2, 3, 2, 3, 4, 2])\n [1, 2, 3, 3, 3, 4, 4]\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a2836", "question": "\ndef is_nested(string):\n '''\n Create a function that takes a string as input which contains only square brackets.\n The function should return True if and only if there is a valid subsequence of brackets \n where at least one bracket in the subsequence is nested.\n\n is_nested('[[]]') ➞ True\n is_nested('[]]]]]]][[[[[]') ➞ False\n is_nested('[][]') ➞ False\n is_nested('[]') ➞ False\n is_nested('[[][]]') ➞ True\n is_nested('[[]][[') ➞ True\n '''\n", "raw_outputs": ""} +{"task_id": "b1630", "question": "Write a function to sort the tuples alphabetically by the first item of each tuple.\nassert sort_tuple([(\"Amana\", 28), (\"Zenat\", 30), (\"Abhishek\", 29),(\"Nikhil\", 21), (\"B\", \"C\")]) == [('Abhishek', 29), ('Amana', 28), ('B', 'C'), ('Nikhil', 21), ('Zenat', 30)]\nassert sort_tuple([(\"aaaa\", 28), (\"aa\", 30), (\"bab\", 29), (\"bb\", 21), (\"csa\", \"C\")]) == [('aa', 30), ('aaaa', 28), ('bab', 29), ('bb', 21), ('csa', 'C')]\nassert sort_tuple([(\"Sarala\", 28), (\"Ayesha\", 30), (\"Suman\", 29),(\"Sai\", 21), (\"G\", \"H\")]) == [('Ayesha', 30), ('G', 'H'), ('Sai', 21), ('Sarala', 28), ('Suman', 29)]\n", "raw_outputs": ""} +{"task_id": "a9039", "question": "from typing import List\n\ndef max_points_inside_square(points: List[List[int]], s: str) -> int:\n \"\"\"\n You are given a 2D array points and a string s where, points[i] represents the coordinates of point i, and s[i] represents the tag of point i.\n\n A valid square is a square centered at the origin (0, 0), has edges parallel to the axes, and does not contain two points with the same tag.\n\n Return the maximum number of points contained in a valid square.\n\n Note:\n\n A point is considered to be inside the square if it lies on or within the square's boundaries.\n The side length of the square can be zero.\n\n Examples:\n >>> points = [[2,2],[-1,-2],[-4,4],[-3,1],[3,-3]], s = \"abdca\"\n 2\n >>> points = [[1,1],[-2,-2],[-2,2]], s = \"abb\"\n 1\n >>> points = [[1,1],[-1,-1],[2,-2]], s = \"ccd\"\n 0\n\n Constraints:\n 1 <= s.length, points.length <= 10^5\n points[i].length == 2\n -10^9 <= points[i][0], points[i][1] <= 10^9\n s.length == points.length\n points consists of distinct coordinates.\n s consists only of lowercase English letters.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a7501", "question": "\ndef get_closest_vowel(word):\n \"\"\"You are given a word. Your task is to find the closest vowel that stands between \n two consonants from the right side of the word (case sensitive).\n \n Vowels in the beginning and ending doesn't count. Return empty string if you didn't\n find any vowel met the above condition. \n\n You may assume that the given string contains English letter only.\n\n Example:\n get_closest_vowel(\"yogurt\") ==> \"u\"\n get_closest_vowel(\"FULL\") ==> \"U\"\n get_closest_vowel(\"quick\") ==> \"\"\n get_closest_vowel(\"ab\") ==> \"\"\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a5306", "question": "from typing import List\n\ndef min_levels_to_get_more_points(possible: List[int]) -> int:\n \"\"\"\n You are given a binary array possible of length n.\n\n Alice and Bob are playing a game that consists of n levels. Some of the levels in the game are impossible to clear while others can always be cleared. In particular, if possible[i] == 0, then the ith level is impossible to clear for both the players. A player gains 1 point on clearing a level and loses 1 point if the player fails to clear it.\n\n At the start of the game, Alice will play some levels in the given order starting from the 0th level, after which Bob will play for the rest of the levels.\n\n Alice wants to know the minimum number of levels she should play to gain more points than Bob, if both players play optimally to maximize their points.\n\n Return the minimum number of levels Alice should play to gain more points. If this is not possible, return -1.\n\n Note that each player must play at least 1 level.\n\n Examples:\n >>> possible = [1,0,1,0]\n 1\n >>> possible = [1,1,1,1,1]\n 3\n >>> possible = [0,0]\n -1\n\n Constraints:\n 2 <= n == possible.length <= 10^5\n possible[i] is either 0 or 1.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a4734", "question": "def min_chairs_in_waiting_room(s: str) -> int:\n \"\"\"\n You are given a string s. Simulate events at each second i:\n\n If s[i] == 'E', a person enters the waiting room and takes one of the chairs in it.\n If s[i] == 'L', a person leaves the waiting room, freeing up a chair.\n Return the minimum number of chairs needed so that a chair is available for every person who enters the waiting room given that it is initially empty.\n\n Examples:\n >>> s = \"EEEEEEE\"\n 7\n >>> s = \"ELELEEL\"\n 2\n\n Constraints:\n 1 <= s.length <= 50\n s consists only of the letters 'E' and 'L'.\n s represents a valid sequence of entries and exits.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b9898", "question": "Write a function to remove particular data type elements from the given tuple.\nassert remove_datatype((4, 5, 4, 7.7, 1.2), int) == [7.7, 1.2]\nassert remove_datatype((7, 8, 9, \"SR\"), str) == [7, 8, 9]\nassert remove_datatype((7, 1.1, 2, 2.2), float) == [7, 2]\n", "raw_outputs": ""} +{"task_id": "a1630", "question": "\n\ndef encode_cyclic(s: str):\n \"\"\"\n returns encoded string by cycling groups of three characters.\n \"\"\"\n # split string to groups. Each of length 3.\n groups = [s[(3 * i):min((3 * i + 3), len(s))] for i in range((len(s) + 2) // 3)]\n # cycle elements in each group. Unless group has fewer elements than 3.\n groups = [(group[1:] + group[0]) if len(group) == 3 else group for group in groups]\n return \"\".join(groups)\n\n\ndef decode_cyclic(s: str):\n \"\"\"\n takes as input string encoded with encode_cyclic function. Returns decoded string.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b7473", "question": "Write a function to find nth centered hexagonal number.\nassert centered_hexagonal_number(10) == 271\nassert centered_hexagonal_number(2) == 7\nassert centered_hexagonal_number(9) == 217\n", "raw_outputs": ""} +{"task_id": "b3168", "question": "Write a function to find the sum of geometric progression series.\nassert sum_gp(1,5,2)==31\nassert sum_gp(1,5,4)==341\nassert sum_gp(2,6,3)==728\n", "raw_outputs": ""} +{"task_id": "b2637", "question": "Write a python function to find whether the given number is present in the infinite sequence or not.\nassert does_Contain_B(1,7,3) == True\nassert does_Contain_B(1,-3,5) == False\nassert does_Contain_B(3,2,5) == False\n", "raw_outputs": ""} +{"task_id": "b4424", "question": "Write a function to find the area of a rombus.\nassert rombus_area(10,20)==100\nassert rombus_area(10,5)==25\nassert rombus_area(4,2)==4\n", "raw_outputs": ""} +{"task_id": "b7822", "question": "Write a function to extract year, month and date from a url by using regex.\nassert extract_date(\"https://www.washingtonpost.com/news/football-insider/wp/2016/09/02/odell-beckhams-fame-rests-on-one-stupid-little-ball-josh-norman-tells-author/\") == [('2016', '09', '02')]\nassert extract_date(\"https://www.indiatoday.in/movies/celebrities/story/wp/2020/11/03/odeof-sushant-singh-rajput-s-death-his-brother-in-law-shares-advice-for-fans-1749646/\") == [('2020', '11', '03')]\nassert extract_date(\"https://economictimes.indiatimes.com/news/economy/2020/12/29/finance/pension-assets-under-pfrda-touch-rs-5-32-lakh-crore/articleshow/79736619.cms\") == [('2020', '12', '29')]\n", "raw_outputs": ""} +{"task_id": "a8837", "question": "from typing import List\n\ndef triangle_type(nums: List[int]) -> str:\n \"\"\"\n You are given a 0-indexed integer array nums of size 3 which can form the sides of a triangle.\n\n A triangle is called equilateral if it has all sides of equal length.\n A triangle is called isosceles if it has exactly two sides of equal length.\n A triangle is called scalene if all its sides are of different lengths.\n Return a string representing the type of triangle that can be formed or \"none\" if it cannot form a triangle.\n\n Examples:\n >>> nums = [3,3,3]\n \"equilateral\"\n >>> nums = [3,4,5]\n \"scalene\"\n\n Constraints:\n nums.length == 3\n 1 <= nums[i] <= 100\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a2853", "question": "\ndef add_elements(arr, k):\n \"\"\"\n Given a non-empty array of integers arr and an integer k, return\n the sum of the elements with at most two digits from the first k elements of arr.\n\n Example:\n\n Input: arr = [111,21,3,4000,5,6,7,8,9], k = 4\n Output: 24 # sum of 21 + 3\n\n Constraints:\n 1. 1 <= len(arr) <= 100\n 2. 1 <= k <= len(arr)\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b1247", "question": "Write a python function to count true booleans in the given list.\nassert count([True,False,True]) == 2\nassert count([False,False]) == 0\nassert count([True,True,True]) == 3\n", "raw_outputs": ""} +{"task_id": "a7426", "question": "from typing import List\n\ndef sum_of_power(nums: List[int], k: int) -> int:\n \"\"\"\n You are given an integer array nums of length n and a positive integer k.\n\n The power of an array of integers is defined as the number of subsequences with their sum equal to k.\n\n Return the sum of power of all subsequences of nums.\n\n Since the answer may be very large, return it modulo 10^9 + 7.\n\n Examples:\n >>> nums = [1,2,3], k = 3\n 6\n >>> nums = [2,3,3], k = 5\n 4\n >>> nums = [1,2,3], k = 7\n 0\n\n Constraints:\n 1 <= n <= 100\n 1 <= nums[i] <= 10^4\n 1 <= k <= 100\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b0518", "question": "Write a python function to set the right most unset bit.\nassert set_Right_most_Unset_Bit(21) == 23\nassert set_Right_most_Unset_Bit(11) == 15\nassert set_Right_most_Unset_Bit(15) == 15\n", "raw_outputs": ""} +{"task_id": "a2495", "question": "\n\ndef derivative(xs: list):\n \"\"\" xs represent coefficients of a polynomial.\n xs[0] + xs[1] * x + xs[2] * x^2 + ....\n Return derivative of this polynomial in the same form.\n >>> derivative([3, 1, 2, 4, 5])\n [1, 4, 12, 20]\n >>> derivative([1, 2, 3])\n [2, 6]\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a2637", "question": "\n\ndef strlen(string: str) -> int:\n \"\"\" Return length of given string\n >>> strlen('')\n 0\n >>> strlen('abc')\n 3\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b2283", "question": "Write a python function to find the sum of all even natural numbers within the range l and r.\nassert sum_Even(2,5) == 6\nassert sum_Even(3,8) == 18\nassert sum_Even(4,6) == 10\n", "raw_outputs": ""} +{"task_id": "b4462", "question": "Write a python function to find the minimum of two numbers.\nassert minimum(1,2) == 1\nassert minimum(-5,-4) == -5\nassert minimum(0,0) == 0\n", "raw_outputs": ""} +{"task_id": "a9211", "question": "\n\ndef same_chars(s0: str, s1: str):\n \"\"\"\n Check if two words have the same characters.\n >>> same_chars('eabcdzzzz', 'dddzzzzzzzddeddabc')\n True\n >>> same_chars('abcd', 'dddddddabc')\n True\n >>> same_chars('dddddddabc', 'abcd')\n True\n >>> same_chars('eabcd', 'dddddddabc')\n False\n >>> same_chars('abcd', 'dddddddabce')\n False\n >>> same_chars('eabcdzzzz', 'dddzzzzzzzddddabc')\n False\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a6247", "question": "from typing import List\nimport heapq\ndef edges_in_shortest_paths(n: int, edges: List[List[int]]) -> List[bool]:\n \"\"\"\n You are given an undirected weighted graph of n nodes numbered from 0 to n - 1. The graph consists of m edges represented by a 2D array edges, where edges[i] = [a_i, b_i, w_i] indicates that there is an edge between nodes a_i and b_i with weight w_i.\n\n Consider all the shortest paths from node 0 to node n - 1 in the graph. You need to find a boolean array answer where answer[i] is true if the edge edges[i] is part of at least one shortest path. Otherwise, answer[i] is false.\n\n Return the array answer.\n\n Note that the graph may not be connected.\n\n Examples:\n >>> n = 6, edges = [[0,1,4],[0,2,1],[1,3,2],[1,4,3],[1,5,1],[2,3,1],[3,5,3],[4,5,2]]\n [true,true,true,false,true,true,true,false]\n >>> n = 4, edges = [[2,0,1],[0,1,1],[0,3,4],[3,2,2]]\n [true,false,false,true]\n\n Constraints:\n 2 <= n <= 5 * 10^4\n m == edges.length\n 1 <= m <= min(5 * 10^4, n * (n - 1) / 2)\n 0 <= a_i, b_i < n\n a_i != b_i\n 1 <= w_i <= 10^5\n There are no repeated edges.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b9637", "question": "Write a python function to count negative numbers in a list.\nassert neg_count([-1,-2,3,-4,-5]) == 4\nassert neg_count([1,2,3]) == 0\nassert neg_count([1,2,-3,-10,20]) == 2\n", "raw_outputs": ""} +{"task_id": "b7354", "question": "Write a function to find the longest chain which can be formed from the given set of pairs.\nassert max_chain_length([Pair(5, 24), Pair(15, 25),Pair(27, 40), Pair(50, 60)], 4) == 3\nassert max_chain_length([Pair(1, 2), Pair(3, 4),Pair(5, 6), Pair(7, 8)], 4) == 4\nassert max_chain_length([Pair(19, 10), Pair(11, 12),Pair(13, 14), Pair(15, 16), Pair(31, 54)], 5) == 5\n", "raw_outputs": ""} +{"task_id": "b0109", "question": "Write a function to add consecutive numbers of a given list.\nassert add_consecutive_nums([1, 1, 3, 4, 4, 5, 6, 7])==[2, 4, 7, 8, 9, 11, 13]\nassert add_consecutive_nums([4, 5, 8, 9, 6, 10])==[9, 13, 17, 15, 16]\nassert add_consecutive_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[3, 5, 7, 9, 11, 13, 15, 17, 19]\n", "raw_outputs": ""} +{"task_id": "b8217", "question": "Write a function to find the number of subsequences having product smaller than k for the given non negative array.\nassert no_of_subsequences([1,2,3,4], 10) == 11\nassert no_of_subsequences([4,8,7,2], 50) == 9\nassert no_of_subsequences([5,6,7,8], 15) == 4\n", "raw_outputs": ""} +{"task_id": "b1972", "question": "Write a function to generate a square matrix filled with elements from 1 to n raised to the power of 2 in spiral order.\nassert generate_matrix(3)==[[1, 2, 3], [8, 9, 4], [7, 6, 5]] \nassert generate_matrix(2)==[[1,2],[4,3]]\nassert generate_matrix(7)==[[1, 2, 3, 4, 5, 6, 7], [24, 25, 26, 27, 28, 29, 8], [23, 40, 41, 42, 43, 30, 9], [22, 39, 48, 49, 44, 31, 10], [21, 38, 47, 46, 45, 32, 11], [20, 37, 36, 35, 34, 33, 12], [19, 18, 17, 16, 15, 14, 13]]\n", "raw_outputs": ""} +{"task_id": "b2836", "question": "Write a function to find numbers within a given range where every number is divisible by every digit it contains.\nassert divisible_by_digits(1,22)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22]\nassert divisible_by_digits(1,15)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15]\nassert divisible_by_digits(20,25)==[22, 24]\n", "raw_outputs": ""} +{"task_id": "b2073", "question": "Write a function to sort a list of elements using radix sort.\nassert radix_sort([15, 79, 25, 68, 37]) == [15, 25, 37, 68, 79]\nassert radix_sort([9, 11, 8, 7, 3, 2]) == [2, 3, 7, 8, 9, 11]\nassert radix_sort([36, 12, 24, 26, 29]) == [12, 24, 26, 29, 36]\n", "raw_outputs": ""} +{"task_id": "b2495", "question": "Write a python function to find the largest number that can be formed with the given digits.\nassert find_Max_Num([1,2,3],3) == 321\nassert find_Max_Num([4,5,6,1],4) == 6541\nassert find_Max_Num([1,2,3,9],4) == 9321\n", "raw_outputs": ""} +{"task_id": "a2000", "question": "import math\n\n\ndef poly(xs: list, x: float):\n \"\"\"\n Evaluates polynomial with coefficients xs at point x.\n return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n\n \"\"\"\n return sum([coeff * math.pow(x, i) for i, coeff in enumerate(xs)])\n\n\ndef find_zero(xs: list):\n \"\"\" xs are coefficients of a polynomial.\n find_zero find x such that poly(x) = 0.\n find_zero returns only only zero point, even if there are many.\n Moreover, find_zero only takes list xs having even number of coefficients\n and largest non zero coefficient as it guarantees\n a solution.\n >>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x\n -0.5\n >>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3\n 1.0\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a6564", "question": "from typing import List\n\n\ndef filter_by_prefix(strings: List[str], prefix: str) -> List[str]:\n \"\"\" Filter an input list of strings only for ones that start with a given prefix.\n >>> filter_by_prefix([], 'a')\n []\n >>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a')\n ['abc', 'array']\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a5713", "question": "def balanced_substrings(s: str) -> int:\n \"\"\"\n Given a string s, you need to partition it into one or more balanced substrings. For example, if s == \"ababcc\" then (\"abab\", \"c\", \"c\"), (\"ab\", \"abc\", \"c\"), and (\"ababcc\") are all valid partitions, but (\"a\", \"bab\", \"cc\"), (\"aba\", \"bc\", \"c\"), and (\"ab\", \"abcc\") are not. The unbalanced substrings are bolded.\n\n Return the minimum number of substrings that you can partition s into.\n\n Note: A balanced string is a string where each character in the string occurs the same number of times.\n\n Examples:\n >>> s = \"fabccddg\"\n 3\n >>> s = \"abababaccddb\"\n 2\n\n Constraints:\n 1 <= s.length <= 1000\n s consists only of English lowercase letters.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b2279", "question": "Write a function to check whether the given number is undulating or not.\nassert is_undulating(\"1212121\") == True\nassert is_undulating(\"1991\") == False\nassert is_undulating(\"121\") == True\n", "raw_outputs": ""} +{"task_id": "b4779", "question": "Write a function to calculate the sum of the digits of a given number N, and convert this sum to a binary number.\nassert solve(1000) == \"1\"\nassert solve(150) == \"110\"\nassert solve(147) == \"1100\"\nassert solve(333) == \"1001\"\nassert solve(963) == \"10010\"\n", "raw_outputs": ""} +{"task_id": "b0768", "question": "Write a function that, for a given number n, find the largest number that divides n evenly, smaller than n.\nassert largest_divisor(3) == 1\nassert largest_divisor(7) == 1\nassert largest_divisor(10) == 5\nassert largest_divisor(100) == 50\nassert largest_divisor(49) == 7\n", "raw_outputs": ""} +{"task_id": "a7822", "question": "\ndef words_in_sentence(sentence):\n \"\"\"\n You are given a string representing a sentence,\n the sentence contains some words separated by a space,\n and you have to return a string that contains the words from the original sentence,\n whose lengths are prime numbers,\n the order of the words in the new string should be the same as the original one.\n\n Example 1:\n Input: sentence = \"This is a test\"\n Output: \"is\"\n\n Example 2:\n Input: sentence = \"lets go for swimming\"\n Output: \"go for\"\n\n Constraints:\n * 1 <= len(sentence) <= 100\n * sentence contains only letters\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a7614", "question": "def find_latest_time(s: str) -> str:\n \"\"\"\n You are given a string s representing a 12-hour format time where some of the digits (possibly none) are replaced with a \"?\".\n\n 12-hour times are formatted as \"HH:MM\", where HH is between 00 and 11, and MM is between 00 and 59. The earliest 12-hour time is 00:00, and the latest is 11:59.\n\n You have to replace all the \"?\" characters in s with digits such that the time we obtain by the resulting string is a valid 12-hour format time and is the latest possible.\n\n Return the resulting string.\n\n Examples:\n >>> s = \"1?:?4\"\n \"11:54\"\n >>> s = \"0?:5?\"\n \"09:59\"\n\n Constraints:\n s.length == 5\n s[2] is equal to the character \":\".\n All characters except s[2] are digits or \"?\" characters.\n The input is generated such that there is at least one time between \"00:00\" and \"11:59\" that you can obtain after replacing the \"?\" characters.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b4616", "question": "Write a function to remove empty lists from a given list of lists.\nassert remove_empty([[], [], [], 'Red', 'Green', [1,2], 'Blue', [], []])==['Red', 'Green', [1, 2], 'Blue']\nassert remove_empty([[], [], [],[],[], 'Green', [1,2], 'Blue', [], []])==[ 'Green', [1, 2], 'Blue']\nassert remove_empty([[], [], [], 'Python',[],[], 'programming', 'language',[],[],[], [], []])==['Python', 'programming', 'language']\n", "raw_outputs": ""} +{"task_id": "a9769", "question": "from typing import List\n\ndef distribute_in_two_arrays(nums: List[int]) -> List[int]:\n \"\"\"\n You are given a 1-indexed array of distinct integers nums of length n.\n\n You need to distribute all the elements of nums between two arrays arr1 and arr2 using n operations. In the first operation, append nums[1] to arr1. In the second operation, append nums[2] to arr2. Afterwards, in the ith operation:\n\n If the last element of arr1 is greater than the last element of arr2, append nums[i] to arr1. Otherwise, append nums[i] to arr2.\n The array result is formed by concatenating the arrays arr1 and arr2. For example, if arr1 == [1,2,3] and arr2 == [4,5,6], then result = [1,2,3,4,5,6].\n\n Return the array result.\n\n Examples:\n >>> nums = [2,1,3]\n [2,3,1]\n >>> nums = [5,4,3,8]\n [5,3,4,8]\n\n Constraints:\n 3 <= n <= 50\n 1 <= nums[i] <= 100\n All elements in nums are distinct.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b0747", "question": "Write a function to sort the given array by using counting sort.\nassert counting_sort([1,23,4,5,6,7,8]) == [1, 4, 5, 6, 7, 8, 23]\nassert counting_sort([12, 9, 28, 33, 69, 45]) == [9, 12, 28, 33, 45, 69]\nassert counting_sort([8, 4, 14, 3, 2, 1]) == [1, 2, 3, 4, 8, 14]\n", "raw_outputs": ""} +{"task_id": "a9422", "question": "\ndef starts_one_ends(n):\n \"\"\"\n Given a positive integer n, return the count of the numbers of n-digit\n positive integers that start or end with 1.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b5901", "question": "Write a function that takes a list of integers as input, and returns the second smallest element in the list, if it exists. If not, return None.\nassert next_smallest([1, 2, 3, 4, 5]) == 2\nassert next_smallest([5, 1, 4, 3, 2]) == 2\nassert next_smallest([]) == None\nassert next_smallest([1, 1]) == None\nassert next_smallest([1,1,1,1,0]) == 1\nassert next_smallest([1, 0**0]) == None\nassert next_smallest([-35, 34, 12, -45]) == -35\n", "raw_outputs": ""} +{"task_id": "a4316", "question": "\ndef decimal_to_binary(decimal):\n \"\"\"You will be given a number in decimal form and your task is to convert it to\n binary format. The function should return a string, with each character representing a binary\n number. Each character in the string will be '0' or '1'.\n\n There will be an extra couple of characters 'db' at the beginning and at the end of the string.\n The extra characters are there to help with the format.\n\n Examples:\n decimal_to_binary(15) # returns \"db1111db\"\n decimal_to_binary(32) # returns \"db100000db\"\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a7672", "question": "\ndef iscube(a):\n '''\n Write a function that takes an integer a and returns True \n if this ingeger is a cube of some integer number.\n Note: you may assume the input is always valid.\n Examples:\n iscube(1) ==> True\n iscube(2) ==> False\n iscube(-1) ==> True\n iscube(64) ==> True\n iscube(0) ==> True\n iscube(180) ==> False\n '''\n", "raw_outputs": ""} +{"task_id": "a3295", "question": "\ndef max_fill(grid, capacity):\n import math\n \"\"\"\n You are given a rectangular grid of wells. Each row represents a single well,\n and each 1 in a row represents a single unit of water.\n Each well has a corresponding bucket that can be used to extract water from it, \n and all buckets have the same capacity.\n Your task is to use the buckets to empty the wells.\n Output the number of times you need to lower the buckets.\n\n Example 1:\n Input: \n grid : [[0,0,1,0], [0,1,0,0], [1,1,1,1]]\n bucket_capacity : 1\n Output: 6\n\n Example 2:\n Input: \n grid : [[0,0,1,1], [0,0,0,0], [1,1,1,1], [0,1,1,1]]\n bucket_capacity : 2\n Output: 5\n \n Example 3:\n Input: \n grid : [[0,0,0], [0,0,0]]\n bucket_capacity : 5\n Output: 0\n\n Constraints:\n * all wells have the same length\n * 1 <= grid.length <= 10^2\n * 1 <= grid[:,1].length <= 10^2\n * grid[i][j] -> 0 | 1\n * 1 <= capacity <= 10\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b5166", "question": "Write a function to remove the parenthesis area in a string.\nassert remove_parenthesis([\"python (chrome)\"])==(\"python\")\nassert remove_parenthesis([\"string(.abc)\"])==(\"string\")\nassert remove_parenthesis([\"alpha(num)\"])==(\"alpha\")\n", "raw_outputs": ""} +{"task_id": "b0323", "question": "Write a function special_factorial to compute the Brazilian factorial of an integer. Brazilian factorial is defined as: brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1! where n > 0. The function will receive an integer as input and should return the special factorial of this integer.\nassert special_factorial(4) == 288\nassert special_factorial(5) == 34560\nassert special_factorial(7) == 125411328000\nassert special_factorial(1) == 1\n", "raw_outputs": ""} +{"task_id": "a0108", "question": "\ndef encode(message):\n \"\"\"\n Write a function that takes a message, and encodes in such a \n way that it swaps case of all letters, replaces all vowels in \n the message with the letter that appears 2 places ahead of that \n vowel in the english alphabet. \n Assume only letters. \n \n Examples:\n >>> encode('test')\n 'TGST'\n >>> encode('This is a message')\n 'tHKS KS C MGSSCGG'\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a1344", "question": "from typing import List\nfrom itertools import accumulate\nfrom math import inf\n\ndef max_energy_of_subarrays(nums: List[int], k: int) -> int:\n \"\"\"\n You are given a 0-indexed array of integers nums of length n, and a positive odd integer k.\n\n The strength of x subarrays is defined as strength = sum[1] * x - sum[2] * (x - 1) + sum[3] * (x - 2) - sum[4] * (x - 3) + ... + sum[x] * 1 where sum[i] is the sum of the elements in the ith subarray. Formally, strength is sum of (-1)i+1 * sum[i] * (x - i + 1) over all i's such that 1 <= i <= x.\n\n You need to select k disjoint subarrays from nums, such that their strength is maximum.\n\n Return the maximum possible strength that can be obtained.\n\n Note that the selected subarrays don't need to cover the entire array.\n\n Examples:\n >>> nums = [1,2,3,-1,2], k = 3\n 22\n >>> nums = [12,-2,-2,-2,-2], k = 5\n 64\n >>> nums = [-1,-2,-3], k = 1\n -1\n\n Constraints:\n 1 <= n <= 10^4\n -10^9 <= nums[i] <= 10^9\n 1 <= k <= n\n 1 <= n * k <= 10^6\n k is odd.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b5713", "question": "Write a function that takes an array of numbers and returns the number of elements in the array that are greater than 10 and both first and last digits of a number are odd (1, 3, 5, 7, 9).\nassert specialFilter([5, -2, 1, -5]) == 0\nassert specialFilter([15, -73, 14, -15]) == 1\nassert specialFilter([33, -2, -3, 45, 21, 109]) == 2\nassert specialFilter([43, -12, 93, 125, 121, 109]) == 4\nassert specialFilter([71, -2, -33, 75, 21, 19]) == 3\nassert specialFilter([1]) == 0\nassert specialFilter([]) == 0\n", "raw_outputs": ""} +{"task_id": "b6149", "question": "Write a function to find t-nth term of arithemetic progression.\nassert tn_ap(1,5,2)==9\nassert tn_ap(2,6,4)==22\nassert tn_ap(1,4,5)==16\n", "raw_outputs": ""} +{"task_id": "a9090", "question": "from typing import List\n\ndef unmarked_sum_array(nums: List[int], queries: List[List[int]]) -> List[int]:\n \"\"\"\n You are given a 0-indexed array nums of size n consisting of positive integers.\n\n You are also given a 2D array queries of size m where queries[i] = [index_i, k_i].\n\n Initially all elements of the array are unmarked.\n\n You need to apply m queries on the array in order, where on the i_th query you do the following:\n\n Mark the element at index index_i if it is not already marked.\n Then mark k_i unmarked elements in the array with the smallest values. If multiple such elements exist, mark the ones with the smallest indices. And if less than k_i unmarked elements exist, then mark all of them.\n\n Return an array answer of size m where answer[i] is the sum of unmarked elements in the array after the i th query.\n\n Examples:\n >>> nums = [1,2,2,1,2,3,1], queries = [[1,2],[3,3],[4,2]]\n [8, 3, 0]\n >>> nums = [1,4,2,3], queries = [[0,1]]\n [7]\n\n Constraints:\n n == nums.length\n m == queries.length\n 1 <= m <= n <= 10^5\n 1 <= nums[i] <= 10^5\n queries[i].length == 2\n 0 <= index_i, k_i <= n - 1\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a6262", "question": "\n\ndef truncate_number(number: float) -> float:\n \"\"\" Given a positive floating point number, it can be decomposed into\n and integer part (largest integer smaller than given number) and decimals\n (leftover part always smaller than 1).\n\n Return the decimal part of the number.\n >>> truncate_number(3.5)\n 0.5\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a4098", "question": "\ndef even_odd_count(num):\n \"\"\"Given an integer. return a tuple that has the number of even and odd digits respectively.\n\n Example:\n even_odd_count(-12) ==> (1, 1)\n even_odd_count(123) ==> (1, 2)\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b3303", "question": "Write a python function to find the largest postive number from the given list.\nassert largest_pos([1,2,3,4,-1]) == 4\nassert largest_pos([0,1,2,-5,-1,6]) == 6\nassert largest_pos([0,0,1,0]) == 1\n", "raw_outputs": ""} +{"task_id": "b7248", "question": "Write a function to sort an array of non-negative integers according to number of ones in their binary representation in ascending order. For similar number of ones, sort based on decimal value.\nassert sort_array([1,5,2,3,4]) == [1, 2, 4, 3, 5]\nassert sort_array([-2,-3,-4,-5,-6]) == [-4, -2, -6, -5, -3]\nassert sort_array([1,0,2,3,4]) == [0, 1, 2, 4, 3]\nassert sort_array([]) == []\nassert sort_array([2,5,77,4,5,3,5,7,2,3,4]) == [2, 2, 4, 4, 3, 3, 5, 5, 5, 7, 77]\nassert sort_array([3,6,44,12,32,5]) == [32, 3, 5, 6, 12, 44]\nassert sort_array([2,4,8,16,32]) == [2, 4, 8, 16, 32]\nassert sort_array([2,4,8,16,32]) == [2, 4, 8, 16, 32]\n", "raw_outputs": ""} +{"task_id": "b7604", "question": "Write a python function to count the number of integral co-ordinates that lie inside a square.\nassert count_Intgral_Points(1,1,4,4) == 4\nassert count_Intgral_Points(1,2,1,2) == 1\nassert count_Intgral_Points(4,2,6,4) == 1\n", "raw_outputs": ""} +{"task_id": "b1623", "question": "Write a python function to check whether the hexadecimal number is even or odd.\nassert even_or_odd(\"AB3454D\") ==\"Odd\"\nassert even_or_odd(\"ABC\") == \"Even\"\nassert even_or_odd(\"AAD\") == \"Odd\"\n", "raw_outputs": ""} +{"task_id": "a5773", "question": "\ndef make_a_pile(n):\n \"\"\"\n Given a positive integer n, you have to make a pile of n levels of stones.\n The first level has n stones.\n The number of stones in the next level is:\n - the next odd number if n is odd.\n - the next even number if n is even.\n Return the number of stones in each level in a list, where element at index\n i represents the number of stones in the level (i+1).\n\n Examples:\n >>> make_a_pile(3)\n [3, 5, 7]\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a9498", "question": "\n\ndef is_palindrome(string: str) -> bool:\n \"\"\" Test if given string is a palindrome \"\"\"\n return string == string[::-1]\n\n\ndef make_palindrome(string: str) -> str:\n \"\"\" Find the shortest palindrome that begins with a supplied string.\n Algorithm idea is simple:\n - Find the longest postfix of supplied string that is a palindrome.\n - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.\n >>> make_palindrome('')\n ''\n >>> make_palindrome('cat')\n 'catac'\n >>> make_palindrome('cata')\n 'catac'\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a1973", "question": "\ndef split_words(txt):\n '''\n Given a string of words, return a list of words split on whitespace, if no whitespaces exists in the text you\n should split on commas ',' if no commas exists you should return the number of lower-case letters with odd order in the\n alphabet, ord('a') = 0, ord('b') = 1, ... ord('z') = 25\n Examples\n split_words(\"Hello world!\") ➞ [\"Hello\", \"world!\"]\n split_words(\"Hello,world!\") ➞ [\"Hello\", \"world!\"]\n split_words(\"abcdef\") == 3 \n '''\n", "raw_outputs": ""} +{"task_id": "a2893", "question": "\ndef cycpattern_check(a , b):\n \"\"\"You are given 2 words. You need to return True if the second word or any of its rotations is a substring in the first word\n cycpattern_check(\"abcd\",\"abd\") => False\n cycpattern_check(\"hello\",\"ell\") => True\n cycpattern_check(\"whassup\",\"psus\") => False\n cycpattern_check(\"abab\",\"baa\") => True\n cycpattern_check(\"efef\",\"eeff\") => False\n cycpattern_check(\"himenss\",\"simen\") => True\n\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a4990", "question": "from typing import List\nimport bisect\ndef count_subarrays_with_and_k(nums: List[int], k: int) -> int:\n \"\"\"\n Given an array of integers nums and an integer k, return the number of\n subarrays\n of nums where the bitwise AND of the elements of the subarray equals k.\n\n Examples:\n >>> nums = [1,1,1], k = 1\n 6\n >>> nums = [1,1,2], k = 1\n 3\n\n Constraints:\n 1 <= nums.length <= 10^5\n 0 <= nums[i], k <= 10^9\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a0098", "question": "def min_operations(k: int) -> int:\n \"\"\"\n You are given a positive integer k. Initially, you have an array nums = [1].\n\n You can perform any of the following operations on the array any number of times (possibly zero):\n\n Choose any element in the array and increase its value by 1.\n Duplicate any element in the array and add it to the end of the array.\n Return the minimum number of operations required to make the sum of elements of the final array greater than or equal to k.\n\n Examples:\n >>> k = 11\n 5\n >>> k = 1\n 0\n\n Constraints:\n 1 <= k <= 10^5\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a3534", "question": "from typing import List\nfrom random import randint\nfrom collections import defaultdict\nfrom math import inf\ndef min_cost_to_make_str(target: str, words: List[str], costs: List[int]) -> int:\n \"\"\"\n You are given a string target, an array of strings words, and an integer array costs, both arrays of the same length.\n\n Imagine an empty string s.\n\n You can perform the following operation any number of times (including zero):\n\n Choose an index i in the range [0, words.length - 1].\n Append words[i] to s.\n The cost of operation is costs[i].\n Return the minimum cost to make s equal to target. If it's not possible, return -1.\n\n Examples:\n >>> target = \"abcdef\", words = [\"abdef\",\"abc\",\"d\",\"def\",\"ef\"], costs = [100,1,1,10,5]\n 7\n >>> target = \"aaaa\", words = [\"z\",\"zz\",\"zzz\"], costs = [1,10,100]\n -1\n\n Constraints:\n 1 <= target.length <= 5 * 10^4\n 1 <= words.length == costs.length <= 5 * 10^4\n 1 <= words[i].length <= target.length\n The total sum of words[i].length is less than or equal to 5 * 10^4.\n target and words[i] consist only of lowercase English letters.\n 1 <= costs[i] <= 10^4\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b7730", "question": "Write a python function to calculate the product of the unique numbers of a given list.\nassert unique_product([10, 20, 30, 40, 20, 50, 60, 40]) == 720000000\nassert unique_product([1, 2, 3, 1,]) == 6\nassert unique_product([7, 8, 9, 0, 1, 1]) == 0\n", "raw_outputs": ""} +{"task_id": "b9526", "question": "Write a function to convert a given string to its md5 hash equivalent string. If the string is empty, return None.\nassert string_to_md5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62'\nassert string_to_md5('') == None\nassert string_to_md5('A B C') == '0ef78513b0cb8cef12743f5aeb35f888'\nassert string_to_md5('password') == '5f4dcc3b5aa765d61d8327deb882cf99'\n", "raw_outputs": ""} +{"task_id": "a7591", "question": "\ndef check_if_last_char_is_a_letter(txt):\n '''\n Create a function that returns True if the last character\n of a given string is an alphabetical character and is not\n a part of a word, and False otherwise.\n Note: \"word\" is a group of characters separated by space.\n\n Examples:\n check_if_last_char_is_a_letter(\"apple pie\") ➞ False\n check_if_last_char_is_a_letter(\"apple pi e\") ➞ True\n check_if_last_char_is_a_letter(\"apple pi e \") ➞ False\n check_if_last_char_is_a_letter(\"\") ➞ False \n '''\n", "raw_outputs": ""} +{"task_id": "b5875", "question": "Write a function that accepts a list of strings. The list contains different words. The function should Return the word with maximum number of unique characters. If multiple strings have maximum number of unique characters, return the one which comes first in lexicographical order.\nassert (find_max([\"name\", \"of\", \"string\"]) == \"string\")\nassert (find_max([\"name\", \"enam\", \"game\"]) == \"enam\")\nassert (find_max([\"aaaaaaa\", \"bb\", \"cc\"]) == \"aaaaaaa\")\nassert (find_max([\"abc\", \"cba\"]) == \"abc\")\nassert (find_max([\"play\", \"this\", \"game\", \"of\",\"footbott\"]) == \"footbott\")\nassert (find_max([\"we\", \"are\", \"gonna\", \"rock\"]) == \"gonna\")\nassert (find_max([\"we\", \"are\", \"a\", \"mad\", \"nation\"]) == \"nation\")\nassert (find_max([\"this\", \"is\", \"a\", \"prrk\"]) == \"this\")\nassert (find_max([\"b\"]) == \"b\")\nassert (find_max([\"play\", \"play\", \"play\"]) == \"play\")\n", "raw_outputs": ""} +{"task_id": "a0683", "question": "from typing import List\n\n\ndef factorize(n: int) -> List[int]:\n \"\"\" Return list of prime factors of given integer in the order from smallest to largest.\n Each of the factors should be listed number of times corresponding to how many times it appeares in factorization.\n Input number should be equal to the product of all factors\n >>> factorize(8)\n [2, 2, 2]\n >>> factorize(25)\n [5, 5]\n >>> factorize(70)\n [2, 5, 7]\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a3988", "question": "from typing import List\n\ndef work_days_without_meetings(days: int, meetings: List[List[int]]) -> int:\n \"\"\"\n You are given a positive integer days representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array meetings of size n where, meetings[i] = [start_i, end_i] represents the starting and ending days of meeting i (inclusive).\n\n Return the count of days when the employee is available for work but no meetings are scheduled.\n\n Note that:\n The meetings may overlap.\n\n Examples:\n >>> days = 10, meetings = [[5,7],[1,3],[9,10]]\n 2\n >>> days = 5, meetings = [[2,4],[1,3]]\n 1\n\n Constraints:\n 1 <= days <= 10^9\n 1 <= meetings.length <= 10^5\n meetings[i].length == 2\n 1 <= meetings[i][0] <= meetings[i][1] <= days\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a1159", "question": "\ndef by_length(arr):\n \"\"\"\n Given an array of integers, sort the integers that are between 1 and 9 inclusive,\n reverse the resulting array, and then replace each digit by its corresponding name from\n \"One\", \"Two\", \"Three\", \"Four\", \"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\".\n\n For example:\n arr = [2, 1, 1, 4, 5, 8, 2, 3] \n -> sort arr -> [1, 1, 2, 2, 3, 4, 5, 8] \n -> reverse arr -> [8, 5, 4, 3, 2, 2, 1, 1]\n return [\"Eight\", \"Five\", \"Four\", \"Three\", \"Two\", \"Two\", \"One\", \"One\"]\n \n If the array is empty, return an empty array:\n arr = []\n return []\n \n If the array has any strange number ignore it:\n arr = [1, -1 , 55] \n -> sort arr -> [-1, 1, 55]\n -> reverse arr -> [55, 1, -1]\n return = ['One']\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b6211", "question": "Write a function which returns the largest index of an element in the given array that is not greater than or equal to the element immediately preceding it. If no such element exists then the function should return -1. The given array will not contain duplicate values.\nassert can_arrange([1,2,4,3,5])==3\nassert can_arrange([1,2,4,5])==-1\nassert can_arrange([1,4,2,5,6,7,8,9,10])==2\nassert can_arrange([4,8,5,7,3])==4\nassert can_arrange([])==-1\n", "raw_outputs": ""} +{"task_id": "b9828", "question": "Write a function to add two numbers and print number of digits of sum.\nassert count_digits(9875,10)==(4)\nassert count_digits(98759853034,100)==(11)\nassert count_digits(1234567,500)==(7)\n", "raw_outputs": ""} +{"task_id": "a7363", "question": "from typing import List\n\ndef integer_to_be_added(nums1: List[int], nums2: List[int]) -> int:\n \"\"\"\n You are given two arrays of equal length, nums1 and nums2.\n\n Each element in nums1 has been increased (or decreased in the case of negative) by an integer, represented by the variable x.\n\n As a result, nums1 becomes equal to nums2. Two arrays are considered equal when they contain the same integers with the same frequencies.\n\n Return the integer x.\n\n Examples:\n >>> nums1 = [2,6,4], nums2 = [9,7,5]\n 3\n >>> nums1 = [10], nums2 = [5]\n -5\n >>> nums1 = [1,1,1,1], nums2 = [1,1,1,1]\n 0\n\n Constraints:\n 1 <= nums1.length == nums2.length <= 100\n 0 <= nums1[i], nums2[i] <= 1000\n The test cases are generated in a way that there is an integer x such that nums1 can become equal to nums2 by adding x to each element of nums1.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a1623", "question": "\n\ndef common(l1: list, l2: list):\n \"\"\"Return sorted unique common elements for two lists.\n >>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])\n [1, 5, 653]\n >>> common([5, 3, 2, 8], [3, 2])\n [2, 3]\n\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b9042", "question": "Write a function to remove all whitespaces from the given string using regex.\nassert remove_whitespaces(' Google Flutter ') == 'GoogleFlutter'\nassert remove_whitespaces(' Google Dart ') == 'GoogleDart'\nassert remove_whitespaces(' iOS Swift ') == 'iOSSwift'\n", "raw_outputs": ""} +{"task_id": "a2479", "question": "from typing import List\n\n\ndef parse_nested_parens(paren_string: str) -> List[int]:\n \"\"\" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.\n For each of the group, output the deepest level of nesting of parentheses.\n E.g. (()()) has maximum two levels of nesting while ((())) has three.\n\n >>> parse_nested_parens('(()()) ((())) () ((())()())')\n [2, 3, 1, 3]\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a9626", "question": "\n\ndef modp(n: int, p: int):\n \"\"\"Return 2^n modulo p (be aware of numerics).\n >>> modp(3, 5)\n 3\n >>> modp(1101, 101)\n 2\n >>> modp(0, 101)\n 1\n >>> modp(3, 11)\n 8\n >>> modp(100, 101)\n 1\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b6564", "question": "Write a python function to find the difference between sum of even and odd digits.\nassert is_Diff (12345) == False\nassert is_Diff(1212112) == True\nassert is_Diff(1212) == False\n", "raw_outputs": ""} +{"task_id": "b6444", "question": "Write a function to check if the letters of a given string can be rearranged so that two characters that are adjacent to each other are different.\nassert rearange_string(\"aab\")==('aba')\nassert rearange_string(\"aabb\")==('abab')\nassert rearange_string(\"abccdd\")==('cdabcd')\n", "raw_outputs": ""} +{"task_id": "b0563", "question": "Write a function to validate a given date string. The function should return True if the date is valid and False otherwise. The date is valid if it is not empty, the number of days and months are within the correct range, and the date is in the 'mm-dd-yyyy' format.\nassert valid_date('03-11-2000') == True\nassert valid_date('15-01-2012') == False\nassert valid_date('04-0-2040') == False\nassert valid_date('06-04-2020') == True\nassert valid_date('01-01-2007') == True\nassert valid_date('03-32-2011') == False\nassert valid_date('') == False\nassert valid_date('04-31-3000') == False\nassert valid_date('06-06-2005') == True\nassert valid_date('21-31-2000') == False\nassert valid_date('04-12-2003') == True\nassert valid_date('04122003') == False\nassert valid_date('20030412') == False\nassert valid_date('2003-04') == False\nassert valid_date('2003-04-12') == False\nassert valid_date('04-2003') == False\n", "raw_outputs": ""} +{"task_id": "a8882", "question": "from typing import List\nfrom collections import Counter\n\ndef can_make_square(grid: List[List[str]]) -> bool:\n \"\"\"\n You are given a 2D matrix grid of size 3 x 3 consisting only of characters 'B' and 'W'. Character 'W' represents the white color, and character 'B' represents the black color.\n\n Your task is to change the color of at most one cell so that the matrix has a 2 x 2 square where all cells are of the same color.\n\n Return true if it is possible to create a 2 x 2 square of the same color, otherwise, return false.\n\n Examples:\n >>> grid = [[\"B\",\"W\",\"B\"],[\"B\",\"W\",\"W\"],[\"B\",\"W\",\"B\"]]\n true\n >>> grid = [[\"B\",\"W\",\"B\"],[\"W\",\"B\",\"W\"],[\"B\",\"W\",\"B\"]]\n false\n >>> grid = [[\"B\",\"W\",\"B\"],[\"B\",\"W\",\"W\"],[\"B\",\"W\",\"W\"]]\n true\n\n Constraints:\n grid.length == 3\n grid[i].length == 3\n grid[i][j] is either 'W' or 'B'.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b6886", "question": "Write a function to find the list of lists with maximum length.\nassert max_length([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==(3, [13, 15, 17])\nassert max_length([[1], [5, 7], [10, 12, 14,15]])==(4, [10, 12, 14,15])\nassert max_length([[5], [15,20,25]])==(3, [15,20,25])\n", "raw_outputs": ""} +{"task_id": "b4147", "question": "Write a function to find the area of a rectangle.\nassert rectangle_area(10,20)==200\nassert rectangle_area(10,5)==50\nassert rectangle_area(4,2)==8\n", "raw_outputs": ""} +{"task_id": "b9078", "question": "Write a function to calculate the sum of the positive numbers of a given list of numbers using lambda function.\nassert sum_positivenum([2, 4, -6, -9, 11, -12, 14, -5, 17])==48\nassert sum_positivenum([10,15,-14,13,-18,12,-20])==50\nassert sum_positivenum([19, -65, 57, 39, 152,-639, 121, 44, 90, -190])==522\n", "raw_outputs": ""} +{"task_id": "b4299", "question": "Write a function to find the n-th rectangular number.\nassert find_rect_num(4) == 20\nassert find_rect_num(5) == 30\nassert find_rect_num(6) == 42\n", "raw_outputs": ""} +{"task_id": "a0739", "question": "from typing import List\n\ndef is_possible_to_split(nums: List[int]) -> bool:\n \"\"\"\n You are given an integer array nums of even length. You have to split the array into two parts nums1 and nums2 such that:\n\n nums1.length == nums2.length == nums.length / 2.\n nums1 should contain distinct elements.\n nums2 should also contain distinct elements.\n\n Return true if it is possible to split the array, and false otherwise.\n\n Examples:\n >>> nums = [1,1,2,2,3,4]\n true\n >>> nums = [1,1,1,1]\n false\n\n Constraints:\n 1 <= nums.length <= 100\n nums.length % 2 == 0\n 1 <= nums[i] <= 100\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b8810", "question": "Write a python function to merge the first and last elements separately in a list of lists.\nassert merge([['x', 'y'], ['a', 'b'], ['m', 'n']]) == [['x', 'a', 'm'], ['y', 'b', 'n']]\nassert merge([[1, 2], [3, 4], [5, 6], [7, 8]]) == [[1, 3, 5, 7], [2, 4, 6, 8]]\nassert merge([['x', 'y','z' ], ['a', 'b','c'], ['m', 'n','o']]) == [['x', 'a', 'm'], ['y', 'b', 'n'],['z', 'c','o']]\n", "raw_outputs": ""} +{"task_id": "a1345", "question": "from typing import List\n\ndef number_of_alternating_groups(colors: List[int]) -> int:\n \"\"\"\n There is a circle of red and blue tiles. You are given an array of integers colors. The color of tile i is represented by colors[i]:\n\n colors[i] == 0 means that tile i is red.\n colors[i] == 1 means that tile i is blue.\n Every 3 contiguous tiles in the circle with alternating colors (the middle tile has a different color from its left and right tiles) is called an alternating group.\n\n Return the number of alternating groups.\n\n Note that:\n since colors represents a circle, the first and the last tiles are considered to be next to each other.\n\n Examples:\n >>> colors = [1,1,1]\n 0\n >>> colors = [0,1,0,0,1]\n 3\n\n Constraints:\n 3 <= colors.length <= 100\n 0 <= colors[i] <= 1\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b4093", "question": "Write a function that returns true if the given number is the multiplication of 3 prime numbers and false otherwise, knowing that the given number is less than 100.\nassert is_multiply_prime(5) == False\nassert is_multiply_prime(30) == True\nassert is_multiply_prime(8) == True\nassert is_multiply_prime(10) == False\nassert is_multiply_prime(125) == True\nassert is_multiply_prime(3 * 5 * 7) == True\nassert is_multiply_prime(3 * 6 * 7) == False\nassert is_multiply_prime(9 * 9 * 9) == False\nassert is_multiply_prime(11 * 9 * 9) == False\nassert is_multiply_prime(11 * 13 * 7) == True\n", "raw_outputs": ""} +{"task_id": "b6262", "question": "Write a python function to find the first natural number whose factorial is divisible by x.\nassert first_Factorial_Divisible_Number(10) == 5\nassert first_Factorial_Divisible_Number(15) == 5\nassert first_Factorial_Divisible_Number(5) == 4\n", "raw_outputs": ""} +{"task_id": "a2868", "question": "from typing import List\n\ndef maximum_total_cost(nums: List[int]) -> int:\n \"\"\"\n You are given an integer array nums with length n.\n\n The cost of a subarray\n nums[l..r], where 0 <= l <= r < n, is defined as:\n\n cost(l, r) = nums[l] - nums[l + 1] + ... + nums[r] * (−1)^(r − l)\n\n Your task is to split nums into subarrays such that the total cost of the subarrays is maximized, ensuring each element belongs to exactly one subarray.\n\n Formally, if nums is split into k subarrays, where k > 1, at indices i_1, i_2, ..., i_k − 1, where 0 <= i_1 < i_2 < ... < i_k - 1 < n - 1, then the total cost will be:\n\n cost(0, i_1) + cost(i_1 + 1, i_2) + ... + cost(i_k − 1 + 1, n − 1)\n\n Return an integer denoting the maximum total cost of the subarrays after splitting the array optimally.\n Note that:\n If nums is not split into subarrays, i.e. k = 1, the total cost is simply cost(0, n - 1).\n\n Examples:\n >>> nums = [1,-2,3,4]\n 10\n >>> nums = [1,-1,1,-1]\n 4\n\n Constraints:\n 1 <= nums.length <= 10^5\n -10^9 <= nums[i] <= 10^9\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a1880", "question": "from typing import List\n\ndef min_subarray_length(nums: List[int], k: int) -> int:\n \"\"\"\n You are given an array nums of non-negative integers and an integer k.\n\n An array is called special if the bitwise OR of all of its elements is at least k.\n\n Return the length of the shortest special non-empty\n subarray of nums, or return -1 if no special subarray exists.\n\n Examples:\n >>> nums = [1,2,3], k = 2\n 1\n >>> nums = [2,1,8], k = 10\n 3\n >>> nums = [1,2], k = 0\n 1\n\n Constraints:\n 1 <= nums.length <= 50\n 0 <= nums[i] <= 50\n 0 <= k < 64\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b0683", "question": "Write a function that matches a string that has an a followed by zero or one 'b'.\nassert text_match_zero_one(\"ac\")==('Found a match!')\nassert text_match_zero_one(\"dc\")==('Not matched!')\nassert text_match_zero_one(\"abbbba\")==('Found a match!')\n", "raw_outputs": ""} +{"task_id": "a3168", "question": "from typing import List\nfrom collections import Counter\nfrom heapq import heappush, heappop\ndef most_frequent_ids(nums: List[int], freq: List[int]) -> List[int]:\n \"\"\"\n The problem involves tracking the frequency of IDs in a collection that changes over time. You have two integer arrays, nums and freq, of equal length n. Each element in nums represents an ID, and the corresponding element in freq indicates how many times that ID should be added to or removed from the collection at each step.\n\n Addition of IDs: If freq[i] is positive, it means freq[i] IDs with the value nums[i] are added to the collection at step i.\n Removal of IDs: If freq[i] is negative, it means -freq[i] IDs with the value nums[i] are removed from the collection at step i.\n Return an array ans of length n, where ans[i] represents the count of the most frequent ID in the collection after the ith step. If the collection is empty at any step, ans[i] should be 0 for that step.\n\n Examples:\n >>> nums = [2,3,2,1], freq = [3,2,-3,1]\n [3,3,2,2]\n >>> nums = [5,5,3], freq = [2,-2,1]\n [2,0,1]\n\n Constraints:\n 1 <= nums.length == freq.length <= 10^5\n 1 <= nums[i] <= 10^5\n -10^5 <= freq[i] <= 10^5\n freq[i] != 0\n The input is generated such that the occurrences of an ID will not be negative in any step.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a3965", "question": "\n\ndef sort_third(l: list):\n \"\"\"This function takes a list l and returns a list l' such that\n l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal\n to the values of the corresponding indicies of l, but sorted.\n >>> sort_third([1, 2, 3])\n [1, 2, 3]\n >>> sort_third([5, 6, 3, 4, 8, 9, 2])\n [2, 6, 3, 4, 8, 9, 5]\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b2000", "question": "Write a python function to count occurences of a character in a repeated string.\nassert count_Char(\"abcac\",'a') == 4\nassert count_Char(\"abca\",'c') == 2\nassert count_Char(\"aba\",'a') == 7\n", "raw_outputs": ""} +{"task_id": "a2289", "question": "from typing import List\n\ndef max_selected_elements(nums: List[int]) -> int:\n \"\"\"\n You are given a 0-indexed array nums consisting of positive integers.\n\n Initially, you can increase the value of any element in the array by at most 1.\n\n After that, you need to select one or more elements from the final array such that those elements are consecutive when sorted in increasing order. For example, the elements [3, 4, 5] are consecutive while [3, 4, 6] and [1, 1, 2, 3] are not.\n\n Return the maximum number of elements that you can select.\n\n Examples:\n >>> nums = [2,1,5,1,1]\n 3\n >>> nums = [1,4,7,10]\n 1\n\n Constraints:\n 1 <= nums.length <= 10^5\n 1 <= nums[i] <= 10^6\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b9345", "question": "Write a function to display sign of the chinese zodiac for given year.\nassert chinese_zodiac(1997)==('Ox')\nassert chinese_zodiac(1998)==('Tiger')\nassert chinese_zodiac(1994)==('Dog')\n", "raw_outputs": ""} +{"task_id": "b7388", "question": "Write a python function to count numbers whose oth and nth bits are set.\nassert count_Num(2) == 1\nassert count_Num(3) == 2\nassert count_Num(1) == 1\n", "raw_outputs": ""} +{"task_id": "a9264", "question": "def sum_of_digits_of_harshad_number(x: int) -> int:\n \"\"\"\n An integer divisible by the sum of its digits is said to be a Harshad number. You are given an integer x. Return the sum of the digits of x if x is a Harshad number, otherwise, return -1.\n\n Examples:\n >>> x = 18\n 9\n >>> x = 23\n -1\n\n Constraints:\n 1 <= x <= 100\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b2868", "question": "Write a function to search some literals strings in a string.\nassert string_literals(['language'],'python language')==('Matched!')\nassert string_literals(['program'],'python language')==('Not Matched!')\nassert string_literals(['python'],'programming language')==('Not Matched!')\n", "raw_outputs": ""} +{"task_id": "b5773", "question": "Write a function to find the list with maximum length using lambda function.\nassert max_length_list([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==(3, [13, 15, 17])\nassert max_length_list([[1,2,3,4,5],[1,2,3,4],[1,2,3],[1,2],[1]])==(5,[1,2,3,4,5])\nassert max_length_list([[3,4,5],[6,7,8,9],[10,11,12]])==(4,[6,7,8,9])\n", "raw_outputs": ""} +{"task_id": "b4901", "question": "Write a function to sort a list of dictionaries using lambda function.\nassert sorted_models([{'make':'Nokia', 'model':216, 'color':'Black'}, {'make':'Mi Max', 'model':2, 'color':'Gold'}, {'make':'Samsung', 'model': 7, 'color':'Blue'}])==[{'make': 'Nokia', 'model': 216, 'color': 'Black'}, {'make': 'Samsung', 'model': 7, 'color': 'Blue'}, {'make': 'Mi Max', 'model': 2, 'color': 'Gold'}]\nassert sorted_models([{'make':'Vivo', 'model':20,'color':'Blue'},{'make': 'oppo','model':17,'color':'Gold'},{'make':'Apple','model':11,'color':'red'}])==([{'make':'Vivo', 'model':20,'color':'Blue'},{'make': 'oppo','model':17,'color':'Gold'},{'make':'Apple','model':11,'color':'red'}])\nassert sorted_models([{'make':'micromax','model':40,'color':'grey'},{'make':'poco','model':60,'color':'blue'}])==([{'make':'poco','model':60,'color':'blue'},{'make':'micromax','model':40,'color':'grey'}])\n", "raw_outputs": ""} +{"task_id": "b0374", "question": "Write a python function to find the first repeated character in a given string.\nassert first_repeated_char(\"abcabc\") == \"a\"\nassert first_repeated_char(\"abc\") == \"None\"\nassert first_repeated_char(\"123123\") == \"1\"\n", "raw_outputs": ""} +{"task_id": "a0808", "question": "from typing import List\n\ndef max_score_after_battle(enemyEnergies: List[int], currentEnergy: int) -> int:\n \"\"\"\n You are given an integer array enemyEnergies denoting the energy values of various enemies.\n\n You are also given an integer currentEnergy denoting the amount of energy you have initially.\n\n You start with 0 points, and all the enemies are unmarked initially.\n\n You can perform either of the following operations zero or multiple times to gain points:\n\n Choose an unmarked enemy, i, such that currentEnergy >= enemyEnergies[i]. By choosing this option:\n You gain 1 point.\n Your energy is reduced by the enemy's energy, i.e. currentEnergy = currentEnergy - enemyEnergies[i].\n If you have at least 1 point, you can choose an unmarked enemy, i. By choosing this option:\n Your energy increases by the enemy's energy, i.e. currentEnergy = currentEnergy + enemyEnergies[i].\n The enemy i is marked.\n Return an integer denoting the maximum points you can get in the end by optimally performing operations.\n\n Examples:\n >>> enemyEnergies = [3,2,2], currentEnergy = 2\n 3\n >>> enemyEnergies = [2], currentEnergy = 10\n 5\n \n Constraints:\n 1 <= enemyEnergies.length <= 10^5\n 1 <= enemyEnergies[i] <= 10^9\n 0 <= currentEnergy <= 10^9\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a4772", "question": "from typing import List\n\n\ndef below_zero(operations: List[int]) -> bool:\n \"\"\" You're given a list of deposit and withdrawal operations on a bank account that starts with\n zero balance. Your task is to detect if at any point the balance of account fallls below zero, and\n at that point function should return True. Otherwise it should return False.\n >>> below_zero([1, 2, 3])\n False\n >>> below_zero([1, 2, -4, 5])\n True\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b8117", "question": "Write a function to calculate the minimum number of elements that need to be changed to make an array of integers palindromic. A palindromic array is an array that is read the same backwards and forwards. You may change one element to any other element in one change.\nassert smallest_change([1,2,3,5,4,7,9,6]) == 4\nassert smallest_change([1, 2, 3, 4, 3, 2, 2]) == 1\nassert smallest_change([1, 4, 2]) == 1\nassert smallest_change([1, 4, 4, 2]) == 1\nassert smallest_change([1, 2, 3, 2, 1]) == 0\nassert smallest_change([3, 1, 1, 3]) == 0\nassert smallest_change([1]) == 0\nassert smallest_change([0, 1]) == 1\n", "raw_outputs": ""} +{"task_id": "a8211", "question": "from typing import List\nfrom itertools import pairwise\ndef translate_queries(queries: List[List[int]]) -> List[bool]:\n \"\"\"\n There exists an infinite number line, with its origin at 0 and extending towards the positive x-axis.\n\n You are given a 2D array queries, which contains two types of queries:\n\n 1.For a query of type 1, queries[i] = [1, x]. Build an obstacle at distance x from the origin. It is guaranteed that there is no obstacle at distance x when the query is asked.\n 2.For a query of type 2, queries[i] = [2, x, sz]. Check if it is possible to place a block of size sz anywhere in the range [0, x] on the line, such that the block entirely lies in the range [0, x]. A block cannot be placed if it intersects with any obstacle, but it may touch it. Note that you do not actually place the block. Queries are separate.\n Return a boolean array results, where results[i] is true if you can place the block specified in the ith query of type 2, and false otherwise.\n\n Examples:\n >>> queries = [[1,2],[2,3,3],[2,3,1],[2,2,2]]\n [false,true,true]\n >>> queries = [[1,7],[2,7,6],[1,2],[2,7,5],[2,7,6]]\n [true,true,false]\n\n Constraints:\n 1 <= queries.length <= 15 * 10^4\n 2 <= queries[i].length <= 3\n 1 <= queries[i][0] <= 2\n 1 <= x, sz <= min(5 * 10^4, 3 * queries.length)\n The input is generated such that for queries of type 1, no obstacle exists at distance x when the query is asked.\n The input is generated such that there is at least one query of type 2.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a6558", "question": "from typing import List\nfrom math import inf\n\ndef max_node_value_sum(nums: List[int], k: int, edges: List[List[int]]) -> int:\n \"\"\"\n There exists an undirected tree with n nodes numbered 0 to n - 1. You are given a 0-indexed 2D integer array edges of length n - 1, where edges[i] = [u_i, v_i] indicates that there is an edge between nodes u_i and v_i in the tree. You are also given a positive integer k, and a 0-indexed array of non-negative integers nums of length n, where nums[i] represents the value of the node numbered i.\n\n Alice wants the sum of values of tree nodes to be maximum, for which Alice can perform the following operation any number of times (including zero) on the tree:\n\n Choose any edge [u, v] connecting the nodes u and v, and update their values as follows:\n nums[u] = nums[u] XOR k\n nums[v] = nums[v] XOR k\n Return the maximum possible sum of the values Alice can achieve by performing the operation any number of times.\n\n Examples:\n >>> nums = [1,2,1], k = 3, edges = [[0,1],[0,2]]\n 6\n >>> nums = [2,3], k = 7, edges = [[0,1]]\n 9\n >>> nums = [7,7,7,7,7,7], k = 3, edges = [[0,1],[0,2],[0,3],[0,4],[0,5]]\n 42\n\n Constraints:\n 2 <= n == nums.length <= 2 * 10^4\n 1 <= k <= 10^9\n 0 <= nums[i] <= 10^9\n edges.length == n - 1\n edges[i].length == 2\n 0 <= edges[i][0], edges[i][1] <= n - 1\n The input is generated such that edges represent a valid tree.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a9672", "question": "from typing import List, Tuple\n\n\ndef sum_product(numbers: List[int]) -> Tuple[int, int]:\n \"\"\" For a given list of integers, return a tuple consisting of a sum and a product of all the integers in a list.\n Empty sum should be equal to 0 and empty product should be equal to 1.\n >>> sum_product([])\n (0, 1)\n >>> sum_product([1, 2, 3, 4])\n (10, 24)\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b0538", "question": "Write a function to calculate the number of collisions when n cars are moving from left to right and another n cars are moving from right to left on a perfectly straight indefinitely long road where all cars move at the same speed. The cars are infinitely sturdy and continue moving in their trajectory even after they collide.\nassert car_race_collision(2) == 4\nassert car_race_collision(3) == 9\nassert car_race_collision(4) == 16\nassert car_race_collision(8) == 64\nassert car_race_collision(10) == 100\n", "raw_outputs": ""} +{"task_id": "b3295", "question": "Write a function to find n-th rencontres number.\nassert rencontres_number(7, 2) == 924\nassert rencontres_number(3, 0) == 2\nassert rencontres_number(3, 1) == 3\n", "raw_outputs": ""} +{"task_id": "a2738", "question": "\n\ndef median(l: list):\n \"\"\"Return median of elements in the list l.\n >>> median([3, 1, 2, 4, 5])\n 3\n >>> median([-10, 4, 6, 1000, 10, 20])\n 15.0\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b7435", "question": "Write a function to round every number of a given list of numbers and print the total sum multiplied by the length of the list.\nassert round_and_sum([22.4, 4.0, -16.22, -9.10, 11.00, -12.22, 14.20, -5.20, 17.50])==243\nassert round_and_sum([5,2,9,24.3,29])==345\nassert round_and_sum([25.0,56.7,89.2])==513\n", "raw_outputs": ""} +{"task_id": "b0514", "question": "Write a function that gives loss amount if the given amount has loss else return none.\nassert loss_amount(1500,1200)==None\nassert loss_amount(100,200)==100\nassert loss_amount(2000,5000)==3000\n", "raw_outputs": ""} +{"task_id": "a2022", "question": "\n\ndef triangle_area(a, h):\n \"\"\"Given length of a side and high return area for a triangle.\n >>> triangle_area(5, 3)\n 7.5\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a6976", "question": "\ndef compare_one(a, b):\n \"\"\"\n Create a function that takes integers, floats, or strings representing\n real numbers, and returns the larger variable in its given variable type.\n Return None if the values are equal.\n Note: If a real number is represented as a string, the floating point might be . or ,\n\n compare_one(1, 2.5) ➞ 2.5\n compare_one(1, \"2,3\") ➞ \"2,3\"\n compare_one(\"5,1\", \"6\") ➞ \"6\"\n compare_one(\"1\", 1) ➞ None\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a0780", "question": "\ndef anti_shuffle(s):\n \"\"\"\n Write a function that takes a string and returns an ordered version of it.\n Ordered version of string, is a string where all words (separated by space)\n are replaced by a new word where all the characters arranged in\n ascending order based on ascii value.\n Note: You should keep the order of words and blank spaces in the sentence.\n\n For example:\n anti_shuffle('Hi') returns 'Hi'\n anti_shuffle('hello') returns 'ehllo'\n anti_shuffle('Hello World!!!') returns 'Hello !!!Wdlor'\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b3990", "question": "Write a function to extract specified size of strings from a give list of string values.\nassert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,8)==['practice', 'solution']\nassert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,6)==['Python']\nassert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,9)==['exercises']\n", "raw_outputs": ""} +{"task_id": "b5864", "question": "Write a function to find whether a given array of integers contains any duplicate element.\nassert test_duplicate(([1,2,3,4,5]))==False\nassert test_duplicate(([1,2,3,4, 4]))==True\nassert test_duplicate([1,1,2,2,3,3,4,4,5])==True\n", "raw_outputs": ""} +{"task_id": "b5242", "question": "Write a function to reverse strings in a given list of string values.\nassert reverse_string_list(['Red', 'Green', 'Blue', 'White', 'Black'])==['deR', 'neerG', 'eulB', 'etihW', 'kcalB']\nassert reverse_string_list(['john','amal','joel','george'])==['nhoj','lama','leoj','egroeg']\nassert reverse_string_list(['jack','john','mary'])==['kcaj','nhoj','yram']\n", "raw_outputs": ""} +{"task_id": "a0883", "question": "\ndef x_or_y(n, x, y):\n \"\"\"A simple program which should return the value of x if n is \n a prime number and should return the value of y otherwise.\n\n Examples:\n for x_or_y(7, 34, 12) == 34\n for x_or_y(15, 8, 5) == 5\n \n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b7501", "question": "Write a function to sort dictionary items by tuple product of keys for the given dictionary with tuple keys.\nassert sort_dict_item({(5, 6) : 3, (2, 3) : 9, (8, 4): 10, (6, 4): 12} ) == {(2, 3): 9, (6, 4): 12, (5, 6): 3, (8, 4): 10}\nassert sort_dict_item({(6, 7) : 4, (3, 4) : 10, (9, 5): 11, (7, 5): 13} ) == {(3, 4): 10, (7, 5): 13, (6, 7): 4, (9, 5): 11}\nassert sort_dict_item({(7, 8) : 5, (4, 5) : 11, (10, 6): 12, (8, 6): 14} ) == {(4, 5): 11, (8, 6): 14, (7, 8): 5, (10, 6): 12}\n", "raw_outputs": ""} +{"task_id": "a9299", "question": "from typing import List, Tuple\n\ndef count_pairs_of_connectable_servers(edges: List[Tuple[int, int, int]], signalSpeed: int) -> List[int]:\n \"\"\"\n You are given an unrooted weighted tree with n vertices representing servers numbered from 0 to n - 1, an array edges where edges[i] = [a_i, b_i, weighti] represents a bidirectional edge between vertices a_i and b_i of weight weight_i. You are also given an integer signalSpeed.\n\n Two servers a and b are connectable through a server c if:\n\n a < b, a != c and b != c.\n The distance from c to a is divisible by signalSpeed.\n The distance from c to b is divisible by signalSpeed.\n The path from c to b and the path from c to a do not share any edges.\n Return an integer array count of length n where count[i] is the number of server pairs that are connectable through the server i.\n\n Examples:\n >>> edges = [[0,1,1],[1,2,5],[2,3,13],[3,4,9],[4,5,2]], signalSpeed = 1\n [0,4,6,6,4,0]\n >>> edges = [[0,6,3],[6,5,3],[0,3,1],[3,2,7],[3,1,6],[3,4,2]], signalSpeed = 3\n [2,0,0,0,0,0,2]\n\n Constraints:\n 2 <= n <= 1000\n edges.length == n - 1\n edges[i].length == 3\n 0 <= a_i, b_i < n\n edges[i] = [a_i, b_i, weight_i]\n 1 <= weight_i <= 10^6\n 1 <= signalSpeed <= 10^6\n The input is generated such that edges represents a valid tree.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b1880", "question": "Write a function to count those characters which have vowels as their neighbors in the given string.\nassert count_vowels('bestinstareels') == 7\nassert count_vowels('partofthejourneyistheend') == 12\nassert count_vowels('amazonprime') == 5\n", "raw_outputs": ""} +{"task_id": "b9299", "question": "Write a function to accept a list of strings, deleting the items with odd lengths and returning the list sorted in ascending order first by the length of each item, then alphabetically if the lengths match.\nassert sorted_list_sum([\"aa\", \"a\", \"aaa\"]) == [\"aa\"]\nassert sorted_list_sum([\"school\", \"AI\", \"asdf\", \"b\"]) == [\"AI\", \"asdf\", \"school\"]\nassert sorted_list_sum([\"d\", \"b\", \"c\", \"a\"]) == []\nassert sorted_list_sum([\"d\", \"dcba\", \"abcd\", \"a\"]) == [\"abcd\", \"dcba\"]\nassert sorted_list_sum([\"AI\", \"ai\", \"au\"]) == [\"AI\", \"ai\", \"au\"]\nassert sorted_list_sum([\"a\", \"b\", \"b\", \"c\", \"c\", \"a\"]) == []\nassert sorted_list_sum(['aaaa', 'bbbb', 'dd', 'cc']) == [\"cc\", \"dd\", \"aaaa\", \"bbbb\"]\n", "raw_outputs": ""} +{"task_id": "a9625", "question": "\n\ndef greatest_common_divisor(a: int, b: int) -> int:\n \"\"\" Return a greatest common divisor of two integers a and b\n >>> greatest_common_divisor(3, 5)\n 1\n >>> greatest_common_divisor(25, 15)\n 5\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a8810", "question": "from typing import List\n\ndef min_operations_to_divisible_by_three(nums: List[int]) -> int:\n \"\"\"\n You are given an integer array nums. In one operation, you can add or subtract 1 from any element of nums.\n\n Return the minimum number of operations to make all elements of nums divisible by 3.\n\n Examples:\n >>> nums = [1,2,3,4]\n 3\n >>> nums = [3,6,9]\n 0\n\n Constraints:\n 1 <= nums.length <= 50\n 1 <= nums[i] <= 50\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b0187", "question": "Write a function to remove the duplicates from the given tuple.\nassert remove_tuple((1, 3, 5, 2, 3, 5, 1, 1, 3)) == (1, 2, 3, 5)\nassert remove_tuple((2, 3, 4, 4, 5, 6, 6, 7, 8, 8)) == (2, 3, 4, 5, 6, 7, 8)\nassert remove_tuple((11, 12, 13, 11, 11, 12, 14, 13)) == (11, 12, 13, 14)\n", "raw_outputs": ""} +{"task_id": "b4772", "question": "Write a python function to find the sum of xor of all pairs of numbers in the given array.\nassert pair_OR_Sum([5,9,7,6],4) == 47\nassert pair_OR_Sum([7,3,5],3) == 12\nassert pair_OR_Sum([7,3],2) == 4\n", "raw_outputs": ""} +{"task_id": "a8217", "question": "\n\ndef encode_shift(s: str):\n \"\"\"\n returns encoded string by shifting every character by 5 in the alphabet.\n \"\"\"\n return \"\".join([chr(((ord(ch) + 5 - ord(\"a\")) % 26) + ord(\"a\")) for ch in s])\n\n\ndef decode_shift(s: str):\n \"\"\"\n takes as input string encoded with encode_shift function. Returns decoded string.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b2892", "question": "Write a function to return the number of times the digit 7 appears in integers less than a given number which are divisible by 11 or 13.\nassert fizz_buzz(50) == 0\nassert fizz_buzz(78) == 2\nassert fizz_buzz(79) == 3\nassert fizz_buzz(100) == 3\nassert fizz_buzz(200) == 6\nassert fizz_buzz(4000) == 192\nassert fizz_buzz(10000) == 639\nassert fizz_buzz(100000) == 8026\n", "raw_outputs": ""} +{"task_id": "b1054", "question": "Write a python function to interchange first and last elements in a given list.\nassert swap_List([1,2,3]) == [3,2,1]\nassert swap_List([1,2,3,4,4]) == [4,2,3,4,1]\nassert swap_List([4,5,6]) == [6,5,4]\n", "raw_outputs": ""} +{"task_id": "b0560", "question": "Write a function to find the list with minimum length using lambda function.\nassert min_length_list([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==(1, [0])\nassert min_length_list([[1,2,3,4,5],[1,2,3,4],[1,2,3],[1,2],[1]])==(1,[1])\nassert min_length_list([[3,4,5],[6,7,8,9],[10,11,12],[1,2]])==(2,[1,2])\n", "raw_outputs": ""} +{"task_id": "b4433", "question": "Write a python function to split the array and add the first part to the end.\nassert split_Arr([12,10,5,6,52,36],6,2) == [5,6,52,36,12,10]\nassert split_Arr([1,2,3,4],4,1) == [2,3,4,1]\nassert split_Arr([0,1,2,3,4,5,6,7],8,3) == [3,4,5,6,7,0,1,2]\n", "raw_outputs": ""} +{"task_id": "b1345", "question": "Write a python function to copy a list from a singleton tuple.\nassert lcopy([1, 2, 3]) == [1, 2, 3]\nassert lcopy([4, 8, 2, 10, 15, 18]) == [4, 8, 2, 10, 15, 18]\nassert lcopy([4, 5, 6]) == [4, 5, 6]\n\n", "raw_outputs": ""} +{"task_id": "a5166", "question": "\ndef sort_array(array):\n \"\"\"\n Given an array of non-negative integers, return a copy of the given array after sorting,\n you will sort the given array in ascending order if the sum( first index value, last index value) is odd,\n or sort it in descending order if the sum( first index value, last index value) is even.\n\n Note:\n * don't change the given array.\n\n Examples:\n * sort_array([]) => []\n * sort_array([5]) => [5]\n * sort_array([2, 4, 3, 0, 1, 5]) => [0, 1, 2, 3, 4, 5]\n * sort_array([2, 4, 3, 0, 1, 5, 6]) => [6, 5, 4, 3, 2, 1, 0]\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b1344", "question": "Write a function to count total characters in a string.\nassert count_charac(\"python programming\")==18\nassert count_charac(\"language\")==8\nassert count_charac(\"words\")==5\n", "raw_outputs": ""} +{"task_id": "a4462", "question": "def max_partitions_after_operations(s: str, k: int) -> int:\n \"\"\"\n You are given a string s and an integer k.\n\n First, you are allowed to change at most one index in s to another lowercase English letter.\n\n After that, do the following partitioning operation until s is empty:\n\n Choose the longest prefix of s containing at most k distinct characters.\n Delete the prefix from s and increase the number of partitions by one. The remaining characters (if any) in s maintain their initial order.\n Return an integer denoting the maximum number of resulting partitions after the operations by optimally choosing at most one index to change.\n\n Examples:\n >>> s = \"accca\", k = 2\n 3\n >>> s = \"aabaab\", k = 3\n 1\n >>> s = \"xxyz\", k = 1\n 4\n\n Constraints:\n 1 <= s.length <= 10^4\n s consists only of lowercase English letters.\n 1 <= k <= 26\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a2445", "question": "from typing import List\n\ndef number_of_pairs(points: List[List[int]]) -> int:\n \"\"\"\n You are given a 2D array points of size n x 2 representing integer coordinates of some points on a 2D plane, where points[i] = [xi, yi].\n\n Count the number of pairs of points (A, B), where A is on the upper left side of B, and there are no other points in the rectangle (or line) they make (including the border).\n\n Return the count.\n\n Examples:\n >>> points = [[1,1],[2,2],[3,3]]\n 0\n >>> points = [[6,2],[4,4],[2,6]]\n 2\n >>> points = [[3,1],[1,3],[1,1]]\n 2\n\n Constraints:\n 2 <= n <= 50\n points[i].length == 2\n 0 <= points[i][0], points[i][1] <= 50\n All points[i] are distinct.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a8654", "question": "from typing import List\nfrom collections import defaultdict\n\ndef count_prefix_suffix_pairs(words: List[str]) -> int:\n \"\"\"\n You are given a 0-indexed string array words.\n\n Let's define a boolean function isPrefixAndSuffix that takes two strings, str1 and str2:\n\n isPrefixAndSuffix(str1, str2) returns true if str1 is both a prefix and a suffix of str2, and false otherwise.\n For example, isPrefixAndSuffix(\"aba\", \"ababa\") is true because \"aba\" is a prefix of \"ababa\" and also a suffix, but isPrefixAndSuffix(\"abc\", \"abcd\") is false.\n\n Return an integer denoting the number of index pairs (i, j) such that i < j, and isPrefixAndSuffix(words[i], words[j]) is true.\n\n Examples:\n >>> words = [\"a\",\"aba\",\"ababa\",\"aa\"]\n 4\n >>> words = [\"pa\",\"papa\",\"ma\",\"mama\"]\n 2\n >>> words = [\"abab\",\"ab\"]\n 0\n\n Constraints:\n 1 <= words.length <= 10^5\n 1 <= words[i].length <= 10^5\n words[i] consists only of lowercase English letters.\n The sum of the lengths of all words[i] does not exceed 5 * 10^5.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a2170", "question": "def check_for_same_substring(s: str) -> bool:\n \"\"\"\n Given a string s, find any substring of length 2 which is also present in the reverse of s.\n\n Return true if such a substring exists, and false otherwise.\n\n Examples:\n >>> s = \"leetcode\"\n true\n >>> s = \"abcba\"\n true\n >>> s = \"abcd\"\n false\n\n Constraints:\n 1 <= s.length <= 100\n s consists only of lowercase English letters.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b3780", "question": "Write a function to check if a given number is prime or not.\nassert is_prime(6) == False\nassert is_prime(101) == True\nassert is_prime(11) == True\nassert is_prime(13441) == True\nassert is_prime(61) == True\nassert is_prime(4) == False\nassert is_prime(1) == False\nassert is_prime(5) == True\nassert is_prime(11) == True\nassert is_prime(17) == True\nassert is_prime(5 * 17) == False\nassert is_prime(11 * 7) == False\nassert is_prime(13441 * 19) == False\n", "raw_outputs": ""} +{"task_id": "b8497", "question": "Write a function to find the largest possible value of k such that k modulo x is y.\nassert find_max_val(15, 10, 5) == 15\nassert find_max_val(187, 10, 5) == 185\nassert find_max_val(16, 11, 1) == 12\n", "raw_outputs": ""} +{"task_id": "b1159", "question": "Write a function to find n’th smart number.\nassert smartNumber(1) == 30\nassert smartNumber(50) == 273\nassert smartNumber(1000) == 2664\n", "raw_outputs": ""} +{"task_id": "a7354", "question": "from typing import List\n\ndef find_index_of_occurrences(nums: List[int], queries: List[int], x: int) -> List[int]:\n \"\"\"\n You are given an integer array nums, an integer array queries, and an integer x.\n\n For each queries[i], you need to find the index of the queries[i]_th occurrence of x in the nums array. If there are fewer than queries[i] occurrences of x, the answer should be -1 for that query.\n\n Return an integer array answer containing the answers to all queries.\n\n Examples:\n >>> nums = [1,3,1,7], queries = [1,3,2,4], x = 1\n [0,-1,2,-1]\n >>> nums = [1,2,3], queries = [10], x = 5\n [-1]\n\n Constraints:\n 1 <= nums.length, queries.length <= 10^5\n 1 <= queries[i] <= 10^5\n 1 <= nums[i], x <= 10^4\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b6665", "question": "Write a python function to find the last two digits in factorial of a given number.\nassert last_Two_Digits(7) == 40\nassert last_Two_Digits(5) == 20\nassert last_Two_Digits(2) == 2\n", "raw_outputs": ""} +{"task_id": "a6211", "question": "from typing import List\n\ndef min_operations_to_write_y(grid: List[List[int]]) -> int:\n \"\"\"\n You are given a 0-indexed n x n grid where n is odd, and grid[r][c] is 0, 1, or 2.\n\n We say that a cell belongs to the Letter Y if it belongs to one of the following:\n\n The diagonal starting at the top-left cell and ending at the center cell of the grid.\n The diagonal starting at the top-right cell and ending at the center cell of the grid.\n The vertical line starting at the center cell and ending at the bottom border of the grid.\n The Letter Y is written on the grid if and only if:\n\n All values at cells belonging to the Y are equal.\n All values at cells not belonging to the Y are equal.\n The values at cells belonging to the Y are different from the values at cells not belonging to the Y.\n Return the minimum number of operations needed to write the letter Y on the grid given that in one operation you can change the value at any cell to 0, 1, or 2.\n\n Examples:\n >>> grid = [[1,2,2],[1,1,0],[0,1,0]]\n 3\n >>> grid = [[0,1,0,1,0],[2,1,0,1,2],[2,2,2,0,1],[2,2,2,2,2],[2,1,2,2,2]]\n 12\n\n Constraints:\n 3 <= n <= 49\n n == grid.length == grid[i].length\n 0 <= grid[i][j] <= 2\n n is odd.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b8115", "question": "Write a function to sort a tuple by its float element.\nassert float_sort([('item1', '12.20'), ('item2', '15.10'), ('item3', '24.5')])==[('item3', '24.5'), ('item2', '15.10'), ('item1', '12.20')] \nassert float_sort([('item1', '15'), ('item2', '10'), ('item3', '20')])==[('item3', '20'), ('item1', '15'), ('item2', '10')] \nassert float_sort([('item1', '5'), ('item2', '10'), ('item3', '14')])==[('item3', '14'), ('item2', '10'), ('item1', '5')] \n", "raw_outputs": ""} +{"task_id": "b3628", "question": "Write a function to find the minimum sum of any non-empty subarray from an array of integers.\nassert minSubArraySum([2, 3, 4, 1, 2, 4]) == 1\nassert minSubArraySum([-1, -2, -3]) == -6\nassert minSubArraySum([-1, -2, -3, 2, -10]) == -14\nassert minSubArraySum([-9999999999999999]) == -9999999999999999\nassert minSubArraySum([0, 10, 20, 1000000]) == 0\nassert minSubArraySum([-1, -2, -3, 10, -5]) == -6\nassert minSubArraySum([100, -1, -2, -3, 10, -5]) == -6\nassert minSubArraySum([10, 11, 13, 8, 3, 4]) == 3\nassert minSubArraySum([100, -33, 32, -1, 0, -2]) == -33\nassert minSubArraySum([-10]) == -10\nassert minSubArraySum([7]) == 7\nassert minSubArraySum([1, -1]) == -1\n", "raw_outputs": ""} +{"task_id": "b2479", "question": "Write a python function to find highest power of 2 less than or equal to given number.\nassert highest_Power_of_2(10) == 8\nassert highest_Power_of_2(19) == 16\nassert highest_Power_of_2(32) == 32\n", "raw_outputs": ""} +{"task_id": "a4189", "question": "from typing import List\n\ndef shortest_substrings(arr: List[str]) -> List[str]:\n \"\"\"\n You are given an array arr of size n consisting of non-empty strings.\n\n Find a string array answer of size n such that:\n\n answer[i] is the shortest substring of arr[i] that does not occur as a substring in any other string in arr. If multiple such substrings exist, answer[i] should be the lexicographically smallest. And if no such substring exists, answer[i] should be an empty string.\n\n Return the array answer.\n\n Examples:\n >>> arr = [\"cab\",\"ad\",\"bad\",\"c\"]\n [\"ab\",\"\",\"ba\",\"\"]\n >>> arr = [\"abc\",\"bcd\",\"abcd\"]\n [\"\",\"\",\"abcd\"]\n\n Constraints:\n n == arr.length\n 2 <= n <= 100\n 1 <= arr[i].length <= 20\n arr[i] consists only of lowercase English letters.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b4990", "question": "Write a function to calculate the discriminant value.\nassert discriminant_value(4,8,2)==(\"Two solutions\",32)\nassert discriminant_value(5,7,9)==(\"no real solution\",-131)\nassert discriminant_value(0,0,9)==(\"one solution\",0)\n", "raw_outputs": ""} +{"task_id": "b2203", "question": "Write a function to substaract two lists using map and lambda function.\nassert sub_list([1, 2, 3],[4,5,6])==[-3,-3,-3]\nassert sub_list([1,2],[3,4])==[-2,-2]\nassert sub_list([90,120],[50,70])==[40,50]\n", "raw_outputs": ""} +{"task_id": "a0518", "question": "\ndef order_by_points(nums):\n \"\"\"\n Write a function which sorts the given list of integers\n in ascending order according to the sum of their digits.\n Note: if there are several items with similar sum of their digits,\n order them based on their index in original list.\n\n For example:\n >>> order_by_points([1, 11, -1, -11, -12]) == [-1, -11, 1, -12, 11]\n >>> order_by_points([]) == []\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a3419", "question": "\ndef reverse_delete(s,c):\n \"\"\"Task\n We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c\n then check if the result string is palindrome.\n A string is called palindrome if it reads the same backward as forward.\n You should return a tuple containing the result string and True/False for the check.\n Example\n For s = \"abcde\", c = \"ae\", the result should be ('bcd',False)\n For s = \"abcdef\", c = \"b\" the result should be ('acdef',False)\n For s = \"abcdedcba\", c = \"ab\", the result should be ('cdedc',True)\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b7426", "question": "Write a function to replace all spaces in a given string with underscores, and if a string has more than 2 consecutive spaces, then replace all consecutive spaces with -.\nassert fix_spaces(\"Example\") == \"Example\"\nassert fix_spaces(\"Mudasir Hanif \") == \"Mudasir_Hanif_\"\nassert fix_spaces(\"Yellow Yellow Dirty Fellow\") == \"Yellow_Yellow__Dirty__Fellow\"\nassert fix_spaces(\"Exa mple\") == \"Exa-mple\"\nassert fix_spaces(\" Exa 1 2 2 mple\") == \"-Exa_1_2_2_mple\"\n", "raw_outputs": ""} +{"task_id": "b2207", "question": "Write a python function to find the cube sum of first n odd natural numbers.\nassert cube_Sum(2) == 28\nassert cube_Sum(3) == 153\nassert cube_Sum(4) == 496\n", "raw_outputs": ""} +{"task_id": "a7947", "question": "\n\ndef count_distinct_characters(string: str) -> int:\n \"\"\" Given a string, find out how many distinct characters (regardless of case) does it consist of\n >>> count_distinct_characters('xyzXYZ')\n 3\n >>> count_distinct_characters('Jerry')\n 4\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b1208", "question": "Write a function to convert radians to degrees.\nassert degree_radian(90)==5156.620156177409\nassert degree_radian(60)==3437.746770784939\nassert degree_radian(120)==6875.493541569878\n", "raw_outputs": ""} +{"task_id": "a0747", "question": "from typing import List\nfrom functools import lru_cache as cache\ndef number_of_permutations(n: int, requirements: List[List[int]]) -> int:\n \"\"\"\n You are given an integer n and a 2D array requirements, where requirements[i] = [end_i, cnt_i] represents the end index and the inversion count of each requirement.\n\n A pair of indices (i, j) from an integer array nums is called an inversion if:\n\n i < j and nums[i] > nums[j]\n Return the number of permutations perm of [0, 1, 2, ..., n - 1] such that for all requirements[i], perm[0..endi] has exactly cnti inversions.\n\n Since the answer may be very large, return it modulo 10^9 + 7.\n\n Examples:\n >>> n = 3, requirements = [[2,2],[0,0]]\n 2\n >>> n = 3, requirements = [[2,2],[1,1],[0,0]]\n 1\n\n Constraints:\n 2 <= n <= 300\n 1 <= requirements.length <= n\n requirements[i] = [end_i, cnt_i]\n 0 <= end_i <= n - 1\n 0 <= cnt_i <= 400\n The input is generated such that there is at least one i such that end_i == n - 1.\n The input is generated such that all endi are unique\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b0780", "question": "Write a function to check a decimal with a precision of 2.\nassert is_decimal('123.11')==True\nassert is_decimal('e666.86')==False\nassert is_decimal('3.124587')==False\n", "raw_outputs": ""} +{"task_id": "b7146", "question": "Write a function to find three closest elements from three sorted arrays.\nassert find_closet([1, 4, 10],[2, 15, 20],[10, 12],3,3,2) == (10, 15, 10)\nassert find_closet([20, 24, 100],[2, 19, 22, 79, 800],[10, 12, 23, 24, 119],3,5,5) == (24, 22, 23)\nassert find_closet([2, 5, 11],[3, 16, 21],[11, 13],3,3,2) == (11, 16, 11)\n", "raw_outputs": ""} +{"task_id": "b6360", "question": "Write a python function to check whether the given number can be represented by sum of two squares or not.\nassert sum_Square(25) == True\nassert sum_Square(24) == False\nassert sum_Square(17) == True\n", "raw_outputs": ""} +{"task_id": "a1402", "question": "from typing import List\n\n\ndef filter_by_substring(strings: List[str], substring: str) -> List[str]:\n \"\"\" Filter an input list of strings only for ones that contain given substring\n >>> filter_by_substring([], 'a')\n []\n >>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a')\n ['abc', 'bacd', 'array']\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a3381", "question": "\ndef f(n):\n \"\"\" Implement the function f that takes n as a parameter,\n and returns a list of size n, such that the value of the element at index i is the factorial of i if i is even\n or the sum of numbers from 1 to i otherwise.\n i starts from 1.\n the factorial of i is the multiplication of the numbers from 1 to i (1 * 2 * ... * i).\n Example:\n f(5) == [1, 2, 6, 24, 15]\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a4299", "question": "def min_moves_to_capture_queen(a: int, b: int, c: int, d: int, e: int, f: int) -> int:\n \"\"\"\n There is a 1-indexed 8 x 8 chessboard containing 3 pieces.\n\n You are given 6 integers a, b, c, d, e, and f where:\n\n (a, b) denotes the position of the white rook.\n (c, d) denotes the position of the white bishop.\n (e, f) denotes the position of the black queen.\n\n Given that you can only move the white pieces, return the minimum number of moves required to capture the black queen.\n\n Note that:\n\n Rooks can move any number of squares either vertically or horizontally, but cannot jump over other pieces.\n Bishops can move any number of squares diagonally, but cannot jump over other pieces.\n A rook or a bishop can capture the queen if it is located in a square that they can move to.\n The queen does not move.\n\n Examples:\n >>> a = 1, b = 1, c = 8, d = 8, e = 2, f = 3\n 2\n >>> a = 5, b = 3, c = 3, d = 4, e = 5, f = 2\n 1\n\n Constraints:\n 1 <= a, b, c, d, e, f <= 8\n No two pieces are on the same square.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b0451", "question": "Write a function to convert all possible convertible elements in the list to float.\nassert list_to_float( [(\"3\", \"4\"), (\"1\", \"26.45\"), (\"7.32\", \"8\"), (\"4\", \"8\")] ) == '[(3.0, 4.0), (1.0, 26.45), (7.32, 8.0), (4.0, 8.0)]'\nassert list_to_float( [(\"4\", \"4\"), (\"2\", \"27\"), (\"4.12\", \"9\"), (\"7\", \"11\")] ) == '[(4.0, 4.0), (2.0, 27.0), (4.12, 9.0), (7.0, 11.0)]'\nassert list_to_float( [(\"6\", \"78\"), (\"5\", \"26.45\"), (\"1.33\", \"4\"), (\"82\", \"13\")] ) == '[(6.0, 78.0), (5.0, 26.45), (1.33, 4.0), (82.0, 13.0)]'\n", "raw_outputs": ""} +{"task_id": "a2984", "question": "from typing import List\n\ndef number_of_unique_colors(limit:int, queries: List[List[int]]) -> List[int]:\n \"\"\"\n You are given an integer limit and a 2D array queries of size n x 2.\n\n There are limit + 1 balls with distinct labels in the range [0, limit]. Initially, all balls are uncolored. For every query in queries that is of the form [x, y], you mark ball x with the color y. After each query, you need to find the number of distinct colors among the balls.\n\n Return an array result of length n, where result[i] denotes the number of distinct colors after ith query.\n\n Note that:\n when answering a query, lack of a color will not be considered as a color.\n\n Examples:\n >>> limit = 4, queries = [[1,4],[2,5],[1,3],[3,4]]\n [1,2,2,3]\n >>> limit = 4, queries = [[0,1],[1,2],[2,2],[3,4],[4,5]]\n [1,2,2,3,4]\n\n Constraints:\n 1 <= limit <= 10^9\n 1 <= n == queries.length <= 10^5\n queries[i].length == 2\n 0 <= queries[i][0] <= limit\n 1 <= queries[i][1] <= 10^9\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a6665", "question": "\ndef is_happy(s):\n \"\"\"You are given a string s.\n Your task is to check if the string is happy or not.\n A string is happy if its length is at least 3 and every 3 consecutive letters are distinct\n For example:\n is_happy(a) => False\n is_happy(aa) => False\n is_happy(abcd) => True\n is_happy(aabb) => False\n is_happy(adb) => True\n is_happy(xyy) => False\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a3780", "question": "from collections import Counter\n\ndef maximum_length_substring(s: str) -> int:\n \"\"\"\n Given a string s, return the maximum length of a \n substring such that it contains at most two occurrences of each character.\n\n Examples:\n >>> s = \"bcbbbcba\"\n 4\n >>> s = \"aaaa\"\n 2\n\n Constraints:\n 2 <= s.length <= 100\n s consists only of lowercase English letters.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b2445", "question": "Write a function to create a list taking alternate elements from another given list.\nassert alternate_elements([\"red\", \"black\", \"white\", \"green\", \"orange\"])==['red', 'white', 'orange']\nassert alternate_elements([2, 0, 3, 4, 0, 2, 8, 3, 4, 2])==[2, 3, 0, 8, 4]\nassert alternate_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1,3,5,7,9]\n", "raw_outputs": ""} +{"task_id": "b0108", "question": "Write a function to check if the given tuple contains all valid values or not.\nassert check_valid((True, True, True, True) ) == True\nassert check_valid((True, False, True, True) ) == False\nassert check_valid((True, True, True, True) ) == True\n", "raw_outputs": ""} +{"task_id": "a2279", "question": "\ndef choose_num(x, y):\n \"\"\"This function takes two positive numbers x and y and returns the\n biggest even integer number that is in the range [x, y] inclusive. If \n there's no such number, then the function should return -1.\n\n For example:\n choose_num(12, 15) = 14\n choose_num(13, 12) = -1\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b1057", "question": "Write a python function to find the sum of all odd natural numbers within the range l and r.\nassert sum_in_Range(2,5) == 8\nassert sum_in_Range(5,7) == 12\nassert sum_in_Range(7,13) == 40\n", "raw_outputs": ""} +{"task_id": "a8115", "question": "\ndef pluck(arr):\n \"\"\"\n \"Given an array representing a branch of a tree that has non-negative integer nodes\n your task is to pluck one of the nodes and return it.\n The plucked node should be the node with the smallest even value.\n If multiple nodes with the same smallest even value are found return the node that has smallest index.\n\n The plucked node should be returned in a list, [ smalest_value, its index ],\n If there are no even values or the given array is empty, return [].\n\n Example 1:\n Input: [4,2,3]\n Output: [2, 1]\n Explanation: 2 has the smallest even value, and 2 has the smallest index.\n\n Example 2:\n Input: [1,2,3]\n Output: [2, 1]\n Explanation: 2 has the smallest even value, and 2 has the smallest index. \n\n Example 3:\n Input: []\n Output: []\n \n Example 4:\n Input: [5, 0, 3, 0, 4, 2]\n Output: [0, 1]\n Explanation: 0 is the smallest value, but there are two zeros,\n so we will choose the first zero, which has the smallest index.\n\n Constraints:\n * 1 <= nodes.length <= 10000\n * 0 <= node.value\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a3038", "question": "from typing import List\n\ndef sum_of_powers(nums: List[int], k: int) -> int:\n \"\"\"\n You are given an integer array nums of length n, and a positive integer k.\n\n The power of a subsequence is defined as the minimum absolute difference between any two elements in the subsequence.\n\n Return the sum of powers of all subsequences of nums which have length equal to k.\n\n Since the answer may be large, return it modulo 10^9 + 7.\n\n Examples:\n >>> nums = [1,2,3,4], k = 3\n 4\n >>> nums = [2,2], k = 2\n 0\n >>> nums = [4,3,-1], k = 2\n 10\n\n Constraints:\n 2 <= n == nums.length <= 50\n -10^8 <= nums[i] <= 10^8 \n 2 <= k <= n\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b3381", "question": "Write a function to find the length of the longest increasing subsequence of the given sequence.\nassert longest_increasing_subsequence([10, 22, 9, 33, 21, 50, 41, 60]) == 5\nassert longest_increasing_subsequence([3, 10, 2, 1, 20]) == 3\nassert longest_increasing_subsequence([50, 3, 10, 7, 40, 80]) == 4 \n", "raw_outputs": ""} +{"task_id": "b8485", "question": "Write a function to return the largest prime factor of a given integer n, assuming n > 1 and is not a prime.\nassert largest_prime_factor(15) == 5\nassert largest_prime_factor(27) == 3\nassert largest_prime_factor(63) == 7\nassert largest_prime_factor(330) == 11\nassert largest_prime_factor(13195) == 29\n", "raw_outputs": ""} +{"task_id": "b7262", "question": "Write a function 'vowels_count' that takes a string representing a word as input and returns the number of vowels in the string. Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a vowel, but only when it is at the end of the given word.\nassert vowels_count(\"abcde\") == 2\nassert vowels_count(\"Alone\") == 3\nassert vowels_count(\"key\") == 2\nassert vowels_count(\"bye\") == 1\nassert vowels_count(\"keY\") == 2\nassert vowels_count(\"bYe\") == 1\nassert vowels_count(\"ACEDY\") == 3\n", "raw_outputs": ""} +{"task_id": "b6980", "question": "Write a function to compute binomial probability for the given number.\nassert binomial_probability(10, 5, 1.0/3) == 0.13656454808718185\nassert binomial_probability(11, 6, 2.0/4) == 0.2255859375\nassert binomial_probability(12, 7, 3.0/5) == 0.227030335488\n", "raw_outputs": ""} +{"task_id": "a0768", "question": "def min_last_element(n: int, x: int) -> int:\n \"\"\"\n You are given two integers n and x. You have to construct an array of positive integers nums of size n where for every 0 <= i < n - 1, nums[i + 1] is greater than nums[i], and the result of the bitwise AND operation between all elements of nums is x.\n\n Return the minimum possible value of nums[n - 1].\n\n Examples:\n >>> n = 3, x = 4\n 6\n >>> n = 2, x = 7\n 15\n\n Constraints:\n 1 <= n, x <= 10^8\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a8171", "question": "\ndef get_row(lst, x):\n \"\"\"\n You are given a 2 dimensional data, as a nested lists,\n which is similar to matrix, however, unlike matrices,\n each row may contain a different number of columns.\n Given lst, and integer x, find integers x in the list,\n and return list of tuples, [(x1, y1), (x2, y2) ...] such that\n each tuple is a coordinate - (row, columns), starting with 0.\n Sort coordinates initially by rows in ascending order.\n Also, sort coordinates of the row by columns in descending order.\n \n Examples:\n get_row([\n [1,2,3,4,5,6],\n [1,2,3,4,1,6],\n [1,2,3,4,5,1]\n ], 1) == [(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)]\n get_row([], 1) == []\n get_row([[], [1], [1, 2, 3]], 3) == [(2, 2)]\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b5182", "question": "Write a function to flip lowercase characters to uppercase and uppercase to lowercase in a given string.\nassert flip_case('') == ''\nassert flip_case('Hello!') == 'hELLO!'\nassert flip_case('These violent delights have violent ends') == 'tHESE VIOLENT DELIGHTS HAVE VIOLENT ENDS'\n", "raw_outputs": ""} +{"task_id": "b9672", "question": "Write a function to sort the given array by using shell sort.\nassert shell_sort([12, 23, 4, 5, 3, 2, 12, 81, 56, 95]) == [2, 3, 4, 5, 12, 12, 23, 56, 81, 95]\nassert shell_sort([24, 22, 39, 34, 87, 73, 68]) == [22, 24, 34, 39, 68, 73, 87]\nassert shell_sort([32, 30, 16, 96, 82, 83, 74]) == [16, 30, 32, 74, 82, 83, 96]\n", "raw_outputs": ""} +{"task_id": "b2111", "question": "Write a function that takes in an array of integers and returns the sum of the absolute values of those integers, multiplied by the product of their signs. If the array is empty, the function should return None.\nassert prod_signs([1, 2, 2, -4]) == -9\nassert prod_signs([0, 1]) == 0\nassert prod_signs([1, 1, 1, 2, 3, -1, 1]) == -10\nassert prod_signs([]) == None\nassert prod_signs([2, 4,1, 2, -1, -1, 9]) == 20\nassert prod_signs([-1, 1, -1, 1]) == 4\nassert prod_signs([-1, 1, 1, 1]) == -4\nassert prod_signs([-1, 1, 1, 0]) == 0\n", "raw_outputs": ""} +{"task_id": "b2546", "question": "Write a function to find average value of the numbers in a given tuple of tuples.\nassert average_tuple(((10, 10, 10, 12), (30, 45, 56, 45), (81, 80, 39, 32), (1, 2, 3, 4)))==[30.5, 34.25, 27.0, 23.25]\nassert average_tuple(((1, 1, -5), (30, -15, 56), (81, -60, -39), (-10, 2, 3)))== [25.5, -18.0, 3.75]\nassert average_tuple( ((100, 100, 100, 120), (300, 450, 560, 450), (810, 800, 390, 320), (10, 20, 30, 40)))==[305.0, 342.5, 270.0, 232.5]\n", "raw_outputs": ""} +{"task_id": "b9211", "question": "Write a python function to check whether the two numbers differ at one bit position only or not.\nassert differ_At_One_Bit_Pos(13,9) == True\nassert differ_At_One_Bit_Pos(15,8) == False\nassert differ_At_One_Bit_Pos(2,4) == False\n", "raw_outputs": ""} +{"task_id": "a9898", "question": "def is_valid_word(word: str) -> bool:\n \"\"\"\n A word is considered valid if:\n\n It contains a minimum of 3 characters.\n It contains only digits (0-9), and English letters (uppercase and lowercase).\n It includes at least one vowel.\n It includes at least one consonant.\n You are given a string word.\n\n Return true if word is valid, otherwise, return false.\n\n Notes:\n\n 'a', 'e', 'i', 'o', 'u', and their uppercases are vowels.\n A consonant is an English letter that is not a vowel.\n\n Examples:\n >>> word = \"234Adas\"\n true\n >>> word = \"b3\"\n false\n >>> word = \"a3$e\"\n false\n\n Constraints:\n 1 <= word.length <= 20\n word consists of English uppercase and lowercase letters, digits, '@', '#', and '$'.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b8909", "question": "Write a python function to find the sum of fourth power of first n odd natural numbers.\nassert odd_Num_Sum(2) == 82\nassert odd_Num_Sum(3) == 707\nassert odd_Num_Sum(4) == 3108\n", "raw_outputs": ""} +{"task_id": "a0323", "question": "from typing import List\nfrom heapq import heappop, heappush\n\ndef minimum_time(n: int, edges: List[List[int]], disappear: List[int]) -> List[int]:\n \"\"\"\n There is an undirected graph of n nodes. You are given a 2D array edges, where edges[i] = [ui, vi, lengthi] describes an edge between node ui and node vi with a traversal time of lengthi units.\n\n Additionally, you are given an array disappear, where disappear[i] denotes the time when the node i disappears from the graph and you won't be able to visit it.\n\n Notice that the graph might be disconnected and might contain multiple edges.\n\n Return the array answer, with answer[i] denoting the minimum units of time required to reach node i from node 0. If node i is unreachable from node 0 then answer[i] is -1.\n\n Examples:\n >>> minimum_time(3, [[0,1,2],[1,2,1],[0,2,4]], [1,1,5])\n [0,-1,4]\n >>> minimum_time(3, [[0,1,2],[1,2,1],[0,2,4]], [1,3,5])\n [0,2,3]\n >>> minimum_time(2, [[0,1,1]], [1,1])\n [0,-1]\n\n Constraints:\n 1 <= n <= 5 * 10^4\n 0 <= edges.length <= 10^5\n edges[i] == [ui, vi, lengthi]\n 0 <= ui, vi <= n - 1\n 1 <= lengthi <= 10^5\n disappear.length == n\n 1 <= disappear[i] <= 10^5\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a3303", "question": "\ndef fruit_distribution(s,n):\n \"\"\"\n In this task, you will be given a string that represents a number of apples and oranges \n that are distributed in a basket of fruit this basket contains \n apples, oranges, and mango fruits. Given the string that represents the total number of \n the oranges and apples and an integer that represent the total number of the fruits \n in the basket return the number of the mango fruits in the basket.\n for examble:\n fruit_distribution(\"5 apples and 6 oranges\", 19) ->19 - 5 - 6 = 8\n fruit_distribution(\"0 apples and 1 oranges\",3) -> 3 - 0 - 1 = 2\n fruit_distribution(\"2 apples and 3 oranges\", 100) -> 100 - 2 - 3 = 95\n fruit_distribution(\"100 apples and 1 oranges\",120) -> 120 - 100 - 1 = 19\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b0808", "question": "Write a function to convert the given string to its MD5 hash equivalent string and return it. If 'text' is an empty string, the function should return None.\nassert string_to_md5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62'\nassert string_to_md5('') == None\nassert string_to_md5('A B C') == '0ef78513b0cb8cef12743f5aeb35f888'\nassert string_to_md5('password') == '5f4dcc3b5aa765d61d8327deb882cf99'\n", "raw_outputs": ""} +{"task_id": "a5901", "question": "from typing import List\nfrom itertools import accumulate\n\ndef count_house_pairs(n: int, x: int, y: int) -> List[int]:\n \"\"\"\n You are given three positive integers n, x, and y.\n\n In a city, there exist houses numbered 1 to n connected by n streets. There is a street connecting the house numbered i with the house numbered i + 1 for all 1 <= i <= n - 1 . An additional street connects the house numbered x with the house numbered y.\n\n For each k, such that 1 <= k <= n, you need to find the number of pairs of houses (house1, house2) such that the minimum number of streets that need to be traveled to reach house2 from house1 is k.\n\n Return a 1-indexed array result of length n where result[k] represents the total number of pairs of houses such that the minimum streets required to reach one house from the other is k.\n\n Note that x and y can be equal.\n\n Examples:\n >>> n = 3, x = 1, y = 3\n [6,0,0]\n >>> n = 5, x = 2, y = 4\n [10,8,2,0,0]\n >>> n = 4, x = 1, y = 1\n [6,4,2,0]\n\n Constraints:\n 2 <= n <= 100\n 1 <= x, y <= n\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a5242", "question": "\ndef digitSum(s):\n \"\"\"Task\n Write a function that takes a string as input and returns the sum of the upper characters only'\n ASCII codes.\n\n Examples:\n digitSum(\"\") => 0\n digitSum(\"abAB\") => 131\n digitSum(\"abcCd\") => 67\n digitSum(\"helloE\") => 69\n digitSum(\"woArBld\") => 131\n digitSum(\"aAaaaXa\") => 153\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b9626", "question": "Write a function to merge two dictionaries into a single expression.\nassert merge_dictionaries({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }, { \"G\": \"Green\", \"W\": \"White\" })=={'B': 'Black', 'R': 'Red', 'P': 'Pink', 'G': 'Green', 'W': 'White'}\nassert merge_dictionaries({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" },{ \"O\": \"Orange\", \"W\": \"White\", \"B\": \"Black\" })=={'O': 'Orange', 'P': 'Pink', 'B': 'Black', 'W': 'White', 'R': 'Red'}\nassert merge_dictionaries({ \"G\": \"Green\", \"W\": \"White\" },{ \"O\": \"Orange\", \"W\": \"White\", \"B\": \"Black\" })=={'W': 'White', 'O': 'Orange', 'G': 'Green', 'B': 'Black'}\n", "raw_outputs": ""} +{"task_id": "a9078", "question": "\n\ndef change_base(x: int, base: int):\n \"\"\"Change numerical base of input number x to base.\n return string representation after the conversion.\n base numbers are less than 10.\n >>> change_base(8, 3)\n '22'\n >>> change_base(8, 2)\n '1000'\n >>> change_base(7, 2)\n '111'\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b7454", "question": "Write a function to return a list of all prefixes from shortest to longest of the given input string.\nassert all_prefixes('') == []\nassert all_prefixes('asdfgh') == ['a', 'as', 'asd', 'asdf', 'asdfg', 'asdfgh']\nassert all_prefixes('WWW') == ['W', 'WW', 'WWW']\n", "raw_outputs": ""} +{"task_id": "b1263", "question": "Write a function that takes a list of numbers, rounds each number to the nearest higher integer, squares each of those rounded numbers and then returns the sum of the squared numbers.\nassert sum_squares([1,2,3])==14\nassert sum_squares([1.0,2,3])==14\nassert sum_squares([1,3,5,7])==84\nassert sum_squares([1.4,4.2,0])==29\nassert sum_squares([-2.4,1,1])==6\nassert sum_squares([100,1,15,2])==10230\nassert sum_squares([10000,10000])==200000000\nassert sum_squares([-1.4,4.6,6.3])==75\nassert sum_squares([-1.4,17.9,18.9,19.9])==1086\nassert sum_squares([0])==0\nassert sum_squares([-1])==1\nassert sum_squares([-1,1,0])==2\n", "raw_outputs": ""} +{"task_id": "b2853", "question": "Write a function to calculate the number of digits and letters in a string.\nassert dig_let(\"python\")==(6,0)\nassert dig_let(\"program\")==(7,0)\nassert dig_let(\"python3.0\")==(6,2)\n", "raw_outputs": ""} +{"task_id": "b3534", "question": "Write a function that takes a string of brackets. If every opening bracket has a corresponding closing bracket, return True. Otherwise, return False.\nassert correct_bracketing(\"()\")\nassert correct_bracketing(\"(()())\")\nassert correct_bracketing(\"()()(()())()\")\nassert correct_bracketing(\"()()((()()())())(()()(()))\")\nassert not correct_bracketing(\"((()())))\")\nassert not correct_bracketing(\")(()\")\nassert not correct_bracketing(\"(\")\nassert not correct_bracketing(\"((((\")\nassert not correct_bracketing(\")\")\nassert not correct_bracketing(\"(()\")\nassert not correct_bracketing(\"()()(()())())(()\")\nassert not correct_bracketing(\"()()(()())()))()\")\n", "raw_outputs": ""} +{"task_id": "b9881", "question": "Write a function to remove all the tuples with length k.\nassert remove_tuples([(4, 5), (4, ), (8, 6, 7), (1, ), (3, 4, 6, 7)] , 1) == [(4, 5), (8, 6, 7), (3, 4, 6, 7)]\nassert remove_tuples([(4, 5), (4,5), (6, 7), (1, 2, 3), (3, 4, 6, 7)] ,2) == [(1, 2, 3), (3, 4, 6, 7)]\nassert remove_tuples([(1, 4, 4), (4, 3), (8, 6, 7), (1, ), (3, 6, 7)] , 3) == [(4, 3), (1,)]\n", "raw_outputs": ""} +{"task_id": "a5737", "question": "from typing import List\n\ndef count_whole_day_pairs(hours: List[int]) -> int:\n \"\"\"\n Given an integer array hours representing times in hours, return an integer denoting the number of pairs i, j where i < j and hours[i] + hours[j] forms a complete day.\n\n A complete day is defined as a time duration that is an exact multiple of 24 hours.\n\n For example, 1 day is 24 hours, 2 days is 48 hours, 3 days is 72 hours, and so on.\n\n Examples:\n >>> hours = [12,12,30,24,24]\n 2\n >>> hours = [72,48,24,3]\n 3\n\n Constraints:\n 1 <= hours.length <= 100\n 1 <= hours[i] <= 10^9\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a0538", "question": "from typing import List\n\ndef find_winning_player(skills: List[int], k: int) -> int:\n \"\"\"\n A competition consists of n players numbered from 0 to n - 1.\n\n You are given an integer array skills of size n and a positive integer k, where skills[i] is the skill level of player i. All integers in skills are unique.\n\n All players are standing in a queue in order from player 0 to player n - 1.\n\n The competition process is as follows:\n\n The first two players in the queue play a game, and the player with the higher skill level wins.\n After the game, the winner stays at the beginning of the queue, and the loser goes to the end of it.\n The winner of the competition is the first player who wins k games in a row.\n\n Return the initial index of the winning player.\n\n Examples:\n >>> skills = [4,2,6,3,9], k = 2\n 2\n >>> skills = [2,5,4], k = 3\n 1\n\n Constraints:\n n == skills.length\n 2 <= n <= 10^5\n 1 <= k <= 10^9\n 1 <= skills[i] <= 10^6\n All integers in skills are unique.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b6855", "question": "Write a function to find out, if the given number is abundant.\nassert is_abundant(12)==True\nassert is_abundant(13)==False\nassert is_abundant(9)==False\n", "raw_outputs": ""} +{"task_id": "b6676", "question": "Write a function to replace blank spaces with any character in a string.\nassert replace_blank(\"hello people\",'@')==(\"hello@people\")\nassert replace_blank(\"python program language\",'$')==(\"python$program$language\")\nassert replace_blank(\"blank space\",\"-\")==(\"blank-space\")\n", "raw_outputs": ""} +{"task_id": "a7604", "question": "from typing import List\n\ndef min_rectangle_area(grid: List[List[int]]) -> int:\n \"\"\"\n You are given a 2D binary array grid. Find a rectangle with horizontal and vertical sides with the smallest area, such that all the 1's in grid lie inside this rectangle.\n\n Return the minimum possible area of the rectangle.\n\n Examples:\n >>> grid = [[0,1,0],[1,0,1]]\n 6\n >>> grid = [[1,0],[0,0]]\n 1\n\n Constraints:\n 1 <= grid.length, grid[i].length <= 1000\n grid[i][j] is either 0 or 1.\n The input is generated such that there is at least one 1 in grid.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a4073", "question": "from typing import List\n\ndef duplicate_numbers_xor(nums: List[int]) -> int:\n \"\"\"\n You are given an array nums, where each number in the array appears either once or twice.\n Return the bitwise XOR of all the numbers that appear twice in the array, or 0 if no number appears twice.\n\n Examples:\n >>> nums = [1,2,1,3]\n 1\n >>> nums = [1,2,3]\n 0\n\n Constraints:\n 1 <= nums.length <= 50\n 1 <= nums[i] <= 50\n Each number in nums appears either once or twice.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a5864", "question": "from typing import List\nfrom functools import reduce\nimport math\ndef minimum_array_length(nums: List[int]) -> int:\n \"\"\"\n You are given a 0-indexed integer array nums containing positive integers.\n\n Your task is to minimize the length of nums by performing the following operations any number of times (including zero):\n\n Select two distinct indices i and j from nums, such that nums[i] > 0 and nums[j] > 0.\n\n Insert the result of nums[i] % nums[j] at the end of nums.\n\n Delete the elements at indices i and j from nums.\n\n Return an integer denoting the minimum length of nums after performing the operation any number of times.\n\n Examples:\n >>> nums = [1,4,3,1]\n 1\n >>> nums = [5,5,5,10,5]\n 2\n >>> nums = [2,3,4]\n 1\n\n Constraints:\n 1 <= nums.length <= 10^5\n 1 <= nums[i] <= 10^9\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b7672", "question": "Write a function to check if each element of the second tuple is greater than its corresponding index in the first tuple.\nassert check_greater((10, 4, 5), (13, 5, 18)) == True\nassert check_greater((1, 2, 3), (2, 1, 4)) == False\nassert check_greater((4, 5, 6), (5, 6, 7)) == True\n", "raw_outputs": ""} +{"task_id": "b8840", "question": "Write a function to find the circumference of a circle.\nassert circle_circumference(10)==62.830000000000005\nassert circle_circumference(5)==31.415000000000003\nassert circle_circumference(4)==25.132\n", "raw_outputs": ""} +{"task_id": "b7947", "question": "Write a python function to find nth bell number.\nassert bell_Number(2) == 2\nassert bell_Number(3) == 5\nassert bell_Number(4) == 15\n", "raw_outputs": ""} +{"task_id": "a0083", "question": "\n\ndef max_element(l: list):\n \"\"\"Return maximum element in the list.\n >>> max_element([1, 2, 3])\n 3\n >>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])\n 123\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b2202", "question": "Write a function to check if a given string is a palindrome.\nassert is_palindrome('') == True\nassert is_palindrome('aba') == True\nassert is_palindrome('aaaaa') == True\nassert is_palindrome('zbcd') == False\nassert is_palindrome('xywyx') == True\nassert is_palindrome('xywyz') == False\nassert is_palindrome('xywzx') == False\n", "raw_outputs": ""} +{"task_id": "a6444", "question": "\ndef count_up_to(n):\n \"\"\"Implement a function that takes an non-negative integer and returns an array of the first n\n integers that are prime numbers and less than n.\n for example:\n count_up_to(5) => [2,3]\n count_up_to(11) => [2,3,5,7]\n count_up_to(0) => []\n count_up_to(20) => [2,3,5,7,11,13,17,19]\n count_up_to(1) => []\n count_up_to(18) => [2,3,5,7,11,13,17]\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b9422", "question": "Write a function to find the median of a trapezium.\nassert median_trapezium(15,25,35)==20\nassert median_trapezium(10,20,30)==15\nassert median_trapezium(6,9,4)==7.5\n", "raw_outputs": ""} +{"task_id": "a8909", "question": "from typing import List\n\n\ndef remove_duplicates(numbers: List[int]) -> List[int]:\n \"\"\" From a list of integers, remove all elements that occur more than once.\n Keep order of elements left the same as in the input.\n >>> remove_duplicates([1, 2, 3, 2, 4])\n [1, 3, 4]\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a0187", "question": "\n\ndef fib4(n: int):\n \"\"\"The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:\n fib4(0) -> 0\n fib4(1) -> 0\n fib4(2) -> 2\n fib4(3) -> 0\n fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).\n Please write a function to efficiently compute the n-th element of the fib4 number sequence. Do not use recursion.\n >>> fib4(5)\n 4\n >>> fib4(6)\n 8\n >>> fib4(7)\n 14\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a8840", "question": "from typing import List\n\n\ndef intersperse(numbers: List[int], delimeter: int) -> List[int]:\n \"\"\" Insert a number 'delimeter' between every two consecutive elements of input list `numbers'\n >>> intersperse([], 4)\n []\n >>> intersperse([1, 2, 3], 4)\n [1, 4, 2, 4, 3]\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a6855", "question": "\ndef triangle_area(a, b, c):\n '''\n Given the lengths of the three sides of a triangle. Return the area of\n the triangle rounded to 2 decimal points if the three sides form a valid triangle. \n Otherwise return -1\n Three sides make a valid triangle when the sum of any two sides is greater \n than the third side.\n Example:\n triangle_area(3, 4, 5) == 6.00\n triangle_area(1, 2, 10) == -1\n '''\n", "raw_outputs": ""} +{"task_id": "a2996", "question": "from typing import List\n\ndef min_boxes_to_refill_apples(apple: List[int], capacity: List[int]) -> int:\n \"\"\"\n You are given an array apple of size n and an array capacity of size m.\n\n There are n packs where the i th pack contains apple[i] apples. There are m boxes as well, and the ith box has a capacity of capacity[i] apples.\n\n Return the minimum number of boxes you need to select to redistribute these n packs of apples into boxes.\n\n Note that, apples from the same pack can be distributed into different boxes.\n\n Examples:\n >>> apple = [1,3,2], capacity = [4,3,1,5,2]\n 2\n >>> apple = [5,5,5], capacity = [2,4,2,7]\n 4\n\n Constraints:\n 1 <= n == apple.length <= 50\n 1 <= m == capacity.length <= 50\n 1 <= apple[i], capacity[i] <= 50\n The input is generated such that it's possible to redistribute packs of apples into boxes.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b9367", "question": "Write a python function to find smallest number in a list.\nassert smallest_num([10, 20, 1, 45, 99]) == 1\nassert smallest_num([1, 2, 3]) == 1\nassert smallest_num([45, 46, 50, 60]) == 45\n", "raw_outputs": ""} +{"task_id": "a1972", "question": "\ndef minPath(grid, k):\n \"\"\"\n Given a grid with N rows and N columns (N >= 2) and a positive integer k, \n each cell of the grid contains a value. Every integer in the range [1, N * N]\n inclusive appears exactly once on the cells of the grid.\n\n You have to find the minimum path of length k in the grid. You can start\n from any cell, and in each step you can move to any of the neighbor cells,\n in other words, you can go to cells which share an edge with you current\n cell.\n Please note that a path of length k means visiting exactly k cells (not\n necessarily distinct).\n You CANNOT go off the grid.\n A path A (of length k) is considered less than a path B (of length k) if\n after making the ordered lists of the values on the cells that A and B go\n through (let's call them lst_A and lst_B), lst_A is lexicographically less\n than lst_B, in other words, there exist an integer index i (1 <= i <= k)\n such that lst_A[i] < lst_B[i] and for any j (1 <= j < i) we have\n lst_A[j] = lst_B[j].\n It is guaranteed that the answer is unique.\n Return an ordered list of the values on the cells that the minimum path go through.\n\n Examples:\n\n Input: grid = [ [1,2,3], [4,5,6], [7,8,9]], k = 3\n Output: [1, 2, 1]\n\n Input: grid = [ [5,9,3], [4,1,6], [7,8,2]], k = 1\n Output: [1]\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b1041", "question": "Write a function that matches a string that has an a followed by zero or more b's by using regex.\nassert text_match(\"msb\") == 'Not matched!'\nassert text_match(\"a0c\") == 'Found a match!'\nassert text_match(\"abbc\") == 'Found a match!'\n", "raw_outputs": ""} +{"task_id": "a4147", "question": "from bisect import bisect_left\nfrom typing import List\n\ndef find_beautiful_indices(s: str, a: str, b: str, k: int) -> List[int]:\n \"\"\"\n You are given a 0-indexed string s, a string a, a string b, and an integer k.\n\n An index i is beautiful if:\n\n 0 <= i <= s.length - a.length\n s[i..(i + a.length - 1)] == a\n There exists an index j such that:\n 0 <= j <= s.length - b.length\n s[j..(j + b.length - 1)] == b\n |j - i| <= k\n Return the array that contains beautiful indices in sorted order from smallest to largest.\n\n Examples:\n >>> s = \"isawsquirrelnearmysquirrelhouseohmy\", a = \"my\", b = \"squirrel\", k = 15\n [16,33]\n >>> s = \"abcd\", a = \"a\", b = \"a\", k = 4\n [0]\n\n Constraints:\n 1 <= k <= s.length <= 10^5\n 1 <= a.length, b.length <= 10\n s, a, and b contain only lowercase English letters.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a5875", "question": "from collections import Counter\ndef minimum_operations_to_make_k_periodic(word: str, k: int) -> int:\n \"\"\"\n You are given a string word of size n, and an integer k such that k divides n.\n\n In one operation, you can pick any two indices i and j, that are divisible by k, then replace the substring of length k starting at i with the substring of length k starting at j. That is, replace the substring word[i..i + k - 1] with the substring word[j..j + k - 1].\n\n Return the minimum number of operations required to make word k-periodic.\n\n We say that word is k-periodic if there is some string s of length k such that word can be obtained by concatenating s an arbitrary number of times. For example, if word == “ababab”, then word is 2-periodic for s = \"ab\".\n \n\n Examples:\n >>> word = \"leetcodeleet\", k = 4\n 1\n >>> word = \"leetcoleet\", k = 2\n 3\n\n Constraints:\n 1 <= n == word.length <= 10^5\n 1 <= k <= word.length\n k divides word.length.\n word consists only of lowercase English letters.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b3330", "question": "Write a function to check if the given tuple has any none value or not.\nassert check_none((10, 4, 5, 6, None)) == True\nassert check_none((7, 8, 9, 11, 14)) == False\nassert check_none((1, 2, 3, 4, None)) == True\n", "raw_outputs": ""} +{"task_id": "a9345", "question": "def min_pushes_needed(word: str) -> int:\n \"\"\"\n You are given a string word containing distinct lowercase English letters.\n\n Telephone keypads have keys mapped with distinct collections of lowercase English letters, which can be used to form words by pushing them. For example, the key 2 is mapped with [\"a\",\"b\",\"c\"], we need to push the key one time to type \"a\", two times to type \"b\", and three times to type \"c\" .\n\n It is allowed to remap the keys numbered 2 to 9 to distinct collections of letters. The keys can be remapped to any amount of letters, but each letter must be mapped to exactly one key. You need to find the minimum number of times the keys will be pushed to type the string word.\n\n Return the minimum number of pushes needed to type word after remapping the keys.\n\n Examples:\n >>> word = \"abcde\"\n 5\n >>> word = \"xycdefghij\"\n 12\n\n Constraints:\n 1 <= word.length <= 26\n word consists of lowercase English letters.\n All letters in word are distinct.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b9427", "question": "Write a function to perform mathematical division operation across the given tuples.\nassert division_elements((10, 4, 6, 9),(5, 2, 3, 3)) == (2, 2, 2, 3)\nassert division_elements((12, 6, 8, 16),(6, 3, 4, 4)) == (2, 2, 2, 4)\nassert division_elements((20, 14, 36, 18),(5, 7, 6, 9)) == (4, 2, 6, 2)\n", "raw_outputs": ""} +{"task_id": "b9660", "question": "Write a function to compute the value of ncr%p.\nassert ncr_modp(10,2,13)==6\nassert ncr_modp(15,12,43)==25\nassert ncr_modp(17,9,18)==10\n", "raw_outputs": ""} +{"task_id": "b4734", "question": "Write a function to apply a linear transform to a list of numbers so that the smallest number becomes 0 and the largest becomes 1.\nassert rescale_to_unit([2.0, 49.9]) == [0.0, 1.0]\nassert rescale_to_unit([100.0, 49.9]) == [1.0, 0.0]\nassert rescale_to_unit([1.0, 2.0, 3.0, 4.0, 5.0]) == [0.0, 0.25, 0.5, 0.75, 1.0]\nassert rescale_to_unit([2.0, 1.0, 5.0, 3.0, 4.0]) == [0.25, 0.0, 1.0, 0.5, 0.75]\nassert rescale_to_unit([12.0, 11.0, 15.0, 13.0, 14.0]) == [0.25, 0.0, 1.0, 0.5, 0.75]\n", "raw_outputs": ""} +{"task_id": "a8497", "question": "\ndef is_equal_to_sum_even(n):\n \"\"\"Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers\n Example\n is_equal_to_sum_even(4) == False\n is_equal_to_sum_even(6) == False\n is_equal_to_sum_even(8) == True\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a1203", "question": "from typing import List\n\ndef find_permutation(nums: List[int]) -> List[int]:\n \"\"\"\n You are given an array nums which is a permutation of [0, 1, 2, ..., n - 1]. The score of any permutation of [0, 1, 2, ..., n - 1] named perm is defined as:\n\n score(perm) = |perm[0] - nums[perm[1]]| + |perm[1] - nums[perm[2]]| + ... + |perm[n - 1] - nums[perm[0]]|\n\n Return the permutation perm which has the minimum possible score. If multiple permutations exist with this score, return the one that is lexicographically smallest among them.\n\n Examples:\n >>> nums = [1,0,2]\n [0,1,2]\n >>> nums = [0,2,1]\n [0,2,1]\n\n Constraints:\n 2 <= n == nums.length <= 14\n nums is a permutation of [0, 1, 2, ..., n - 1].\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b6976", "question": "Write a function to calculate the maximum aggregate from the list of tuples.\nassert max_aggregate([('Juan Whelan',90),('Sabah Colley',88),('Peter Nichols',7),('Juan Whelan',122),('Sabah Colley',84)])==('Juan Whelan', 212)\nassert max_aggregate([('Juan Whelan',50),('Sabah Colley',48),('Peter Nichols',37),('Juan Whelan',22),('Sabah Colley',14)])==('Juan Whelan', 72)\nassert max_aggregate([('Juan Whelan',10),('Sabah Colley',20),('Peter Nichols',30),('Juan Whelan',40),('Sabah Colley',50)])==('Sabah Colley', 70)\n", "raw_outputs": ""} +{"task_id": "a0374", "question": "from typing import List\nfrom math import gcd\nfrom bisect import bisect_left\ndef lcm(a: int, b: int) -> int:\n return a * b // gcd(a, b)\ndef find_kth_smallest(coins: List[int], k: int) -> int:\n \"\"\"\n You are given an integer array coins representing coins of different denominations and an integer k.\n\n You have an infinite number of coins of each denomination. However, you are not allowed to combine coins of different denominations.\n\n Return the kth smallest amount that can be made using these coins.\n\n Examples:\n >>> coins = [3,6,9], k = 3\n 9\n >>> coins = [5,2], k = 7\n 12\n\n Constraints:\n 1 <= coins.length <= 15\n 1 <= coins[i] <= 25\n 1 <= k <= 2 * 10^9\n coins contains pairwise distinct integers.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b6589", "question": "Write a function to find the smallest integers from a given list of numbers using heap queue algorithm.\nassert heap_queue_smallest( [25, 35, 22, 85, 14, 65, 75, 25, 58],3)==[14, 22, 25] \nassert heap_queue_smallest( [25, 35, 22, 85, 14, 65, 75, 25, 58],2)==[14, 22]\nassert heap_queue_smallest( [25, 35, 22, 85, 14, 65, 75, 22, 58],5)==[14, 22, 22, 25, 35]\n", "raw_outputs": ""} +{"task_id": "b2984", "question": "Write a function to return the product of the odd digits in a given positive integer n, or 0 if all digits are even.\nassert digits(5) == 5\nassert digits(54) == 5\nassert digits(120) == 1\nassert digits(5014) == 5\nassert digits(98765) == 315\nassert digits(5576543) == 2625\nassert digits(2468) == 0\n", "raw_outputs": ""} +{"task_id": "b1550", "question": "Write a python function to toggle bits of the number except the first and the last bit.\nassert toggle_middle_bits(9) == 15\nassert toggle_middle_bits(10) == 12\nassert toggle_middle_bits(11) == 13\n", "raw_outputs": ""} +{"task_id": "a5391", "question": "from typing import List\n\ndef flower_game(n: int, m: int) -> int:\n \"\"\"\n Alice and Bob are playing a turn-based game on a circular field surrounded by flowers. The circle represents the field, and there are x flowers in the clockwise direction between Alice and Bob, and y flowers in the anti-clockwise direction between them.\n\n The game proceeds as follows:\n\n Alice takes the first turn.\n In each turn, a player must choose either the clockwise or anti-clockwise direction and pick one flower from that side.\n At the end of the turn, if there are no flowers left at all, the current player captures their opponent and wins the game.\n Given two integers, n and m, the task is to compute the number of possible pairs (x, y) that satisfy the conditions:\n\n Alice must win the game according to the described rules.\n The number of flowers x in the clockwise direction must be in the range [1,n].\n The number of flowers y in the anti-clockwise direction must be in the range [1,m].\n Return the number of possible pairs (x, y) that satisfy the conditions mentioned in the statement.\n\n Examples:\n >>> n = 3, m = 2\n 3\n >>> n = 1, m = 1\n 0\n\n Constraints:\n 1 <= n, m <= 10^5\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b9044", "question": "Write a python function to find the hamming distance between given two integers.\nassert hamming_Distance(4,8) == 2\nassert hamming_Distance(2,4) == 2\nassert hamming_Distance(1,2) == 2\n", "raw_outputs": ""} +{"task_id": "b0083", "question": "Write a function to sort a list of lists by a given index of the inner list.\nassert index_on_inner_list([('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,0)==[('Beau Turnbull', 94, 98), ('Brady Kent', 97, 96), ('Greyson Fulton', 98, 99), ('Wyatt Knott', 91, 94)]\nassert index_on_inner_list([('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,1)==[('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98), ('Brady Kent', 97, 96), ('Greyson Fulton', 98, 99)]\nassert index_on_inner_list([('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,2)==[('Wyatt Knott', 91, 94), ('Brady Kent', 97, 96), ('Beau Turnbull', 94, 98), ('Greyson Fulton', 98, 99)]\n", "raw_outputs": ""} +{"task_id": "b8882", "question": "Write a function to create a list containing the power of said number in bases raised to the corresponding number in the index using map function.\nassert basesnum_coresspondingnum([10, 20, 30, 40, 50, 60, 70, 80, 90, 100],[1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[10, 400, 27000, 2560000, 312500000, 46656000000, 8235430000000, 1677721600000000, 387420489000000000, 100000000000000000000]\nassert basesnum_coresspondingnum([1, 2, 3, 4, 5, 6, 7],[10, 20, 30, 40, 50, 60, 70])==[1, 1048576, 205891132094649, 1208925819614629174706176, 88817841970012523233890533447265625, 48873677980689257489322752273774603865660850176, 143503601609868434285603076356671071740077383739246066639249]\nassert basesnum_coresspondingnum([4, 8, 12, 16, 20, 24, 28],[3, 6, 9, 12, 15, 18, 21])==[64, 262144, 5159780352, 281474976710656, 32768000000000000000, 6979147079584381377970176, 2456510688823056210273111113728]\n", "raw_outputs": ""} +{"task_id": "a6980", "question": "\ndef get_max_triples(n):\n \"\"\"\n You are given a positive integer n. You have to create an integer array a of length n.\n For each i (1 ≤ i ≤ n), the value of a[i] = i * i - i + 1.\n Return the number of triples (a[i], a[j], a[k]) of a where i < j < k, \n and a[i] + a[j] + a[k] is a multiple of 3.\n\n Example :\n Input: n = 5\n Output: 1\n Explanation: \n a = [1, 3, 7, 13, 21]\n The only valid triple is (1, 7, 13).\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a3085", "question": "from typing import List\n\ndef min_rectangles_to_cover_points(points: List[List[int]], w: int) -> int:\n \"\"\"\n You are given a 2D integer array points, where points[i] = [x_i, y_i]. You are also given an integer w. Your task is to cover all the given points with rectangles.\n\n Each rectangle has its lower end at some point (x_1, 0) and its upper end at some point (x_2, y_2), where x_1 <= x_2, y_2 >= 0, and the condition x_2 - x_1 <= w must be satisfied for each rectangle.\n\n A point is considered covered by a rectangle if it lies within or on the boundary of the rectangle.\n\n Return an integer denoting the minimum number of rectangles needed so that each point is covered by at least one rectangle.\n\n Note: A point may be covered by more than one rectangle.\n\n Examples:\n >>> points = [[2,1],[1,0],[1,4],[1,8],[3,5],[4,6]], w = 1\n 2\n >>> points = [[0,0],[1,1],[2,2],[3,3],[4,4],[5,5],[6,6]], w = 2\n 3\n >>> points = [[2,3],[1,2]], w = 0\n 2\n\n Constraints:\n 1 <= points.length <= 10^5\n points[i].length == 2\n 0 <= x_i == points[i][0] <= 10^9\n 0 <= y_i == points[i][1] <= 10^9\n 0 <= w <= 10^9\n All pairs (x_i, y_i) are distinct.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b6110", "question": "Write a function to check if the given tuples contain the k or not.\nassert check_K((10, 4, 5, 6, 8), 6) == True\nassert check_K((1, 2, 3, 4, 5, 6), 7) == False\nassert check_K((7, 8, 9, 44, 11, 12), 11) == True\n", "raw_outputs": ""} +{"task_id": "a1167", "question": "from typing import List\n\ndef min_or_value_after_operations(nums: List[int], k: int) -> int:\n \"\"\"\n You are given a 0-indexed integer array nums and an integer k.\n\n In one operation, you can pick any index i of nums such that 0 <= i < nums.length - 1 and replace nums[i] and nums[i + 1] with a single occurrence of nums[i] & nums[i + 1], where & represents the bitwise AND operator.\n\n Return the minimum possible value of the bitwise OR of the remaining elements of nums after applying at most k operations.\n\n Examples:\n >>> nums = [3,5,3,2,7], k = 2\n 3\n >>> nums = [7,3,15,14,2,8], k = 4\n 2\n >>> nums = [10,7,10,3,9,14,9,4], k = 1\n 15\n\n Constraints:\n 1 <= nums.length <= 10^5\n 0 <= nums[i] < 2^30\n 0 <= k < nums.length\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a0191", "question": "def find_permutation_difference(s: str, t: str) -> int:\n \"\"\"\n You are given two strings s and t such that every character occurs at most once in s and t is a permutation of s.\n\n The permutation difference between s and t is defined as the sum of the absolute difference between the index of the occurrence of each character in s and the index of the occurrence of the same character in t.\n\n Return the permutation difference between s and t.\n\n Examples:\n >>> s = \"abc\", t = \"bac\"\n 2\n >>> s = \"abcde\", t = \"edbac\"\n 12\n\n Constraints:\n 1 <= s.length <= 26\n Each character occurs at most once in s.\n t is a permutation of s.\n s consists only of lowercase English letters.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a7248", "question": "from typing import List\n\ndef longest_monotonic_subarray(nums: List[int]) -> int:\n \"\"\"\n You are given an array of integers nums. Return the length of the longest subarray of nums which is either strictly increasing or strictly decreasing.\n\n Examples:\n >>> nums = [1,4,3,3,2]\n 2\n\n >>> nums = [3,3,3,3]\n 1\n\n >>> nums = [3,2,1]\n 3\n\n Constraints:\n 1 <= nums.length <= 50\n 1 <= nums[i] <= 50\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a1600", "question": "\ndef closest_integer(value):\n '''\n Create a function that takes a value (string) representing a number\n and returns the closest integer to it. If the number is equidistant\n from two integers, round it away from zero.\n\n Examples\n >>> closest_integer(\"10\")\n 10\n >>> closest_integer(\"15.3\")\n 15\n\n Note:\n Rounding away from zero means that if the given number is equidistant\n from two integers, the one you should return is the one that is the\n farthest from zero. For example closest_integer(\"14.5\") should\n return 15 and closest_integer(\"-14.5\") should return -15.\n '''\n", "raw_outputs": ""} +{"task_id": "a9656", "question": "from typing import List\n\ndef min_operations(nums: List[int], k: int) -> int:\n \"\"\"\n You are given a 0-indexed integer array nums, and an integer k.\n\n In one operation, you can remove one occurrence of the smallest element of nums.\n\n Return the minimum number of operations needed so that all elements of the array are greater than or equal to k.\n\n Examples:\n >>> nums = [2,11,10,1,3], k = 10\n 3\n >>> nums = [1,1,2,4,9], k = 1\n 0\n >>> nums = [1,1,2,4,9], k = 9\n 4\n\n Constraints:\n 1 <= nums.length <= 50\n 1 <= nums[i] <= 10^9\n 1 <= k <= 10^9\n The input is generated such that there is at least one index i such that nums[i] >= k.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b2337", "question": "Write a function to find the maximum sum of subsequences of given array with no adjacent elements.\nassert max_sum_subseq([1, 2, 9, 4, 5, 0, 4, 11, 6]) == 26\nassert max_sum_subseq([1, 2, 9, 5, 6, 0, 5, 12, 7]) == 28\nassert max_sum_subseq([1, 3, 10, 5, 6, 0, 6, 14, 21]) == 44\n", "raw_outputs": ""} +{"task_id": "a2456", "question": "\ndef odd_count(lst):\n \"\"\"Given a list of strings, where each string consists of only digits, return a list.\n Each element i of the output should be \"the number of odd elements in the\n string i of the input.\" where all the i's should be replaced by the number\n of odd digits in the i'th string of the input.\n\n >>> odd_count(['1234567'])\n [\"the number of odd elements 4n the str4ng 4 of the 4nput.\"]\n >>> odd_count(['3',\"11111111\"])\n [\"the number of odd elements 1n the str1ng 1 of the 1nput.\",\n \"the number of odd elements 8n the str8ng 8 of the 8nput.\"]\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b9769", "question": "Write a function to remove an empty tuple from a list of tuples.\nassert remove_empty([(), (), ('',), ('a', 'b'), ('a', 'b', 'c'), ('d')])==[('',), ('a', 'b'), ('a', 'b', 'c'), 'd'] \nassert remove_empty([(), (), ('',), (\"python\"), (\"program\")])==[('',), (\"python\"), (\"program\")] \nassert remove_empty([(), (), ('',), (\"java\")])==[('',),(\"java\") ] \n", "raw_outputs": ""} +{"task_id": "b9656", "question": "Write a function to filter odd numbers using lambda function.\nassert filter_oddnumbers([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1,3,5,7,9]\nassert filter_oddnumbers([10,20,45,67,84,93])==[45,67,93]\nassert filter_oddnumbers([5,7,9,8,6,4,3])==[5,7,9,3]\n", "raw_outputs": ""} +{"task_id": "a6110", "question": "from typing import List\n\n\ndef concatenate(strings: List[str]) -> str:\n \"\"\" Concatenate list of strings into a single string\n >>> concatenate([])\n ''\n >>> concatenate(['a', 'b', 'c'])\n 'abc'\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b7363", "question": "Write a python function to get the position of rightmost set bit.\nassert get_First_Set_Bit_Pos(12) == 3\nassert get_First_Set_Bit_Pos(18) == 2\nassert get_First_Set_Bit_Pos(16) == 5\n", "raw_outputs": ""} +{"task_id": "b7114", "question": "Write a python function to check whether the count of inversion of two types are same or not.\nassert solve([1,0,2],3) == True\nassert solve([1,2,0],3) == False\nassert solve([1,2,1],3) == True\n", "raw_outputs": ""} +{"task_id": "b0191", "question": "Write a function to remove tuple elements that occur more than once and replace the duplicates with some custom value.\nassert remove_replica((1, 1, 4, 4, 4, 5, 5, 6, 7, 7)) == (1, 'MSP', 4, 'MSP', 'MSP', 5, 'MSP', 6, 7, 'MSP')\nassert remove_replica((2, 3, 4, 4, 5, 6, 6, 7, 8, 9, 9)) == (2, 3, 4, 'MSP', 5, 6, 'MSP', 7, 8, 9, 'MSP')\nassert remove_replica((2, 2, 5, 4, 5, 7, 5, 6, 7, 7)) == (2, 'MSP', 5, 4, 'MSP', 7, 'MSP', 6, 'MSP', 'MSP')\n", "raw_outputs": ""} +{"task_id": "a6766", "question": "from typing import List\nfrom collections import defaultdict\n\ndef max_subarray_sum(nums: List[int], k: int) -> int:\n \"\"\"\n You are given an array nums of length n and a positive integer k.\n\n A subarray of nums is called good if the absolute difference between its first and last element is exactly k, in other words, the subarray nums[i..j] is good if |nums[i] - nums[j]| == k.\n\n Return the maximum sum of a good subarray of nums. If there are no good subarrays, return 0.\n\n Examples:\n >>> nums = [1,2,3,4,5,6], k = 1\n 11\n >>> nums = [-1,3,2,4,5], k = 3\n 11\n >>> nums = [-1,-2,-3,-4], k = 2\n -6\n\n Constraints:\n 2 <= nums.length <= 10^5\n -10^9 <= nums[i] <= 10^9\n 1 <= k <= 10^9\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a9828", "question": "from typing import List\n\ndef diff_between_k_and_sub_array(nums: List[int], k: int) -> int:\n \"\"\"\n You are given an array nums and an integer k. You need to find a subarray of nums such that the absolute difference between k and the bitwise OR of the subarray elements is as small as possible. In other words, select a subarray nums[l..r] such that |k - (nums[l] OR nums[l + 1] ... OR nums[r])| is minimum.\n\n Return the minimum possible value of the absolute difference.\n\n A subarray is a contiguous non-empty sequence of elements within an array.\n\n Examples:\n >>> nums = [1,2,4,5], k = 3\n 0\n >>> nums = [1,3,1,3], k = 2\n 1\n\n Constraints:\n 1 <= nums.length <= 10^5\n 1 <= nums[i] <= 10^9\n 1 <= k <= 10^9\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b4073", "question": "Write a function that takes an array of integers and returns the number of elements which has a sum of their digits greater than zero. If a number is negative, then its first signed digit will be negative, e.g. -123 has signed digits -1, 2, and 3.\nassert count_nums([]) == 0\nassert count_nums([-1, -2, 0]) == 0\nassert count_nums([1, 1, 2, -2, 3, 4, 5]) == 6\nassert count_nums([1, 6, 9, -6, 0, 1, 5]) == 5\nassert count_nums([1, 100, 98, -7, 1, -1]) == 4\nassert count_nums([12, 23, 34, -45, -56, 0]) == 5\nassert count_nums([-0, 1**0]) == 1\nassert count_nums([1]) == 1\n", "raw_outputs": ""} +{"task_id": "a5700", "question": "from collections import Counter\n\ndef min_anagram_length(s: str) -> int:\n \"\"\"\n You are given a string s, which is known to be a concatenation of anagrams of some string t.\n\n Return the minimum possible length of the string t.\n\n An anagram is formed by rearranging the letters of a string. For example, \"aab\", \"aba\", and, \"baa\" are anagrams of \"aab\".\n\n\n Examples:\n >>> s = \"abba\"\n 2\n >>> s = \"cdef\"\n 4\n\n Constraints:\n 1 <= s.length <= 10^5\n s consist only of lowercase English letters.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b8194", "question": "Write a function to find the volume of a cone.\nassert volume_cone(5,12)==314.15926535897927\nassert volume_cone(10,15)==1570.7963267948965\nassert volume_cone(19,17)==6426.651371693521\n", "raw_outputs": ""} +{"task_id": "b8986", "question": "Write a python function to print negative numbers in a list.\nassert neg_nos([-1,4,5,-6]) == -1,-6\nassert neg_nos([-1,-2,3,4]) == -1,-2\nassert neg_nos([-7,-6,8,9]) == -7,-6\n", "raw_outputs": ""} +{"task_id": "b3965", "question": "Write a python function to count number of cubes of size k in a cube of size n.\nassert No_of_cubes(2,1) == 8\nassert No_of_cubes(5,2) == 64\nassert No_of_cubes(1,1) == 1\n", "raw_outputs": ""} +{"task_id": "b6247", "question": "Write a function that takes a string and returns the string without vowels.\nassert remove_vowels('') == ''\nassert remove_vowels(\"abcdef\\nghijklm\") == 'bcdf\\nghjklm'\nassert remove_vowels('fedcba') == 'fdcb'\nassert remove_vowels('eeeee') == ''\nassert remove_vowels('acBAA') == 'cB'\nassert remove_vowels('EcBOO') == 'cB'\nassert remove_vowels('ybcd') == 'ybcd'\n", "raw_outputs": ""} +{"task_id": "b6558", "question": "Write a python function to check whether the given number is co-prime or not.\nassert is_coprime(17,13) == True\nassert is_coprime(15,21) == False\nassert is_coprime(25,45) == False\n", "raw_outputs": ""} +{"task_id": "a8363", "question": "from typing import List\n\ndef min_cost_to_split_array(nums: List[int]) -> int:\n \"\"\"\n You are given an array of integers nums of length n.\n\n The cost of an array is the value of its first element. For example, the cost of [1,2,3] is 1 while the cost of [3,4,1] is 3.\n\n You need to divide nums into 3 disjoint contiguous subarrays.\n\n Return the minimum possible sum of the cost of these subarrays.\n\n Examples:\n >>> nums = [1,2,3,12]\n 6\n >>> nums = [5,4,3]\n 12\n >>> nums = [10,3,1,1]\n 12\n\n Constraints:\n 3 <= n <= 50\n 1 <= nums[i] <= 50\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a4901", "question": "\ndef bf(planet1, planet2):\n '''\n There are eight planets in our solar system: the closerst to the Sun \n is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn, \n Uranus, Neptune.\n Write a function that takes two planet names as strings planet1 and planet2. \n The function should return a tuple containing all planets whose orbits are \n located between the orbit of planet1 and the orbit of planet2, sorted by \n the proximity to the sun. \n The function should return an empty tuple if planet1 or planet2\n are not correct planet names. \n Examples\n bf(\"Jupiter\", \"Neptune\") ==> (\"Saturn\", \"Uranus\")\n bf(\"Earth\", \"Mercury\") ==> (\"Venus\")\n bf(\"Mercury\", \"Uranus\") ==> (\"Venus\", \"Earth\", \"Mars\", \"Jupiter\", \"Saturn\")\n '''\n", "raw_outputs": ""} +{"task_id": "a1208", "question": "\n\ndef monotonic(l: list):\n \"\"\"Return True is list elements are monotonically increasing or decreasing.\n >>> monotonic([1, 2, 4, 20])\n True\n >>> monotonic([1, 20, 4, 10])\n False\n >>> monotonic([4, 1, 0, -10])\n True\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b8654", "question": "Write a python function to count number of vowels in the string.\nassert Check_Vow('corner','AaEeIiOoUu') == 2\nassert Check_Vow('valid','AaEeIiOoUu') == 2\nassert Check_Vow('true','AaEeIiOoUu') ==2\n", "raw_outputs": ""} +{"task_id": "a3440", "question": "from typing import List\n\n\ndef parse_music(music_string: str) -> List[int]:\n \"\"\" Input to this function is a string representing musical notes in a special ASCII format.\n Your task is to parse this string and return list of integers corresponding to how many beats does each\n not last.\n\n Here is a legend:\n 'o' - whole note, lasts four beats\n 'o|' - half note, lasts two beats\n '.|' - quater note, lasts one beat\n\n >>> parse_music('o o| .| o| o| .| .| .| .| o o')\n [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b3440", "question": "Write a function to find the perimeter of a square.\nassert square_perimeter(10)==40\nassert square_perimeter(5)==20\nassert square_perimeter(4)==16\n", "raw_outputs": ""} +{"task_id": "b6264", "question": "Write a function to locate the right insertion point for a specified value in sorted order.\nassert right_insertion([1,2,4,5],6)==4\nassert right_insertion([1,2,4,5],3)==2\nassert right_insertion([1,2,4,5],7)==4\n", "raw_outputs": ""} +{"task_id": "b4624", "question": "Write a function that takes a string and returns True if the string length is a prime number or False otherwise.\nassert prime_length('Hello') == True\nassert prime_length('abcdcba') == True\nassert prime_length('kittens') == True\nassert prime_length('orange') == False\nassert prime_length('wow') == True\nassert prime_length('world') == True\nassert prime_length('MadaM') == True\nassert prime_length('Wow') == True\nassert prime_length('') == False\nassert prime_length('HI') == True\nassert prime_length('go') == True\nassert prime_length('gogo') == False\nassert prime_length('aaaaaaaaaaaaaaa') == False\nassert prime_length('Madam') == True\nassert prime_length('M') == False\nassert prime_length('0') == False\n", "raw_outputs": ""} +{"task_id": "a0921", "question": "\ndef total_match(lst1, lst2):\n '''\n Write a function that accepts two lists of strings and returns the list that has \n total number of chars in the all strings of the list less than the other list.\n\n if the two lists have the same number of chars, return the first list.\n\n Examples\n total_match([], []) ➞ []\n total_match(['hi', 'admin'], ['hI', 'Hi']) ➞ ['hI', 'Hi']\n total_match(['hi', 'admin'], ['hi', 'hi', 'admin', 'project']) ➞ ['hi', 'admin']\n total_match(['hi', 'admin'], ['hI', 'hi', 'hi']) ➞ ['hI', 'hi', 'hi']\n total_match(['4'], ['1', '2', '3', '4', '5']) ➞ ['4']\n '''\n", "raw_outputs": ""} +{"task_id": "a0109", "question": "from typing import List\n\n\ndef number_of_subarrays(nums: List[int]) -> int:\n \"\"\"\n You are given an array of positive integers nums.\n Return the number of subarrays of nums, where the first and the last elements of the subarray are equal to the largest element in the subarray.\n \n Parameters:\n nums (List[int]): The input array of positive integers.\n \n Returns:\n int: The number of subarrays fulfilling the condition.\n \n Examples:\n >>> number_of_subarrays([1, 4, 3, 3, 2])\n 6\n >>> number_of_subarrays([3, 3, 3])\n 6\n >>> number_of_subarrays([1])\n 1\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a0514", "question": "\n\ndef string_sequence(n: int) -> str:\n \"\"\" Return a string containing space-delimited numbers starting from 0 upto n inclusive.\n >>> string_sequence(0)\n '0'\n >>> string_sequence(5)\n '0 1 2 3 4 5'\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b1600", "question": "Write a function to find the number of ways to fill it with 2 x 1 dominoes for the given 3 x n board.\nassert count_ways(2) == 3\nassert count_ways(8) == 153\nassert count_ways(12) == 2131\n", "raw_outputs": ""} +{"task_id": "a8194", "question": "\ndef rounded_avg(n, m):\n \"\"\"You are given two positive integers n and m, and your task is to compute the\n average of the integers from n through m (including n and m). \n Round the answer to the nearest integer and convert that to binary.\n If n is greater than m, return -1.\n Example:\n rounded_avg(1, 5) => \"0b11\"\n rounded_avg(7, 5) => -1\n rounded_avg(10, 20) => \"0b1111\"\n rounded_avg(20, 33) => \"0b11010\"\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b4189", "question": "Write a function to find the focus of a parabola.\nassert parabola_focus(5,3,2)==(-0.3, 1.6)\nassert parabola_focus(9,8,4)==(-0.4444444444444444, 2.25)\nassert parabola_focus(2,4,6)==(-1.0, 4.125)\n", "raw_outputs": ""} +{"task_id": "b9264", "question": "Write a function that given a list of integers, returns the list in a strange order. Strange sorting is when you start with the minimum value, then maximum of the remaining integers, then minimum and so on.\nassert strange_sort_list([1, 2, 3, 4]) == [1, 4, 2, 3]\nassert strange_sort_list([5, 6, 7, 8, 9]) == [5, 9, 6, 8, 7]\nassert strange_sort_list([1, 2, 3, 4, 5]) == [1, 5, 2, 4, 3]\nassert strange_sort_list([5, 6, 7, 8, 9, 1]) == [1, 9, 5, 8, 6, 7]\nassert strange_sort_list([5, 5, 5, 5]) == [5, 5, 5, 5]\nassert strange_sort_list([]) == []\nassert strange_sort_list([1,2,3,4,5,6,7,8]) == [1, 8, 2, 7, 3, 6, 4, 5]\nassert strange_sort_list([0,2,2,2,5,5,-5,-5]) == [-5, 5, -5, 5, 0, 2, 2, 2]\nassert strange_sort_list([111111]) == [111111]\n", "raw_outputs": ""} +{"task_id": "a2202", "question": "from typing import List\nfrom collections import Counter\n\ndef maximum_length(nums: List[int]) -> int:\n \"\"\"\n You are given an array of positive integers nums.\n\n You need to select a subset of nums which satisfies the following condition:\n\n You can place the selected elements in a 0-indexed array such that it follows the pattern: [x, x2, x4, ..., xk/2, xk, xk/2, ..., x4, x2, x] (Note that k can be be any non-negative power of 2). For example, [2, 4, 16, 4, 2] and [3, 9, 3] follow the pattern while [2, 4, 8, 4, 2] does not.\n\n Return the maximum number of elements in a subset that satisfies these conditions.\n\n Examples:\n >>> nums = [5,4,1,2,2]\n 3\n >>> nums = [1,3,2,4]\n 1\n\n Constraints:\n 2 <= nums.length <= 10^5\n 1 <= nums[i] <= 10^9\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a5182", "question": "def calculate_score(s: str) -> int:\n \"\"\"\n You are given a string s. The score of a string is defined as the sum of the absolute difference between the ASCII values of adjacent characters.\n\n Return the score of s.\n\n Examples:\n >>> s = \"hello\"\n 13\n >>> s = \"zaz\"\n 50\n\n Constraints:\n 2 <= s.length <= 100\n s consists only of lowercase English letters.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a7388", "question": "from typing import List\n\ndef minimum_average(nums: List[int]) -> float:\n \"\"\"\n You have an array of floating point numbers averages which is initially empty. You are given an array nums of n integers where n is even.\n\n You repeat the following procedure n / 2 times:\n\n Remove the smallest element, minElement, and the largest element maxElement, from nums.\n Add (minElement + maxElement) / 2 to averages.\n Return the minimum element in averages.\n\n Examples:\n >>> nums = [7,8,3,4,15,13,4,1]\n 5.5\n >>> nums = [1,9,8,3,10,5]\n 5.5\n\n Constraints:\n 2 <= n == nums.length <= 50\n n is even.\n 1 <= nums[i] <= 50\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b3038", "question": "Write a function that takes a list of integers as input and checks if there are three distinct elements in the list that sum to zero.\nassert triples_sum_to_zero([1, 3, 5, 0]) == False\nassert triples_sum_to_zero([1, 3, 5, -1]) == False\nassert triples_sum_to_zero([1, 3, -2, 1]) == True\nassert triples_sum_to_zero([1, 2, 3, 7]) == False\nassert triples_sum_to_zero([1, 2, 5, 7]) == False\nassert triples_sum_to_zero([2, 4, -5, 3, 9, 7]) == True\nassert triples_sum_to_zero([1]) == False\nassert triples_sum_to_zero([1, 3, 5, -100]) == False\nassert triples_sum_to_zero([100, 3, 5, -100]) == False\n", "raw_outputs": ""} +{"task_id": "a9473", "question": "from typing import List\n\ndef max_total_reward(rewardValues: List[int]) -> int:\n \"\"\"\n You are given an integer array rewardValues of length n, representing the values of rewards.\n\n Initially, your total reward x is 0, and all indices are unmarked. You are allowed to perform the following operation any number of times:\n\n Choose an unmarked index i from the range [0, n - 1].\n If rewardValues[i] is greater than your current total reward x, then add rewardValues[i] to x (i.e., x = x + rewardValues[i]), and mark the index i.\n\n Return an integer denoting the maximum total reward you can collect by performing the operations optimally.\n\n Examples:\n >>> rewardValues = [1,1,3,3]\n 4\n >>> rewardValues = [1,6,4,3,2]\n 11\n\n Constraints:\n 1 <= rewardValues.length <= 2000\n 1 <= rewardValues[i] <= 2000\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a4424", "question": "\ndef tri(n):\n \"\"\"Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in \n the last couple centuries. However, what people don't know is Tribonacci sequence.\n Tribonacci sequence is defined by the recurrence:\n tri(1) = 3\n tri(n) = 1 + n / 2, if n is even.\n tri(n) = tri(n - 1) + tri(n - 2) + tri(n + 1), if n is odd.\n For example:\n tri(2) = 1 + (2 / 2) = 2\n tri(4) = 3\n tri(3) = tri(2) + tri(1) + tri(4)\n = 2 + 3 + 3 = 8 \n You are given a non-negative integer number n, you have to a return a list of the \n first n + 1 numbers of the Tribonacci sequence.\n Examples:\n tri(3) = [1, 3, 2, 8]\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b1203", "question": "Write a function to find the median of three specific numbers.\nassert median_numbers(25,55,65)==55.0\nassert median_numbers(20,10,30)==20.0\nassert median_numbers(15,45,75)==45.0\n", "raw_outputs": ""} +{"task_id": "a2203", "question": "\ndef select_words(s, n):\n \"\"\"Given a string s and a natural number n, you have been tasked to implement \n a function that returns a list of all words from string s that contain exactly \n n consonants, in order these words appear in the string s.\n If the string s is empty then the function should return an empty list.\n Note: you may assume the input string contains only letters and spaces.\n Examples:\n select_words(\"Mary had a little lamb\", 4) ==> [\"little\"]\n select_words(\"Mary had a little lamb\", 3) ==> [\"Mary\", \"lamb\"]\n select_words(\"simple white space\", 2) ==> []\n select_words(\"Hello world\", 4) ==> [\"world\"]\n select_words(\"Uncle sam\", 3) ==> [\"Uncle\"]\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b2022", "question": "Write a python function to left rotate the string.\nassert left_rotate(\"python\",2) == \"thonpy\" \nassert left_rotate(\"bigdata\",3 ) == \"databig\" \nassert left_rotate(\"hadoop\",1 ) == \"adooph\" \n", "raw_outputs": ""} +{"task_id": "b0375", "question": "Write a function to check if all the elements in tuple have same data type or not.\nassert check_type((5, 6, 7, 3, 5, 6) ) == True\nassert check_type((1, 2, \"4\") ) == False\nassert check_type((3, 2, 1, 4, 5) ) == True\n", "raw_outputs": ""} +{"task_id": "b5306", "question": "Write a function to get the word with most number of occurrences in the given strings list.\nassert most_occurrences([\"UTS is best for RTF\", \"RTF love UTS\", \"UTS is best\"] ) == 'UTS'\nassert most_occurrences([\"Its been a great year\", \"this year is so worse\", \"this year is okay\"] ) == 'year'\nassert most_occurrences([\"Families can be reunited\", \"people can be reunited\", \"Tasks can be achieved \"] ) == 'can'\n", "raw_outputs": ""} +{"task_id": "a7454", "question": "from typing import List\n\ndef find_maximum_length_of_valid_subsequence(nums: List[int]) -> int:\n \"\"\"\n You are given an integer array nums.\n A subsequence sub of nums with length x is called valid if it satisfies:\n\n (sub[0] + sub[1]) % 2 == (sub[1] + sub[2]) % 2 == ... == (sub[x - 2] + sub[x - 1]) % 2.\n Return the length of the longest valid subsequence of nums.\n\n A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements..\n\n Examples:\n >>> nums = [1,2,3,4]\n 4\n >>> nums = [1,2,1,1,2,1,2]\n 6\n\n Constraints:\n 2 <= nums.length <= 2 * 10^5\n 1 <= nums[i] <= 10^7\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b9039", "question": "Write a function that takes a string of space-separated lowercase letters and returns a dictionary with the most frequently occurring letters and their counts. If multiple letters occur equally often, include all of them.\nassert histogram('a b b a') == {'a':2,'b': 2}\nassert histogram('a b c a b') == {'a': 2, 'b': 2}\nassert histogram('a b c d g') == {'a': 1, 'b': 1, 'c': 1, 'd': 1, 'g': 1}\nassert histogram('r t g') == {'r': 1,'t': 1,'g': 1}\nassert histogram('b b b b a') == {'b': 4}\nassert histogram('r t g') == {'r': 1,'t': 1,'g': 1}\nassert histogram('') == {}\nassert histogram('a') == {'a': 1}\n", "raw_outputs": ""} +{"task_id": "a8986", "question": "from typing import List\n\ndef max_sum_no_adjacent_subsequence(nums: List[int], queries: List[List[int]]) -> int:\n \"\"\"\n You are given an array nums consisting of integers. You are also given a 2D array queries, where queries[i] = [pos_i, x_i].\n\n For query i, we first set nums[pos_i] equal to x_i, then we calculate the answer to query i which is the maximum sum of a\n subsequence\n of nums where no two adjacent elements are selected.\n\n Return the sum of the answers to all queries.\n\n Since the final answer may be very large, return it modulo 10^9 + 7.\n\n A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.\n\n Examples:\n >>> nums = [3,5,9], queries = [[1,-2],[0,-3]]\n 21\n >>> nums = [0,-1], queries = [[0,-5]]\n 0\n\n Constraints:\n 1 <= nums.length <= 5 * 10^4\n -10^5 <= nums[i] <= 10^5\n 1 <= queries.length <= 5 * 10^4\n queries[i] == [pos_i, x_i]\n 0 <= pos_i <= nums.length - 1\n -10^5 <= x_i <= 10^5\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a4093", "question": "from typing import List\n\ndef min_cost_of_travel(n: int, edges: List[List[int]], query: List[List[int]]) -> List[int]:\n \"\"\"\n There is an undirected weighted graph with n vertices labeled from 0 to n - 1.\n\n You are given the integer n and an array edges, where edges[i] = [u_i, v_i, w_i] indicates that there is an edge between vertices u_i and v_i with a weight of w_i.\n\n A walk on a graph is a sequence of vertices and edges. The walk starts and ends with a vertex, and each edge connects the vertex that comes before it and the vertex that comes after it. It's important to note that a walk may visit the same edge or vertex more than once.\n\n The cost of a walk starting at node u and ending at node v is defined as the bitwise AND of the weights of the edges traversed during the walk. In other words, if the sequence of edge weights encountered during the walk is w_0, w_1, w_2, ..., w_k, then the cost is calculated as w_0 & w_1 & w_2 & ... & w_k, where & denotes the bitwise AND operator.\n\n You are also given a 2D array query, where query[i] = [s_i, t_i]. For each query, you need to find the minimum cost of the walk starting at vertex s_i and ending at vertex t_i. If there exists no such walk, the answer is -1.\n\n Return the array answer, where answer[i] denotes the minimum cost of a walk for query i.\n\n Examples:\n >>> n = 5, edges = [[0,1,7],[1,3,7],[1,2,1]], query = [[0,3],[3,4]]\n [1,-1]\n >>> n = 3, edges = [[0,2,7],[0,1,15],[1,2,6],[1,2,1]], query = [[1,2]]\n [0]\n\n Constraints:\n 2 <= n <= 10^5\n 0 <= edges.length <= 10^5\n edges[i].length == 3\n 0 <= u_i, v_i <= n - 1\n u_i != v_i\n 0 <= w_i <= 10^5\n 1 <= query.length <= 10^5\n query[i].length == 2\n 0 <= s_i, t_i <= n - 1\n s_i != t_i\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a9367", "question": "\ndef double_the_difference(lst):\n '''\n Given a list of numbers, return the sum of squares of the numbers\n in the list that are odd. Ignore numbers that are negative or not integers.\n \n double_the_difference([1, 3, 2, 0]) == 1 + 9 + 0 + 0 = 10\n double_the_difference([-1, -2, 0]) == 0\n double_the_difference([9, -2]) == 81\n double_the_difference([0]) == 0 \n \n If the input list is empty, return 0.\n '''\n", "raw_outputs": ""} +{"task_id": "a8675", "question": "from typing import List\n\ndef min_operations_to_make_median_k(nums: List[int], k: int) -> int:\n \"\"\"\n You are given an integer array nums and a non-negative integer k. In one operation, you can increase or decrease any element by 1.\n\n Return the minimum number of operations needed to make the median of nums equal to k.\n\n The median of an array is defined as the middle element of the array when it is sorted in non-decreasing order. If there are two choices for a median, the larger of the two values is taken.\n\n Examples:\n >>> nums = [2,5,6,8,5], k = 4\n 2\n >>> nums = [2,5,6,8,5], k = 7\n 3\n >>> nums = [1,2,3,4,5,6], k = 4\n 0\n\n Constraints:\n 1 <= nums.length <= 2 * 10^5\n 1 <= nums[i] <= 10^9\n 1 <= k <= 10^9\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a5656", "question": "from typing import List\n\ndef number_of_right_triangles(grid: List[List[int]]) -> int:\n \"\"\"\n You are given a 2D boolean matrix grid.\n\n Return an integer that is the number of right triangles that can be made with the 3 elements of grid such that all of them have a value of 1.\n\n Note:\n\n A collection of 3 elements of grid is a right triangle if one of its elements is in the same row with another element and in the same column with the third element. The 3 elements do not have to be next to each other.\n\n Examples:\n >>> grid = [[0,1,0],[0,1,1],[0,1,0]]\n 2\n >>> grid = [[1,0,0,0],[0,1,0,1],[1,0,0,0]]\n 0\n >>> grid = [[1,0,1],[1,0,0],[1,0,0]]\n 2\n\n Constraints:\n 1 <= grid.length <= 1000\n 1 <= grid[i].length <= 1000\n 0 <= grid[i][j] <= 1\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b3419", "question": "Write a python function to find the sublist having maximum length.\nassert Find_Max([['A'],['A','B'],['A','B','C']]) == ['A','B','C']\nassert Find_Max([[1],[1,2],[1,2,3]]) == [1,2,3]\nassert Find_Max([[1,1],[1,2,3],[1,5,6,1]]) == [1,5,6,1]\n", "raw_outputs": ""} +{"task_id": "b5700", "question": "Write a python function to count minimum number of swaps required to convert one binary string to another.\nassert min_Swaps(\"1101\",\"1110\") == 1\nassert min_Swaps(\"111\",\"000\") == \"Not Possible\"\nassert min_Swaps(\"111\",\"110\") == \"Not Possible\"\n", "raw_outputs": ""} +{"task_id": "b8675", "question": "Write a python function to count the total unset bits from 1 to n.\nassert count_Unset_Bits(2) == 1\nassert count_Unset_Bits(5) == 4\nassert count_Unset_Bits(14) == 17\n", "raw_outputs": ""} +{"task_id": "a9637", "question": "\ndef hex_key(num):\n \"\"\"You have been tasked to write a function that receives \n a hexadecimal number as a string and counts the number of hexadecimal \n digits that are primes (prime number, or a prime, is a natural number \n greater than 1 that is not a product of two smaller natural numbers).\n Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.\n Prime numbers are 2, 3, 5, 7, 11, 13, 17,...\n So you have to determine a number of the following digits: 2, 3, 5, 7, \n B (=decimal 11), D (=decimal 13).\n Note: you may assume the input is always correct or empty string, \n and symbols A,B,C,D,E,F are always uppercase.\n Examples:\n For num = \"AB\" the output should be 1.\n For num = \"1077E\" the output should be 2.\n For num = \"ABED1A33\" the output should be 4.\n For num = \"123456789ABCDEF0\" the output should be 6.\n For num = \"2020\" the output should be 2.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b1973", "question": "Write a function to find the second smallest number in a list.\nassert second_smallest([1, 2, -8, -2, 0, -2])==-2\nassert second_smallest([1, 1, -0.5, 0, 2, -2, -2])==-0.5\nassert second_smallest([2,2])==None\n", "raw_outputs": ""} +{"task_id": "b2738", "question": "Write a function to calculate the harmonic sum of n-1.\nassert harmonic_sum(7) == 2.5928571428571425\nassert harmonic_sum(4) == 2.083333333333333\nassert harmonic_sum(19) == 3.547739657143682\n", "raw_outputs": ""} +{"task_id": "a1263", "question": "from typing import List\n\ndef remove_stars(s: str) -> str:\n \"\"\"\n You are given a string s. It may contain any number of '*' characters. Your task is to remove all '*' characters.\n\n While there is a '*', do the following operation:\n\n Delete the leftmost '*' and the smallest non-'*' character to its left. If there are several smallest characters, you can delete any of them.\n Return the lexicographically smallest resulting string after removing all '*' characters.\n\n Examples:\n >>> s = \"aaba*\"\n aab\n >>> s = \"abc\"\n abc\n\n Constraints:\n 1 <= s.length <= 10^5\n s consists only of lowercase English letters and '*'.\n The input is generated such that it is possible to delete all '*' characters.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b2675", "question": "Write a python function to find the sum of non-repeated elements in a given array.\nassert find_Sum([1,2,3,1,1,4,5,6],8) == 21\nassert find_Sum([1,10,9,4,2,10,10,45,4],9) == 71\nassert find_Sum([12,10,9,45,2,10,10,45,10],9) == 78\n", "raw_outputs": ""} +{"task_id": "a6360", "question": "\ndef count_upper(s):\n \"\"\"\n Given a string s, count the number of uppercase vowels in even indices.\n \n For example:\n count_upper('aBCdEf') returns 1\n count_upper('abcdefg') returns 0\n count_upper('dBBE') returns 0\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a6525", "question": "\ndef eat(number, need, remaining):\n \"\"\"\n You're a hungry rabbit, and you already have eaten a certain number of carrots,\n but now you need to eat more carrots to complete the day's meals.\n you should return an array of [ total number of eaten carrots after your meals,\n the number of carrots left after your meals ]\n if there are not enough remaining carrots, you will eat all remaining carrots, but will still be hungry.\n \n Example:\n * eat(5, 6, 10) -> [11, 4]\n * eat(4, 8, 9) -> [12, 1]\n * eat(1, 10, 10) -> [11, 0]\n * eat(2, 11, 5) -> [7, 0]\n \n Variables:\n @number : integer\n the number of carrots that you have eaten.\n @need : integer\n the number of carrots that you need to eat.\n @remaining : integer\n the number of remaining carrots thet exist in stock\n \n Constrain:\n * 0 <= number <= 1000\n * 0 <= need <= 1000\n * 0 <= remaining <= 1000\n\n Have fun :)\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a2283", "question": "from typing import List\nfrom math import comb\n\ndef count_substrings(s: str, c: str) -> int:\n \"\"\"\n You are given a string s and a character c. Return the total number of \n substrings of s that start and end with c.\n\n Examples:\n >>> s = \"abada\", c = \"a\"\n 6\n >>> s = \"zzz\", c = \"z\"\n 6\n\n Constraints:\n 1 <= s.length <= 10^5\n s and c consist only of lowercase English letters.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a8330", "question": "from typing import List\n\n\ndef mean_absolute_deviation(numbers: List[float]) -> float:\n \"\"\" For a given list of input numbers, calculate Mean Absolute Deviation\n around the mean of this dataset.\n Mean Absolute Deviation is the average absolute difference between each\n element and a centerpoint (mean in this case):\n MAD = average | x - x_mean |\n >>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0])\n 1.0\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a3628", "question": "from typing import List\n\ndef largest_square_area(bottomLeft: List[List[int]], topRight: List[List[int]]) -> int:\n \"\"\"\n There exist n rectangles in a 2D plane. You are given two 0-indexed 2D integer arrays bottomLeft and topRight, both of size n x 2, where bottomLeft[i] and topRight[i] represent the bottom-left and top-right coordinates of the i th rectangle respectively.\n\n You can select a region formed from the intersection of two of the given rectangles. You need to find the largest area of a square that can fit inside this region if you select the region optimally.\n\n Return the largest possible area of a square, or 0 if there do not exist any intersecting regions between the rectangles.\n\n Examples:\n >>> bottomLeft = [[1,1],[2,2],[3,1]], topRight = [[3,3],[4,4],[6,6]]\n 1\n >>> bottomLeft = [[1,1],[2,2],[1,2]], topRight = [[3,3],[4,4],[3,4]]\n 1\n >>> bottomLeft = [[1,1],[3,3],[3,1]], topRight = [[2,2],[4,4],[4,2]]\n 0\n\n Constraints:\n n == bottomLeft.length == topRight.length\n 2 <= n <= 10^3\n bottomLeft[i].length == topRight[i].length == 2\n 1 <= bottomLeft[i][0], bottomLeft[i][1] <= 10^7\n 1 <= topRight[i][0], topRight[i][1] <= 10^7\n bottomLeft[i][0] < topRight[i][0]\n bottomLeft[i][1] < topRight[i][1]\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a6886", "question": "def max_height_of_triangle(red: int, blue: int) -> int:\n \"\"\"\n You are given two integers red and blue representing the count of red and blue colored balls. You have to arrange these balls to form a triangle such that the 1st row will have 1 ball, the 2nd row will have 2 balls, the 3rd row will have 3 balls, and so on.\n\n All the balls in a particular row should be the same color, and adjacent rows should have different colors.\n\n Return the maximum height of the triangle that can be achieved.\n\n Examples:\n >>> red = 2, blue = 4\n 3\n >>> red = 2, blue = 1\n 2\n\n Constraints:\n 1 <= red, blue <= 100\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b5737", "question": "Write a function to check for the number of jumps required of given length to reach a point of form (d, 0) from origin in a 2d plane.\nassert min_Jumps(3,4,11)==3.5\nassert min_Jumps(3,4,0)==0\nassert min_Jumps(11,14,11)==1\n", "raw_outputs": ""} +{"task_id": "b4098", "question": "Write a python function to check whether the given strings are rotations of each other or not.\nassert are_Rotations(\"abc\",\"cba\") == False\nassert are_Rotations(\"abcd\",\"cdba\") == False\nassert are_Rotations(\"abacd\",\"cdaba\") == True\n", "raw_outputs": ""} +{"task_id": "a4624", "question": "from typing import List\n\ndef min_operations_to_all_ones(nums: List[int]) -> int:\n \"\"\"\n You are given a binary array nums.\n\n You can do the following operation on the array any number of times (possibly zero):\n\n Choose any 3 consecutive elements from the array and flip all of them.\n Flipping an element means changing its value from 0 to 1, and from 1 to 0.\n\n Return the minimum number of operations required to make all elements in nums equal to 1. If it is impossible, return -1.\n\n Examples:\n >>> nums = [0,1,1,1,0,0]\n 3\n >>> nums = [0,1,1,1]\n -1\n\n Constraints:\n 3 <= nums.length <= 10^5\n 0 <= nums[i] <= 1\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a0702", "question": "\ndef get_odd_collatz(n):\n \"\"\"\n Given a positive integer n, return a sorted list that has the odd numbers in collatz sequence.\n\n The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined\n as follows: start with any positive integer n. Then each term is obtained from the \n previous term as follows: if the previous term is even, the next term is one half of \n the previous term. If the previous term is odd, the next term is 3 times the previous\n term plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1.\n\n Note: \n 1. Collatz(1) is [1].\n 2. returned list sorted in increasing order.\n\n For example:\n get_odd_collatz(5) returns [1, 5] # The collatz sequence for 5 is [5, 16, 8, 4, 2, 1], so the odd numbers are only 1, and 5.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a7435", "question": "def swap_to_get_smallest_string(s: str) -> str:\n \"\"\"\n Given a string s containing only digits, return the \n lexicographically smallest string\n that can be obtained after swapping adjacent digits in s with the same parity at most once.\n\n Digits have the same parity if both are odd or both are even. For example, 5 and 9, as well as 2 and 4, have the same parity, while 6 and 9 do not.\n\n Examples:\n >>> s = \"45320\"\n \"43520\"\n >>> s = \"001\"\n \"001\"\n\n Constraints:\n 2 <= s.length <= 100\n s consists only of digits.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a8117", "question": "from typing import List\nfrom collections import Counter\nfrom functools import cache\ndef max_total_damage(power: List[int]) -> int:\n \"\"\"\n A magician has various spells.\n\n You are given an array power, where each element represents the damage of a spell. Multiple spells can have the same damage value.\n\n It is a known fact that if a magician decides to cast a spell with a damage of power[i], they cannot cast any spell with a damage of power[i] - 2, power[i] - 1, power[i] + 1, or power[i] + 2.\n\n Each spell can be cast only once.\n\n Return the maximum possible total damage that a magician can cast.\n\n Examples:\n >>> power = [1,1,3,4]\n 6\n >>> power = [7,1,6,6]\n 13\n\n Constraints:\n 1 <= power.length <= 10^5\n 1 <= power[i] <= 10^9\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b8211", "question": "Write a python function to remove odd numbers from a given list.\nassert remove_odd([1,2,3]) == [2]\nassert remove_odd([2,4,6]) == [2,4,6]\nassert remove_odd([10,20,3]) == [10,20]\n", "raw_outputs": ""} +{"task_id": "a2675", "question": "\n\ndef incr_list(l: list):\n \"\"\"Return list with elements incremented by 1.\n >>> incr_list([1, 2, 3])\n [2, 3, 4]\n >>> incr_list([5, 3, 5, 2, 3, 3, 9, 0, 123])\n [6, 4, 6, 3, 4, 4, 10, 1, 124]\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a0560", "question": "from typing import List\n\ndef modified_matrix(matrix: List[List[int]]) -> List[List[int]]:\n \"\"\"\n Given a 0-indexed m x n integer matrix matrix, create a new 0-indexed matrix called answer. Make answer equal to matrix, then replace each element with the value -1 with the maximum element in its respective column.\n\n Return the matrix answer.\n\n Examples:\n >>> matrix = [[1,2,-1],[4,-1,6],[7,8,9]]\n [[1,2,9],[4,8,6],[7,8,9]]\n >>> matrix = [[3,-1],[5,2]]\n [[3,2],[5,2]]\n\n Constraints:\n m == matrix.length\n n == matrix[i].length\n 2 <= m, n <= 50\n -1 <= matrix[i][j] <= 100\n The input is generated such that each column contains at least one non-negative integer.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b7591", "question": "Write a python function to convert octal number to decimal number.\nassert octal_To_Decimal(25) == 21\nassert octal_To_Decimal(30) == 24\nassert octal_To_Decimal(40) == 32\n", "raw_outputs": ""} +{"task_id": "a9660", "question": "\ndef maximum(arr, k):\n \"\"\"\n Given an array arr of integers and a positive integer k, return a sorted list \n of length k with the maximum k numbers in arr.\n\n Example 1:\n\n Input: arr = [-3, -4, 5], k = 3\n Output: [-4, -3, 5]\n\n Example 2:\n\n Input: arr = [4, -4, 4], k = 2\n Output: [4, 4]\n\n Example 3:\n\n Input: arr = [-3, 2, 1, 2, -1, -2, 1], k = 1\n Output: [2]\n\n Note:\n 1. The length of the array will be in the range of [1, 1000].\n 2. The elements in the array will be in the range of [-1000, 1000].\n 3. 0 <= k <= len(arr)\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b5656", "question": "Write a function to count the number of boredoms in a string of words. A boredom is defined as a sentence that starts with the word 'I'. Sentences in the string are separated by '.', '?' or '!'.\nassert is_bored(\"Hello world\") == 0\nassert is_bored(\"Is the sky blue?\") == 0\nassert is_bored(\"I love It !\") == 1\nassert is_bored(\"bIt\") == 0\nassert is_bored(\"I feel good today. I will be productive. will kill It\") == 2\nassert is_bored(\"You and I are going for a walk\") == 0\n", "raw_outputs": ""} +{"task_id": "a8744", "question": "from typing import List\nfrom collections import Counter\n\ndef max_frequency_elements(nums: List[int]) -> int:\n \"\"\"\n You are given an array nums consisting of positive integers.\n\n Return the total frequencies of elements in nums such that those elements all have the maximum frequency.\n\n The frequency of an element is the number of occurrences of that element in the array.\n\n Examples:\n >>> nums = [1,2,2,3,1,4]\n 4\n >>> nums = [1,2,3,4,5]\n 5\n\n Constraints:\n 1 <= nums.length <= 100\n 1 <= nums[i] <= 100\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a4446", "question": "def encrypt_string(s: str, k: int) -> str:\n \"\"\"\n You are given a string s and an integer k. Encrypt the string using the following algorithm:\n\n For each character c in s, replace c with the kth character after c in the string (in a cyclic manner).\n Return the encrypted string.\n\n Examples:\n >>> s = \"dart\", k = 3\n \"tdar\"\n >>> s = \"aaa\", k = 1\n \"aaa\"\n\n Constraints:\n 1 <= s.length <= 100\n 1 <= k <= 10^4\n s consists only of lowercase English letters.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a1075", "question": "\ndef largest_smallest_integers(lst):\n '''\n Create a function that returns a tuple (a, b), where 'a' is\n the largest of negative integers, and 'b' is the smallest\n of positive integers in a list.\n If there is no negative or positive integers, return them as None.\n\n Examples:\n largest_smallest_integers([2, 4, 1, 3, 5, 7]) == (None, 1)\n largest_smallest_integers([]) == (None, None)\n largest_smallest_integers([0]) == (None, None)\n '''\n", "raw_outputs": ""} +{"task_id": "b2456", "question": "Write a function to find whether an array is subset of another array.\nassert is_subset([11, 1, 13, 21, 3, 7], 6, [11, 3, 7, 1], 4) == True\nassert is_subset([1, 2, 3, 4, 5, 6], 6, [1, 2, 4], 3) == True\nassert is_subset([10, 5, 2, 23, 19], 5, [19, 5, 3], 3) == False\n", "raw_outputs": ""} +{"task_id": "b2289", "question": "Write a python function to find maximum possible value for the given periodic function.Given three numbers A, B, and N, the task is to find the maximum possible value of floor(A * x / B) – A * floor(x / b) where x is a non-negative integer less than or equal to N. Here floor(T) = denotes the greatest integer not greater than the real number T.\nassert floor_Max(11,10,9) == 9\nassert floor_Max(5,7,4) == 2\nassert floor_Max(2,2,1) == 1\n", "raw_outputs": ""} +{"task_id": "b2170", "question": "Write a function that takes a non-empty list of integers and returns the sum of even elements located at odd indices.\nassert add([4, 88]) == 88\nassert add([4, 5, 6, 7, 2, 122]) == 122\nassert add([4, 0, 6, 7]) == 0\nassert add([4, 4, 6, 8]) == 12\n", "raw_outputs": ""} +{"task_id": "b0883", "question": "Write a python function to count unset bits of a given number.\nassert count_unset_bits(2) == 1\nassert count_unset_bits(4) == 2\nassert count_unset_bits(6) == 1\n", "raw_outputs": ""} +{"task_id": "a4616", "question": "\n\ndef correct_bracketing(brackets: str):\n \"\"\" brackets is a string of \"<\" and \">\".\n return True if every opening bracket has a corresponding closing bracket.\n\n >>> correct_bracketing(\"<\")\n False\n >>> correct_bracketing(\"<>\")\n True\n >>> correct_bracketing(\"<<><>>\")\n True\n >>> correct_bracketing(\"><<>\")\n False\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b4316", "question": "Write a function to find the nth jacobsthal-lucas number.\nassert jacobsthal_lucas(5) == 31\nassert jacobsthal_lucas(2) == 5\nassert jacobsthal_lucas(4) == 17\n", "raw_outputs": ""} +{"task_id": "a1041", "question": "from typing import List\n\n\ndef separate_paren_groups(paren_string: str) -> List[str]:\n \"\"\" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to\n separate those group into separate strings and return the list of those.\n Separate groups are balanced (each open brace is properly closed) and not nested within each other\n Ignore any spaces in the input string.\n >>> separate_paren_groups('( ) (( )) (( )( ))')\n ['()', '(())', '(()())']\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a4779", "question": "from typing import List\n\ndef satisfies_conditions(grid: List[List[int]]) -> bool:\n \"\"\"\n You are given a 2D matrix grid of size m x n. You need to check if each cell grid[i][j] is:\n\n Equal to the cell below it, i.e. grid[i][j] == grid[i + 1][j] (if it exists).\n Different from the cell to its right, i.e. grid[i][j] != grid[i][j + 1] (if it exists).\n Return true if all the cells satisfy these conditions, otherwise, return false.\n\n Examples:\n >>> grid = [[1,0,2],[1,0,2]]\n true\n >>> grid = [[1,1,1],[0,0,0]]\n false\n >>> grid = [[1],[2],[3]]\n false\n\n Constraints:\n 1 <= n, m <= 10\n 0 <= grid[i][j] <= 9\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b9090", "question": "Write a function to split a given string of words separated by commas or spaces into a list of words.\nassert words_string(\"Hi, my name is John\") == [\"Hi\", \"my\", \"name\", \"is\", \"John\"]\nassert words_string(\"One, two, three, four, five, six\") == [\"One\", \"two\", \"three\", \"four\", \"five\", \"six\"]\nassert words_string(\"Hi, my name\") == [\"Hi\", \"my\", \"name\"]\nassert words_string(\"One,, two, three, four, five, six,\") == [\"One\", \"two\", \"three\", \"four\", \"five\", \"six\"]\nassert words_string(\"\") == []\nassert words_string(\"ahmed , gamal\") == [\"ahmed\", \"gamal\"]\n", "raw_outputs": ""} +{"task_id": "a9042", "question": "\n\ndef add(x: int, y: int):\n \"\"\"Add two numbers x and y\n >>> add(2, 3)\n 5\n >>> add(5, 7)\n 12\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b1167", "question": "Write a function that, given a list of strings, returns the longest one. If there are multiple strings of the same length, return the first one. If the input list is empty, return None.\nassert longest([]) == None\nassert longest(['x', 'y', 'z']) == 'x'\nassert longest(['x', 'yyy', 'zzzz', 'www', 'kkkk', 'abc']) == 'zzzz'\n", "raw_outputs": ""} +{"task_id": "a1247", "question": "from typing import List\n\n\ndef string_xor(a: str, b: str) -> str:\n \"\"\" Input are two strings a and b consisting only of 1s and 0s.\n Perform binary XOR on these inputs and return result also as a string.\n >>> string_xor('010', '110')\n '100'\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a6212", "question": "from typing import List\n\ndef max_good_subsequence_length(nums: List[int], k: int) -> int:\n \"\"\"\n You are given an integer array nums and a non-negative integer k. A sequence of integers seq is called good if there are at most k indices i in the range [0, seq.length - 2] such that seq[i] != seq[i + 1].\n\n Return the maximum possible length of a good subsequence of nums.\n\n Examples:\n >>> nums = [1,2,1,1,3], k = 2\n 4\n >>> nums = [1,2,3,4,5,1], k = 0\n 2\n\n Constraints:\n 1 <= nums.length <= 500\n 1 <= nums[i] <= 10^9\n 0 <= k <= min(nums.length, 25)\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a3330", "question": "from typing import List\nfrom math import isqrt\n\ndef max_prime_index_diff(nums: List[int]) -> int:\n \"\"\"\n You are given an integer array nums.\n\n Return an integer that is the maximum distance between the indices of two (not necessarily different) prime numbers in nums.\n\n Examples:\n >>> nums = [4,2,9,5,3]\n 3\n >>> nums = [4,8,2,8]\n 0\n\n Constraints:\n 1 <= nums.length <= 3 * 10^5\n 1 <= nums[i] <= 100\n The input is generated such that the number of prime numbers in the nums is at least one.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a6149", "question": "from typing import List\nimport math\n\ndef find_region_average_intensity(image: List[List[int]], threshold: int) -> List[List[int]]:\n \"\"\"\n You are given m x n grid image which represents a grayscale image, where image[i][j] represents a pixel with intensity in the range [0..255]. You are also given a non-negative integer threshold.\n\n Two pixels are adjacent if they share an edge.\n\n A region is a 3 x 3 subgrid where the absolute difference in intensity between any two adjacent pixels is less than or equal to threshold.\n\n All pixels in a region belong to that region, note that a pixel can belong to multiple regions.\n\n You need to calculate a m x n grid result, where result[i][j] is the average intensity of the regions to which image[i][j] belongs, rounded down to the nearest integer. If image[i][j] belongs to multiple regions, result[i][j] is the average of the rounded-down average intensities of these regions, rounded down to the nearest integer. If image[i][j] does not belong to any region, result[i][j] is equal to image[i][j].\n\n Return the grid result.\n\n Examples:\n >>> image = [[5,6,7,10],[8,9,10,10],[11,12,13,10]], threshold = 3\n [[9,9,9,9],[9,9,9,9],[9,9,9,9]]\n >>> image = [[10,20,30],[15,25,35],[20,30,40],[25,35,45]], threshold = 12\n [[25,25,25],[27,27,27],[27,27,27],[30,30,30]]\n >>> image = [[5,6,7],[8,9,10],[11,12,13]], threshold = 1\n [[5,6,7],[8,9,10],[11,12,13]]\n\n Constraints:\n 3 <= n, m <= 500\n 0 <= image[i][j] <= 255\n 0 <= threshold <= 255\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b1402", "question": "Write a function to find the similar elements from the given two tuple lists.\nassert similar_elements((3, 4, 5, 6),(5, 7, 4, 10)) == (4, 5)\nassert similar_elements((1, 2, 3, 4),(5, 4, 3, 7)) == (3, 4)\nassert similar_elements((11, 12, 14, 13),(17, 15, 14, 13)) == (13, 14)\n", "raw_outputs": ""} +{"task_id": "a0563", "question": "from typing import List\n\ndef max_elements_in_set_after_removal(nums1: List[int], nums2: List[int]) -> int:\n \"\"\"\n You are given two 0-indexed integer arrays nums1 and nums2 of even length n.\n\n You must remove n / 2 elements from nums1 and n / 2 elements from nums2. After the removals, you insert the remaining elements of nums1 and nums2 into a set s.\n\n Return the maximum possible size of the set s.\n\n Examples:\n >>> nums1 = [1,2,1,2], nums2 = [1,1,1,1]\n 2\n >>> nums1 = [1,2,3,4,5,6], nums2 = [2,3,2,3,2,3]\n 5\n >>> nums1 = [1,1,2,2,3,3], nums2 = [4,4,5,5,6,6]\n 6\n\n Constraints:\n n == nums1.length == nums2.length\n 1 <= n <= 2 * 10^4\n n is even.\n 1 <= nums1[i], nums2[i] <= 10^9\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a2207", "question": "\ndef match_parens(lst):\n '''\n You are given a list of two strings, both strings consist of open\n parentheses '(' or close parentheses ')' only.\n Your job is to check if it is possible to concatenate the two strings in\n some order, that the resulting string will be good.\n A string S is considered to be good if and only if all parentheses in S\n are balanced. For example: the string '(())()' is good, while the string\n '())' is not.\n Return 'Yes' if there's a way to make a good string, and return 'No' otherwise.\n\n Examples:\n match_parens(['()(', ')']) == 'Yes'\n match_parens([')', ')']) == 'No'\n '''\n", "raw_outputs": ""} +{"task_id": "b2893", "question": "Write a python function to find even numbers from a mixed list.\nassert Split([1,2,3,4,5]) == [2,4]\nassert Split([4,5,6,7,8,0,1]) == [4,6,8,0]\nassert Split ([8,12,15,19]) == [8,12]\n", "raw_outputs": ""} +{"task_id": "a9427", "question": "\ndef do_algebra(operator, operand):\n \"\"\"\n Given two lists operator, and operand. The first list has basic algebra operations, and \n the second list is a list of integers. Use the two given lists to build the algebric \n expression and return the evaluation of this expression.\n\n The basic algebra operations:\n Addition ( + ) \n Subtraction ( - ) \n Multiplication ( * ) \n Floor division ( // ) \n Exponentiation ( ** ) \n\n Example:\n operator['+', '*', '-']\n array = [2, 3, 4, 5]\n result = 2 + 3 * 4 - 5\n => result = 9\n\n Note:\n The length of operator list is equal to the length of operand list minus one.\n Operand is a list of of non-negative integers.\n Operator list has at least one operator, and operand list has at least two operands.\n\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a7262", "question": "from typing import List\n\ndef number_of_stable_arrays(zero: int, one: int, limit: int) -> int:\n \"\"\"\n You are given 3 positive integers zero, one, and limit.\n\n A binary array arr is called stable if:\n\n The number of occurrences of 0 in arr is exactly zero.\n The number of occurrences of 1 in arr is exactly one.\n Each subarray of arr with a size greater than limit must contain both 0 and 1.\n Return the total number of stable binary arrays.\n\n Since the answer may be very large, return it modulo 10^9 + 7.\n\n Examples:\n >>> zero = 1, one = 1, limit = 2\n 2\n >>> zero = 1, one = 2, limit = 1\n 1\n >>> zero = 3, one = 3, limit = 2\n 14\n\n Constraints:\n 1 <= zero, one, limit <= 200\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b9473", "question": "Write a function to count array elements having modular inverse under given prime number p equal to itself.\nassert modular_inverse([ 1, 6, 4, 5 ], 4, 7) == 2\nassert modular_inverse([1, 3, 8, 12, 12], 5, 13) == 3\nassert modular_inverse([2, 3, 4, 5], 4, 6) == 1\n", "raw_outputs": ""} +{"task_id": "a9526", "question": "def count_special_chars(word: str) -> int:\n \"\"\"\n You are given a string word. A letter is called special if it appears both in lowercase and uppercase in word.\n\n Return the number of special letters in word.\n\n Examples:\n >>> word = \"aaAbcBC\"\n 3\n >>> word = \"abc\"\n 0\n >>> word = \"abBCab\"\n 1\n\n Constraints:\n 1 <= word.length <= 50\n word consists of only lowercase and uppercase English letters.\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b9498", "question": "Write a function to find the size of the given tuple.\nassert tuple_size((\"A\", 1, \"B\", 2, \"C\", 3) ) == sys.getsizeof((\"A\", 1, \"B\", 2, \"C\", 3))\nassert tuple_size((1, \"Raju\", 2, \"Nikhil\", 3, \"Deepanshu\") ) == sys.getsizeof((1, \"Raju\", 2, \"Nikhil\", 3, \"Deepanshu\"))\nassert tuple_size(((1, \"Lion\"), ( 2, \"Tiger\"), (3, \"Fox\"), (4, \"Wolf\")) ) == sys.getsizeof(((1, \"Lion\"), ( 2, \"Tiger\"), (3, \"Fox\"), (4, \"Wolf\")))\n", "raw_outputs": ""} +{"task_id": "a4433", "question": "from typing import List\n\ndef max_score_in_matrix(grid: List[List[int]]) -> int:\n \"\"\"\n You are given an m x n matrix grid consisting of positive integers. You can move from a cell in the matrix to any other cell that is either to the bottom or to the right (not necessarily adjacent). The score of a move from a cell with the value c1 to a cell with the value c2 is c2 - c1.\n\n You can start at any cell, and you have to make at least one move.\n\n Return the maximum total score you can achieve.\n\n Examples:\n >>> grid = [[9,5,7,3],[8,9,6,1],[6,7,14,3],[2,5,3,1]]\n 9\n >>> grid = [[4,3,2],[3,2,1]]\n -1\n\n Constraints:\n m == grid.length\n n == grid[i].length\n 2 <= m, n <= 1000\n 4 <= m * n <= 10^5\n 1 <= grid[i][j] <= 10^5\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a7146", "question": "\n\ndef fibfib(n: int):\n \"\"\"The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:\n fibfib(0) == 0\n fibfib(1) == 0\n fibfib(2) == 1\n fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).\n Please write a function to efficiently compute the n-th element of the fibfib number sequence.\n >>> fibfib(1)\n 0\n >>> fibfib(5)\n 4\n >>> fibfib(8)\n 24\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "a6264", "question": "\n\ndef get_positive(l: list):\n \"\"\"Return only positive numbers in the list.\n >>> get_positive([-1, 2, -4, 5, 6])\n [2, 5, 6]\n >>> get_positive([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])\n [5, 3, 2, 3, 9, 123, 1]\n \"\"\"\n", "raw_outputs": ""} +{"task_id": "b0921", "question": "Write a python function to find the first missing positive number.\nassert first_Missing_Positive([1,2,3,-1,5],5) == 4\nassert first_Missing_Positive([0,-1,-2,1,5,8],6) == 2\nassert first_Missing_Positive([0,1,2,5,-8],5) == 3\n", "raw_outputs": ""} +{"task_id": "b2996", "question": "Write a python function to find the sum of fourth power of n natural numbers.\nassert fourth_Power_Sum(2) == 17\nassert fourth_Power_Sum(4) == 354\nassert fourth_Power_Sum(6) == 2275\n", "raw_outputs": ""} +{"task_id": "b3988", "question": "Write a function to check whether the given list of numbers are sorted in ascending order or not. If the list contains more than one duplicate of the same number, the function should return False. The function assumes no negative numbers and only integers.\nassert is_sorted([5]) == True\nassert is_sorted([1, 2, 3, 4, 5]) == True\nassert is_sorted([1, 3, 2, 4, 5]) == False\nassert is_sorted([1, 2, 3, 4, 5, 6]) == True\nassert is_sorted([1, 2, 3, 4, 5, 6, 7]) == True\nassert is_sorted([1, 3, 2, 4, 5, 6, 7]) == False\nassert is_sorted([]) == True\nassert is_sorted([1]) == True\nassert is_sorted([3, 2, 1]) == False\nassert is_sorted([1, 2, 2, 2, 3, 4]) == False\nassert is_sorted([1, 2, 3, 3, 3, 4]) == False\nassert is_sorted([1, 2, 2, 3, 3, 4]) == True\nassert is_sorted([1, 2, 3, 4]) == True\n", "raw_outputs": ""} \ No newline at end of file diff --git a/training/config.yaml b/training/config.yaml new file mode 100644 index 0000000..8d7e949 --- /dev/null +++ b/training/config.yaml @@ -0,0 +1,17 @@ +compute_environment: LOCAL_MACHINE +debug: false +distributed_type: MULTI_GPU +downcast_bf16: 'no' +enable_cpu_affinity: false +gpu_ids: 0,1,2,3 +num_machines: 1 +num_processes: 4 +rdzv_backend: static +same_network: true +tpu_env: [] +tpu_use_cluster: false +tpu_use_sudo: false +use_cpu: false +machine_rank: 0 +main_training_function: main +mixed_precision: bf16 \ No newline at end of file diff --git a/training/src/__init__.py b/training/src/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/training/src/__pycache__/__init__.cpython-310.pyc b/training/src/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..3f5bdbc Binary files /dev/null and b/training/src/__pycache__/__init__.cpython-310.pyc differ diff --git a/training/src/__pycache__/config.cpython-310.pyc b/training/src/__pycache__/config.cpython-310.pyc new file mode 100644 index 0000000..a1783db Binary files /dev/null and b/training/src/__pycache__/config.cpython-310.pyc differ diff --git a/training/src/__pycache__/data.cpython-310.pyc b/training/src/__pycache__/data.cpython-310.pyc new file mode 100644 index 0000000..61cd633 Binary files /dev/null and b/training/src/__pycache__/data.cpython-310.pyc differ diff --git a/training/src/__pycache__/trainer.cpython-310.pyc b/training/src/__pycache__/trainer.cpython-310.pyc new file mode 100644 index 0000000..f52d275 Binary files /dev/null and b/training/src/__pycache__/trainer.cpython-310.pyc differ diff --git a/training/src/__pycache__/utils.cpython-310.pyc b/training/src/__pycache__/utils.cpython-310.pyc new file mode 100644 index 0000000..6d4a04e Binary files /dev/null and b/training/src/__pycache__/utils.cpython-310.pyc differ diff --git a/training/src/config.py b/training/src/config.py new file mode 100644 index 0000000..90513b2 --- /dev/null +++ b/training/src/config.py @@ -0,0 +1,39 @@ +from dataclasses import field, dataclass +from typing import Optional +from transformers import TrainingArguments + +@dataclass() +class ModelConfiguration: + pretrained_model_name_or_path: Optional[str] = field(default="/2b_sft_model") + +@dataclass() +class DataConfiguration: + train_dataset_path: Optional[str] = field(default="test.parquet") + eval_dataset_path: Optional[str] = field(default="eval.parquet") + eval_size: Optional[int] = field(default=256) + max_length: Optional[int] = field(default=512) + num_data_proc: Optional[int] = field(default=16) + training_key: Optional[str] = field(default='input') + skip_eos_token: Optional[bool] = field(default=False) + +@dataclass() +class TrainingConfiguration(TrainingArguments): + run_name: Optional[str] = field(default="cpm") + output_dir: Optional[str] = field(default="checkpoints/") + per_device_train_batch_size: Optional[int] = field(default=4) + per_device_eval_batch_size: Optional[int] = field(default=4) + num_train_epochs: Optional[int] = field(default=20) + weight_decay: Optional[float] = field(default=0) + learning_rate: Optional[float] = field(default=1e-7) + lr_scheduler_type: Optional[str] = field(default="cosine") + warmup_ratio: Optional[float] = field(default=0.1) + eval_strategy: Optional[str] = field(default="steps") + eval_steps: Optional[int] = field(default=100) + load_best_model_at_end: Optional[bool] = field(default=True) + logging_strategy: Optional[str] = field(default="steps") + logging_steps: Optional[int] = field(default=1) + save_strategy: Optional[str] = field(default="steps") + save_steps: Optional[int] = field(default=100) + save_total_limit: Optional[int] = field(default=10) + save_only_model: Optional[bool] = field(default=True) + bf16: Optional[bool] = field(default=True) \ No newline at end of file diff --git a/training/src/data.py b/training/src/data.py new file mode 100644 index 0000000..73c67e8 --- /dev/null +++ b/training/src/data.py @@ -0,0 +1,68 @@ +import torch +from datasets import load_dataset +from dataclasses import asdict +from .utils import clean_source_code + +def create_training_instances(raw_data, tokenizer, training_key, max_length, skip_eos_token=False, **kwargs): + conversations = [] + for idx, prompt in enumerate(raw_data['input']): + conversations.append(f"<用户>{prompt}{clean_source_code(raw_data['output'][idx])}{tokenizer.eos_token}") + + encoded_data = tokenizer.batch_encode_plus( + conversations, + max_length=max_length, + padding="max_length", + truncation=True, + return_tensors="pt" + ) + + input_ids = encoded_data["input_ids"] + attention_mask = encoded_data["attention_mask"] + attention_mask = torch.where(input_ids == 0, torch.zeros_like(attention_mask), attention_mask) + target_ids = input_ids.clone() + + for idx, sequence in enumerate(input_ids): + ai_marker_pos = (sequence == tokenizer.encode("", add_special_tokens=False)[2]).nonzero(as_tuple=False) + if ai_marker_pos.nelement() > 0: + mask_pos = ai_marker_pos[0].item() + target_ids[idx, :mask_pos] = -100 + if skip_eos_token: + target_ids[idx, -1] = -100 + + return { + "input_ids": input_ids, + "attention_mask": attention_mask, + "labels": target_ids + } + +def handle_batch(items): + return { + "input_ids": torch.tensor([x["input_ids"] for x in items]), + "attention_mask": torch.tensor([x["attention_mask"] for x in items]), + "labels": torch.tensor([x["labels"] for x in items]) + } + +def get_processed_datasets(data_cfg, tokenizer): + train_set = load_dataset('parquet', data_files={'train': data_cfg.train_dataset_path.split(',')})['train'] + eval_set = load_dataset('parquet', data_files={'train': data_cfg.eval_dataset_path})['train'] + + processing_args = { + "tokenizer": tokenizer, + **asdict(data_cfg) + } + + processed_train = train_set.map( + create_training_instances, + batched=True, + num_proc=data_cfg.num_data_proc, + fn_kwargs=processing_args + ) + + processed_eval = eval_set.map( + create_training_instances, + batched=True, + num_proc=data_cfg.num_data_proc, + fn_kwargs=processing_args + ) + + return processed_train, processed_eval \ No newline at end of file diff --git a/training/src/trainer.py b/training/src/trainer.py new file mode 100644 index 0000000..2ff9c97 --- /dev/null +++ b/training/src/trainer.py @@ -0,0 +1,27 @@ +import os +from transformers import AutoModelForCausalLM, AutoTokenizer, Trainer +from transformers.trainer_utils import is_main_process +from .data import get_processed_datasets, handle_batch + +def setup_model_components(cfg): + base_model = AutoModelForCausalLM.from_pretrained(cfg.pretrained_model_name_or_path, trust_remote_code=True) + tok = AutoTokenizer.from_pretrained(cfg.pretrained_model_name_or_path) + tok.pad_token_id = tok.unk_token_id + return base_model, tok + +def build_trainer(model_cfg, data_cfg, training_cfg): + base_model, tok = setup_model_components(model_cfg) + train_set, val_set = get_processed_datasets(data_cfg, tok) + + rank = int(os.environ.get("LOCAL_RANK", -1)) + if is_main_process(rank): + print(train_set[0]) + + return Trainer( + model=base_model, + args=training_cfg, + train_dataset=train_set, + eval_dataset=val_set, + tokenizer=tok, + data_collator=handle_batch, + ) \ No newline at end of file diff --git a/training/src/utils.py b/training/src/utils.py new file mode 100644 index 0000000..b9471db --- /dev/null +++ b/training/src/utils.py @@ -0,0 +1,3 @@ +def clean_source_code(text): + return '\n'.join(line for line in text.split('\n') + if not any(line.strip().startswith(x) for x in ('print', 'assert', '# '))).strip() \ No newline at end of file diff --git a/training/train.py b/training/train.py new file mode 100644 index 0000000..b5ec071 --- /dev/null +++ b/training/train.py @@ -0,0 +1,13 @@ +from transformers import HfArgumentParser +from src.config import ModelConfiguration, DataConfiguration, TrainingConfiguration +from src.trainer import build_trainer + +def execute_training(): + parser = HfArgumentParser((ModelConfiguration, DataConfiguration, TrainingConfiguration)) + model_cfg, data_cfg, train_cfg = parser.parse_args_into_dataclasses() + + training_engine = build_trainer(model_cfg, data_cfg, train_cfg) + training_engine.train() + +if __name__ == '__main__': + execute_training() \ No newline at end of file diff --git a/training/train.sh b/training/train.sh new file mode 100755 index 0000000..70cc651 --- /dev/null +++ b/training/train.sh @@ -0,0 +1,10 @@ +accelerate launch --config_file config.yaml train.py \ + --pretrained_model_name_or_path=2b_sft_model \ + --train_dataset_path=../datasets/数据.parquet \ + --eval_dataset_path=../datasets/eval.parquet \ + --max_length=512 \ + --eval_steps=200 \ + --save_steps=5000 \ + --num_train_epochs=3 \ + --learning_rate=1e-5 \ + --output_dir=../checkpoints/py \ \ No newline at end of file diff --git a/training/wandb/debug-internal.log b/training/wandb/debug-internal.log new file mode 120000 index 0000000..d3fb26a --- /dev/null +++ b/training/wandb/debug-internal.log @@ -0,0 +1 @@ +offline-run-20241111_125651-umlr61gt/logs/debug-internal.log \ No newline at end of file diff --git a/training/wandb/debug.log b/training/wandb/debug.log new file mode 120000 index 0000000..4da9616 --- /dev/null +++ b/training/wandb/debug.log @@ -0,0 +1 @@ +offline-run-20241111_125651-umlr61gt/logs/debug.log \ No newline at end of file diff --git a/training/wandb/latest-run b/training/wandb/latest-run new file mode 120000 index 0000000..3e95c07 --- /dev/null +++ b/training/wandb/latest-run @@ -0,0 +1 @@ +offline-run-20241111_125651-umlr61gt \ No newline at end of file diff --git a/training/wandb/offline-run-20241111_125651-umlr61gt/files/output.log b/training/wandb/offline-run-20241111_125651-umlr61gt/files/output.log new file mode 100644 index 0000000..e69de29 diff --git a/training/wandb/offline-run-20241111_125651-umlr61gt/files/requirements.txt b/training/wandb/offline-run-20241111_125651-umlr61gt/files/requirements.txt new file mode 100644 index 0000000..73103e1 --- /dev/null +++ b/training/wandb/offline-run-20241111_125651-umlr61gt/files/requirements.txt @@ -0,0 +1,79 @@ +ninja==1.11.1.1 +pynvml==11.5.0 +hjson==3.1.0 +trampoline==0.1.2 +imageio==2.34.0 +py-cpuinfo==9.0.0 +imageio-ffmpeg==0.4.9 +torchsde==0.2.6 +pytz==2024.2 +propcache==0.2.0 +nvidia-cusparse-cu12==12.1.0.106 +sentry-sdk==2.18.0 +PyYAML==6.0.2 +tqdm==4.66.1 +sympy==1.13.1 +aiohappyeyeballs==2.4.3 +yarl==1.17.1 +frozenlist==1.5.0 +fsspec==2024.2.0 +nvidia-cublas-cu12==12.1.3.1 +charset-normalizer==3.4.0 +torch==2.1.2 +certifi==2024.8.30 +pyarrow==18.0.0 +xxhash==3.5.0 +transformers==4.44.0 +wandb==0.18.6 +gitdb==4.0.11 +networkx==3.4.2 +MarkupSafe==3.0.2 +six==1.16.0 +python-dateutil==2.9.0.post0 +datasets==2.18.0 +pip==24.2 +protobuf==5.28.3 +nvidia-cuda-nvrtc-cu12==12.1.105 +nvidia-cudnn-cu12==8.9.2.26 +nvidia-cusolver-cu12==11.4.5.107 +accelerate==0.34.2 +tzdata==2024.2 +nvidia-nvtx-cu12==12.1.105 +dill==0.3.8 +async-timeout==4.0.3 +psutil==6.1.0 +mpmath==1.3.0 +nvidia-nvjitlink-cu12==12.4.127 +nvidia-nccl-cu12==2.18.1 +setuptools==75.1.0 +pandas==2.2.3 +aiohttp==3.10.10 +multidict==6.1.0 +huggingface-hub==0.26.2 +tokenizers==0.19.1 +numpy==1.26.3 +nvidia-cufft-cu12==11.0.2.54 +aiosignal==1.3.1 +triton==2.1.0 +idna==3.10 +regex==2024.11.6 +click==8.1.7 +filelock==3.16.1 +GitPython==3.1.43 +packaging==24.2 +smmap==5.0.1 +Jinja2==3.1.4 +nvidia-cuda-runtime-cu12==12.1.105 +requests==2.32.3 +docker-pycreds==0.4.0 +multiprocess==0.70.16 +setproctitle==1.3.3 +pyarrow-hotfix==0.6 +nvidia-cuda-cupti-cu12==12.1.105 +nvidia-curand-cu12==10.3.2.106 +typing_extensions==4.12.2 +attrs==24.2.0 +wheel==0.44.0 +platformdirs==4.3.6 +safetensors==0.4.5 +urllib3==2.2.3 diff --git a/training/wandb/offline-run-20241111_125651-umlr61gt/files/wandb-metadata.json b/training/wandb/offline-run-20241111_125651-umlr61gt/files/wandb-metadata.json new file mode 100644 index 0000000..fd1199c --- /dev/null +++ b/training/wandb/offline-run-20241111_125651-umlr61gt/files/wandb-metadata.json @@ -0,0 +1,82 @@ +{ + "os": "Linux-5.4.0-187-generic-x86_64-with-glibc2.31", + "python": "3.10.15", + "startedAt": "2024-11-11T12:56:51.331444Z", + "args": [ + "--pretrained_model_name_or_path=2b_sft_model", + "--train_dataset_path=../datasets/数据.parquet", + "--eval_dataset_path=../datasets/eval.parquet", + "--max_length=512", + "--eval_steps=200", + "--save_steps=5000", + "--num_train_epochs=3", + "--learning_rate=1e-5", + "--output_dir=../checkpoints/py" + ], + "gpu": "NVIDIA A100-SXM4-80GB", + "gpu_count": 8, + "disk": { + "/": { + "total": "931113000960", + "used": "790839361536" + } + }, + "memory": { + "total": "1081822208000" + }, + "cpu": { + "count": 64, + "countLogical": 128 + }, + "gpu_nvidia": [ + { + "name": "NVIDIA A100-SXM4-80GB", + "memoryTotal": "85899345920", + "cudaCores": 6912, + "architecture": "Ampere" + }, + { + "name": "NVIDIA A100-SXM4-80GB", + "memoryTotal": "85899345920", + "cudaCores": 6912, + "architecture": "Ampere" + }, + { + "name": "NVIDIA A100-SXM4-80GB", + "memoryTotal": "85899345920", + "cudaCores": 6912, + "architecture": "Ampere" + }, + { + "name": "NVIDIA A100-SXM4-80GB", + "memoryTotal": "85899345920", + "cudaCores": 6912, + "architecture": "Ampere" + }, + { + "name": "NVIDIA A100-SXM4-80GB", + "memoryTotal": "85899345920", + "cudaCores": 6912, + "architecture": "Ampere" + }, + { + "name": "NVIDIA A100-SXM4-80GB", + "memoryTotal": "85899345920", + "cudaCores": 6912, + "architecture": "Ampere" + }, + { + "name": "NVIDIA A100-SXM4-80GB", + "memoryTotal": "85899345920", + "cudaCores": 6912, + "architecture": "Ampere" + }, + { + "name": "NVIDIA A100-SXM4-80GB", + "memoryTotal": "85899345920", + "cudaCores": 6912, + "architecture": "Ampere" + } + ], + "cudaVersion": "12.2" +} \ No newline at end of file diff --git a/training/wandb/offline-run-20241111_125651-umlr61gt/logs/debug-core.log b/training/wandb/offline-run-20241111_125651-umlr61gt/logs/debug-core.log new file mode 120000 index 0000000..6529770 --- /dev/null +++ b/training/wandb/offline-run-20241111_125651-umlr61gt/logs/debug-core.log @@ -0,0 +1 @@ +/home/lz/.cache/wandb/logs/core-debug-20241111_125651.log \ No newline at end of file diff --git a/training/wandb/offline-run-20241111_125651-umlr61gt/logs/debug-internal.log b/training/wandb/offline-run-20241111_125651-umlr61gt/logs/debug-internal.log new file mode 100644 index 0000000..f77b0cf --- /dev/null +++ b/training/wandb/offline-run-20241111_125651-umlr61gt/logs/debug-internal.log @@ -0,0 +1,14 @@ +{"time":"2024-11-11T12:56:51.334384302Z","level":"INFO","msg":"using version","core version":"0.18.6"} +{"time":"2024-11-11T12:56:51.901034785Z","level":"INFO","msg":"created new stream","id":"umlr61gt"} +{"time":"2024-11-11T12:56:51.901092394Z","level":"INFO","msg":"stream: started","id":"umlr61gt"} +{"time":"2024-11-11T12:56:51.901166874Z","level":"INFO","msg":"sender: started","stream_id":"umlr61gt"} +{"time":"2024-11-11T12:56:51.901163121Z","level":"INFO","msg":"handler: started","stream_id":{"value":"umlr61gt"}} +{"time":"2024-11-11T12:56:51.901144193Z","level":"INFO","msg":"writer: Do: started","stream_id":{"value":"umlr61gt"}} +{"time":"2024-11-11T12:56:51.91240037Z","level":"INFO","msg":"Starting system monitor"} +{"time":"2024-11-11T14:57:47.411095079Z","level":"INFO","msg":"stream: closing","id":"umlr61gt"} +{"time":"2024-11-11T14:57:47.411171015Z","level":"INFO","msg":"Stopping system monitor"} +{"time":"2024-11-11T14:57:47.412170725Z","level":"INFO","msg":"Stopped system monitor"} +{"time":"2024-11-11T14:57:47.412558537Z","level":"INFO","msg":"handler: closed","stream_id":{"value":"umlr61gt"}} +{"time":"2024-11-11T14:57:47.412594759Z","level":"INFO","msg":"writer: Close: closed","stream_id":{"value":"umlr61gt"}} +{"time":"2024-11-11T14:57:47.412612416Z","level":"INFO","msg":"sender: closed","stream_id":"umlr61gt"} +{"time":"2024-11-11T14:57:47.412694971Z","level":"INFO","msg":"stream: closed","id":"umlr61gt"} diff --git a/training/wandb/offline-run-20241111_125651-umlr61gt/logs/debug.log b/training/wandb/offline-run-20241111_125651-umlr61gt/logs/debug.log new file mode 100644 index 0000000..0dbb298 --- /dev/null +++ b/training/wandb/offline-run-20241111_125651-umlr61gt/logs/debug.log @@ -0,0 +1,23 @@ +2024-11-11 12:56:51,328 INFO MainThread:4047510 [wandb_setup.py:_flush():79] Current SDK version is 0.18.6 +2024-11-11 12:56:51,328 INFO MainThread:4047510 [wandb_setup.py:_flush():79] Configure stats pid to 4047510 +2024-11-11 12:56:51,329 INFO MainThread:4047510 [wandb_setup.py:_flush():79] Loading settings from environment variables: {'mode': 'offline'} +2024-11-11 12:56:51,329 INFO MainThread:4047510 [wandb_setup.py:_flush():79] Applying setup settings: {'mode': 'offline', '_disable_service': None} +2024-11-11 12:56:51,329 INFO MainThread:4047510 [wandb_init.py:init():619] calling init triggers +2024-11-11 12:56:51,329 INFO MainThread:4047510 [wandb_init.py:init():626] wandb.init called with sweep_config: {} +config: {} +2024-11-11 12:56:51,329 INFO MainThread:4047510 [wandb_init.py:init():669] starting backend +2024-11-11 12:56:51,329 INFO MainThread:4047510 [wandb_init.py:init():673] sending inform_init request +2024-11-11 12:56:51,330 INFO MainThread:4047510 [backend.py:_multiprocessing_setup():104] multiprocessing start_methods=fork,spawn,forkserver, using: spawn +2024-11-11 12:56:51,331 INFO MainThread:4047510 [wandb_init.py:init():686] backend started and connected +2024-11-11 12:56:51,334 INFO MainThread:4047510 [wandb_init.py:init():781] updated telemetry +2024-11-11 12:56:51,334 INFO MainThread:4047510 [wandb_init.py:init():814] communicating run to backend with 90.0 second timeout +2024-11-11 12:56:51,909 INFO MainThread:4047510 [wandb_init.py:init():867] starting run threads in backend +2024-11-11 12:56:51,969 INFO MainThread:4047510 [wandb_run.py:_console_start():2451] atexit reg +2024-11-11 12:56:51,969 INFO MainThread:4047510 [wandb_run.py:_redirect():2299] redirect: wrap_raw +2024-11-11 12:56:51,969 INFO MainThread:4047510 [wandb_run.py:_redirect():2364] Wrapping output streams. +2024-11-11 12:56:51,969 INFO MainThread:4047510 [wandb_run.py:_redirect():2389] Redirects installed. +2024-11-11 12:56:51,970 INFO MainThread:4047510 [wandb_init.py:init():911] run started, returning control to user process +2024-11-11 12:56:51,972 INFO MainThread:4047510 [wandb_run.py:_config_callback():1389] config_cb None None {'vocab_size': 122753, 'max_position_embeddings': 4096, 'hidden_size': 2304, 'intermediate_size': 5760, 'num_hidden_layers': 40, 'num_attention_heads': 36, 'num_key_value_heads': 36, 'hidden_act': 'silu', 'initializer_range': 0.1, 'rms_norm_eps': 1e-05, 'pretraining_tp': 1, 'use_cache': True, 'rope_theta': 10000.0, 'rope_scaling': None, 'attention_bias': False, 'attention_dropout': 0.0, 'scale_emb': 12, 'dim_model_base': 256, 'scale_depth': 1.4, 'return_dict': True, 'output_hidden_states': False, 'output_attentions': False, 'torchscript': False, 'torch_dtype': 'bfloat16', 'use_bfloat16': False, 'tf_legacy_loss': False, 'pruned_heads': {}, 'tie_word_embeddings': True, 'chunk_size_feed_forward': 0, 'is_encoder_decoder': False, 'is_decoder': False, 'cross_attention_hidden_size': None, 'add_cross_attention': False, 'tie_encoder_decoder': False, 'max_length': 20, 'min_length': 0, 'do_sample': False, 'early_stopping': False, 'num_beams': 1, 'num_beam_groups': 1, 'diversity_penalty': 0.0, 'temperature': 1.0, 'top_k': 50, 'top_p': 1.0, 'typical_p': 1.0, 'repetition_penalty': 1.0, 'length_penalty': 1.0, 'no_repeat_ngram_size': 0, 'encoder_no_repeat_ngram_size': 0, 'bad_words_ids': None, 'num_return_sequences': 1, 'output_scores': False, 'return_dict_in_generate': False, 'forced_bos_token_id': None, 'forced_eos_token_id': None, 'remove_invalid_values': False, 'exponential_decay_length_penalty': None, 'suppress_tokens': None, 'begin_suppress_tokens': None, 'architectures': ['FM9GForCausalLM'], 'finetuning_task': None, 'id2label': {0: 'LABEL_0', 1: 'LABEL_1'}, 'label2id': {'LABEL_0': 0, 'LABEL_1': 1}, 'tokenizer_class': None, 'prefix': None, 'bos_token_id': 1, 'pad_token_id': None, 'eos_token_id': 2, 'sep_token_id': None, 'decoder_start_token_id': None, 'task_specific_params': None, 'problem_type': None, '_name_or_path': '/data02/cpm/2b_sft_model', 'transformers_version': '4.44.0', 'auto_map': {'AutoConfig': 'configuration_fm9g.FM9GConfig', 'AutoModel': 'modeling_fm9g.FM9GModel', 'AutoModelForCausalLM': 'modeling_fm9g.FM9GForCausalLM', 'AutoModelForSeq2SeqLM': 'modeling_fm9g.FM9GForCausalLM', 'AutoModelForSequenceClassification': 'modeling_fm9g.FM9GForSequenceClassification'}, 'model_type': 'fm9g', 'output_dir': '../checkpoints/py', 'overwrite_output_dir': False, 'do_train': False, 'do_eval': True, 'do_predict': False, 'eval_strategy': 'steps', 'prediction_loss_only': False, 'per_device_train_batch_size': 4, 'per_device_eval_batch_size': 4, 'per_gpu_train_batch_size': None, 'per_gpu_eval_batch_size': None, 'gradient_accumulation_steps': 1, 'eval_accumulation_steps': None, 'eval_delay': 0, 'torch_empty_cache_steps': None, 'learning_rate': 1e-05, 'weight_decay': 0, 'adam_beta1': 0.9, 'adam_beta2': 0.999, 'adam_epsilon': 1e-08, 'max_grad_norm': 1.0, 'num_train_epochs': 3, 'max_steps': -1, 'lr_scheduler_type': 'cosine', 'lr_scheduler_kwargs': {}, 'warmup_ratio': 0.1, 'warmup_steps': 0, 'log_level': 'passive', 'log_level_replica': 'warning', 'log_on_each_node': True, 'logging_dir': '../checkpoints/py/runs/Nov11_12-56-23_ly-node-214-3-10-2', 'logging_strategy': 'steps', 'logging_first_step': False, 'logging_steps': 1, 'logging_nan_inf_filter': True, 'save_strategy': 'steps', 'save_steps': 5000, 'save_total_limit': 10, 'save_safetensors': True, 'save_on_each_node': False, 'save_only_model': True, 'restore_callback_states_from_checkpoint': False, 'no_cuda': False, 'use_cpu': False, 'use_mps_device': False, 'seed': 42, 'data_seed': None, 'jit_mode_eval': False, 'use_ipex': False, 'bf16': True, 'fp16': False, 'fp16_opt_level': 'O1', 'half_precision_backend': 'auto', 'bf16_full_eval': False, 'fp16_full_eval': False, 'tf32': None, 'local_rank': 0, 'ddp_backend': None, 'tpu_num_cores': None, 'tpu_metrics_debug': False, 'debug': [], 'dataloader_drop_last': False, 'eval_steps': 200, 'dataloader_num_workers': 0, 'dataloader_prefetch_factor': None, 'past_index': -1, 'run_name': 'cpm', 'disable_tqdm': False, 'remove_unused_columns': True, 'label_names': None, 'load_best_model_at_end': True, 'metric_for_best_model': 'loss', 'greater_is_better': False, 'ignore_data_skip': False, 'fsdp': [], 'fsdp_min_num_params': 0, 'fsdp_config': {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}, 'fsdp_transformer_layer_cls_to_wrap': None, 'accelerator_config': {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}, 'deepspeed': None, 'label_smoothing_factor': 0.0, 'optim': 'adamw_torch', 'optim_args': None, 'adafactor': False, 'group_by_length': False, 'length_column_name': 'length', 'report_to': ['wandb'], 'ddp_find_unused_parameters': None, 'ddp_bucket_cap_mb': None, 'ddp_broadcast_buffers': None, 'dataloader_pin_memory': True, 'dataloader_persistent_workers': False, 'skip_memory_metrics': True, 'use_legacy_prediction_loop': False, 'push_to_hub': False, 'resume_from_checkpoint': None, 'hub_model_id': None, 'hub_strategy': 'every_save', 'hub_token': '', 'hub_private_repo': False, 'hub_always_push': False, 'gradient_checkpointing': False, 'gradient_checkpointing_kwargs': None, 'include_inputs_for_metrics': False, 'eval_do_concat_batches': True, 'fp16_backend': 'auto', 'evaluation_strategy': None, 'push_to_hub_model_id': None, 'push_to_hub_organization': None, 'push_to_hub_token': '', 'mp_parameters': '', 'auto_find_batch_size': False, 'full_determinism': False, 'torchdynamo': None, 'ray_scope': 'last', 'ddp_timeout': 1800, 'torch_compile': False, 'torch_compile_backend': None, 'torch_compile_mode': None, 'dispatch_batches': None, 'split_batches': None, 'include_tokens_per_second': False, 'include_num_input_tokens_seen': False, 'neftune_noise_alpha': None, 'optim_target_modules': None, 'batch_eval_metrics': False, 'eval_on_start': False, 'eval_use_gather_object': False} +2024-11-11 12:56:51,975 INFO MainThread:4047510 [wandb_config.py:__setitem__():154] config set model/num_parameters = 2724880896 - > +2024-11-11 12:56:51,975 INFO MainThread:4047510 [wandb_run.py:_config_callback():1389] config_cb model/num_parameters 2724880896 None +2024-11-11 14:57:47,411 WARNING MsgRouterThr:4047510 [router.py:message_loop():75] message_loop has been closed diff --git a/training/wandb/offline-run-20241111_125651-umlr61gt/run-umlr61gt.wandb b/training/wandb/offline-run-20241111_125651-umlr61gt/run-umlr61gt.wandb new file mode 100644 index 0000000..fd7a557 Binary files /dev/null and b/training/wandb/offline-run-20241111_125651-umlr61gt/run-umlr61gt.wandb differ