task_type
stringclasses
1 value
problem
stringlengths
209
3.39k
answer
stringlengths
35
6.15k
problem_tokens
int64
60
774
answer_tokens
int64
12
2.04k
coding
Solve the programming task below in a Python markdown code block. There are $ n $ acitivities with start times $ \\ {s_i \\} $ and finish times $ \\ {t_i \\} $. Assuming that a person can only work on a single activity at a time, find the maximum number of activities that can be performed by a single person. Constrain...
{"inputs": ["3\n1 1\n2 3\n3 4", "3\n0 5\n3 4\n2 5", "3\n1 1\n2 4\n3 4", "3\n1 1\n2 4\n3 3", "3\n2 1\n2 4\n3 3", "3\n4 1\n2 4\n3 3", "3\n4 1\n2 4\n3 2", "3\n4 1\n4 4\n3 2"], "outputs": ["2\n", "1\n", "2\n", "2\n", "2\n", "2\n", "2\n", "3\n"]}
279
158
coding
Solve the programming task below in a Python markdown code block. Rose loves to play games. This problem is about a game he recently played. In the game there are N locations, numbered 0 through N-1. Each location has one entrance and one exit. You are given an array aka A with N elements.For each i, A[i] describes the...
{"inputs": ["10\n2\n1 -1\n3\n1 0 -1\n3\n0 1 2\n37\n29 33 28 16 -1 11 10 14 6 31 7 35 34 8 15 17 26 12 13 22 1 20 2 21 -1 5 19 9 18 4 25 32 3 30 23 10 27\n48\n17 43 20 41 42 15 18 35 -1 31 7 33 23 33 -1 -1 0 33 19 12 42 -1 -1 9 9 -1 39 -1 31 46 -1 20 44 41 -1 -1 12 -1 36 -1 -1 6 47 10 2 4 1 29\n6\n3 1 1 2 -1 4\n47\n15 1...
372
1,895
coding
Solve the programming task below in a Python markdown code block. Ilya plays a card game by the following rules. A player has several cards. Each card contains two non-negative integers inscribed, one at the top of the card and one at the bottom. At the beginning of the round the player chooses one of his cards to pla...
{"inputs": ["1\n7 0\n", "1\n0 0\n", "1\n7 1\n", "1\n1 0\n", "1\n3 1\n", "1\n0 1\n", "1\n1 1\n", "1\n2 0\n"], "outputs": ["7\n", "0\n", "7\n", "1\n", "3\n", "0\n", "1\n", "2\n"]}
451
102
coding
Solve the programming task below in a Python markdown code block. Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one. In school, where Noora is studying...
{"inputs": ["1 1\n1\n", "1 2\n2\n", "1 3\n3\n", "1 4\n4\n", "1 5\n5\n", "1 7\n1\n", "1 5\n1\n", "1 9\n9\n"], "outputs": ["0", "0", "0", "0", "0", "11", "7", "0"]}
729
95
coding
Solve the programming task below in a Python markdown code block. Description THE BY DOLM @ STER is a training simulation game scheduled to be released on EXIDNA by 1rem on April 1, 2010. For the time being, it probably has nothing to do with an arcade game where the network connection service stopped earlier this mon...
{"inputs": ["3 10\nDobkeradops\n7 3 18 0\nPaatQata\n1 0 6 1\ndop\n5 9 28 13\n2 2\nBydp syStem ahplA\n7 11 4 0\nFedrn Infermo\n243 80 32 80", "3 10\nDobkesadops\n7 1 18 0\nPaatQaua\n1 0 0 1\ndop\n8 9 28 13\n2 3\nBydp syStem ahplA\n20 1 4 0\nEedrn Infeqmo\n438 102 15 80", "3 18\nDobkesadops\n7 1 18 0\nPaatQaua\n1 0 0 1\n...
557
782
coding
Solve the programming task below in a Python markdown code block. Create a program that calculates and outputs the surface distance by inputting the north latitude and east longitude of two cities on the earth. However, the earth is a sphere with a radius of 6,378.1 km, and the surface distance between two points is th...
{"inputs": ["35.68 139.77 51.15 359.82\n1.37 103.92 41.78 272.25\n51.15 359.82 -34.58 301.52\n-1 -1 -1 -1", "35.68 139.77 51.15 360.3067312023825\n1.37 103.92 41.78 272.25\n51.15 359.82 -34.58 301.52\n-1 -1 -1 -1", "35.68 139.77 51.15 359.82\n1.37 103.92 41.78 272.25\n51.15 359.82 -34.03920544232073 301.52\n-1 -1 -1 -1...
513
973
coding
Solve the programming task below in a Python markdown code block. Simple, given a string of words, return the length of the shortest word(s). String will never be empty and you do not need to account for different data types. Also feel free to reuse/extend the following starter code: ```python def find_short(s): ```
{"functional": "_inputs = [['bitcoin take over the world maybe who knows perhaps'], ['turns out random test cases are easier than writing out basic ones'], ['lets talk about javascript the best language'], ['i want to travel the world writing code one day'], ['Lets all go on holiday somewhere very cold']]\n_outputs = [...
68
220
coding
Solve the programming task below in a Python markdown code block. There is a large pile of socks that must be paired by color. Given an array of integers representing the color of each sock, determine how many pairs of socks with matching colors there are. Example $n=7$ $ar=[1,2,1,2,1,3,2]$ There is one pair o...
{"inputs": ["9\n10 20 20 10 10 30 50 10 20"], "outputs": ["3"]}
356
39
coding
Solve the programming task below in a Python markdown code block. Your task is to get Zodiac Sign using input ```day``` and ```month```. For exapmle: ```python get_zodiac_sign(1,5) => 'Taurus' get_zodiac_sign(10,10) => 'Libra' ``` Correct answers are (preloaded): ```python SIGNS = ['Capricorn', 'Aquarius', 'Pisces...
{"functional": "_inputs = [[10, 10], [1, 5], [6, 9], [25, 11]]\n_outputs = [['Libra'], ['Taurus'], ['Virgo'], ['Sagittarius']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple...
351
196
coding
Solve the programming task below in a Python markdown code block. Given an array, find the duplicates in that array, and return a new array of those duplicates. The elements of the returned array should appear in the order when they first appeared as duplicates. __*Note*__: numbers and their corresponding string repre...
{"functional": "_inputs = [[[1, 2, 4, 4, 3, 3, 1, 5, 3, '5']], [[0, 1, 2, 3, 4, 5]], [[1, 1, 2, 3, 4, 5, 4]]]\n_outputs = [[[4, 3, 1]], [[]], [[1, 4]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if i...
171
234
coding
Solve the programming task below in a Python markdown code block. One day Mr. Takahashi picked up a dictionary containing all of the N! permutations of integers 1 through N. The dictionary has N! pages, and page i (1 ≤ i ≤ N!) contains the i-th permutation in the lexicographical order. Mr. Takahashi wanted to look up ...
{"inputs": ["1\n1", "1\n0", "3\n0 0 1", "3\n0 0 2", "3\n0 0 3", "3\n0 1 0", "3\n1 3 0", "3\n1 0 0"], "outputs": ["1\n", "1", "10\n", "7\n", "4\n", "8\n", "2\n", "3\n"]}
402
102
coding
Solve the programming task below in a Python markdown code block. Read problems statements [Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. You are given an integer sequence $A$ with length $N$. In one move, you are allowed to choose one element of this sequence and change it to an arbitrary intege...
{"inputs": ["2\n4\n1 2 3 3\n3\n2 6 2"], "outputs": ["1\n2"]}
393
32
coding
Solve the programming task below in a Python markdown code block. There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: - A random alive monster attacks another r...
{"inputs": ["4\n1 1 1 2", "4\n1 1 1 3", "4\n1 1 1 6", "4\n1 1 2 6", "4\n1 1 4 6", "4\n1 1 0 6", "4\n2 1 0 6", "4\n2 1 0 1"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]}
247
126
coding
Solve the programming task below in a Python markdown code block. # Task Your task is to find the smallest number which is evenly divided by all numbers between `m` and `n` (both inclusive). # Example For `m = 1, n = 2`, the output should be `2`. For `m = 2, n = 3`, the output should be `6`. For `m = 3, n = 2...
{"functional": "_inputs = [[1, 2], [1, 5], [5, 1], [1, 10], [2, 3], [3, 5], [10, 20], [1, 25], [24, 25]]\n_outputs = [[2], [60], [60], [2520], [6], [60], [232792560], [26771144400], [600]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b...
208
263
coding
Solve the programming task below in a Python markdown code block. Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit n should be located in the centre. The digits should dec...
{"inputs": ["4\n", "5\n", "9\n", "7\n", "8\n", "6\n", "3\n", "2\n"], "outputs": [" 0\n 0 1 0\n 0 1 2 1 0\n 0 1 2 3 2 1 0\n0 1 2 3 4 3 2 1 0\n 0 1 2 3 2 1 0\n 0 1 2 1 0\n 0 1 0\n 0\n", " 0\n 0 1 0\n 0 1 2 1 0\n 0 1 2 3 2 1 0\n 0 1 2 3 4 3 2 1 0\n0 1 2 3 4 5 4 3 2 ...
463
1,558
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are the manager of a basketball team. For the upcoming tournament, you want to choose the team with the highest overall score. The score of the team is the sum of scores of all the players in the team. However, th...
{"functional": "def check(candidate):\n assert candidate(scores = [1,3,5,10,15], ages = [1,2,3,4,5]) == 34\n assert candidate(scores = [4,5,6,5], ages = [2,1,2,1]) == 16\n assert candidate(scores = [1,2,3,5], ages = [8,9,10,1]) == 6\n\n\ncheck(Solution().bestTeamScore)"}
179
116
coding
Solve the programming task below in a Python markdown code block. Devu has an array A consisting of N positive integers. He would like to perform following operation on array. - Pick some two elements a, b in the array (a could be same as b, but their corresponding indices in the array should not be same). Remove both...
{"inputs": ["1 2\n1\n1\n2", "1 1\n1\n0\n0", "1 1\n0\n0\n0", "1 2\n1\n1\n0", "1 2\n1\n0\n0", "0 2\n0\n0\n0", "1 2\n1\n1\n2", "1 1\n0\n-1\n0"], "outputs": ["Yes\nNo", "No\n", "Yes\n", "Yes\nNo\n", "No\nNo\n", "Yes\nYes\n", "Yes\nNo\n", "No\n"]}
511
136
coding
Solve the programming task below in a Python markdown code block. Polycarp decided to relax on his weekend and visited to the performance of famous ropewalkers: Agafon, Boniface and Konrad. The rope is straight and infinite in both directions. At the beginning of the performance, Agafon, Boniface and Konrad are locate...
{"inputs": ["5 2 6 3\n", "3 1 5 6\n", "8 3 3 2\n", "1 3 2 5\n", "2 3 1 6\n", "9 6 2 5\n", "1 1 1 1\n", "1 2 1 1\n"], "outputs": ["2\n", "8\n", "2\n", "8\n", "10\n", "3\n", "2\n", "1\n"]}
572
119
coding
Solve the programming task below in a Python markdown code block. It can be shown that any positive integer x can be uniquely represented as x = 1 + 2 + 4 + ... + 2^{k} - 1 + r, where k and r are integers, k ≥ 0, 0 < r ≤ 2^{k}. Let's call that representation prairie partition of x. For example, the prairie partitions ...
{"inputs": ["1\n1\n", "1\n2\n", "1\n2\n", "1\n1\n", "1\n3\n", "1\n6\n", "1\n4\n", "1\n5\n"], "outputs": ["1 \n", "-1\n", "-1\n", "1 \n", "-1\n", "-1\n", "-1\n", "-1\n"]}
524
88
coding
Solve the programming task below in a Python markdown code block. In this kata you will be given a random string of letters and tasked with returning them as a string of comma-separated sequences sorted alphabetically, with each sequence starting with an uppercase character followed by `n-1` lowercase characters, where...
{"functional": "_inputs = [['BfcFA'], ['ZpglnRxqenU'], ['NyffsGeyylB'], ['MjtkuBovqrU'], ['EvidjUnokmM'], ['HbideVbxncC']]\n_outputs = [['A,Bb,Ccc,Ffffff,Ffffff'], ['Eeeee,Ggggggg,Llllllllllll,Nnnnnnnnnnnnnn,Nnnnnnnnnnnnnn,Pppppppppppppppp,Qqqqqqqqqqqqqqqqq,Rrrrrrrrrrrrrrrrrr,Uuuuuuuuuuuuuuuuuuuuu,Xxxxxxxxxxxxxxxxxxxxx...
253
574
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a positive integer n, there exists a 0-indexed array called powers, composed of the minimum number of powers of 2 that sum to n. The array is sorted in non-decreasing order, and there is only one way to form the...
{"functional": "def check(candidate):\n assert candidate(n = 15, queries = [[0,1],[2,2],[0,3]]) == [2,4,64]\n assert candidate(n = 2, queries = [[0,0]]) == [2]\n\n\ncheck(Solution().productQueries)"}
214
73
coding
Solve the programming task below in a Python markdown code block. Description Since the cubic equation: ax ^ 3 + bx ^ 2 + cx + d = 0 is given, please check the number of positive real roots and the number of negative real roots, respectively. The number of roots shall be counted including the multiple roots. Input...
{"inputs": ["2\n1 4 3 0\n-1 0 1 1", "2\n1 4 3 0\n-1 0 0 0", "2\n1 4 3 0\n-1 0 1 0", "2\n2 4 3 0\n-1 0 1 0", "2\n1 3 3 1\n-8 0 0 0", "2\n1 4 5 0\n-1 0 0 1", "2\n1 4 5 0\n-1 0 0 0", "2\n1 4 3 1\n-3 0 0 1"], "outputs": ["0 2\n1 0\n", "0 2\n0 0\n", "0 2\n1 1\n", "0 0\n1 1\n", "0 3\n0 0\n", "0 0\n1 0\n", "0 0\n0 0\n", "0 1\...
196
246
coding
Solve the programming task below in a Python markdown code block. Extended Euclid Algorithm Given positive integers a and b, find the integer solution (x, y) to ax + by = gcd(a, b), where gcd(a, b) is the greatest common divisor of a and b. Constraints * 1 ≤ a, b ≤ 109 Input a b Two positive integers a and b...
{"inputs": ["5 8", "5 1", "5 2", "6 8", "5 4", "5 3", "8 3", "7 2"], "outputs": ["-3 2\n", "0 1\n", "1 -2\n", "-1 1\n", "1 -1\n", "-1 2\n", "-1 3\n", "1 -3\n"]}
173
95
coding
Solve the programming task below in a Python markdown code block. Omkar is building a waterslide in his water park, and he needs your help to ensure that he does it as efficiently as possible. Omkar currently has $n$ supports arranged in a line, the $i$-th of which has height $a_i$. Omkar wants to build his waterslide...
{"inputs": ["1\n1\n1\n", "1\n1\n1\n", "1\n1\n0\n", "1\n4\n6 5 5 6\n", "1\n4\n6 5 5 6\n", "1\n4\n6 5 5 7\n", "1\n4\n6 4 5 7\n", "1\n4\n6 4 9 7\n"], "outputs": ["0\n", "0\n", "0\n", "1\n", "1\n", "1\n", "2\n", "4\n"]}
685
132
coding
Solve the programming task below in a Python markdown code block. There is unrest in the Galactic Senate. Several thousand solar systems have declared their intentions to leave the Republic. Master Heidi needs to select the Jedi Knights who will go on peacekeeping missions throughout the galaxy. It is well-known that t...
{"inputs": ["1 1\n1\n1\n", "1 1\n1\n1\n", "2 1\n1 1\n1\n", "2 1\n1 1\n2\n", "2 1\n1 1\n1\n", "2 1\n1 1\n2\n", "2 2\n1 2\n1 1\n", "2 2\n2 2\n0 2\n"], "outputs": ["YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n"]}
360
134
coding
Solve the programming task below in a Python markdown code block. You are given an integer n. You have to apply m operations to it. In a single operation, you must replace every digit d of the number with the decimal representation of integer d + 1. For example, 1912 becomes 21023 after applying the operation once. Y...
{"inputs": ["5\n22 1\n26 9\n2 11\n3 6\n3 96\n", "5\n22 1\n26 61\n2 11\n3 6\n3 96\n", "5\n4 1\n42 61\n10 11\n3 1\n3 47\n", "5\n4 1\n42 61\n13 11\n3 1\n3 63\n", "5\n41 1\n26 13\n2 14\n3 6\n3 96\n", "5\n41 1\n26 13\n2 14\n3 6\n5 96\n", "5\n1 1\n42 61\n13 11\n3 1\n5 63\n", "5\n41 1\n26 13\n2 14\n3 6\n5 18\n"], "outputs": [...
368
357
coding
Solve the programming task below in a Python markdown code block. Given a time in AM/PM format as a string, convert it to military (24-hour) time as a string. Midnight is 12:00:00AM on a 12-hour clock, and 00:00:00 on a 24-hour clock. Noon is 12:00:00PM on a 12-hour clock, and 12:00:00 on a 24-hour clock Sample Inpu...
{"functional": "_inputs = [['12:00:01AM'], ['01:02:03AM'], ['02:04:05AM'], ['03:06:07AM'], ['04:08:09AM'], ['05:10:11AM'], ['06:12:13AM'], ['07:14:15AM'], ['08:16:17AM'], ['09:18:19AM'], ['10:20:21AM'], ['11:22:23AM'], ['12:24:25PM'], ['01:26:27PM'], ['02:28:29PM'], ['03:30:31PM'], ['04:32:33PM'], ['05:34:35PM'], ['06:...
200
654
coding
Solve the programming task below in a Python markdown code block. This is a hard version of the problem. The actual problems are different, but the easy version is almost a subtask of the hard version. Note that the constraints and the output format are different. You are given a string $s$ consisting of $n$ lowercase...
{"inputs": ["1\nr\n", "1\nr\n", "1\ns\n", "2\ntj\n", "2\ntj\n", "2\nti\n", "2\nit\n", "5\nabcde\n"], "outputs": ["1\n1 \n", "1\n1 \n", "1\n1 \n", "2\n1 2 \n", "2\n1 2 \n", "2\n1 2 \n", "1\n1 1 \n", "1\n1 1 1 1 1 \n"]}
514
130
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. There is an undirected tree with n nodes labeled from 0 to n - 1, rooted at node 0. You are given a 2D integer array edges of length n - 1 where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and...
{"functional": "def check(candidate):\n assert candidate(edges = [[0,1],[1,2],[1,3],[3,4]], bob = 3, amount = [-2,4,2,-4,6]) == 6\n assert candidate(edges = [[0,1]], bob = 1, amount = [-7280,2350]) == -7280\n\n\ncheck(Solution().mostProfitablePath)"}
409
100
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an integer array nums, return the length of the longest strictly increasing subsequence.   Please complete the following python code precisely: ```python class Solution: def lengthOfLIS(self, nums: List[int]...
{"functional": "def check(candidate):\n assert candidate(nums = [10,9,2,5,3,7,101,18]) == 4\n assert candidate(nums = [0,1,0,3,2,3]) == 4\n assert candidate(nums = [7,7,7,7,7,7,7]) == 1\n\n\ncheck(Solution().lengthOfLIS)"}
67
97
coding
Solve the programming task below in a Python markdown code block. This time minions are celebrating Diwali Festival. There are N minions in total. Each of them owns a house. On this Festival, Each of them wants to decorate their house. But none of them have enough money to do that. One of the minion, Kevin, requested G...
{"inputs": ["2\n4 9\n5 2 2 4\n4 9\n5 2 18 3"], "outputs": ["YES\nNO"]}
442
39
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given a 0-indexed 2D integer array brackets where brackets[i] = [upperi, percenti] means that the ith tax bracket has an upper bound of upperi and is taxed at a rate of percenti. The brackets are sorted by upp...
{"functional": "def check(candidate):\n assert candidate(brackets = [[3,50],[7,10],[12,25]], income = 10) == 2.65000\n assert candidate(brackets = [[1,0],[4,25],[5,50]], income = 2) == 0.25000\n assert candidate(brackets = [[2,50]], income = 0) == 0.00000\n\n\ncheck(Solution().calculateTax)"}
232
121
coding
Solve the programming task below in a Python markdown code block. Initially, you have the array $a$ consisting of one element $1$ ($a = [1]$). In one move, you can do one of the following things: Increase some (single) element of $a$ by $1$ (choose some $i$ from $1$ to the current length of $a$ and increase $a_i$ b...
{"inputs": ["5\n2\n2\n18\n2\n1000001010\n", "5\n1\n4\n9\n129\n1000001000\n", "5\n2\n2\n16\n13\n1000000000\n", "5\n2\n13\n78\n7\n1000001100\n", "5\n2\n2\n18\n13\n1000001000\n", "5\n2\n7\n9\n284\n1000001000\n", "5\n1\n2\n9\n129\n1000001000\n", "5\n1\n4\n9\n110\n1000001010\n"], "outputs": ["1\n1\n7\n1\n63244\n", "0\n2\n4\...
518
338
coding
Solve the programming task below in a Python markdown code block. As Sherlock Holmes was investigating a crime, he identified n suspects. He knows for sure that exactly one of them committed the crime. To find out which one did it, the detective lines up the suspects and numbered them from 1 to n. After that, he asked ...
{"inputs": ["1 0\n-1\n", "1 1\n+1\n", "2 1\n+2\n+1\n", "2 0\n-2\n-2\n", "2 2\n+1\n+1\n", "3 1\n+2\n+3\n+3\n", "3 2\n-1\n+2\n+3\n", "3 0\n-2\n-2\n-2\n"], "outputs": ["Lie\n", "Truth\n", "Not defined\nNot defined\n", "Lie\nLie\n", "Truth\nTruth\n", "Truth\nLie\nLie\n", "Truth\nNot defined\nNot defined\n", "Lie\nLie\nLie\...
615
159
coding
Solve the programming task below in a Python markdown code block. Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two...
{"inputs": ["0 0 0", "4 0 13", "3 0 13", "6 0 13", "6 0 24", "1 25 5", "1 25 0", "2 25 0"], "outputs": ["-1\n", "0\n", "0\n", "0\n", "1\n", "0\n", "0\n", "0\n"]}
223
102
coding
Solve the programming task below in a Python markdown code block. You invited $n$ guests to dinner! You plan to arrange one or more circles of chairs. Each chair is going to be either occupied by one guest, or be empty. You can make any number of circles. Your guests happen to be a little bit shy, so the $i$-th guest...
{"inputs": ["1\n5 6\n", "1\n0 0\n", "1\n0 0\n", "1\n5 8\n", "1\n0 8\n", "1\n0 9\n", "1\n5 6\n", "2\n6 6\n3 3\n"], "outputs": ["7\n", "1\n", "1\n", "9\n", "9\n", "10\n", "7\n", "11\n"]}
468
108
coding
Solve the programming task below in a Python markdown code block. You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print None instead. -----Constraints...
{"inputs": ["atcoderregularcontest\n", "abcdefghijklmnopqrstuvwxyz\n", "fajsonlslfepbjtsaayxbymeskptcumtwrmkkinjxnnucagfrg\n"], "outputs": ["b\n", "None\n", "d\n"]}
175
59
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an m x n grid grid of values 0, 1, or 2, where: each 0 marks an empty land that you can pass by freely, each 1 marks a building that you cannot pass through, and each 2 marks an obstacle that you cannot...
{"functional": "def check(candidate):\n assert candidate(grid = [[1,0,2,0,1],[0,0,0,0,0],[0,0,1,0,0]]) == 7\n assert candidate(grid = [[1,0]]) == 1\n assert candidate(grid = [[1]]) == -1\n\n\ncheck(Solution().shortestDistance)"}
233
86
coding
Solve the programming task below in a Python markdown code block. You have a laser with P amount of energy in it. You are playing a game where you have to use the laser to destroy some crystals, each with some health of their own. Initially, you have 0 points. Each crystal has an associated health. The health of the it...
{"inputs": ["1\n200\n100"], "outputs": ["0"]}
514
20
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. There are n cities numbered from 1 to n. You are given an array edges of size n-1, where edges[i] = [ui, vi] represents a bidirectional edge between cities ui and vi. There exists a unique path between each pair of ci...
{"functional": "def check(candidate):\n assert candidate(n = 4, edges = [[1,2],[2,3],[2,4]]) == [3,4,0]\n assert candidate(n = 2, edges = [[1,2]]) == [1]\n assert candidate(n = 3, edges = [[1,2],[2,3]]) == [2,1]\n\n\ncheck(Solution().countSubgraphsForEachDiameter)"}
272
101
coding
Solve the programming task below in a Python markdown code block. Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive). -----Constraints----- - 1 \leq N \leq 10^4 - 1 \leq A \leq B \leq 36 - All input values are integers. -----Input----- In...
{"inputs": ["4 1 6", "2 0 8", "2 2 2", "3 0 4", "6 2 3", "6 2 5", "4 4 6", "5 1 0"], "outputs": ["10\n", "3\n", "2\n", "6\n", "5\n", "14\n", "4\n", "0\n"]}
223
96
coding
Solve the programming task below in a Python markdown code block. As we know, DZY loves playing games. One day DZY decided to play with a n × m matrix. To be more precise, he decided to modify the matrix with exactly k operations. Each modification is one of the following: 1. Pick some row of the matrix and decreas...
{"inputs": ["2 2 2 2\n1 6\n2 4\n", "2 2 5 2\n1 3\n2 8\n", "2 2 2 2\n1 6\n2 0\n", "2 2 5 2\n1 3\n0 8\n", "2 2 5 2\n1 3\n0 6\n", "2 2 5 2\n2 3\n0 6\n", "2 2 2 2\n1 3\n2 4\n", "2 2 5 2\n1 3\n2 4\n"], "outputs": ["16\n", "26\n", "11\n", "22\n", "14\n", "15\n", "11\n", "11\n"]}
423
190
coding
Solve the programming task below in a Python markdown code block. Given an array of integers, find the longest subarray where the absolute difference between any two elements is less than or equal to $\mbox{1}$. Example $a=[1,1,2,2,4,4,5,5,5]$ There are two subarrays meeting the criterion: $[1,1,2,2]$ and $[4,...
{"inputs": ["6\n4 6 5 3 3 1\n", "6\n1 2 2 3 1 2\n"], "outputs": ["3\n", "5\n"]}
465
46
coding
Solve the programming task below in a Python markdown code block. You are given a string $a$, consisting of $n$ characters, $n$ is even. For each $i$ from $1$ to $n$ $a_i$ is one of 'A', 'B' or 'C'. A bracket sequence is a string containing only characters "(" and ")". A regular bracket sequence is a bracket sequence ...
{"inputs": ["3\nAABB\nCAAB\nABCA\n", "3\nAABB\nCAAB\nABCA\n", "3\nAABB\nBAAC\nABCA\n", "3\nAAAB\nBAAC\nABCA\n", "3\nBAAA\nAABC\nABCA\n", "3\nAABB\nACAB\nABCA\n", "3\nBAAA\nAABB\nBACA\n", "3\nBAAA\nBAAC\nABCA\n"], "outputs": ["YES\nNO\nNO\n", "YES\nNO\nNO\n", "YES\nNO\nNO\n", "NO\nNO\nNO\n", "NO\nYES\nNO\n", "YES\nYES\n...
556
174
coding
Solve the programming task below in a Python markdown code block. Given an array of integers your solution should find the smallest integer. For example: - Given `[34, 15, 88, 2]` your solution will return `2` - Given `[34, -345, -1, 100]` your solution will return `-345` You can assume, for the purpose of this kat...
{"functional": "_inputs = [[[78, 56, 232, 12, 11, 43]], [[78, 56, -2, 12, 8, -33]], [[0, -18446744073709551615, 18446744073709551616]], [[-133, -5666, -89, -12341, -321423, 18446744073709551616]], [[0, 18446744073709551616, -18446744073709551617, 18446744073709551616, 18446744073709551616]], [[1, 2, 3, 4, 5, 6, 7, 8, 9...
127
564
coding
Solve the programming task below in a Python markdown code block. Inspired by the development team at Vooza, write the function `howManyLightsabersDoYouOwn`/`how_many_light_sabers_do_you_own` that * accepts the name of a programmer, and * returns the number of lightsabers owned by that person. The only person who ow...
{"functional": "_inputs = [['Zach'], ['zach']]\n_outputs = [[18], [0]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): return False\n ...
266
171
coding
Solve the programming task below in a Python markdown code block. Recently Vova found $n$ candy wrappers. He remembers that he bought $x$ candies during the first day, $2x$ candies during the second day, $4x$ candies during the third day, $\dots$, $2^{k-1} x$ candies during the $k$-th day. But there is an issue: Vova r...
{"inputs": ["1\n6\n", "1\n7\n", "1\n6\n", "1\n7\n", "1\n9\n", "1\n3\n", "1\n14\n", "1\n27\n"], "outputs": ["2\n", "1\n", "2\n", "1\n", "3\n", "1\n", "2\n", "9\n"]}
698
88
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.   Please complete the following python code precisely: ```python class So...
{"functional": "def check(candidate):\n assert candidate(haystack = \"sadbutsad\", needle = \"sad\") == 0\n assert candidate(haystack = \"leetcode\", needle = \"leeto\") == -1\n\n\ncheck(Solution().strStr)"}
81
61
coding
Solve the programming task below in a Python markdown code block. An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number. -----Constraints----- - 1?N?10^8 - N is an integer. ---...
{"inputs": ["1", "2", "3", "6", "8", "5", "4", "9"], "outputs": ["Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n"]}
164
62
coding
Solve the programming task below in a Python markdown code block. You are beta testing the new secret Terraria update. This update will add quests to the game! Simply, the world map can be represented as an array of length $n$, where the $i$-th column of the world has height $a_i$. There are $m$ quests you have to te...
{"inputs": ["10 1\n5 5 5 3 5 5 5 5 5 1\n10 7\n", "7 6\n10 8 9 6 8 12 7\n1 2\n1 7\n4 6\n7 1\n3 5\n4 2\n", "8 6\n1 2 3 4 5 6 7 8\n1 8\n7 1\n1 2\n2 3\n4 5\n4 5\n", "10 4\n1 1 1 1 1 1 1 1 1 1\n1 10\n10 1\n10 9\n1 2\n", "38 1\n2 999999999 2 999999999 2 999999999 2 999999999 2 999999999 2 999999999 2 999999999 2 999999999 2 ...
630
471
coding
Solve the programming task below in a Python markdown code block. There are $N$ friends in a group. Each of them have $A_{i}$ candies. Can they share all of these candies among themselves such that each one of them have equal no. of candies. -----Input:----- - First line will contain $T$, number of testcases. Then the...
{"inputs": ["1\n3\n1 2 3"], "outputs": ["Yes"]}
259
20
coding
Solve the programming task below in a Python markdown code block. This is another problem about Indraneel's library. His library has one long shelf. His books are numbered and he identifies the books by their number. Each book has a distinct number. He has lost many books, since many of his friends borrow his books and...
{"inputs": ["5\n26 1 42 15 3\n2\n3\n4"], "outputs": ["42\n3"]}
622
34
coding
Solve the programming task below in a Python markdown code block. We have a string S of length N consisting of A, T, C, and G. Strings T_1 and T_2 of the same length are said to be complementary when, for every i (1 \leq i \leq l), the i-th character of T_1 and the i-th character of T_2 are complementary. Here, A and T...
{"inputs": ["1 A\n", "4 AGCT\n", "4 ATAT\n", "10 AAATACCGCG\n"], "outputs": ["0\n", "2\n", "4\n", "6\n"]}
307
49
coding
Solve the programming task below in a Python markdown code block. Chef wants to give a burger party to all his N friends i.e. he wants to buy one burger for each of his friends. The cost of each burger is X rupees while Chef has a total of K rupees. Determine whether he has enough money to buy a burger for each of h...
{"inputs": ["4\n5 10 70\n5 10 40\n10 40 400\n14 14 150\n"], "outputs": ["YES\nNO\nYES\nNO\n"]}
555
56
coding
Solve the programming task below in a Python markdown code block. Write a program of the Bubble Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: BubbleSort(A) 1 for i = 0 to A.length-1 2 for j = A.length-1 downto i+1 3 if A[j] < A[j-1] ...
{"inputs": ["5\n7 3 2 4 1", "5\n7 3 2 3 1", "5\n7 3 2 3 0", "5\n7 3 4 3 0", "5\n7 1 4 3 0", "5\n7 1 4 3 1", "5\n4 2 4 3 1", "5\n4 2 5 3 1"], "outputs": ["1 2 3 4 7\n8\n", "1 2 3 3 7\n8\n", "0 2 3 3 7\n8\n", "0 3 3 4 7\n8\n", "0 1 3 4 7\n8\n", "1 1 3 4 7\n7\n", "1 2 3 4 4\n7\n", "1 2 3 4 5\n7\n"]}
288
222
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an n x n grid containing only values 0 and 1, where 0 represents water and 1 represents land, find a water cell such that its distance to the nearest land cell is maximized, and return the distance. If no land o...
{"functional": "def check(candidate):\n assert candidate(grid = [[1,0,1],[0,0,0],[1,0,1]]) == 2\n assert candidate(grid = [[1,0,0],[0,0,0],[0,0,0]]) == 4\n\n\ncheck(Solution().maxDistance)"}
163
75
coding
Solve the programming task below in a Python markdown code block. There are two rival donut shops. The first shop sells donuts at retail: each donut costs a dollars. The second shop sells donuts only in bulk: box of b donuts costs c dollars. So if you want to buy x donuts from this shop, then you have to buy the smal...
{"inputs": ["1\n8042 1 2\n", "1\n9353 1 2\n", "1\n12313 2 2\n", "1\n12313 1 2\n", "1\n13806 1 2\n", "1\n165 82 165\n", "1\n165 82 173\n", "1\n165 165 165\n"], "outputs": ["-1 1\n", "-1 1\n", "-1 2\n", "-1 1\n", "-1 1\n", "-1 82\n", "1 82\n", "-1 165\n"]}
762
173
coding
Solve the programming task below in a Python markdown code block. Theatre Square in the capital city of Berland has a rectangular shape with the size n × m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a × a. What...
{"inputs": ["s\ninput\n6 6 4\noutput\n4"], "outputs": [""]}
214
23
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. In a string s of lowercase letters, these letters form consecutive groups of the same character. For example, a string like s = "abbxxxxzyy" has the groups "a", "bb", "xxxx", "z", and "yy". A group is identified by an...
{"functional": "def check(candidate):\n assert candidate(s = \"abbxxxxzzy\") == [[3,6]]\n assert candidate(s = \"abc\") == []\n assert candidate(s = \"abcdddeeeeaabbbcd\") == [[3,5],[6,9],[12,14]]\n assert candidate(s = \"aba\") == []\n\n\ncheck(Solution().largeGroupPositions)"}
191
96
coding
Solve the programming task below in a Python markdown code block. Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi'...
{"inputs": ["121", "888", "435", "684", "394", "124", "143", "110"], "outputs": ["21\n", "271\n", "193\n", "243\n", "182\n", "24\n", "43\n", "10\n"]}
238
90
coding
Solve the programming task below in a Python markdown code block. There is a directed graph G with N vertices and M edges. The vertices are numbered 1, 2, \ldots, N, and for each i (1 \leq i \leq M), the i-th directed edge goes from Vertex x_i to y_i. G does not contain directed cycles. Find the length of the longest ...
{"inputs": ["6 3\n2 6\n4 5\n5 6", "6 3\n2 6\n4 6\n5 6", "6 3\n4 3\n3 5\n5 6", "7 3\n2 3\n4 5\n5 6", "7 3\n2 3\n1 5\n5 6", "6 3\n2 6\n4 5\n4 6", "7 1\n2 3\n4 5\n5 6", "6 3\n2 6\n4 6\n5 2"], "outputs": ["2\n", "1\n", "3\n", "2\n", "2\n", "1\n", "1\n", "2\n"]}
328
174
coding
Solve the programming task below in a Python markdown code block. Complete the function to determine the number of bits required to convert integer `A` to integer `B` (where `A` and `B` >= 0) The upper limit for `A` and `B` is 2^(16), `int.MaxValue` or similar. For example, you can change 31 to 14 by flipping the 4th...
{"functional": "_inputs = [[31, 14], [7, 17], [31, 0], [0, 0], [127681, 127681], [312312312, 5645657], [43, 2009989843]]\n_outputs = [[2], [3], [5], [0], [0], [13], [17]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs...
204
251
coding
Solve the programming task below in a Python markdown code block. We have a string of letters 'a' and 'b'. We want to perform some operations on it. On each step we choose one of substrings "ab" in the string and replace it with the string "bba". If we have no "ab" as a substring, our job is done. Print the minimum num...
{"inputs": ["ba\n", "ca\n", "ab\n", "aab\n", "abbaa\n", "bbbaa\n", "aabbb\n", "aabaa\n"], "outputs": ["0\n", "0\n", "1", "3", "2", "0\n", "9\n", "3\n"]}
239
73
coding
Solve the programming task below in a Python markdown code block. For a non-negative integer K, we define a fractal of level K as follows: * A fractal of level 0 is a grid with just one white square. * When K > 0, a fractal of level K is a 3^K \times 3^K grid. If we divide this grid into nine 3^{K-1} \times 3^{K-1} su...
{"inputs": ["2\n3 2 7 4\n9 9 1 9", "2\n3 2 7 4\n9 3 1 9", "2\n3 2 4 4\n7 3 1 9", "2\n3 2 6 4\n7 3 1 9", "2\n3 2 6 4\n4 3 1 9", "2\n3 2 6 4\n4 3 2 9", "2\n3 2 6 4\n4 3 2 4", "2\n3 4 6 4\n4 3 2 4"], "outputs": ["6\n8\n", "6\n14\n", "3\n12\n", "5\n12\n", "5\n9\n", "5\n8\n", "5\n3\n", "3\n3\n"]}
556
209
coding
Solve the programming task below in a Python markdown code block. Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some amount of snow every day. On day i he will make a pile of s...
{"inputs": ["1\n4\n5\n", "1\n5\n4\n", "1\n5\n5\n", "1\n5\n4\n", "1\n4\n5\n", "1\n5\n5\n", "1\n5\n2\n", "1\n4\n6\n"], "outputs": ["4\n", "4\n", "5\n", "4 ", "4 ", "5 ", "2\n", "4\n"]}
578
99
coding
Solve the programming task below in a Python markdown code block. Pete and his mate Phil are out in the countryside shooting clay pigeons with a shotgun - amazing fun. They decide to have a competition. 3 rounds, 2 shots each. Winner is the one with the most hits. Some of the clays have something attached to create ...
{"functional": "_inputs = [[[[{'P1': 'XX', 'P2': 'XO'}, True], [{'P1': 'OX', 'P2': 'OO'}, False], [{'P1': 'XX', 'P2': 'OX'}, True]]], [[[{'P1': 'XX', 'P2': 'XO'}, False], [{'P1': 'OX', 'P2': 'XX'}, False], [{'P1': 'OO', 'P2': 'XX'}, True]]], [[[{'P1': 'OO', 'P2': 'XX'}, False], [{'P1': 'OO', 'P2': 'XX'}, False], [{'P1'...
312
425
coding
Solve the programming task below in a Python markdown code block. There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies. You will take out the candies from some consecutive boxes and distribute them evenly to M children. Such being the case, find the number of the pairs...
{"inputs": ["1 2\n1\n", "1 2\n2\n", "3 2\n5 2 7", "3 2\n4 1 7", "3 2\n4 2 7", "3 2\n5 2 6", "3 1\n5 2 6", "3 2\n4 1 5"], "outputs": ["0\n", "1\n", "2\n", "3\n", "3\n", "3\n", "6\n", "3"]}
375
119
coding
Solve the programming task below in a Python markdown code block. Petya has a rectangular Board of size $n \times m$. Initially, $k$ chips are placed on the board, $i$-th chip is located in the cell at the intersection of $sx_i$-th row and $sy_i$-th column. In one action, Petya can move all the chips to the left, righ...
{"inputs": ["2 2 1\n1 1\n1 1\n", "2 2 1\n1 1\n2 2\n", "2 2 1\n1 1\n1 1\n", "2 2 1\n1 1\n2 2\n", "3 2 1\n1 1\n1 1\n", "2 2 1\n2 1\n2 2\n", "3 3 2\n1 2\n2 1\n3 3\n3 2\n", "2 5 2\n1 1\n1 1\n1 1\n1 1\n"], "outputs": ["5\nULRDL", "5\nULRDL", "5\nULRDL", "5\nULRDL", "8\nUULRDLDR", "5\nULRDL", "12\nUULLRRDLLDRR", "14\nULLLLRR...
648
216
coding
Solve the programming task below in a Python markdown code block. # Task You are given a positive integer `n`. We intend to make some ascending sequences according to the following rules: 1. Make a sequence of length 1: [ n ] 2. Or, insert a number to the left side of the sequence. But this number can not exceed h...
{"functional": "_inputs = [[6], [10], [1000]]\n_outputs = [[6], [14], [1981471878]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n if len(a) != len(b): return Fa...
534
180
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given three positive integers: n, index, and maxSum. You want to construct an array nums (0-indexed) that satisfies the following conditions: nums.length == n nums[i] is a positive integer where 0 <= i < n. a...
{"functional": "def check(candidate):\n assert candidate(n = 4, index = 2, maxSum = 6) == 2\n assert candidate(n = 6, index = 1, maxSum = 10) == 3\n\n\ncheck(Solution().maxValue)"}
180
68
coding
Solve the programming task below in a Python markdown code block. One upon a time there were three best friends Abhinav, Harsh, and Akash decided to form a team and take part in ICPC from KIIT. Participants are usually offered several problems during the programming contest. Long before the start, the friends decided...
{"inputs": ["3\n1 1 0\n1 1 1\n1 0 0"], "outputs": ["2"]}
403
30
coding
Solve the programming task below in a Python markdown code block. You are given a positive integer N. Find the number of the pairs of integers u and v (0≦u,v≦N) such that there exist two non-negative integers a and b satisfying a xor b=u and a+b=v. Here, xor denotes the bitwise exclusive OR. Since it can be extremely l...
{"inputs": ["4", "0", "1", "2", "7", "5", "8", "6"], "outputs": ["8\n", "1\n", "2\n", "4\n", "14\n", "10\n", "18\n", "13\n"]}
201
66
coding
Solve the programming task below in a Python markdown code block. This is the easy version of the problem. The difference in the constraints between both versions is colored below in red. You can make hacks only if all versions of the problem are solved. Marin and Gojou are playing hide-and-seek with an array. Gojou ...
{"inputs": ["3\n0 3\n3 2 1 0\n0 3\n4 7 6 5\n0 2\n1 2 3\n"], "outputs": ["0\n4\n3\n"]}
578
52
coding
Solve the programming task below in a Python markdown code block. You are given a graph with N vertices (numbered 1 to N) and M bidirectional edges, which doesn't contain multiple edges or self-loops — that is, the given graph is a simple undirected graph. For each pair of vertices a, b such that 1 ≤ a, b ≤ N, it is p...
{"inputs": ["3\n2 0\n5 4\n3 2\n1 4\n5 3\n4 2\n6 3\n1 2\n3 2\n1 3\n"], "outputs": ["1\n0\n3\n"]}
490
58
coding
Solve the programming task below in a Python markdown code block. In one little known, but very beautiful country called Waterland, lives a lovely shark Valerie. Like all the sharks, she has several rows of teeth, and feeds on crucians. One of Valerie's distinguishing features is that while eating one crucian she uses ...
{"inputs": ["1 1 0\n1 3\n", "2 2 13\n1 13\n2 12\n", "1 1 1000000\n1 1000000\n", "4 2 4\n1 9\n1 0\n1 4\n2 6\n", "4 2 4\n1 9\n1 1\n1 4\n2 6\n", "4 2 4\n1 4\n1 1\n1 4\n2 6\n", "4 2 8\n1 9\n1 10\n1 4\n2 6\n", "4 2 4\n1 9\n1 10\n1 4\n2 6\n"], "outputs": ["0\n", "13\n", "1000000\n", "4\n", "4\n", "4\n", "8\n", "4\n"]}
590
222
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. A sequence is special if it consists of a positive number of 0s, followed by a positive number of 1s, then a positive number of 2s. For example, [0,1,2] and [0,0,1,1,1,2] are special. In contrast, [2,1,0], [1], and [...
{"functional": "def check(candidate):\n assert candidate(nums = [0,1,2,2]) == 3\n assert candidate(nums = [2,2,0,0]) == 0\n assert candidate(nums = [0,1,2,0,1,2]) == 7\n\n\ncheck(Solution().countSpecialSubsequences)"}
234
79
coding
Solve the programming task below in a Python markdown code block. Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. You are a warrior and you have to fight $N$ enemy warriors (numbered $1$ through $N$) one by one, in any order you choose. You have to win as many o...
{"inputs": ["1\n3 4\n1 2 1\n10\n2\n3\n1"], "outputs": ["3\n2\n3\n0"]}
462
37
coding
Solve the programming task below in a Python markdown code block. There are N stones arranged in a row. The i-th stone from the left is painted in the color C_i. Snuke will perform the following operation zero or more times: * Choose two stones painted in the same color. Repaint all the stones between them, with the ...
{"inputs": ["5\n1\n4\n1\n2\n2", "5\n1\n2\n1\n2\n3", "5\n1\n2\n1\n2\n1", "5\n1\n2\n1\n3\n2", "5\n1\n2\n1\n5\n2", "5\n1\n2\n1\n1\n2", "5\n1\n3\n1\n1\n2", "5\n2\n3\n1\n1\n2"], "outputs": ["2\n", "3\n", "5\n", "3\n", "3\n", "3\n", "2\n", "2\n"]}
267
142
coding
Solve the programming task below in a Python markdown code block. The Chef is given an array of numbers and asked to find the first balance point of an array. A balance point is an index in the array N where the sum of the integers to the left of N is equal to the sum of the integers to the right of N. If there is no s...
{"inputs": ["2\n7\n7 8 9 1 9 8 7\n6\n1 100 50 -51 1 1"], "outputs": ["3\n1"]}
426
48
coding
Solve the programming task below in a Python markdown code block. Marcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other. Let's focus on the students. They are indexed with integer...
{"inputs": ["1\n1\n1\n", "1\n2\n1\n", "1\n2\n2\n", "1\n2\n0\n", "1\n3\n0\n", "1\n5\n1\n", "1\n5\n0\n", "1\n4\n0\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]}
538
102
coding
Solve the programming task below in a Python markdown code block. As AtCoder Beginner Contest 100 is taking place, the office of AtCoder, Inc. is decorated with a sequence of length N, a = {a_1, a_2, a_3, ..., a_N}. Snuke, an employee, would like to play with this sequence. Specifically, he would like to repeat the fo...
{"inputs": ["3\n5 2 8", "3\n5 3 8", "3\n5 2 7", "3\n3 3 8", "3\n5 2 4", "3\n5 2 4\n", "3\n3 3 11", "3\n3 5 11"], "outputs": ["4\n", "3\n", "1\n", "3\n", "3", "3\n", "0\n", "0\n"]}
436
112
coding
Solve the programming task below in a Python markdown code block. ### Vaccinations for children under 5 You have been put in charge of administrating vaccinations for children in your local area. Write a function that will generate a list of vaccines for each child presented for vaccination, based on the child's age an...
{"functional": "_inputs = [['12 weeks', 'up-to-date', 'december'], ['12 months', '16 weeks', 'june'], ['40 months', '12 months', 'october']]\n_outputs = [[['fiveInOne', 'rotavirus']], [['fiveInOne', 'hibMenC', 'measlesMumpsRubella', 'meningitisB', 'pneumococcal']], [['hibMenC', 'measlesMumpsRubella', 'meningitisB', 'of...
707
267
coding
Solve the programming task below in a Python markdown code block. Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well. You are given an array $A$ with $N$ integers. An array's score is defined as the bitwise AND of all its elements. You need to find the bitwise OR of the scores of all poss...
{"inputs": ["2\n3 2\n1 2 3\n1 4\n3 0\n4 1\n1 2 3 4\n4 0"], "outputs": ["3\n7\n6\n7\n3"]}
658
54
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. A subarray of a 0-indexed integer array is a contiguous non-empty sequence of elements within an array. The alternating subarray sum of a subarray that ranges from index i to j (inclusive, 0 <= i <= j < nums.length) i...
{"functional": "def check(candidate):\n assert candidate(nums = [3,-1,1,2]) == 5\n assert candidate(nums = [2,2,2,2,2]) == 2\n assert candidate(nums = [1]) == 1\n\n\ncheck(Solution().maximumAlternatingSubarraySum)"}
150
73
coding
Solve the programming task below in a Python markdown code block. Reading books is one of Sasha's passions. Once while he was reading one book, he became acquainted with an unusual character. The character told about himself like that: "Many are my names in many countries. Mithrandir among the Elves, Tharkûn to the Dwa...
{"inputs": ["f\n", "a\n", "g\n", "b\n", "e\n", "c\n", "h\n", "d\n"], "outputs": ["Impossible\n", "Impossible\n", "Impossible\n", "Impossible\n", "Impossible\n", "Impossible\n", "Impossible\n", "Impossible\n"]}
650
70
coding
Solve the programming task below in a Python markdown code block. "Point reflection" or "point symmetry" is a basic concept in geometry where a given point, P, at a given position relative to a mid-point, Q has a corresponding point, P1, which is the same distance from Q but in the opposite direction. ## Task Given t...
{"functional": "_inputs = [[[0, 0], [1, 1]], [[2, 6], [-2, -6]], [[10, -10], [-10, 10]], [[1, -35], [-12, 1]], [[1000, 15], [-7, -214]], [[0, 0], [0, 0]]]\n_outputs = [[[2, 2]], [[-6, -18]], [[-30, 30]], [[-25, 37]], [[-1014, -443]], [[0, 0]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or ...
185
283
coding
Solve the programming task below in a Python markdown code block. Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has $N$ dishes, numbered $1$ through $N$. For each valid $i$, dish $i$ is described by a string $D_{i}$ containing only lowercase vowels, i.e. c...
{"inputs": ["1\n3\naaooaoaooa\nuiieieiieieuuu\naeioooeeiiaiei"], "outputs": ["2"]}
636
36
coding
Solve the programming task below in a Python markdown code block. Probably everyone has experienced an awkward situation due to shared armrests between seats in cinemas. A highly accomplished cinema manager named "Chef" decided to solve this problem. When a customer wants to buy a ticket, the clerk at the ticket windo...
{"inputs": ["2\n2 2 3 2 1 1\n3 3 1 2 0 9"], "outputs": ["4\n8"]}
531
38
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given a 32-bit integer num, return a string representing its hexadecimal representation. For negative integers, two’s complement method is used. All the letters in the answer string should be lowercase characters, and...
{"functional": "def check(candidate):\n assert candidate(num = 26) == \"1a\"\n assert candidate(num = -1) == \"ffffffff\"\n\n\ncheck(Solution().toHex)"}
124
47
coding
Solve the programming task below in a Python markdown code block. # Pythagorean Triples A Pythagorean triplet is a set of three numbers a, b, and c where `a^2 + b^2 = c^2`. In this Kata, you will be tasked with finding the Pythagorean triplets whose product is equal to `n`, the given argument to the function `pythagor...
{"functional": "_inputs = [[60], [780], [2040], [4200], [12180], [120120], [192720], [328860], [907200], [1440600]]\n_outputs = [[[3, 4, 5]], [[5, 12, 13]], [[8, 15, 17]], [[7, 24, 25]], [[20, 21, 29]], [[33, 56, 65]], [[48, 55, 73]], [[60, 63, 87]], [[42, 144, 150]], [[49, 168, 175]]]\nimport math\ndef _deep_eq(a, b, ...
349
338
coding
Solve the programming task below in a Python markdown code block. Let us consider a grid of squares with 10^9 rows and N columns. Let (i, j) be the square at the i-th column (1 \leq i \leq N) from the left and j-th row (1 \leq j \leq 10^9) from the bottom. Snuke has cut out some part of the grid so that, for each i = ...
{"inputs": ["2\n4 2", "2\n2 2", "5\n2 1 2 1 2", "9\n3 3 5 4 1 2 4 2 1", "9\n2 3 7 4 1 2 4 2 1", "9\n2 3 4 4 1 2 4 2 1", "9\n2 3 2 4 1 2 4 2 1", "9\n2 3 2 4 1 2 4 2 2"], "outputs": ["24", "6", "256", "11520", "51200", "6400", "23040", "20736"]}
462
184
coding
Solve the programming task below in a Python markdown code block. In the current semester, you have taken X RTP courses, Y Audit courses and Z Non-RTP courses. The credit distribution for the courses are: 4 credits for clearing each RTP course. 2 credits for clearing each Audit course. No credits for clearing a Non-R...
{"inputs": ["4\n6 6 5\n8 7 2\n9 3 8\n9 2 4\n"], "outputs": ["36\n46\n42\n40\n"]}
746
48
coding
Solve the programming task below in a Python markdown code block. Counting sort can be used for sorting elements in an array which each of the n input elements is an integer in the range 0 to k. The idea of counting sort is to determine, for each input element x, the number of elements less than x as C[x]. This informa...
{"inputs": ["7\n2 5 1 3 2 3 1", "7\n2 5 1 3 4 3 1", "7\n2 5 2 3 4 3 1", "7\n4 5 2 3 4 3 1", "7\n4 9 2 3 4 3 1", "7\n4 9 2 3 4 3 2", "7\n4 9 2 1 4 3 2", "7\n4 9 2 0 4 3 3"], "outputs": ["1 1 2 2 3 3 5\n", "1 1 2 3 3 4 5\n", "1 2 2 3 3 4 5\n", "1 2 3 3 4 4 5\n", "1 2 3 3 4 4 9\n", "2 2 3 3 4 4 9\n", "1 2 2 3 4 4 9\n", "0...
421
270
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. You are given an array points containing the coordinates of points on a 2D plane, sorted by the x-values, where points[i] = [xi, yi] such that xi < xj for all 1 <= i < j <= points.length. You are also given an integer...
{"functional": "def check(candidate):\n assert candidate(points = [[1,3],[2,0],[5,10],[6,-10]], k = 1) == 4\n assert candidate(points = [[0,0],[3,0],[9,2]], k = 3) == 3\n\n\ncheck(Solution().findMaxValueOfEquation)"}
180
83
coding
Solve the programming task below in a Python markdown code block. You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string. In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at lea...
{"inputs": ["1\na\n", "1\nt\n", "1\nz\n", "1\nt\n", "1\nz\n", "1\na\n", "1\ns\n", "1\ny\n"], "outputs": ["0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]}
683
86
coding
Solve the programming task below in a Python markdown code block. Given an array A of length N, your task is to find the element which repeats in A maximum number of times as well as the corresponding count. In case of ties, choose the smaller element first. -----Input----- First line of input contains an integer T, d...
{"inputs": ["2\n5\n1 2 3 2 5\n6\n1 2 2 1 1 2\n\n"], "outputs": ["2 2\n1 3"]}
269
46
coding
Solve the programming task below in a Python markdown code block. Chef has two numbers X and Y. Chef wants to find three integers A, B, and C such that: -1000 ≤ A, B, C ≤ 1000 mean([A, B, C]) = X median([A, B, C]) = Y Can you help Chef find such three integers? As a reminder, mean([P, Q, R]) = \frac{P + Q + R}{3} and...
{"inputs": ["3\n5 5\n67 100\n4 5\n"], "outputs": ["5 5 5\n0 100 101\n0 5 7"]}
513
48
coding
Solve the programming task below in a Python markdown code block. You are given an integer K. Consider an integer sequence A = [A_{1}, A_{2}, \ldots, A_{N}]. Define another sequence S of length N, such that S_{i} = A_{1} + A_{2} + \ldots + A_{i} for each 1 ≤ i ≤ N. A is said to be *interesting* if A_{i} + S_{i} = K ...
{"inputs": ["2\n8\n4"], "outputs": ["3\n2"]}
498
18
coding
Solve the programming task below in a Python markdown code block. Iahub recently has learned Bubble Sort, an algorithm that is used to sort a permutation with n elements a_1, a_2, ..., a_{n} in ascending order. He is bored of this so simple algorithm, so he invents his own graph. The graph (let's call it G) initially h...
{"inputs": ["3\n3 1 2\n", "3\n3 1 3\n", "3\n2 1 3\n", "3\n3 1 2\n", "5\n4 2 1 3 5\n", "5\n4 2 1 3 5\n", "5\n4 2 1 2 5\n", "10\n1 9 8 10 2 3 4 6 5 7\n"], "outputs": ["2\n", "2\n", "2\n", "2\n", "3\n", "3\n", "3\n", "6\n"]}
496
146
coding
Please solve the programming task below using a self-contained code snippet in a markdown code block. Given an integer n, return true if it is a power of two. Otherwise, return false. An integer n is a power of two, if there exists an integer x such that n == 2x.   Please complete the following python code precisely: ...
{"functional": "def check(candidate):\n assert candidate(n = 1) == True\n assert candidate(n = 16) == True\n assert candidate(n = 3) == False\n\n\ncheck(Solution().isPowerOfTwo)"}
92
55