{"problem": "You are given two integers l and r, l≤ r. Find the largest possible value of a mod b over all pairs (a, b) of integers for which r≥ a ≥ b ≥ l.\n\nAs a reminder, a mod b is a remainder we get when dividing a by b. For example, 26 mod 8 = 2.\n\nInput\n\nEach test contains multiple test cases.\n\nThe first line contains one positive integer t (1≤ t≤ 10^4), denoting the number of test cases. Description of the test cases follows.\n\nThe only line of each test case contains two integers l, r (1≤ l ≤ r ≤ 10^9).\n\nOutput\n\nFor every test case, output the largest possible value of a mod b over all pairs (a, b) of integers for which r≥ a ≥ b ≥ l.\n\nExample\n\nInput\n\n\n4\n1 1\n999999999 1000000000\n8 26\n1 999999999\n\n\nOutput\n\n\n0\n1\n12\n499999999\n\nNote\n\nIn the first test case, the only allowed pair is (a, b) = (1, 1), for which a mod b = 1 mod 1 = 0.\n\nIn the second test case, the optimal choice is pair (a, b) = (1000000000, 999999999), for which a mod b = 1.", "test_cases": {"inputs": ["4\n1 1\n999999999 1000000000\n8 26\n1 999999999\n", "4\n1 1\n999999999 1000000000\n9 26\n1 999999999\n", "4\n1 1\n817823218 1000000000\n9 26\n1 999999999\n", "4\n1 1\n817823218 1000001000\n9 26\n1 999999999\n", "4\n1 1\n817823218 1000001100\n9 26\n1 999999999\n", "4\n1 1\n817823218 1000101100\n9 26\n1 999999999\n", "4\n1 1\n999999999 1000000000\n8 51\n1 999999999\n", "4\n1 1\n47273429 1000000000\n9 26\n1 999999999\n", "4\n1 2\n817823218 1000101100\n9 9\n1 999999999\n", "4\n1 1\n275585933 1000000000\n13 51\n1 999999999\n", "4\n1 2\n817823218 1000001100\n9 9\n1 999999999\n", "4\n1 1\n275585933 1000000000\n13 102\n1 999999999\n", "4\n1 1\n999999999 1000000000\n9 45\n1 999999999\n", "4\n1 1\n999999999 1000100000\n8 51\n1 999999999\n", "4\n1 1\n47273429 1000100000\n9 26\n1 999999999\n", "4\n1 1\n999999999 1000100001\n8 51\n1 999999999\n", "4\n1 1\n97511508 1000000000\n13 102\n1 1137810732\n", "4\n1 2\n47273429 1000100000\n9 26\n1 778959304\n", "4\n1 1\n42793887 1100000000\n6 51\n1 999999999\n", "4\n1 1\n42793887 1100000000\n6 24\n1 999999999\n", "4\n1 1\n117772020 1000000000\n13 102\n1 1716228987\n", "4\n1 1\n117772020 1010000000\n16 102\n2 1716228987\n", "4\n1 1\n999999999 1000000000\n9 26\n1 1780017340\n", "4\n1 1\n817823218 1000000000\n9 26\n1 1708560079\n", "4\n1 1\n80338547 1000101100\n9 26\n1 999999999\n", "4\n1 1\n999999999 1000000000\n13 51\n1 1652373546\n", "4\n1 2\n817823218 1010101100\n9 9\n1 999999999\n", "4\n1 1\n275585933 1000000000\n13 51\n1 260171240\n", "4\n1 2\n453480888 1000001100\n9 9\n1 999999999\n", "4\n1 1\n999999999 1000000000\n6 51\n1 91587037\n", "4\n1 1\n999999999 1000100001\n8 100\n1 999999999\n", "4\n1 2\n47273429 1000100000\n9 23\n1 999999999\n", "4\n1 1\n42793887 1000001000\n6 51\n1 999999999\n", "4\n1 1\n97511508 1000000000\n13 102\n1 1877902695\n", "4\n1 2\n47273429 1000100000\n9 26\n1 246478402\n", "4\n1 1\n117772020 1000000000\n13 139\n1 1137810732\n", "4\n1 1\n117772020 1000000000\n13 26\n2 1716228987\n", "4\n1 1\n45742919 1010000001\n16 102\n2 1716228987\n", "4\n1 1\n817823218 1000000000\n9 26\n1 1618244496\n", "4\n1 2\n817823218 1000001110\n9 26\n1 999999999\n", "4\n1 1\n999999999 1000000000\n13 25\n1 1652373546\n", "4\n1 2\n817823218 1010101100\n9 9\n1 322616884\n", "4\n1 1\n275585933 1000000000\n13 42\n2 999999999\n", "4\n1 1\n41505550 1000110000\n9 26\n1 999999999\n", "4\n1 1\n999999999 1000100001\n8 110\n1 999999999\n", "4\n1 1\n97511508 1000000100\n13 102\n1 1877902695\n", "4\n1 2\n47273429 1000110000\n9 26\n1 246478402\n", "4\n1 1\n185161768 1000000010\n13 102\n2 1137810732\n", "4\n1 1\n117772020 1000000000\n13 126\n1 1137810732\n", "4\n1 1\n117772020 1010000000\n4 102\n2 1844169080\n"], "outputs": ["0\n1\n12\n499999999\n", "0\n1\n12\n499999999\n", "0\n182176782\n12\n499999999\n", "0\n182177782\n12\n499999999\n", "0\n182177882\n12\n499999999\n", "0\n182277882\n12\n499999999\n", "0\n1\n25\n499999999\n", "0\n499999999\n12\n499999999\n", "0\n182277882\n0\n499999999\n", "0\n499999999\n25\n499999999\n", "0\n182177882\n0\n499999999\n", "0\n499999999\n50\n499999999\n", "0\n1\n22\n499999999\n", "0\n100001\n25\n499999999\n", "0\n500049999\n12\n499999999\n", "0\n100002\n25\n499999999\n", "0\n499999999\n50\n568905365\n", "0\n500049999\n12\n389479651\n", "0\n549999999\n25\n499999999\n", "0\n549999999\n11\n499999999\n", "0\n499999999\n50\n858114493\n", "0\n504999999\n50\n858114493\n", "0\n1\n12\n890008669\n", "0\n182176782\n12\n854280039\n", "0\n500050549\n12\n499999999\n", "0\n1\n25\n826186772\n", "0\n192277882\n0\n499999999\n", "0\n499999999\n25\n130085619\n", "0\n500000549\n0\n499999999\n", "0\n1\n25\n45793518\n", "0\n100002\n49\n499999999\n", "0\n500049999\n11\n499999999\n", "0\n500000499\n25\n499999999\n", "0\n499999999\n50\n938951347\n", "0\n500049999\n12\n123239200\n", "0\n499999999\n69\n568905365\n", "0\n499999999\n12\n858114493\n", "0\n505000000\n50\n858114493\n", "0\n182176782\n12\n809122247\n", "0\n182177892\n12\n499999999\n", "0\n1\n12\n826186772\n", "0\n192277882\n0\n161308441\n", "0\n499999999\n20\n499999999\n", "0\n500054999\n12\n499999999\n", "0\n100002\n54\n499999999\n", "0\n500000049\n50\n938951347\n", "0\n500054999\n12\n123239200\n", "0\n500000004\n50\n568905365\n", "0\n499999999\n62\n568905365\n", "0\n504999999\n50\n922084539\n"]}, "starter_code": "", "problem_sha1": "412a78d35d6dcc247c2d827b1d2b97e85e31fa12", "n_test_cases_total": 201, "n_test_cases_kept": 50, "test_cases_truncated": true, "seed_id": "cc-06491", "original_id": null, "source": "code_contests", "domain": "code", "test_case_format": "stdin_stdout", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": null} {"problem": "It is the easy version of the problem. The only difference is that in this version n = 1.\n\nIn the cinema seats can be represented as the table with n rows and m columns. The rows are numbered with integers from 1 to n. The seats in each row are numbered with consecutive integers from left to right: in the k-th row from m (k - 1) + 1 to m k for all rows 1 ≤ k ≤ n.\n\n1| 2| ⋅⋅⋅| m - 1| m \n---|---|---|---|--- \nm + 1| m + 2| ⋅⋅⋅| 2 m - 1| 2 m \n2m + 1| 2m + 2| ⋅⋅⋅| 3 m - 1| 3 m \n\\vdots| \\vdots| \\ddots| \\vdots| \\vdots \nm (n - 1) + 1| m (n - 1) + 2| ⋅⋅⋅| n m - 1| n m \nThe table with seats indices\n\nThere are nm people who want to go to the cinema to watch a new film. They are numbered with integers from 1 to nm. You should give exactly one seat to each person.\n\nIt is known, that in this cinema as lower seat index you have as better you can see everything happening on the screen. i-th person has the level of sight a_i. Let's define s_i as the seat index, that will be given to i-th person. You want to give better places for people with lower sight levels, so for any two people i, j such that a_i < a_j it should be satisfied that s_i < s_j.\n\nAfter you will give seats to all people they will start coming to their seats. In the order from 1 to nm, each person will enter the hall and sit in their seat. To get to their place, the person will go to their seat's row and start moving from the first seat in this row to theirs from left to right. While moving some places will be free, some will be occupied with people already seated. The inconvenience of the person is equal to the number of occupied seats he or she will go through.\n\nLet's consider an example: m = 5, the person has the seat 4 in the first row, the seats 1, 3, 5 in the first row are already occupied, the seats 2 and 4 are free. The inconvenience of this person will be 2, because he will go through occupied seats 1 and 3.\n\nFind the minimal total inconvenience (the sum of inconveniences of all people), that is possible to have by giving places for all people (all conditions should be satisfied).\n\nInput\n\nThe input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. Description of the test cases follows.\n\nThe first line of each test case contains two integers n and m (n = 1, 1 ≤ m ≤ 300) — the number of rows and places in each row respectively.\n\nThe second line of each test case contains n ⋅ m integers a_1, a_2, …, a_{n ⋅ m} (1 ≤ a_i ≤ 10^9), where a_i is the sight level of i-th person.\n\nIt's guaranteed that the sum of n ⋅ m over all test cases does not exceed 10^5.\n\nOutput\n\nFor each test case print a single integer — the minimal total inconvenience that can be achieved.\n\nExample\n\nInput\n\n\n4\n1 3\n1 2 3\n1 5\n2 1 5 3 3\n1 2\n2 1\n1 6\n2 3 2 1 1 1\n\n\nOutput\n\n\n3\n6\n0\n1\n\nNote\n\nIn the first test case, there is a single way to arrange people, because all sight levels are distinct. The first person will sit on the first seat, the second person will sit on the second place, the third person will sit on the third place. So inconvenience of the first person will be 0, inconvenience of the second person will be 1 and inconvenience of the third person will be 2. The total inconvenience is 0 + 1 + 2 = 3.\n\nIn the second test case, people should sit as follows: s_1 = 2, s_2 = 1, s_3 = 5, s_4 = 4, s_5 = 3. The total inconvenience will be 6.", "test_cases": {"inputs": ["4\n1 3\n1 2 3\n1 5\n2 1 5 3 3\n1 2\n2 1\n1 6\n2 3 2 1 1 1\n", "4\n1 3\n1 2 3\n1 5\n2 1 5 3 3\n1 2\n2 1\n1 6\n2 1 2 1 1 1\n", "4\n1 3\n1 2 3\n1 5\n3 1 10 3 3\n1 2\n2 1\n1 6\n2 1 2 1 1 1\n", "4\n1 3\n1 2 3\n1 5\n3 1 5 3 6\n1 2\n3 1\n1 6\n2 3 2 1 1 1\n", "4\n1 3\n1 3 3\n1 5\n3 1 10 3 2\n1 2\n2 0\n1 6\n2 1 2 1 1 1\n", "4\n1 3\n1 2 3\n1 5\n2 1 5 3 3\n1 2\n2 1\n1 6\n2 1 2 1 1 2\n", "4\n1 3\n1 2 3\n1 5\n3 1 5 3 6\n1 2\n3 1\n1 6\n3 3 2 1 1 1\n", "4\n1 3\n1 2 0\n1 5\n3 1 5 3 6\n1 2\n1 1\n1 6\n2 3 2 1 1 1\n", "4\n1 3\n1 3 3\n1 5\n3 1 10 3 2\n1 2\n1 0\n1 6\n2 1 2 1 2 1\n", "4\n1 3\n1 2 3\n1 5\n2 1 5 3 3\n1 2\n2 1\n1 6\n2 1 2 1 2 2\n", "4\n1 3\n1 2 0\n1 5\n3 1 5 3 10\n1 2\n1 1\n1 6\n2 3 2 1 2 1\n", "4\n1 3\n1 2 3\n1 5\n2 1 10 3 3\n1 2\n2 1\n1 6\n4 1 2 1 2 1\n", "4\n1 3\n1 2 3\n1 5\n2 1 5 3 6\n1 2\n3 1\n1 6\n2 3 2 1 1 1\n", "4\n1 3\n1 2 3\n1 5\n3 1 5 3 6\n1 2\n1 1\n1 6\n2 3 4 1 1 1\n", "4\n1 3\n1 2 3\n1 5\n2 1 4 3 2\n1 2\n2 1\n1 6\n2 3 2 1 1 1\n", "4\n1 3\n1 4 0\n1 5\n1 1 5 3 10\n1 2\n1 1\n1 6\n2 3 2 2 2 1\n", "4\n1 3\n1 2 3\n1 5\n2 1 5 3 6\n1 2\n2 1\n1 6\n2 1 2 2 2 2\n", "4\n1 3\n2 2 3\n1 5\n2 1 5 3 6\n1 2\n3 1\n1 6\n2 3 1 1 1 1\n", "4\n1 3\n2 2 3\n1 5\n2 1 5 3 6\n1 2\n3 1\n1 6\n2 3 1 1 2 1\n", "4\n1 3\n1 2 3\n1 5\n2 1 4 3 6\n1 2\n1 0\n1 6\n2 3 2 1 1 2\n", "4\n1 3\n2 2 3\n1 5\n2 1 5 3 6\n1 2\n3 1\n1 6\n3 3 1 1 2 1\n", "4\n1 3\n2 2 3\n1 5\n2 1 7 3 6\n1 2\n3 1\n1 6\n3 4 1 1 2 1\n", "4\n1 3\n2 1 2\n1 5\n2 1 7 3 6\n1 2\n3 1\n1 6\n3 4 1 1 2 1\n", "4\n1 3\n1 2 0\n1 5\n2 1 5 3 3\n1 2\n3 1\n1 6\n2 3 2 1 1 1\n", "4\n1 3\n1 3 3\n1 5\n3 1 10 4 2\n1 2\n1 0\n1 6\n2 1 2 1 1 1\n", "4\n1 3\n1 2 3\n1 5\n2 1 4 3 3\n1 2\n1 1\n1 6\n3 3 2 1 1 1\n", "4\n1 3\n1 2 3\n1 5\n2 1 5 3 3\n1 2\n2 1\n1 6\n2 1 2 1 3 2\n", "4\n1 3\n1 2 3\n1 5\n4 1 4 3 3\n1 2\n1 0\n1 6\n2 3 2 1 1 1\n", "4\n1 3\n1 4 0\n1 5\n1 1 5 3 10\n1 2\n1 1\n1 6\n4 3 2 2 2 1\n", "4\n1 3\n2 2 3\n1 5\n3 1 5 1 6\n1 2\n1 1\n1 6\n2 3 4 1 1 1\n", "4\n1 3\n1 1 4\n1 5\n1 1 5 3 5\n1 2\n2 1\n1 6\n2 3 2 1 1 1\n", "4\n1 3\n2 2 3\n1 5\n2 1 5 3 6\n1 2\n3 1\n1 6\n3 3 1 1 1 1\n", "4\n1 3\n2 2 3\n1 5\n2 1 4 3 6\n1 2\n1 0\n1 6\n2 3 2 1 1 3\n", "4\n1 3\n2 2 3\n1 5\n2 1 7 3 6\n1 2\n3 1\n1 6\n3 4 1 1 4 1\n", "4\n1 3\n1 3 3\n1 5\n3 1 10 4 2\n1 2\n1 0\n1 6\n1 1 2 1 1 1\n", "4\n1 3\n1 2 3\n1 5\n2 1 4 3 3\n1 2\n1 2\n1 6\n3 3 2 1 1 1\n", "4\n1 3\n1 2 3\n1 5\n4 1 5 3 3\n1 2\n2 1\n1 6\n2 1 2 1 3 2\n", "4\n1 3\n1 2 0\n1 5\n3 1 5 3 10\n1 2\n1 0\n1 6\n2 2 2 1 1 1\n", "4\n1 3\n1 3 3\n1 5\n2 1 4 3 3\n1 2\n1 1\n1 6\n2 8 2 1 1 1\n", "4\n1 3\n2 2 3\n1 5\n3 1 17 3 3\n1 2\n2 1\n1 6\n2 1 2 2 1 1\n", "4\n1 3\n1 2 4\n1 5\n2 1 5 3 5\n1 2\n2 0\n1 6\n1 3 2 1 1 1\n", "4\n1 3\n2 2 3\n1 5\n3 1 5 1 6\n1 2\n1 1\n1 6\n3 3 4 1 1 1\n", "4\n1 3\n2 2 3\n1 5\n2 1 5 3 0\n1 2\n3 1\n1 6\n3 3 1 1 1 1\n", "4\n1 3\n1 1 3\n1 5\n2 1 4 3 2\n1 2\n1 0\n1 6\n2 3 2 1 1 2\n", "4\n1 3\n1 3 3\n1 5\n4 1 5 3 3\n1 2\n2 1\n1 6\n2 1 2 1 3 2\n", "4\n1 3\n2 2 0\n1 5\n3 1 5 3 10\n1 2\n1 0\n1 6\n2 2 2 1 1 1\n", "4\n1 3\n2 2 2\n1 5\n3 1 9 3 11\n1 2\n1 1\n1 6\n2 3 2 1 1 1\n", "4\n1 3\n2 2 2\n1 5\n3 1 9 4 11\n1 2\n1 1\n1 6\n2 3 2 1 1 1\n", "4\n1 3\n1 3 4\n1 5\n2 1 5 3 7\n1 2\n4 0\n1 6\n1 2 2 1 1 1\n", "4\n1 3\n3 2 2\n1 5\n3 1 9 7 11\n1 2\n1 1\n1 6\n2 3 1 2 1 1\n"], "outputs": ["3\n6\n0\n1\n", "3\n6\n0\n1\n", "3\n4\n0\n1\n", "3\n7\n0\n1\n", "2\n4\n0\n1\n", "3\n6\n0\n4\n", "3\n7\n0\n0\n", "1\n7\n0\n1\n", "2\n4\n0\n3\n", "3\n6\n0\n5\n", "1\n7\n0\n2\n", "3\n6\n0\n3\n", "3\n8\n0\n1\n", "3\n7\n0\n3\n", "3\n5\n0\n1\n", "1\n8\n0\n1\n", "3\n8\n0\n4\n", "2\n8\n0\n1\n", "2\n8\n0\n3\n", "3\n8\n0\n3\n", "2\n8\n0\n2\n", "2\n7\n0\n3\n", "1\n7\n0\n3\n", "1\n6\n0\n1\n", "2\n5\n0\n1\n", "3\n6\n0\n0\n", "3\n6\n0\n7\n", "3\n3\n0\n1\n", "1\n8\n0\n0\n", "2\n6\n0\n3\n", "2\n7\n0\n1\n", "2\n8\n0\n0\n", "2\n8\n0\n5\n", "2\n7\n0\n4\n", "2\n5\n0\n2\n", "3\n6\n1\n0\n", "3\n4\n0\n7\n", "1\n7\n0\n0\n", "2\n6\n0\n1\n", "2\n4\n0\n2\n", "3\n7\n0\n2\n", "2\n6\n0\n2\n", "2\n4\n0\n0\n", "2\n5\n0\n3\n", "2\n4\n0\n7\n", "0\n7\n0\n0\n", "0\n7\n0\n1\n", "0\n8\n0\n1\n", "3\n8\n0\n2\n", "0\n8\n0\n2\n"]}, "starter_code": "", "problem_sha1": "b1ace83017d3cb0a41248973da40fc580530abd4", "n_test_cases_total": 201, "n_test_cases_kept": 50, "test_cases_truncated": true, "seed_id": "cc-06496", "original_id": null, "source": "code_contests", "domain": "code", "test_case_format": "stdin_stdout", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": null} {"problem": "There is a city that can be represented as a square grid with corner points in (0, 0) and (10^6, 10^6).\n\nThe city has n vertical and m horizontal streets that goes across the whole city, i. e. the i-th vertical streets goes from (x_i, 0) to (x_i, 10^6) and the j-th horizontal street goes from (0, y_j) to (10^6, y_j). \n\nAll streets are bidirectional. Borders of the city are streets as well.\n\nThere are k persons staying on the streets: the p-th person at point (x_p, y_p) (so either x_p equal to some x_i or y_p equal to some y_j, or both).\n\nLet's say that a pair of persons form an inconvenient pair if the shortest path from one person to another going only by streets is strictly greater than the Manhattan distance between them.\n\nCalculate the number of inconvenient pairs of persons (pairs (x, y) and (y, x) are the same pair).\n\nLet's recall that Manhattan distance between points (x_1, y_1) and (x_2, y_2) is |x_1 - x_2| + |y_1 - y_2|.\n\nInput\n\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases.\n\nThe first line of each test case contains three integers n, m and k (2 ≤ n, m ≤ 2 ⋅ 10^5; 2 ≤ k ≤ 3 ⋅ 10^5) — the number of vertical and horizontal streets and the number of persons.\n\nThe second line of each test case contains n integers x_1, x_2, ..., x_n (0 = x_1 < x_2 < ... < x_{n - 1} < x_n = 10^6) — the x-coordinates of vertical streets.\n\nThe third line contains m integers y_1, y_2, ..., y_m (0 = y_1 < y_2 < ... < y_{m - 1} < y_m = 10^6) — the y-coordinates of horizontal streets.\n\nNext k lines contains description of people. The p-th line contains two integers x_p and y_p (0 ≤ x_p, y_p ≤ 10^6; x_p ∈ \\\\{x_1, ..., x_n\\} or y_p ∈ \\\\{y_1, ..., y_m\\}) — the coordinates of the p-th person. All points are distinct.\n\nIt guaranteed that sum of n doesn't exceed 2 ⋅ 10^5, sum of m doesn't exceed 2 ⋅ 10^5 and sum of k doesn't exceed 3 ⋅ 10^5.\n\nOutput\n\nFor each test case, print the number of inconvenient pairs.\n\nExample\n\nInput\n\n\n2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n999999 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n2 5\n2 2\n6 3\n1000000 1\n3 8\n5 8\n8 8\n6 8\n\n\nOutput\n\n\n2\n5\n\nNote\n\nThe second test case is pictured below: \n\n\n\nFor example, points 3 and 4 form an inconvenient pair, since the shortest path between them (shown red and equal to 7) is greater than its Manhattan distance (equal to 5).\n\nPoints 3 and 5 also form an inconvenient pair: the shortest path equal to 1000001 (shown green) is greater than the Manhattan distance equal to 999999.\n\nBut points 5 and 9 don't form an inconvenient pair, since the shortest path (shown purple) is equal to its Manhattan distance.", "test_cases": {"inputs": ["2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n999999 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n2 5\n2 2\n6 3\n1000000 1\n3 8\n5 8\n8 8\n6 8\n", "1\n2 2 2\n0 1000000\n0 1000000\n1556 1000000\n0 34\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n999999 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n1 5\n2 2\n6 3\n1000000 1\n3 8\n5 8\n8 8\n6 8\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n999999 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n1 5\n2 2\n6 3\n1000000 1\n3 8\n2 8\n8 8\n6 8\n", "1\n2 2 2\n0 1010000\n0 1000000\n1556 1000000\n0 34\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 0\n999999 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n2 5\n2 2\n6 3\n1000000 1\n3 8\n5 8\n8 8\n6 8\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n999999 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n0 4\n1 5\n2 2\n6 3\n1000000 1\n3 8\n2 8\n8 8\n6 8\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 0\n999999 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n0 5\n2 4\n6 3\n1000000 1\n3 8\n2 5\n8 8\n6 8\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 0\n172846 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n8 4\n2 5\n2 2\n6 3\n1000000 1\n3 8\n5 8\n8 8\n6 8\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 0\n172846 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n8 4\n2 5\n2 2\n6 4\n1000000 1\n3 8\n5 8\n8 8\n6 8\n", "2\n2 2 4\n0 1000000\n0 1000000\n0 0\n1000000 0\n172846 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n8 4\n2 5\n2 2\n6 4\n1000000 1\n3 8\n5 8\n8 8\n6 8\n", "2\n2 2 4\n0 1000000\n0 1000000\n0 0\n1000000 0\n172846 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n8 4\n2 5\n2 4\n6 4\n1000000 1\n3 8\n5 8\n8 8\n6 8\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 0\n999999 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n2 5\n2 2\n6 3\n1000000 1\n3 8\n5 8\n8 8\n6 6\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n717934 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n1 3\n2 2\n6 3\n1000000 1\n3 8\n2 8\n8 8\n1 15\n", "2\n2 2 4\n0 1000000\n0 1000000\n2 0\n1000000 1\n999999 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n1 0\n2 4\n6 5\n1000000 1\n5 8\n2 5\n8 8\n6 8\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n999999 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000001\n4 4\n2 5\n2 2\n6 3\n1000000 1\n3 8\n2 1\n8 8\n6 8\n", "2\n2 2 4\n0 1000000\n0 1000000\n0 0\n1000000 0\n999999 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n2 5\n2 2\n6 3\n1000000 1\n3 8\n5 8\n8 8\n6 6\n", "2\n2 2 4\n0 1000000\n0 1000000\n2 0\n1000000 1\n999999 1000000\n0 999999\n5 4 1\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n1 5\n2 4\n6 3\n1000000 1\n3 8\n2 5\n8 8\n6 16\n", "2\n2 2 4\n0 1000000\n0 1000000\n0 0\n1000000 0\n172846 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n8 4\n2 5\n2 4\n6 4\n1000000 1\n3 8\n5 8\n6 8\n6 8\n", "2\n2 2 4\n0 1000000\n0 1000000\n0 0\n1000000 0\n999999 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n2 6\n2 2\n6 5\n1000000 1\n3 8\n5 8\n8 8\n6 6\n", "2\n2 2 4\n0 1000000\n0 1000000\n2 0\n1000000 0\n999999 1000000\n0 999999\n5 4 1\n0 0 2 6 1000000\n0 4 8 1000000\n4 4\n1 5\n2 4\n6 3\n1000000 1\n3 8\n1 1\n8 8\n6 16\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n999999 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n0 4\n1 5\n2 2\n6 3\n1000000 0\n3 8\n2 8\n8 8\n6 8\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 0\n717934 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n1 1\n2 2\n6 3\n1000000 1\n3 8\n2 8\n8 8\n1 15\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n717934 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n1 5\n2 2\n6 3\n1000000 1\n3 8\n2 8\n8 8\n6 8\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n717934 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n1 5\n2 2\n6 3\n1000000 1\n3 8\n2 8\n8 8\n1 8\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n999999 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n1 5\n2 2\n6 3\n1000000 1\n3 8\n2 5\n8 8\n6 8\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n999999 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000001\n4 4\n1 5\n2 2\n6 3\n1000000 1\n3 8\n2 5\n8 8\n6 8\n", "1\n2 2 2\n0 1000000\n0 1000000\n371 1000000\n0 34\n", "1\n2 2 2\n0 1010000\n0 1000000\n1556 1000000\n0 14\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n999999 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n1 5\n2 4\n6 3\n1000000 1\n3 8\n2 5\n8 8\n6 8\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n999999 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000001\n4 4\n1 5\n2 4\n6 3\n1000000 1\n3 8\n2 5\n8 8\n6 8\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n999999 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n0 5\n2 4\n6 3\n1000000 1\n3 8\n2 5\n8 8\n6 8\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n999999 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n1 5\n2 2\n6 3\n1000000 1\n3 8\n5 8\n8 8\n6 9\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n717934 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n1 5\n2 2\n6 3\n1000000 1\n3 8\n2 8\n8 8\n1 15\n", "1\n2 2 2\n0 1000000\n0 1000000\n721 1000000\n0 34\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 0\n172846 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n2 5\n2 2\n6 3\n1000000 1\n3 8\n5 8\n8 8\n6 8\n", "2\n2 2 4\n0 1000000\n0 1000000\n2 0\n1000000 1\n999999 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n1 5\n2 4\n6 3\n1000000 1\n3 8\n2 5\n8 8\n6 8\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n717934 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n1 5\n2 2\n6 2\n1000000 1\n3 8\n2 8\n8 8\n6 8\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n999999 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n1 5\n2 2\n6 3\n1000000 1\n6 8\n5 8\n8 8\n6 9\n", "1\n2 2 2\n0 1010000\n0 1000000\n721 1000000\n0 34\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 0\n75308 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n8 4\n2 5\n2 2\n6 4\n1000000 1\n3 8\n5 8\n8 8\n6 8\n", "2\n2 2 4\n0 1000000\n0 1000000\n0 0\n1000000 0\n313077 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n8 4\n2 5\n2 2\n6 4\n1000000 1\n3 8\n5 8\n8 8\n6 8\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 0\n75308 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n8 4\n2 5\n2 2\n6 4\n1000000 1\n3 8\n5 8\n8 8\n6 10\n", "2\n2 2 4\n0 1000000\n0 1000000\n0 0\n1000000 0\n313077 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n8 4\n2 5\n2 1\n6 4\n1000000 1\n3 8\n5 8\n8 8\n6 8\n", "1\n2 2 0\n0 1000000\n0 1000000\n1556 1000000\n0 34\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n999999 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n1 5\n2 2\n6 3\n1000000 1\n3 8\n1 8\n8 8\n6 8\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n999999 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n2 5\n2 2\n6 3\n1000000 1\n3 8\n2 8\n8 8\n6 8\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n717934 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n1 5\n2 2\n6 3\n1000000 1\n3 8\n2 11\n8 8\n1 8\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n999999 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000000\n4 4\n1 5\n2 4\n6 3\n1000000 1\n3 8\n2 5\n8 8\n6 0\n", "2\n2 2 4\n0 1000000\n0 1000000\n1 0\n1000000 1\n999999 1000000\n0 999999\n5 4 9\n0 1 2 6 1000000\n0 4 8 1000001\n4 0\n1 5\n2 2\n6 3\n1000000 1\n3 8\n2 5\n8 8\n6 8\n"], "outputs": ["2\n5\n", "0\n", "2\n5\n", "2\n4\n", "0\n", "1\n5\n", "2\n3\n", "1\n3\n", "1\n4\n", "1\n2\n", "0\n2\n", "0\n1\n", "1\n6\n", "2\n7\n", "2\n2\n", "2\n6\n", "0\n6\n", "2\n0\n", "0\n0\n", "0\n5\n", "1\n0\n", "2\n1\n", "1\n7\n", "2\n4\n", "2\n4\n", "2\n5\n", "2\n5\n", "0\n", "0\n", "2\n3\n", "2\n3\n", "2\n3\n", "2\n5\n", "2\n4\n", "0\n", "1\n5\n", "2\n3\n", "2\n4\n", "2\n4\n", "0\n", "1\n2\n", "0\n2\n", "1\n2\n", "0\n2\n", "0\n", "2\n4\n", "2\n4\n", "2\n4\n", "2\n3\n", "2\n5\n"]}, "starter_code": "", "problem_sha1": "d5264edff2dc456523ecd208ae4a4c41164dbdc8", "n_test_cases_total": 202, "n_test_cases_kept": 50, "test_cases_truncated": true, "seed_id": "cc-06501", "original_id": null, "source": "code_contests", "domain": "code", "test_case_format": "stdin_stdout", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": null} {"problem": "Recently, Petya learned about a new game \"Slay the Dragon\". As the name suggests, the player will have to fight with dragons. To defeat a dragon, you have to kill it and defend your castle. To do this, the player has a squad of n heroes, the strength of the i-th hero is equal to a_i.\n\nAccording to the rules of the game, exactly one hero should go kill the dragon, all the others will defend the castle. If the dragon's defense is equal to x, then you have to send a hero with a strength of at least x to kill it. If the dragon's attack power is y, then the total strength of the heroes defending the castle should be at least y.\n\nThe player can increase the strength of any hero by 1 for one gold coin. This operation can be done any number of times.\n\nThere are m dragons in the game, the i-th of them has defense equal to x_i and attack power equal to y_i. Petya was wondering what is the minimum number of coins he needs to spend to defeat the i-th dragon.\n\nNote that the task is solved independently for each dragon (improvements are not saved).\n\nInput\n\nThe first line contains a single integer n (2 ≤ n ≤ 2 ⋅ 10^5) — number of heroes.\n\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^{12}), where a_i is the strength of the i-th hero.\n\nThe third line contains a single integer m (1 ≤ m ≤ 2 ⋅ 10^5) — the number of dragons.\n\nThe next m lines contain two integers each, x_i and y_i (1 ≤ x_i ≤ 10^{12}; 1 ≤ y_i ≤ 10^{18}) — defense and attack power of the i-th dragon.\n\nOutput\n\nPrint m lines, i-th of which contains a single integer — the minimum number of coins that should be spent to defeat the i-th dragon.\n\nExample\n\nInput\n\n\n4\n3 6 2 3\n5\n3 12\n7 9\n4 14\n1 10\n8 7\n\n\nOutput\n\n\n1\n2\n4\n0\n2\n\nNote\n\nTo defeat the first dragon, you can increase the strength of the third hero by 1, then the strength of the heroes will be equal to [3, 6, 3, 3]. To kill the dragon, you can choose the first hero.\n\nTo defeat the second dragon, you can increase the forces of the second and third heroes by 1, then the strength of the heroes will be equal to [3, 7, 3, 3]. To kill the dragon, you can choose a second hero.\n\nTo defeat the third dragon, you can increase the strength of all the heroes by 1, then the strength of the heroes will be equal to [4, 7, 3, 4]. To kill the dragon, you can choose a fourth hero.\n\nTo defeat the fourth dragon, you don't need to improve the heroes and choose a third hero to kill the dragon.\n\nTo defeat the fifth dragon, you can increase the strength of the second hero by 2, then the strength of the heroes will be equal to [3, 8, 2, 3]. To kill the dragon, you can choose a second hero.", "test_cases": {"inputs": ["4\n3 6 2 3\n5\n3 12\n7 9\n4 14\n1 10\n8 7\n", "4\n3 5 2 3\n5\n3 12\n7 9\n4 14\n1 10\n8 7\n", "4\n3 5 2 3\n3\n3 12\n7 9\n4 14\n1 10\n8 7\n", "4\n3 5 2 3\n5\n3 12\n2 9\n4 14\n1 7\n8 7\n", "4\n3 5 2 3\n5\n3 12\n2 9\n4 14\n1 7\n8 13\n", "4\n3 5 2 3\n5\n3 12\n2 9\n4 14\n1 7\n14 13\n", "4\n3 5 2 3\n3\n3 12\n7 9\n4 11\n0 10\n8 7\n", "4\n3 5 2 3\n5\n3 12\n2 9\n1 14\n1 7\n14 13\n", "4\n3 5 2 4\n3\n3 12\n7 9\n4 11\n0 10\n8 7\n", "4\n3 5 2 3\n5\n3 12\n2 9\n1 14\n1 7\n14 17\n", "4\n3 5 4 4\n3\n3 12\n7 9\n4 11\n0 10\n8 7\n", "4\n3 5 4 4\n3\n3 12\n7 9\n7 11\n-1 10\n8 7\n", "4\n2 5 4 4\n3\n3 12\n7 9\n7 11\n0 10\n12 7\n", "4\n6 6 2 3\n5\n3 12\n7 9\n4 14\n1 10\n8 7\n", "4\n3 5 2 3\n5\n3 12\n7 5\n4 14\n1 10\n8 7\n", "4\n1 5 2 3\n5\n3 12\n7 9\n4 14\n1 7\n8 7\n", "4\n2 5 2 3\n3\n3 12\n7 9\n4 14\n2 10\n8 7\n", "4\n3 5 2 3\n3\n3 12\n7 9\n4 9\n0 10\n8 7\n", "4\n3 5 2 3\n5\n3 12\n2 15\n1 14\n1 7\n14 13\n", "4\n3 5 2 3\n5\n6 12\n2 9\n2 14\n1 7\n14 17\n", "4\n2 5 4 4\n3\n3 12\n7 13\n7 11\n0 10\n12 7\n", "4\n6 6 2 3\n5\n3 12\n7 9\n4 14\n1 10\n9 7\n", "4\n3 5 2 4\n5\n3 12\n7 5\n4 14\n1 10\n8 7\n", "4\n1 5 3 3\n5\n3 12\n7 9\n4 14\n1 7\n8 7\n", "4\n3 5 2 3\n3\n3 12\n7 9\n4 21\n1 6\n8 7\n", "4\n2 5 2 0\n3\n3 12\n7 9\n4 14\n2 10\n8 7\n", "4\n3 5 0 3\n3\n3 12\n7 9\n4 9\n0 10\n8 7\n", "4\n3 5 2 3\n5\n3 8\n2 15\n1 14\n1 7\n14 13\n", "4\n3 5 2 4\n3\n3 2\n7 9\n4 11\n0 10\n11 7\n", "4\n3 5 2 3\n3\n3 12\n1 9\n1 14\n1 7\n14 17\n", "4\n3 5 4 2\n3\n3 12\n7 9\n4 10\n0 10\n8 7\n", "4\n3 5 4 4\n1\n3 12\n7 9\n1 11\n-1 10\n8 7\n", "4\n3 5 3 4\n3\n3 12\n7 9\n7 11\n-1 10\n24 7\n", "4\n3 5 4 4\n3\n3 12\n12 8\n7 11\n0 10\n12 7\n", "4\n6 6 2 3\n5\n4 12\n7 9\n4 14\n1 10\n9 7\n", "4\n3 5 2 4\n5\n3 10\n7 5\n4 14\n1 10\n8 7\n", "4\n1 9 3 3\n5\n3 12\n7 9\n4 14\n1 7\n8 7\n", "4\n3 5 2 3\n3\n3 12\n7 17\n4 21\n1 6\n8 7\n", "4\n2 6 2 0\n3\n3 12\n7 9\n4 14\n2 10\n8 7\n", "4\n3 8 0 3\n3\n3 12\n7 9\n4 9\n0 10\n8 7\n", "4\n3 3 2 3\n5\n3 8\n2 15\n1 14\n1 7\n14 13\n", "4\n3 5 4 2\n3\n5 12\n7 9\n4 10\n0 10\n8 7\n", "4\n3 5 2 3\n5\n6 12\n2 22\n2 14\n1 7\n14 17\n", "4\n4 5 4 4\n3\n3 12\n7 13\n7 11\n-1 10\n12 7\n", "4\n6 6 2 3\n5\n4 12\n7 9\n7 14\n1 10\n9 7\n", "4\n1 9 3 3\n5\n5 12\n7 9\n4 14\n1 7\n8 7\n", "4\n3 5 2 3\n3\n3 12\n7 17\n7 21\n1 6\n8 7\n", "4\n2 6 2 0\n1\n3 12\n7 9\n4 14\n2 10\n8 7\n", "4\n5 8 0 3\n3\n3 12\n7 9\n4 9\n0 10\n8 7\n", "4\n3 5 2 3\n5\n6 4\n2 22\n2 14\n1 7\n14 17\n"], "outputs": ["1\n2\n4\n0\n2\n", "2\n3\n5\n0\n3\n", "2\n3\n5\n", "2\n0\n5\n0\n3\n", "2\n0\n5\n0\n8\n", "2\n0\n5\n0\n14\n", "2\n3\n2\n", "2\n0\n3\n0\n14\n", "1\n2\n1\n", "2\n0\n3\n0\n18\n", "0\n2\n0\n", "0\n2\n2\n", "1\n2\n3\n", "0\n1\n1\n0\n2\n", "2\n2\n5\n0\n3\n", "4\n5\n7\n0\n4\n", "3\n4\n6\n", "2\n3\n1\n", "2\n4\n3\n0\n14\n", "5\n0\n3\n0\n18\n", "1\n5\n3\n", "0\n1\n1\n0\n3\n", "1\n2\n4\n0\n3\n", "3\n4\n6\n0\n3\n", "2\n3\n12\n", "6\n7\n9\n", "4\n5\n2\n", "0\n4\n3\n0\n14\n", "0\n2\n1\n", "2\n0\n3\n", "1\n2\n0\n", "0\n", "0\n2\n3\n", "0\n7\n2\n", "1\n1\n1\n0\n3\n", "0\n2\n4\n0\n3\n", "0\n2\n2\n0\n0\n", "2\n11\n12\n", "5\n6\n8\n", "1\n3\n1\n", "0\n6\n5\n0\n16\n", "3\n2\n0\n", "5\n11\n3\n0\n18\n", "0\n3\n2\n", "1\n1\n4\n0\n3\n", "2\n2\n2\n0\n0\n", "2\n11\n15\n", "5\n", "0\n1\n0\n", "1\n11\n3\n0\n18\n"]}, "starter_code": "", "problem_sha1": "4cc59b30d310c9fd4f92294b788b92689ee6575f", "n_test_cases_total": 201, "n_test_cases_kept": 50, "test_cases_truncated": true, "seed_id": "cc-06506", "original_id": null, "source": "code_contests", "domain": "code", "test_case_format": "stdin_stdout", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": null} {"seed_id": "apps-00004", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given an array $a_1, a_2 \\dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \\le i < j < k < l \\le n$; $a_i = a_k$ and $a_j = a_l$; \n\n\n-----Input-----\n\nThe first line contains a single integer $t$ ($1 \\le t \\le 100$) — the number of test cases.\n\nThe first line of each test case contains a single integer $n$ ($4 \\le n \\le 3000$) — the size of the array $a$.\n\nThe second line of each test case contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le n$) — the array $a$.\n\nIt's guaranteed that the sum of $n$ in one test doesn't exceed $3000$.\n\n\n-----Output-----\n\nFor each test case, print the number of described tuples.\n\n\n-----Example-----\nInput\n2\n5\n2 2 2 2 2\n6\n1 3 3 1 2 3\n\nOutput\n5\n2\n\n\n\n-----Note-----\n\nIn the first test case, for any four indices $i < j < k < l$ are valid, so the answer is the number of tuples.\n\nIn the second test case, there are $2$ valid tuples: $(1, 2, 4, 6)$: $a_1 = a_4$ and $a_2 = a_6$; $(1, 3, 4, 6)$: $a_1 = a_4$ and $a_3 = a_6$.", "starter_code": "", "test_cases": {"inputs": ["2\n5\n2 2 2 2 2\n6\n1 3 3 1 2 3\n"], "outputs": ["5\n2\n"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "e0288c89f4f6ca80dd54b2990e4cda3456b08043", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00009", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given a string $s$ of even length $n$. String $s$ is binary, in other words, consists only of 0's and 1's.\n\nString $s$ has exactly $\\frac{n}{2}$ zeroes and $\\frac{n}{2}$ ones ($n$ is even).\n\nIn one operation you can reverse any substring of $s$. A substring of a string is a contiguous subsequence of that string.\n\nWhat is the minimum number of operations you need to make string $s$ alternating? A string is alternating if $s_i \\neq s_{i + 1}$ for all $i$. There are two types of alternating strings in general: 01010101... or 10101010...\n\n\n-----Input-----\n\nThe first line contains a single integer $t$ ($1 \\le t \\le 1000$) — the number of test cases.\n\nThe first line of each test case contains a single integer $n$ ($2 \\le n \\le 10^5$; $n$ is even) — the length of string $s$.\n\nThe second line of each test case contains a binary string $s$ of length $n$ ($s_i \\in$ {0, 1}). String $s$ has exactly $\\frac{n}{2}$ zeroes and $\\frac{n}{2}$ ones.\n\nIt's guaranteed that the total sum of $n$ over test cases doesn't exceed $10^5$.\n\n\n-----Output-----\n\nFor each test case, print the minimum number of operations to make $s$ alternating.\n\n\n-----Example-----\nInput\n3\n2\n10\n4\n0110\n8\n11101000\n\nOutput\n0\n1\n2\n\n\n\n-----Note-----\n\nIn the first test case, string 10 is already alternating.\n\nIn the second test case, we can, for example, reverse the last two elements of $s$ and get: 0110 $\\rightarrow$ 0101.\n\nIn the third test case, we can, for example, make the following two operations: 11101000 $\\rightarrow$ 10101100; 10101100 $\\rightarrow$ 10101010.", "starter_code": "", "test_cases": {"inputs": ["3\n2\n10\n4\n0110\n8\n11101000\n"], "outputs": ["0\n1\n2\n"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "5cdd0e1d434d2f2c39efbd500f307904f6e9e90c", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00014", "original_id": null, "source": "apps", "domain": "code", "problem": "In order to celebrate Twice's 5th anniversary, Tzuyu and Sana decided to play a game.\n\nTzuyu gave Sana two integers $a$ and $b$ and a really important quest.\n\nIn order to complete the quest, Sana has to output the smallest possible value of ($a \\oplus x$) + ($b \\oplus x$) for any given $x$, where $\\oplus$ denotes the bitwise XOR operation. \n\n\n-----Input-----\n\nEach test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \\le t \\le 10^{4}$). Description of the test cases follows.\n\nThe only line of each test case contains two integers $a$ and $b$ ($1 \\le a, b \\le 10^{9}$).\n\n\n-----Output-----\n\nFor each testcase, output the smallest possible value of the given expression.\n\n\n-----Example-----\nInput\n6\n6 12\n4 9\n59 832\n28 14\n4925 2912\n1 1\n\nOutput\n10\n13\n891\n18\n6237\n0\n\n\n\n-----Note-----\n\nFor the first test case Sana can choose $x=4$ and the value will be ($6 \\oplus 4$) + ($12 \\oplus 4$) = $2 + 8$ = $10$. It can be shown that this is the smallest possible value.", "starter_code": "", "test_cases": {"inputs": ["6\n6 12\n4 9\n59 832\n28 14\n4925 2912\n1 1\n"], "outputs": ["10\n13\n891\n18\n6237\n0\n"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "226efe8ef8da3c524395d9fea4b6e9086a76e860", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00019", "original_id": null, "source": "apps", "domain": "code", "problem": "Let's look at the following process: initially you have an empty stack and an array $s$ of the length $l$. You are trying to push array elements to the stack in the order $s_1, s_2, s_3, \\dots s_{l}$. Moreover, if the stack is empty or the element at the top of this stack is not equal to the current element, then you just push the current element to the top of the stack. Otherwise, you don't push the current element to the stack and, moreover, pop the top element of the stack. \n\nIf after this process the stack remains empty, the array $s$ is considered stack exterminable.\n\nThere are samples of stack exterminable arrays: $[1, 1]$; $[2, 1, 1, 2]$; $[1, 1, 2, 2]$; $[1, 3, 3, 1, 2, 2]$; $[3, 1, 3, 3, 1, 3]$; $[3, 3, 3, 3, 3, 3]$; $[5, 1, 2, 2, 1, 4, 4, 5]$; \n\nLet's consider the changing of stack more details if $s = [5, 1, 2, 2, 1, 4, 4, 5]$ (the top of stack is highlighted). after pushing $s_1 = 5$ the stack turn into $[\\textbf{5}]$; after pushing $s_2 = 1$ the stack turn into $[5, \\textbf{1}]$; after pushing $s_3 = 2$ the stack turn into $[5, 1, \\textbf{2}]$; after pushing $s_4 = 2$ the stack turn into $[5, \\textbf{1}]$; after pushing $s_5 = 1$ the stack turn into $[\\textbf{5}]$; after pushing $s_6 = 4$ the stack turn into $[5, \\textbf{4}]$; after pushing $s_7 = 4$ the stack turn into $[\\textbf{5}]$; after pushing $s_8 = 5$ the stack is empty. \n\nYou are given an array $a_1, a_2, \\ldots, a_n$. You have to calculate the number of its subarrays which are stack exterminable.\n\nNote, that you have to answer $q$ independent queries.\n\n\n-----Input-----\n\nThe first line contains one integer $q$ ($1 \\le q \\le 3 \\cdot 10^5$) — the number of queries.\n\nThe first line of each query contains one integer $n$ ($1 \\le n \\le 3 \\cdot 10^5$) — the length of array $a$.\n\nThe second line of each query contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($1 \\le a_i \\le n$) — the elements.\n\nIt is guaranteed that the sum of all $n$ over all queries does not exceed $3 \\cdot 10^5$.\n\n\n-----Output-----\n\nFor each test case print one integer in single line — the number of stack exterminable subarrays of the array $a$.\n\n\n-----Example-----\nInput\n3\n5\n2 1 1 2 2\n6\n1 2 1 1 3 2\n9\n3 1 2 2 1 6 6 3 3\n\nOutput\n4\n1\n8\n\n\n\n-----Note-----\n\nIn the first query there are four stack exterminable subarrays: $a_{1 \\ldots 4} = [2, 1, 1, 2], a_{2 \\ldots 3} = [1, 1], a_{2 \\ldots 5} = [1, 1, 2, 2], a_{4 \\ldots 5} = [2, 2]$.\n\nIn the second query, only one subarray is exterminable subarray — $a_{3 \\ldots 4}$.\n\nIn the third query, there are eight stack exterminable subarrays: $a_{1 \\ldots 8}, a_{2 \\ldots 5}, a_{2 \\ldots 7}, a_{2 \\ldots 9}, a_{3 \\ldots 4}, a_{6 \\ldots 7}, a_{6 \\ldots 9}, a_{8 \\ldots 9}$.", "starter_code": "", "test_cases": {"inputs": ["3\n5\n2 1 1 2 2\n6\n1 2 1 1 3 2\n9\n3 1 2 2 1 6 6 3 3\n"], "outputs": ["4\n1\n8\n"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "df0990f0b58a9b65304c40ec063661cedb474b4f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00024", "original_id": null, "source": "apps", "domain": "code", "problem": "Your music player contains N different songs and she wants to listen to L (not necessarily different) songs during your trip.  You create a playlist so that:\n\nEvery song is played at least once\nA song can only be played again only if K other songs have been played\n\nReturn the number of possible playlists.  As the answer can be very large, return it modulo 10^9 + 7.\n \n\n\n\nExample 1:\nInput: N = 3, L = 3, K = 1\nOutput: 6\nExplanation: There are 6 possible playlists. [1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1].\n\n\nExample 2:\nInput: N = 2, L = 3, K = 0\nOutput: 6\nExplanation: There are 6 possible playlists. [1, 1, 2], [1, 2, 1], [2, 1, 1], [2, 2, 1], [2, 1, 2], [1, 2, 2]\n\n\nExample 3:\nInput: N = 2, L = 3, K = 1\nOutput: 2\nExplanation: There are 2 possible playlists. [1, 2, 1], [2, 1, 2]\n\n\n\n \nNote:\n\n0 <= K < N <= L <= 100", "starter_code": "\nclass Solution:\n def numMusicPlaylists(self, N: int, L: int, K: int) -> int:\n ", "test_cases": {"inputs": [[3, 3, 1]], "outputs": [6], "fn_name": "numMusicPlaylists"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "fc35843ff3117648110fa8fd362ac5aaa00c6ec6", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "numMusicPlaylists"} {"seed_id": "apps-00029", "original_id": null, "source": "apps", "domain": "code", "problem": "Implement a basic calculator to evaluate a simple expression string.\n\nThe expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers and empty spaces .\n\nExample 1:\n\n\nInput: \"1 + 1\"\nOutput: 2\n\n\nExample 2:\n\n\nInput: \" 2-1 + 2 \"\nOutput: 3\n\nExample 3:\n\n\nInput: \"(1+(4+5+2)-3)+(6+8)\"\nOutput: 23\nNote:\n\n\n You may assume that the given expression is always valid.\n Do not use the eval built-in library function.", "starter_code": "\nclass Solution:\n def calculate(self, s: str) -> int:\n ", "test_cases": {"inputs": [["\"1 + 1\""]], "outputs": [2], "fn_name": "calculate"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "befd84df7cbe70b2c298080b8dd6c3c5e1612f4f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "calculate"} {"seed_id": "apps-00034", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an integer n, you must transform it into 0 using the following operations any number of times:\n\nChange the rightmost (0th) bit in the binary representation of n.\nChange the ith bit in the binary representation of n if the (i-1)th bit is set to 1 and the (i-2)th through 0th bits are set to 0.\n\nReturn the minimum number of operations to transform n into 0.\n \nExample 1:\nInput: n = 0\nOutput: 0\n\nExample 2:\nInput: n = 3\nOutput: 2\nExplanation: The binary representation of 3 is \"11\".\n\"11\" -> \"01\" with the 2nd operation since the 0th bit is 1.\n\"01\" -> \"00\" with the 1st operation.\n\nExample 3:\nInput: n = 6\nOutput: 4\nExplanation: The binary representation of 6 is \"110\".\n\"110\" -> \"010\" with the 2nd operation since the 1st bit is 1 and 0th through 0th bits are 0.\n\"010\" -> \"011\" with the 1st operation.\n\"011\" -> \"001\" with the 2nd operation since the 0th bit is 1.\n\"001\" -> \"000\" with the 1st operation.\n\nExample 4:\nInput: n = 9\nOutput: 14\n\nExample 5:\nInput: n = 333\nOutput: 393\n\n \nConstraints:\n\n0 <= n <= 109", "starter_code": "\nclass Solution:\n def minimumOneBitOperations(self, n: int) -> int:\n ", "test_cases": {"inputs": [[0]], "outputs": [0], "fn_name": "minimumOneBitOperations"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "fae44988f2cec5f9c018d4cc75e0def9d84921fe", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "minimumOneBitOperations"} {"seed_id": "apps-00039", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a list of strings, you need to find the longest uncommon subsequence among them. The longest uncommon subsequence is defined as the longest subsequence of one of these strings and this subsequence should not be any subsequence of the other strings.\n\n\n\nA subsequence is a sequence that can be derived from one sequence by deleting some characters without changing the order of the remaining elements. Trivially, any string is a subsequence of itself and an empty string is a subsequence of any string.\n\n\n\nThe input will be a list of strings, and the output needs to be the length of the longest uncommon subsequence. If the longest uncommon subsequence doesn't exist, return -1.\n\n\nExample 1:\n\nInput: \"aba\", \"cdc\", \"eae\"\nOutput: 3\n\n\n\nNote:\n\nAll the given strings' lengths will not exceed 10.\nThe length of the given list will be in the range of [2, 50].", "starter_code": "\nclass Solution:\n def findLUSlength(self, strs: List[str]) -> int:\n ", "test_cases": {"inputs": [[["\"aba\"", "\"cdc\"", "\"eae\""]]], "outputs": [5], "fn_name": "findLUSlength"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "fcebe0244209ad175df7491374cfde0434209bf9", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "findLUSlength"} {"seed_id": "apps-00044", "original_id": null, "source": "apps", "domain": "code", "problem": "There are n engineers numbered from 1 to n and two arrays: speed and efficiency, where speed[i] and efficiency[i] represent the speed and efficiency for the i-th engineer respectively. Return the maximum performance of a team composed of at most k engineers, since the answer can be a huge number, return this modulo 10^9 + 7.\nThe performance of a team is the sum of their engineers' speeds multiplied by the minimum efficiency among their engineers. \n \nExample 1:\nInput: n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 2\nOutput: 60\nExplanation: \nWe have the maximum performance of the team by selecting engineer 2 (with speed=10 and efficiency=4) and engineer 5 (with speed=5 and efficiency=7). That is, performance = (10 + 5) * min(4, 7) = 60.\n\nExample 2:\nInput: n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 3\nOutput: 68\nExplanation:\nThis is the same example as the first but k = 3. We can select engineer 1, engineer 2 and engineer 5 to get the maximum performance of the team. That is, performance = (2 + 10 + 5) * min(5, 4, 7) = 68.\n\nExample 3:\nInput: n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 4\nOutput: 72\n\n \nConstraints:\n\n1 <= n <= 10^5\nspeed.length == n\nefficiency.length == n\n1 <= speed[i] <= 10^5\n1 <= efficiency[i] <= 10^8\n1 <= k <= n", "starter_code": "\nclass Solution:\n def maxPerformance(self, n: int, speed: List[int], efficiency: List[int], k: int) -> int:\n ", "test_cases": {"inputs": [[6, [2, 10, 3, 1, 5, 8], [5, 4, 3, 9, 7, 2], 2]], "outputs": [60], "fn_name": "maxPerformance"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "f54270cea8795e3b7470861e8d8a792061f55c3d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "maxPerformance"} {"seed_id": "apps-00049", "original_id": null, "source": "apps", "domain": "code", "problem": "In universe Earth C-137, Rick discovered a special form of magnetic force between two balls if they are put in his new invented basket. Rick has n empty baskets, the ith basket is at position[i], Morty has m balls and needs to distribute the balls into the baskets such that the minimum magnetic force between any two balls is maximum.\nRick stated that magnetic force between two different balls at positions x and y is |x - y|.\nGiven the integer array position and the integer m. Return the required force.\n \nExample 1:\n\nInput: position = [1,2,3,4,7], m = 3\nOutput: 3\nExplanation: Distributing the 3 balls into baskets 1, 4 and 7 will make the magnetic force between ball pairs [3, 3, 6]. The minimum magnetic force is 3. We cannot achieve a larger minimum magnetic force than 3.\n\nExample 2:\nInput: position = [5,4,3,2,1,1000000000], m = 2\nOutput: 999999999\nExplanation: We can use baskets 1 and 1000000000.\n\n \nConstraints:\n\nn == position.length\n2 <= n <= 10^5\n1 <= position[i] <= 10^9\nAll integers in position are distinct.\n2 <= m <= position.length", "starter_code": "\nclass Solution:\n def maxDistance(self, position: List[int], m: int) -> int:\n ", "test_cases": {"inputs": [[[1, 2, 3, 4, 7], 3]], "outputs": [3], "fn_name": "maxDistance"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "8786dad9ba43873d3e78b8b1192fb52b095e02e0", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "maxDistance"} {"seed_id": "apps-00054", "original_id": null, "source": "apps", "domain": "code", "problem": "Strings A and B are K-similar (for some non-negative integer K) if we can swap the positions of two letters in A exactly K times so that the resulting string equals B.\nGiven two anagrams A and B, return the smallest K for which A and B are K-similar.\nExample 1:\nInput: A = \"ab\", B = \"ba\"\nOutput: 1\n\n\nExample 2:\nInput: A = \"abc\", B = \"bca\"\nOutput: 2\n\n\nExample 3:\nInput: A = \"abac\", B = \"baca\"\nOutput: 2\n\n\nExample 4:\nInput: A = \"aabc\", B = \"abca\"\nOutput: 2\n\n\n\nNote:\n\n1 <= A.length == B.length <= 20\nA and B contain only lowercase letters from the set {'a', 'b', 'c', 'd', 'e', 'f'}", "starter_code": "\nclass Solution:\n def kSimilarity(self, A: str, B: str) -> int:\n ", "test_cases": {"inputs": [["\"ab\"", "\"ba\""]], "outputs": [1], "fn_name": "kSimilarity"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "f798b42fc1183f42f13baf8a8c5406bef89250db", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "kSimilarity"} {"seed_id": "apps-00059", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a string s and a string t, check if s is subsequence of t.\n\n\n\nYou may assume that there is only lower case English letters in both s and t. t is potentially a very long (length ~= 500,000) string, and s is a short string (\n\n\nA subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, \"ace\" is a subsequence of \"abcde\" while \"aec\" is not).\n\n\nExample 1:\ns = \"abc\", t = \"ahbgdc\"\n\n\nReturn true.\n\n\nExample 2:\ns = \"axc\", t = \"ahbgdc\"\n\n\nReturn false.\n\n\nFollow up:\nIf there are lots of incoming S, say S1, S2, ... , Sk where k >= 1B, and you want to check one by one to see if T has its subsequence. In this scenario, how would you change your code?\n\nCredits:Special thanks to @pbrother for adding this problem and creating all test cases.", "starter_code": "\nclass Solution:\n def isSubsequence(self, s: str, t: str) -> bool:\n ", "test_cases": {"inputs": [["\"abc\"", "\"ahbgdc\""]], "outputs": [true], "fn_name": "isSubsequence"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "73bfd13336597dc3e71abbcaea1639278144d63c", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "isSubsequence"} {"seed_id": "apps-00064", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.\n\n\n\nFor example, given n = 2, return 1 (2 = 1 + 1); given n = 10, return 36 (10 = 3 + 3 + 4).\n\n\n\nNote: You may assume that n is not less than 2 and not larger than 58.\n\n\nCredits:Special thanks to @jianchao.li.fighter for adding this problem and creating all test cases.", "starter_code": "\nclass Solution:\n def integerBreak(self, n: int) -> int:\n ", "test_cases": {"inputs": [[2]], "outputs": [1], "fn_name": "integerBreak"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "24137cabff5745bec3cf1d8f2691237c4ddb7590", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "integerBreak"} {"seed_id": "apps-00069", "original_id": null, "source": "apps", "domain": "code", "problem": "Suppose we abstract our file system by a string in the following manner:\n\nThe string \"dir\\n\\tsubdir1\\n\\tsubdir2\\n\\t\\tfile.ext\" represents:\n\ndir\n subdir1\n subdir2\n file.ext\n\n\nThe directory dir contains an empty sub-directory subdir1 and a sub-directory subdir2 containing a file file.ext.\n\nThe string \"dir\\n\\tsubdir1\\n\\t\\tfile1.ext\\n\\t\\tsubsubdir1\\n\\tsubdir2\\n\\t\\tsubsubdir2\\n\\t\\t\\tfile2.ext\" represents:\n\ndir\n subdir1\n file1.ext\n subsubdir1\n subdir2\n subsubdir2\n file2.ext\n\n\nThe directory dir contains two sub-directories subdir1 and subdir2. subdir1 contains a file file1.ext and an empty second-level sub-directory subsubdir1. subdir2 contains a second-level sub-directory subsubdir2 containing a file file2.ext.\n\nWe are interested in finding the longest (number of characters) absolute path to a file within our file system. For example, in the second example above, the longest absolute path is \"dir/subdir2/subsubdir2/file2.ext\", and its length is 32 (not including the double quotes).\n\nGiven a string representing the file system in the above format, return the length of the longest absolute path to file in the abstracted file system. If there is no file in the system, return 0.\n\nNote:\n\nThe name of a file contains at least a . and an extension.\nThe name of a directory or sub-directory will not contain a ..\n\n\n\nTime complexity required: O(n) where n is the size of the input string.\n\nNotice that a/aa/aaa/file1.txt is not the longest file path, if there is another path aaaaaaaaaaaaaaaaaaaaa/sth.png.", "starter_code": "\nclass Solution:\n def lengthLongestPath(self, input: str) -> int:\n ", "test_cases": {"inputs": [["\"dir\\n\\tsubdir1\\n\\tsubdir2\\n\\t\\tfile.ext\""]], "outputs": [41], "fn_name": "lengthLongestPath"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "9da444d656c7cc327013929151a055099b57db2c", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "lengthLongestPath"} {"seed_id": "apps-00074", "original_id": null, "source": "apps", "domain": "code", "problem": "Say you have an array for which the ith element is the price of a given stock on day i.\n\nDesign an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times) with the following restrictions:\n\n\n You may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).\n After you sell your stock, you cannot buy stock on next day. (ie, cooldown 1 day)\n\n\nExample:\n\n\nInput: [1,2,3,0,2]\nOutput: 3 \nExplanation: transactions = [buy, sell, cooldown, buy, sell]", "starter_code": "\nclass Solution:\n def maxProfit(self, prices: List[int]) -> int:\n ", "test_cases": {"inputs": [[[1, 2, 3, 0, 2]]], "outputs": [3], "fn_name": "maxProfit"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "addba41d2021b0bdc69f3a95c1e62e331ccd4635", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "maxProfit"} {"seed_id": "apps-00079", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array of integers cost and an integer target. Return the maximum integer you can paint under the following rules:\n\nThe cost of painting a digit (i+1) is given by cost[i] (0 indexed).\nThe total cost used must be equal to target.\nInteger does not have digits 0.\n\nSince the answer may be too large, return it as string.\nIf there is no way to paint any integer given the condition, return \"0\".\n \nExample 1:\nInput: cost = [4,3,2,5,6,7,2,5,5], target = 9\nOutput: \"7772\"\nExplanation: The cost to paint the digit '7' is 2, and the digit '2' is 3. Then cost(\"7772\") = 2*3+ 3*1 = 9. You could also paint \"977\", but \"7772\" is the largest number.\nDigit cost\n 1 -> 4\n 2 -> 3\n 3 -> 2\n 4 -> 5\n 5 -> 6\n 6 -> 7\n 7 -> 2\n 8 -> 5\n 9 -> 5\n\nExample 2:\nInput: cost = [7,6,5,5,5,6,8,7,8], target = 12\nOutput: \"85\"\nExplanation: The cost to paint the digit '8' is 7, and the digit '5' is 5. Then cost(\"85\") = 7 + 5 = 12.\n\nExample 3:\nInput: cost = [2,4,6,2,4,6,4,4,4], target = 5\nOutput: \"0\"\nExplanation: It's not possible to paint any integer with total cost equal to target.\n\nExample 4:\nInput: cost = [6,10,15,40,40,40,40,40,40], target = 47\nOutput: \"32211\"\n\n \nConstraints:\n\ncost.length == 9\n1 <= cost[i] <= 5000\n1 <= target <= 5000", "starter_code": "\nclass Solution:\n def largestNumber(self, cost: List[int], target: int) -> str:\n ", "test_cases": {"inputs": [[[4, 3, 2, 5, 6, 7, 2, 5, 5], 9]], "outputs": ["7772"], "fn_name": "largestNumber"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "46639ff39e8dd486a785e5a763eabd056e09bcc1", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "largestNumber"} {"seed_id": "apps-00084", "original_id": null, "source": "apps", "domain": "code", "problem": "There are 3n piles of coins of varying size, you and your friends will take piles of coins as follows:\n\nIn each step, you will choose any 3 piles of coins (not necessarily consecutive).\nOf your choice, Alice will pick the pile with the maximum number of coins.\nYou will pick the next pile with maximum number of coins.\nYour friend Bob will pick the last pile.\nRepeat until there are no more piles of coins.\n\nGiven an array of integers piles where piles[i] is the number of coins in the ith pile.\nReturn the maximum number of coins which you can have.\n \nExample 1:\nInput: piles = [2,4,1,2,7,8]\nOutput: 9\nExplanation: Choose the triplet (2, 7, 8), Alice Pick the pile with 8 coins, you the pile with 7 coins and Bob the last one.\nChoose the triplet (1, 2, 4), Alice Pick the pile with 4 coins, you the pile with 2 coins and Bob the last one.\nThe maximum number of coins which you can have are: 7 + 2 = 9.\nOn the other hand if we choose this arrangement (1, 2, 8), (2, 4, 7) you only get 2 + 4 = 6 coins which is not optimal.\n\nExample 2:\nInput: piles = [2,4,5]\nOutput: 4\n\nExample 3:\nInput: piles = [9,8,7,6,5,1,2,3,4]\nOutput: 18\n\n \nConstraints:\n\n3 <= piles.length <= 10^5\npiles.length % 3 == 0\n1 <= piles[i] <= 10^4", "starter_code": "\nclass Solution:\n def maxCoins(self, piles: List[int]) -> int:\n ", "test_cases": {"inputs": [[[1, 2, 2, 4, 7, 8]]], "outputs": [9], "fn_name": "maxCoins"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "1bb7d705bf9b569d9f0ec184537bae5c233062f4", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "maxCoins"} {"seed_id": "apps-00089", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a string s, determine if it is valid.\nA string s is valid if, starting with an empty string t = \"\", you can transform t into s after performing the following operation any number of times:\n\nInsert string \"abc\" into any position in t. More formally, t becomes tleft + \"abc\" + tright, where t == tleft + tright. Note that tleft and tright may be empty.\n\nReturn true if s is a valid string, otherwise, return false.\n \nExample 1:\nInput: s = \"aabcbc\"\nOutput: true\nExplanation:\n\"\" -> \"abc\" -> \"aabcbc\"\nThus, \"aabcbc\" is valid.\nExample 2:\nInput: s = \"abcabcababcc\"\nOutput: true\nExplanation:\n\"\" -> \"abc\" -> \"abcabc\" -> \"abcabcabc\" -> \"abcabcababcc\"\nThus, \"abcabcababcc\" is valid.\n\nExample 3:\nInput: s = \"abccba\"\nOutput: false\nExplanation: It is impossible to get \"abccba\" using the operation.\n\nExample 4:\nInput: s = \"cababc\"\nOutput: false\nExplanation: It is impossible to get \"cababc\" using the operation.\n\n \nConstraints:\n\n1 <= s.length <= 2 * 104\ns consists of letters 'a', 'b', and 'c'", "starter_code": "\nclass Solution:\n def isValid(self, s: str) -> bool:\n ", "test_cases": {"inputs": [["\"aabcbc\""]], "outputs": [false], "fn_name": "isValid"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "08652a52b5f58322d61d870ea981c3f03b9723d7", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "isValid"} {"seed_id": "apps-00094", "original_id": null, "source": "apps", "domain": "code", "problem": "Let's call any (contiguous) subarray B (of A) a mountain if the following properties hold:\n\nB.length >= 3\nThere exists some 0 < i < B.length - 1 such that B[0] < B[1] < ... B[i-1] < B[i] > B[i+1] > ... > B[B.length - 1]\n\n(Note that B could be any subarray of A, including the entire array A.)\nGiven an array A of integers, return the length of the longest mountain. \nReturn 0 if there is no mountain.\nExample 1:\nInput: [2,1,4,7,3,2,5]\nOutput: 5\nExplanation: The largest mountain is [1,4,7,3,2] which has length 5.\n\nExample 2:\nInput: [2,2,2]\nOutput: 0\nExplanation: There is no mountain.\n\nNote:\n\n0 <= A.length <= 10000\n0 <= A[i] <= 10000\n\nFollow up:\n\nCan you solve it using only one pass?\nCan you solve it in O(1) space?", "starter_code": "\nclass Solution:\n def longestMountain(self, A: List[int]) -> int:\n ", "test_cases": {"inputs": [[[2, 1, 4, 7, 3, 2, 5]]], "outputs": [5], "fn_name": "longestMountain"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "7169416cf76b495200fd13f61765f4e0d8729966", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "longestMountain"} {"seed_id": "apps-00099", "original_id": null, "source": "apps", "domain": "code", "problem": "In the world of Dota2, there are two parties: the Radiant and the Dire.\n\n\n\nThe Dota2 senate consists of senators coming from two parties. Now the senate wants to make a decision about a change in the Dota2 game. The voting for this change is a round-based procedure. In each round, each senator can exercise one of the two rights:\n\nBan one senator's right: A senator can make another senator lose all his rights in this and all the following rounds.\nAnnounce the victory: If this senator found the senators who still have rights to vote are all from the same party, he can announce the victory and make the decision about the change in the game.\n\n\n\n\nGiven a string representing each senator's party belonging. The character 'R' and 'D' represent the Radiant party and the Dire party respectively. Then if there are n senators, the size of the given string will be n.\n\n\n\nThe round-based procedure starts from the first senator to the last senator in the given order. This procedure will last until the end of voting. All the senators who have lost their rights will be skipped during the procedure.\n\n\n\nSuppose every senator is smart enough and will play the best strategy for his own party, you need to predict which party will finally announce the victory and make the change in the Dota2 game. The output should be Radiant or Dire.\n\n\nExample 1:\n\nInput: \"RD\"\nOutput: \"Radiant\"\nExplanation: The first senator comes from Radiant and he can just ban the next senator's right in the round 1. And the second senator can't exercise any rights any more since his right has been banned. And in the round 2, the first senator can just announce the victory since he is the only guy in the senate who can vote.\n\n\n\n\nExample 2:\n\nInput: \"RDD\"\nOutput: \"Dire\"\nExplanation: \nThe first senator comes from Radiant and he can just ban the next senator's right in the round 1. And the second senator can't exercise any rights anymore since his right has been banned. And the third senator comes from Dire and he can ban the first senator's right in the round 1. And in the round 2, the third senator can just announce the victory since he is the only guy in the senate who can vote.\n\n\n\nNote:\n\nThe length of the given string will in the range [1, 10,000].", "starter_code": "\nclass Solution:\n def predictPartyVictory(self, senate: str) -> str:\n ", "test_cases": {"inputs": [["\"RD\""]], "outputs": ["Dire"], "fn_name": "predictPartyVictory"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "e040f4e6a7b3091476f08a5780f76fbfb1eb7d8d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "predictPartyVictory"} {"seed_id": "apps-00104", "original_id": null, "source": "apps", "domain": "code", "problem": "Implement pow(x, n), which calculates x raised to the power n (xn).\n\nExample 1:\n\n\nInput: 2.00000, 10\nOutput: 1024.00000\n\n\nExample 2:\n\n\nInput: 2.10000, 3\nOutput: 9.26100\n\n\nExample 3:\n\n\nInput: 2.00000, -2\nOutput: 0.25000\nExplanation: 2-2 = 1/22 = 1/4 = 0.25\n\n\nNote:\n\n\n -100.0 < x < 100.0\n n is a 32-bit signed integer, within the range [−231, 231 − 1]", "starter_code": "\nclass Solution:\n def myPow(self, x: float, n: int) -> float:\n ", "test_cases": {"inputs": [[2.0, 10]], "outputs": [1024.0], "fn_name": "myPow"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "a05f0e13f5a59f25e2379a9ce5081c2e2c79f342", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "myPow"} {"seed_id": "apps-00109", "original_id": null, "source": "apps", "domain": "code", "problem": "We are given hours, a list of the number of hours worked per day for a given employee.\nA day is considered to be a tiring day if and only if the number of hours worked is (strictly) greater than 8.\nA well-performing interval is an interval of days for which the number of tiring days is strictly larger than the number of non-tiring days.\nReturn the length of the longest well-performing interval.\n \nExample 1:\nInput: hours = [9,9,6,0,6,6,9]\nOutput: 3\nExplanation: The longest well-performing interval is [9,9,6].\n\n \nConstraints:\n\n1 <= hours.length <= 10000\n0 <= hours[i] <= 16", "starter_code": "\nclass Solution:\n def longestWPI(self, hours: List[int]) -> int:\n ", "test_cases": {"inputs": [[[9, 9, 6, 0, 6, 6, 9]]], "outputs": [3], "fn_name": "longestWPI"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "f6bb1ba11782c486a41846031aeb5da4a8199cd8", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "longestWPI"} {"seed_id": "apps-00114", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a string S and a string T, count the number of distinct subsequences of S which equals T.\n\nA subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, \"ACE\" is a subsequence of \"ABCDE\" while \"AEC\" is not).\n\nExample 1:\n\n\nInput: S = \"rabbbit\", T = \"rabbit\"\nOutput: 3\nExplanation:\n\nAs shown below, there are 3 ways you can generate \"rabbit\" from S.\n(The caret symbol ^ means the chosen letters)\n\nrabbbit\n^^^^ ^^\nrabbbit\n^^ ^^^^\nrabbbit\n^^^ ^^^\n\n\nExample 2:\n\n\nInput: S = \"babgbag\", T = \"bag\"\nOutput: 5\nExplanation:\n\nAs shown below, there are 5 ways you can generate \"bag\" from S.\n(The caret symbol ^ means the chosen letters)\n\nbabgbag\n^^ ^\nbabgbag\n^^ ^\nbabgbag\n^ ^^\nbabgbag\n ^ ^^\nbabgbag\n ^^^", "starter_code": "\nclass Solution:\n def numDistinct(self, s: str, t: str) -> int:\n ", "test_cases": {"inputs": [["\"rabbbit\"", "\"rabbit\""]], "outputs": [3], "fn_name": "numDistinct"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "a07db7adeab15cadf1f9b0507037d464144b0ab4", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "numDistinct"} {"seed_id": "apps-00119", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array of integers A with even length, return true if and only if it is possible to reorder it such that A[2 * i + 1] = 2 * A[2 * i] for every 0 <= i < len(A) / 2.\n\n\n\n\n\n\n\n\n \nExample 1:\nInput: A = [3,1,3,6]\nOutput: false\n\nExample 2:\nInput: A = [2,1,2,6]\nOutput: false\n\nExample 3:\nInput: A = [4,-2,2,-4]\nOutput: true\nExplanation: We can take two groups, [-2,-4] and [2,4] to form [-2,-4,2,4] or [2,4,-2,-4].\n\nExample 4:\nInput: A = [1,2,4,16,8,4]\nOutput: false\n\n \nConstraints:\n\n0 <= A.length <= 3 * 104\nA.length is even.\n-105 <= A[i] <= 105", "starter_code": "\nclass Solution:\n def canReorderDoubled(self, A: List[int]) -> bool:\n ", "test_cases": {"inputs": [[[3, 1, 3, 6]]], "outputs": [false], "fn_name": "canReorderDoubled"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "35ef379003e0fea250f70e60ca6cbb2cb01fba20", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "canReorderDoubled"} {"seed_id": "apps-00124", "original_id": null, "source": "apps", "domain": "code", "problem": "A string of '0's and '1's is monotone increasing if it consists of some number of '0's (possibly 0), followed by some number of '1's (also possibly 0.)\nWe are given a string S of '0's and '1's, and we may flip any '0' to a '1' or a '1' to a '0'.\nReturn the minimum number of flips to make S monotone increasing.\n \n\nExample 1:\nInput: \"00110\"\nOutput: 1\nExplanation: We flip the last digit to get 00111.\n\n\nExample 2:\nInput: \"010110\"\nOutput: 2\nExplanation: We flip to get 011111, or alternatively 000111.\n\n\nExample 3:\nInput: \"00011000\"\nOutput: 2\nExplanation: We flip to get 00000000.\n\n \nNote:\n\n1 <= S.length <= 20000\nS only consists of '0' and '1' characters.", "starter_code": "\nclass Solution:\n def minFlipsMonoIncr(self, S: str) -> int:\n ", "test_cases": {"inputs": [["\"00110\""]], "outputs": [2], "fn_name": "minFlipsMonoIncr"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "7be82fbb5518092f7f33e6c13f7ad4c8cf450040", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "minFlipsMonoIncr"} {"seed_id": "apps-00129", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array nums of positive integers, return the longest possible length of an array prefix of nums, such that it is possible to remove exactly one element from this prefix so that every number that has appeared in it will have the same number of occurrences.\nIf after removing one element there are no remaining elements, it's still considered that every appeared number has the same number of ocurrences (0).\n \nExample 1:\nInput: nums = [2,2,1,1,5,3,3,5]\nOutput: 7\nExplanation: For the subarray [2,2,1,1,5,3,3] of length 7, if we remove nums[4]=5, we will get [2,2,1,1,3,3], so that each number will appear exactly twice.\n\nExample 2:\nInput: nums = [1,1,1,2,2,2,3,3,3,4,4,4,5]\nOutput: 13\n\nExample 3:\nInput: nums = [1,1,1,2,2,2]\nOutput: 5\n\nExample 4:\nInput: nums = [10,2,8,9,3,8,1,5,2,3,7,6]\nOutput: 8\n\n \nConstraints:\n\n2 <= nums.length <= 10^5\n1 <= nums[i] <= 10^5", "starter_code": "\nclass Solution:\n def maxEqualFreq(self, nums: List[int]) -> int:\n ", "test_cases": {"inputs": [[[2, 2, 1, 1, 5, 3, 3, 5]]], "outputs": [7], "fn_name": "maxEqualFreq"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "645de3626cfdd5e08d0a35d7bccbaff19ea41583", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "maxEqualFreq"} {"seed_id": "apps-00134", "original_id": null, "source": "apps", "domain": "code", "problem": "There are N workers.  The i-th worker has a quality[i] and a minimum wage expectation wage[i].\nNow we want to hire exactly K workers to form a paid group.  When hiring a group of K workers, we must pay them according to the following rules:\n\nEvery worker in the paid group should be paid in the ratio of their quality compared to other workers in the paid group.\nEvery worker in the paid group must be paid at least their minimum wage expectation.\n\nReturn the least amount of money needed to form a paid group satisfying the above conditions.\n \n\n\n\nExample 1:\nInput: quality = [10,20,5], wage = [70,50,30], K = 2\nOutput: 105.00000\nExplanation: We pay 70 to 0-th worker and 35 to 2-th worker.\n\n\nExample 2:\nInput: quality = [3,1,10,10,1], wage = [4,8,2,2,7], K = 3\nOutput: 30.66667\nExplanation: We pay 4 to 0-th worker, 13.33333 to 2-th and 3-th workers seperately. \n\n \nNote:\n\n1 <= K <= N <= 10000, where N = quality.length = wage.length\n1 <= quality[i] <= 10000\n1 <= wage[i] <= 10000\nAnswers within 10^-5 of the correct answer will be considered correct.", "starter_code": "\nclass Solution:\n def mincostToHireWorkers(self, quality: List[int], wage: List[int], K: int) -> float:\n ", "test_cases": {"inputs": [[[10, 20, 5], [70, 50, 30], 2]], "outputs": [105.0], "fn_name": "mincostToHireWorkers"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "3579be756b36619faee0deb9cb12b120a6d27535", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "mincostToHireWorkers"} {"seed_id": "apps-00139", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array of non-negative integers, you are initially positioned at the first index of the array.\n\nEach element in the array represents your maximum jump length at that position.\n\nYour goal is to reach the last index in the minimum number of jumps.\n\nExample:\n\n\nInput: [2,3,1,1,4]\nOutput: 2\nExplanation: The minimum number of jumps to reach the last index is 2.\n Jump 1 step from index 0 to 1, then 3 steps to the last index.\n\nNote:\n\nYou can assume that you can always reach the last index.", "starter_code": "\nclass Solution:\n def jump(self, nums: List[int]) -> int:\n ", "test_cases": {"inputs": [[[2, 3, 1, 1, 4]]], "outputs": [2], "fn_name": "jump"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "61889e44e70f86ef7acd8f256381cb1c148bf5c8", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "jump"} {"seed_id": "apps-00144", "original_id": null, "source": "apps", "domain": "code", "problem": "Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.\n\nExample 1:\n\n\nInput: [3,2,1,5,6,4] and k = 2\nOutput: 5\n\n\nExample 2:\n\n\nInput: [3,2,3,1,2,4,5,5,6] and k = 4\nOutput: 4\n\nNote: \nYou may assume k is always valid, 1 ≤ k ≤ array's length.", "starter_code": "\nclass Solution:\n def findKthLargest(self, nums: List[int], k: int) -> int:\n ", "test_cases": {"inputs": [[[2, 1, 3, 4, 5, 6], 2]], "outputs": [5], "fn_name": "findKthLargest"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "8761e7011b52b9ddd0f71fbde412d0298d049486", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "findKthLargest"} {"seed_id": "apps-00149", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a number N, return a string consisting of \"0\"s and \"1\"s that represents its value in base -2 (negative two).\nThe returned string must have no leading zeroes, unless the string is \"0\".\n \n\nExample 1:\nInput: 2\nOutput: \"110\"\nExplantion: (-2) ^ 2 + (-2) ^ 1 = 2\n\n\nExample 2:\nInput: 3\nOutput: \"111\"\nExplantion: (-2) ^ 2 + (-2) ^ 1 + (-2) ^ 0 = 3\n\n\nExample 3:\nInput: 4\nOutput: \"100\"\nExplantion: (-2) ^ 2 = 4\n\n \nNote:\n\n0 <= N <= 10^9", "starter_code": "\nclass Solution:\n def baseNeg2(self, N: int) -> str:\n ", "test_cases": {"inputs": [[2]], "outputs": ["110"], "fn_name": "baseNeg2"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "803407a4bca1f643db0583b3baa7b2b9fbeb77b1", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "baseNeg2"} {"seed_id": "apps-00154", "original_id": null, "source": "apps", "domain": "code", "problem": "Your car starts at position 0 and speed +1 on an infinite number line.  (Your car can go into negative positions.)\nYour car drives automatically according to a sequence of instructions A (accelerate) and R (reverse).\nWhen you get an instruction \"A\", your car does the following: position += speed, speed *= 2.\nWhen you get an instruction \"R\", your car does the following: if your speed is positive then speed = -1 , otherwise speed = 1.  (Your position stays the same.)\nFor example, after commands \"AAR\", your car goes to positions 0->1->3->3, and your speed goes to 1->2->4->-1.\nNow for some target position, say the length of the shortest sequence of instructions to get there.\nExample 1:\nInput: \ntarget = 3\nOutput: 2\nExplanation: \nThe shortest instruction sequence is \"AA\".\nYour position goes from 0->1->3.\n\nExample 2:\nInput: \ntarget = 6\nOutput: 5\nExplanation: \nThe shortest instruction sequence is \"AAARA\".\nYour position goes from 0->1->3->7->7->6.\n\n \nNote: \n\n1 <= target <= 10000.", "starter_code": "\nclass Solution:\n def racecar(self, target: int) -> int:\n ", "test_cases": {"inputs": [[3]], "outputs": [2], "fn_name": "racecar"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "e1e1392850ada89b089279a2df03a349dda7e891", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "racecar"} {"seed_id": "apps-00159", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an integer array of digits, return the largest multiple of three that can be formed by concatenating some of the given digits in any order.\nSince the answer may not fit in an integer data type, return the answer as a string.\nIf there is no answer return an empty string.\n \nExample 1:\nInput: digits = [8,1,9]\nOutput: \"981\"\n\nExample 2:\nInput: digits = [8,6,7,1,0]\nOutput: \"8760\"\n\nExample 3:\nInput: digits = [1]\nOutput: \"\"\n\nExample 4:\nInput: digits = [0,0,0,0,0,0]\nOutput: \"0\"\n\n \nConstraints:\n\n1 <= digits.length <= 10^4\n0 <= digits[i] <= 9\nThe returning answer must not contain unnecessary leading zeros.", "starter_code": "\nclass Solution:\n def largestMultipleOfThree(self, digits: List[int]) -> str:\n ", "test_cases": {"inputs": [[[9, 8, 1]]], "outputs": ["981"], "fn_name": "largestMultipleOfThree"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "412eba075856d7bf3b0535fbd4f6c01ef708b2b1", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "largestMultipleOfThree"} {"seed_id": "apps-00164", "original_id": null, "source": "apps", "domain": "code", "problem": "You have an initial power P, an initial score of 0 points, and a bag of tokens.\nEach token can be used at most once, has a value token[i], and has potentially two ways to use it.\n\nIf we have at least token[i] power, we may play the token face up, losing token[i] power, and gaining 1 point.\nIf we have at least 1 point, we may play the token face down, gaining token[i] power, and losing 1 point.\n\nReturn the largest number of points we can have after playing any number of tokens.\n \n\n\n\nExample 1:\nInput: tokens = [100], P = 50\nOutput: 0\n\n\nExample 2:\nInput: tokens = [100,200], P = 150\nOutput: 1\n\n\nExample 3:\nInput: tokens = [100,200,300,400], P = 200\nOutput: 2\n\n \nNote:\n\ntokens.length <= 1000\n0 <= tokens[i] < 10000\n0 <= P < 10000", "starter_code": "\nclass Solution:\n def bagOfTokensScore(self, tokens: List[int], P: int) -> int:\n ", "test_cases": {"inputs": [[[100], 50]], "outputs": [0], "fn_name": "bagOfTokensScore"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "3ce6ab64a11546c6101fdcd7a19a24601366a0ea", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "bagOfTokensScore"} {"seed_id": "apps-00169", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array A of non-negative integers, return the maximum sum of elements in two non-overlapping (contiguous) subarrays, which have lengths L and M.  (For clarification, the L-length subarray could occur before or after the M-length subarray.)\nFormally, return the largest V for which V = (A[i] + A[i+1] + ... + A[i+L-1]) + (A[j] + A[j+1] + ... + A[j+M-1]) and either:\n\n0 <= i < i + L - 1 < j < j + M - 1 < A.length, or\n0 <= j < j + M - 1 < i < i + L - 1 < A.length.\n\n \n\n\n\nExample 1:\nInput: A = [0,6,5,2,2,5,1,9,4], L = 1, M = 2\nOutput: 20\nExplanation: One choice of subarrays is [9] with length 1, and [6,5] with length 2.\n\n\nExample 2:\nInput: A = [3,8,1,3,2,1,8,9,0], L = 3, M = 2\nOutput: 29\nExplanation: One choice of subarrays is [3,8,1] with length 3, and [8,9] with length 2.\n\n\nExample 3:\nInput: A = [2,1,5,6,0,9,5,0,3,8], L = 4, M = 3\nOutput: 31\nExplanation: One choice of subarrays is [5,6,0,9] with length 4, and [3,8] with length 3.\n\n \nNote:\n\nL >= 1\nM >= 1\nL + M <= A.length <= 1000\n0 <= A[i] <= 1000", "starter_code": "\nclass Solution:\n def maxSumTwoNoOverlap(self, A: List[int], L: int, M: int) -> int:\n ", "test_cases": {"inputs": [[[0, 6, 5, 2, 2, 5, 1, 9, 4], 1, 2]], "outputs": [20], "fn_name": "maxSumTwoNoOverlap"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "2cb2a075998a0b5d0debd8218613359df22045c6", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "maxSumTwoNoOverlap"} {"seed_id": "apps-00174", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given an array x of n positive numbers. You start at point (0,0) and moves x[0] metres to the north, then x[1] metres to the west,\n x[2] metres to the south,\n x[3] metres to the east and so on. In other words, after each move your direction changes\n counter-clockwise.\n\n\n Write a one-pass algorithm with O(1) extra space to determine, if your path crosses itself, or not.\n\n\n\nExample 1:\n\nGiven x = [2, 1, 1, 2],\n?????\n? ?\n???????>\n ?\n\nReturn true (self crossing)\n\n\n\n\nExample 2:\n\nGiven x = [1, 2, 3, 4],\n????????\n? ?\n?\n?\n?????????????>\n\nReturn false (not self crossing)\n\n\n\n\nExample 3:\n\nGiven x = [1, 1, 1, 1],\n?????\n? ?\n?????>\n\nReturn true (self crossing)\n\n\n\nCredits:Special thanks to @dietpepsi for adding this problem and creating all test cases.", "starter_code": "\nclass Solution:\n def isSelfCrossing(self, x: List[int]) -> bool:\n ", "test_cases": {"inputs": [[[2, 1, 1, 2]]], "outputs": [true], "fn_name": "isSelfCrossing"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "d3ef8e4e3e2feeb4ad2cce0204f8bb31c94bc59d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "isSelfCrossing"} {"seed_id": "apps-00179", "original_id": null, "source": "apps", "domain": "code", "problem": "Given the coordinates of four points in 2D space, return whether the four points could construct a square.\n\nThe coordinate (x,y) of a point is represented by an integer array with two integers.\n\nExample:\n\nInput: p1 = [0,0], p2 = [1,1], p3 = [1,0], p4 = [0,1]\nOutput: True\n\n\n\n Note: \n\nAll the input integers are in the range [-10000, 10000].\nA valid square has four equal sides with positive length and four equal angles (90-degree angles).\nInput points have no order.", "starter_code": "\nclass Solution:\n def validSquare(self, p1: List[int], p2: List[int], p3: List[int], p4: List[int]) -> bool:\n ", "test_cases": {"inputs": [[[0, 0], [1, 1], [1, 0], [0, 1]]], "outputs": [true], "fn_name": "validSquare"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "b2798baef0d00b91d52cac0a8d1520ca2dd91236", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "validSquare"} {"seed_id": "apps-00184", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a string representing a code snippet, you need to implement a tag validator to parse the code and return whether it is valid. A code snippet is valid if all the following rules hold:\n\nThe code must be wrapped in a valid closed tag. Otherwise, the code is invalid.\nA closed tag (not necessarily valid) has exactly the following format : TAG_CONTENT. Among them, is the start tag, and is the end tag. The TAG_NAME in start and end tags should be the same. A closed tag is valid if and only if the TAG_NAME and TAG_CONTENT are valid.\nA valid TAG_NAME only contain upper-case letters, and has length in range [1,9]. Otherwise, the TAG_NAME is invalid.\nA valid TAG_CONTENT may contain other valid closed tags, cdata and any characters (see note1) EXCEPT unmatched <, unmatched start and end tag, and unmatched or closed tags with invalid TAG_NAME. Otherwise, the TAG_CONTENT is invalid.\nA start tag is unmatched if no end tag exists with the same TAG_NAME, and vice versa. However, you also need to consider the issue of unbalanced when tags are nested.\nA < is unmatched if you cannot find a subsequent >. And when you find a < or should be parsed as TAG_NAME (not necessarily valid).\nThe cdata has the following format : . The range of CDATA_CONTENT is defined as the characters between . \nCDATA_CONTENT may contain any characters. The function of cdata is to forbid the validator to parse CDATA_CONTENT, so even it has some characters that can be parsed as tag (no matter valid or invalid), you should treat it as regular characters. \n\n\nValid Code Examples:\n\nInput: \"
This is the first line ]]>
\"\nOutput: True\nExplanation: \nThe code is wrapped in a closed tag :
and
. \nThe TAG_NAME is valid, the TAG_CONTENT consists of some characters and cdata. \nAlthough CDATA_CONTENT has unmatched start tag with invalid TAG_NAME, it should be considered as plain text, not parsed as tag.\nSo TAG_CONTENT is valid, and then the code is valid. Thus return true.\n\nInput: \"
>> ![cdata[]] ]>]]>]]>>]
\"\nOutput: True\nExplanation:\nWe first separate the code into : start_tag|tag_content|end_tag.\nstart_tag -> \"
\"\nend_tag -> \"
\"\ntag_content could also be separated into : text1|cdata|text2.\ntext1 -> \">> ![cdata[]] \"\ncdata -> \"]>]]>\", where the CDATA_CONTENT is \"
]>\"\ntext2 -> \"]]>>]\"\n\nThe reason why start_tag is NOT \"
>>\" is because of the rule 6.\nThe reason why cdata is NOT \"]>]]>]]>\" is because of the rule 7.\n\n\n\nInvalid Code Examples:\n\nInput: \" \"\nOutput: False\nExplanation: Unbalanced. If \"\" is closed, then \"\" must be unmatched, and vice versa.\n\nInput: \"
div tag is not closed
\"\nOutput: False\n\nInput: \"
unmatched <
\"\nOutput: False\n\nInput: \"
closed tags with invalid tag name 123
\"\nOutput: False\n\nInput: \"
unmatched tags with invalid tag name and
\"\nOutput: False\n\nInput: \"
unmatched start tag and unmatched end tag
\"\nOutput: False\n\n\n\nNote:\n\nFor simplicity, you could assume the input code (including the any characters mentioned above) only contain letters, digits, '<','>','/','!','[',']' and ' '.", "starter_code": "\nclass Solution:\n def isValid(self, code: str) -> bool:\n ", "test_cases": {"inputs": [["\"
This is the first line ]]>
\""]], "outputs": [false], "fn_name": "isValid"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "ecbed381aa2afec9d67b57e571c13d17c72f97aa", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "isValid"} {"seed_id": "apps-00189", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an integer array bloomDay, an integer m and an integer k.\nWe need to make m bouquets. To make a bouquet, you need to use k adjacent flowers from the garden.\nThe garden consists of n flowers, the ith flower will bloom in the bloomDay[i] and then can be used in exactly one bouquet.\nReturn the minimum number of days you need to wait to be able to make m bouquets from the garden. If it is impossible to make m bouquets return -1.\n \nExample 1:\nInput: bloomDay = [1,10,3,10,2], m = 3, k = 1\nOutput: 3\nExplanation: Let's see what happened in the first three days. x means flower bloomed and _ means flower didn't bloom in the garden.\nWe need 3 bouquets each should contain 1 flower.\nAfter day 1: [x, _, _, _, _] // we can only make one bouquet.\nAfter day 2: [x, _, _, _, x] // we can only make two bouquets.\nAfter day 3: [x, _, x, _, x] // we can make 3 bouquets. The answer is 3.\n\nExample 2:\nInput: bloomDay = [1,10,3,10,2], m = 3, k = 2\nOutput: -1\nExplanation: We need 3 bouquets each has 2 flowers, that means we need 6 flowers. We only have 5 flowers so it is impossible to get the needed bouquets and we return -1.\n\nExample 3:\nInput: bloomDay = [7,7,7,7,12,7,7], m = 2, k = 3\nOutput: 12\nExplanation: We need 2 bouquets each should have 3 flowers.\nHere's the garden after the 7 and 12 days:\nAfter day 7: [x, x, x, x, _, x, x]\nWe can make one bouquet of the first three flowers that bloomed. We cannot make another bouquet from the last three flowers that bloomed because they are not adjacent.\nAfter day 12: [x, x, x, x, x, x, x]\nIt is obvious that we can make two bouquets in different ways.\n\nExample 4:\nInput: bloomDay = [1000000000,1000000000], m = 1, k = 1\nOutput: 1000000000\nExplanation: You need to wait 1000000000 days to have a flower ready for a bouquet.\n\nExample 5:\nInput: bloomDay = [1,10,2,9,3,8,4,7,5,6], m = 4, k = 2\nOutput: 9\n\n \nConstraints:\n\nbloomDay.length == n\n1 <= n <= 10^5\n1 <= bloomDay[i] <= 10^9\n1 <= m <= 10^6\n1 <= k <= n", "starter_code": "\nclass Solution:\n def minDays(self, bloomDay: List[int], m: int, k: int) -> int:", "test_cases": {"inputs": [[[1, 10, 3, 10, 2], 3, 1]], "outputs": [3], "fn_name": "minDays"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "a82ecebeff9fc1c289b71a9b0ef8e3fdb966a88a", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "minDays"} {"seed_id": "apps-00194", "original_id": null, "source": "apps", "domain": "code", "problem": "Alice and Bob continue their games with piles of stones. There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue.\nAlice and Bob take turns, with Alice starting first. On each player's turn, that player can take 1, 2 or 3 stones from the first remaining stones in the row.\nThe score of each player is the sum of values of the stones taken. The score of each player is 0 initially.\nThe objective of the game is to end with the highest score, and the winner is the player with the highest score and there could be a tie. The game continues until all the stones have been taken.\nAssume Alice and Bob play optimally.\nReturn \"Alice\" if Alice will win, \"Bob\" if Bob will win or \"Tie\" if they end the game with the same score.\n \nExample 1:\nInput: values = [1,2,3,7]\nOutput: \"Bob\"\nExplanation: Alice will always lose. Her best move will be to take three piles and the score become 6. Now the score of Bob is 7 and Bob wins.\n\nExample 2:\nInput: values = [1,2,3,-9]\nOutput: \"Alice\"\nExplanation: Alice must choose all the three piles at the first move to win and leave Bob with negative score.\nIf Alice chooses one pile her score will be 1 and the next move Bob's score becomes 5. The next move Alice will take the pile with value = -9 and lose.\nIf Alice chooses two piles her score will be 3 and the next move Bob's score becomes 3. The next move Alice will take the pile with value = -9 and also lose.\nRemember that both play optimally so here Alice will choose the scenario that makes her win.\n\nExample 3:\nInput: values = [1,2,3,6]\nOutput: \"Tie\"\nExplanation: Alice cannot win this game. She can end the game in a draw if she decided to choose all the first three piles, otherwise she will lose.\n\nExample 4:\nInput: values = [1,2,3,-1,-2,-3,7]\nOutput: \"Alice\"\n\nExample 5:\nInput: values = [-1,-2,-3]\nOutput: \"Tie\"\n\n \nConstraints:\n\n1 <= values.length <= 50000\n-1000 <= values[i] <= 1000", "starter_code": "\nclass Solution:\n def stoneGameIII(self, stoneValue: List[int]) -> str:\n ", "test_cases": {"inputs": [[[1, 2, 3, 7]]], "outputs": ["Bob"], "fn_name": "stoneGameIII"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "7837104f960ee5d49dcc575d3eb7a5ebe35b73f7", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "stoneGameIII"} {"seed_id": "apps-00199", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a positive 32-bit integer n, you need to find the smallest 32-bit integer which has exactly the same digits existing in the integer n and is greater in value than n. If no such positive 32-bit integer exists, you need to return -1.\n\nExample 1:\n\n\nInput: 12\nOutput: 21\n\n\n \n\nExample 2:\n\n\nInput: 21\nOutput: -1", "starter_code": "\nclass Solution:\n def nextGreaterElement(self, n: int) -> int:\n ", "test_cases": {"inputs": [[12]], "outputs": [21], "fn_name": "nextGreaterElement"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "dd45d77ac0ee82a31e5f52f13f30e8fc8c3dfef6", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "nextGreaterElement"} {"seed_id": "apps-00204", "original_id": null, "source": "apps", "domain": "code", "problem": "Given two numbers, hour and minutes. Return the smaller angle (in degrees) formed between the hour and the minute hand.\n \nExample 1:\n\nInput: hour = 12, minutes = 30\nOutput: 165\n\nExample 2:\n\nInput: hour = 3, minutes = 30\nOutput: 75\n\nExample 3:\n\nInput: hour = 3, minutes = 15\nOutput: 7.5\n\nExample 4:\nInput: hour = 4, minutes = 50\nOutput: 155\n\nExample 5:\nInput: hour = 12, minutes = 0\nOutput: 0\n\n \nConstraints:\n\n1 <= hour <= 12\n0 <= minutes <= 59\nAnswers within 10^-5 of the actual value will be accepted as correct.", "starter_code": "\nclass Solution:\n def angleClock(self, hour: int, minutes: int) -> float:\n ", "test_cases": {"inputs": [[12, 30]], "outputs": [165.0], "fn_name": "angleClock"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "f9f01c8d48559f12b1dc5510aa5a24204df5eac8", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "angleClock"} {"seed_id": "apps-00209", "original_id": null, "source": "apps", "domain": "code", "problem": "Given two equal-size strings s and t. In one step you can choose any character of t and replace it with another character.\nReturn the minimum number of steps to make t an anagram of s.\nAn Anagram of a string is a string that contains the same characters with a different (or the same) ordering.\n \nExample 1:\nInput: s = \"bab\", t = \"aba\"\nOutput: 1\nExplanation: Replace the first 'a' in t with b, t = \"bba\" which is anagram of s.\n\nExample 2:\nInput: s = \"leetcode\", t = \"practice\"\nOutput: 5\nExplanation: Replace 'p', 'r', 'a', 'i' and 'c' from t with proper characters to make t anagram of s.\n\nExample 3:\nInput: s = \"anagram\", t = \"mangaar\"\nOutput: 0\nExplanation: \"anagram\" and \"mangaar\" are anagrams. \n\nExample 4:\nInput: s = \"xxyyzz\", t = \"xxyyzz\"\nOutput: 0\n\nExample 5:\nInput: s = \"friend\", t = \"family\"\nOutput: 4\n\n \nConstraints:\n\n1 <= s.length <= 50000\ns.length == t.length\ns and t contain lower-case English letters only.", "starter_code": "\nclass Solution:\n def minSteps(self, s: str, t: str) -> int:\n ", "test_cases": {"inputs": [["\"bab\"", "\"aba\""]], "outputs": [1], "fn_name": "minSteps"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "4e186061494bf4e9aff545af82995a53db602f4e", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "minSteps"} {"seed_id": "apps-00214", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.\n\nExample 1:\n\n\nInput: n = 12\nOutput: 3 \nExplanation: 12 = 4 + 4 + 4.\n\nExample 2:\n\n\nInput: n = 13\nOutput: 2\nExplanation: 13 = 4 + 9.", "starter_code": "\nclass Solution:\n def numSquares(self, n: int) -> int:\n ", "test_cases": {"inputs": [[12]], "outputs": [3], "fn_name": "numSquares"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "bbf30d87a0d99bf3037387ef203094594b9781d0", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "numSquares"} {"seed_id": "apps-00219", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array nums of integers, you can perform operations on the array.\n\nIn each operation, you pick any nums[i] and delete it to earn nums[i] points. After, you must delete every element equal to nums[i] - 1 or nums[i] + 1.\n\nYou start with 0 points. Return the maximum number of points you can earn by applying such operations.\n\n\nExample 1:\n\nInput: nums = [3, 4, 2]\nOutput: 6\nExplanation: \nDelete 4 to earn 4 points, consequently 3 is also deleted.\nThen, delete 2 to earn 2 points. 6 total points are earned.\n\n\n\nExample 2:\n\nInput: nums = [2, 2, 3, 3, 3, 4]\nOutput: 9\nExplanation: \nDelete 3 to earn 3 points, deleting both 2's and the 4.\nThen, delete 3 again to earn 3 points, and 3 again to earn 3 points.\n9 total points are earned.\n\n\n\nNote:\nThe length of nums is at most 20000.\nEach element nums[i] is an integer in the range [1, 10000].", "starter_code": "\nclass Solution:\n def deleteAndEarn(self, nums: List[int]) -> int:\n ", "test_cases": {"inputs": [[[2, 3, 4]]], "outputs": [6], "fn_name": "deleteAndEarn"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "d82710d25ecf41a8a944034a7878bb49231d1a21", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "deleteAndEarn"} {"seed_id": "apps-00224", "original_id": null, "source": "apps", "domain": "code", "problem": "A die simulator generates a random number from 1 to 6 for each roll. You introduced a constraint to the generator such that it cannot roll the number i more than rollMax[i] (1-indexed) consecutive times. \nGiven an array of integers rollMax and an integer n, return the number of distinct sequences that can be obtained with exact n rolls.\nTwo sequences are considered different if at least one element differs from each other. Since the answer may be too large, return it modulo 10^9 + 7.\n \nExample 1:\nInput: n = 2, rollMax = [1,1,2,2,2,3]\nOutput: 34\nExplanation: There will be 2 rolls of die, if there are no constraints on the die, there are 6 * 6 = 36 possible combinations. In this case, looking at rollMax array, the numbers 1 and 2 appear at most once consecutively, therefore sequences (1,1) and (2,2) cannot occur, so the final answer is 36-2 = 34.\n\nExample 2:\nInput: n = 2, rollMax = [1,1,1,1,1,1]\nOutput: 30\n\nExample 3:\nInput: n = 3, rollMax = [1,1,1,2,2,3]\nOutput: 181\n\n \nConstraints:\n\n1 <= n <= 5000\nrollMax.length == 6\n1 <= rollMax[i] <= 15", "starter_code": "\nclass Solution:\n def dieSimulator(self, n: int, rollMax: List[int]) -> int:\n ", "test_cases": {"inputs": [[2, [1, 1, 2, 2, 2, 3]]], "outputs": [34], "fn_name": "dieSimulator"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "8d1472b26fc58a5315a4e431c8f58937d1415c03", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "dieSimulator"} {"seed_id": "apps-00229", "original_id": null, "source": "apps", "domain": "code", "problem": "A conveyor belt has packages that must be shipped from one port to another within D days.\nThe i-th package on the conveyor belt has a weight of weights[i].  Each day, we load the ship with packages on the conveyor belt (in the order given by weights). We may not load more weight than the maximum weight capacity of the ship.\nReturn the least weight capacity of the ship that will result in all the packages on the conveyor belt being shipped within D days.\n \nExample 1:\nInput: weights = [1,2,3,4,5,6,7,8,9,10], D = 5\nOutput: 15\nExplanation: \nA ship capacity of 15 is the minimum to ship all the packages in 5 days like this:\n1st day: 1, 2, 3, 4, 5\n2nd day: 6, 7\n3rd day: 8\n4th day: 9\n5th day: 10\n\nNote that the cargo must be shipped in the order given, so using a ship of capacity 14 and splitting the packages into parts like (2, 3, 4, 5), (1, 6, 7), (8), (9), (10) is not allowed. \n\nExample 2:\nInput: weights = [3,2,2,4,1,4], D = 3\nOutput: 6\nExplanation: \nA ship capacity of 6 is the minimum to ship all the packages in 3 days like this:\n1st day: 3, 2\n2nd day: 2, 4\n3rd day: 1, 4\n\nExample 3:\nInput: weights = [1,2,3,1,1], D = 4\nOutput: 3\nExplanation: \n1st day: 1\n2nd day: 2\n3rd day: 3\n4th day: 1, 1\n\n \nConstraints:\n\n1 <= D <= weights.length <= 50000\n1 <= weights[i] <= 500", "starter_code": "\nclass Solution:\n def shipWithinDays(self, weights: List[int], D: int) -> int:\n ", "test_cases": {"inputs": [[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 5]], "outputs": [15], "fn_name": "shipWithinDays"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "525375443445170c95b1bf2f75198269e60cc752", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "shipWithinDays"} {"seed_id": "apps-00234", "original_id": null, "source": "apps", "domain": "code", "problem": "Find the length of the longest substring T of a given string (consists of lowercase letters only) such that every character in T appears no less than k times.\n\n\nExample 1:\n\nInput:\ns = \"aaabb\", k = 3\n\nOutput:\n3\n\nThe longest substring is \"aaa\", as 'a' is repeated 3 times.\n\n\n\nExample 2:\n\nInput:\ns = \"ababbc\", k = 2\n\nOutput:\n5\n\nThe longest substring is \"ababb\", as 'a' is repeated 2 times and 'b' is repeated 3 times.", "starter_code": "\nclass Solution:\n def longestSubstring(self, s: str, k: int) -> int:\n ", "test_cases": {"inputs": [["\"aaabb\"", 3]], "outputs": [3], "fn_name": "longestSubstring"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "b94e5fb4bb9c095c07fb28461e7c833df8ff2e7b", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "longestSubstring"} {"seed_id": "apps-00239", "original_id": null, "source": "apps", "domain": "code", "problem": "Say you have an array for which the ith element is the price of a given stock on day i.\n\nDesign an algorithm to find the maximum profit. You may complete at most k transactions.\n\nNote:\nYou may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).\n\nExample 1:\n\n\nInput: [2,4,1], k = 2\nOutput: 2\nExplanation: Buy on day 1 (price = 2) and sell on day 2 (price = 4), profit = 4-2 = 2.\n\n\nExample 2:\n\n\nInput: [3,2,6,5,0,3], k = 2\nOutput: 7\nExplanation: Buy on day 2 (price = 2) and sell on day 3 (price = 6), profit = 6-2 = 4.\n  Then buy on day 5 (price = 0) and sell on day 6 (price = 3), profit = 3-0 = 3.", "starter_code": "\nclass Solution:\n def maxProfit(self, k: int, prices: List[int]) -> int:\n ", "test_cases": {"inputs": [[2, [2, 4, 1]]], "outputs": [2], "fn_name": "maxProfit"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "fbdbe31abf951fef3cf4b52791d22de368bff69f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "maxProfit"} {"seed_id": "apps-00244", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.\n\n\nNote:\n\nEach of the array element will not exceed 100.\nThe array size will not exceed 200.\n\n\n\nExample 1:\n\nInput: [1, 5, 11, 5]\n\nOutput: true\n\nExplanation: The array can be partitioned as [1, 5, 5] and [11].\n\n\n\nExample 2:\n\nInput: [1, 2, 3, 5]\n\nOutput: false\n\nExplanation: The array cannot be partitioned into equal sum subsets.", "starter_code": "\nclass Solution:\n def canPartition(self, nums: List[int]) -> bool:\n ", "test_cases": {"inputs": [[[1, 5, 5, 11]]], "outputs": [true], "fn_name": "canPartition"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "ce8b871c223b037b6644a54315298e881a1bc863", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "canPartition"} {"seed_id": "apps-00249", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array of integers A, consider all non-empty subsequences of A.\nFor any sequence S, let the width of S be the difference between the maximum and minimum element of S.\nReturn the sum of the widths of all subsequences of A. \nAs the answer may be very large, return the answer modulo 10^9 + 7.\n\n \nExample 1:\nInput: [2,1,3]\nOutput: 6\nExplanation:\nSubsequences are [1], [2], [3], [2,1], [2,3], [1,3], [2,1,3].\nThe corresponding widths are 0, 0, 0, 1, 1, 2, 2.\nThe sum of these widths is 6.\n\n \nNote:\n\n1 <= A.length <= 20000\n1 <= A[i] <= 20000", "starter_code": "\nclass Solution:\n def sumSubseqWidths(self, A: List[int]) -> int:\n ", "test_cases": {"inputs": [[[1, 2, 3]]], "outputs": [6], "fn_name": "sumSubseqWidths"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "f8de70ac681883ca7e5a2c40504c1ae1ab100b30", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "sumSubseqWidths"} {"seed_id": "apps-00254", "original_id": null, "source": "apps", "domain": "code", "problem": "Alice and Bob take turns playing a game, with Alice starting first.\nInitially, there are n stones in a pile.  On each player's turn, that player makes a move consisting of removing any non-zero square number of stones in the pile.\nAlso, if a player cannot make a move, he/she loses the game.\nGiven a positive integer n. Return True if and only if Alice wins the game otherwise return False, assuming both players play optimally.\n \nExample 1:\nInput: n = 1\nOutput: true\nExplanation: Alice can remove 1 stone winning the game because Bob doesn't have any moves.\nExample 2:\nInput: n = 2\nOutput: false\nExplanation: Alice can only remove 1 stone, after that Bob removes the last one winning the game (2 -> 1 -> 0).\nExample 3:\nInput: n = 4\nOutput: true\nExplanation: n is already a perfect square, Alice can win with one move, removing 4 stones (4 -> 0).\n\nExample 4:\nInput: n = 7\nOutput: false\nExplanation: Alice can't win the game if Bob plays optimally.\nIf Alice starts removing 4 stones, Bob will remove 1 stone then Alice should remove only 1 stone and finally Bob removes the last one (7 -> 3 -> 2 -> 1 -> 0). \nIf Alice starts removing 1 stone, Bob will remove 4 stones then Alice only can remove 1 stone and finally Bob removes the last one (7 -> 6 -> 2 -> 1 -> 0).\nExample 5:\nInput: n = 17\nOutput: false\nExplanation: Alice can't win the game if Bob plays optimally.\n\n \nConstraints:\n\n1 <= n <= 10^5", "starter_code": "\nclass Solution:\n def winnerSquareGame(self, n: int) -> bool:\n ", "test_cases": {"inputs": [[1]], "outputs": [true], "fn_name": "winnerSquareGame"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "6cf011a6550e5ed7c0b2df59c9d68fe6582f6d5a", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "winnerSquareGame"} {"seed_id": "apps-00259", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given an integer array A.  From some starting index, you can make a series of jumps.  The (1st, 3rd, 5th, ...) jumps in the series are called odd numbered jumps, and the (2nd, 4th, 6th, ...) jumps in the series are called even numbered jumps.\nYou may from index i jump forward to index j (with i < j) in the following way:\n\nDuring odd numbered jumps (ie. jumps 1, 3, 5, ...), you jump to the index j such that A[i] <= A[j] and A[j] is the smallest possible value.  If there are multiple such indexes j, you can only jump to the smallest such index j.\nDuring even numbered jumps (ie. jumps 2, 4, 6, ...), you jump to the index j such that A[i] >= A[j] and A[j] is the largest possible value.  If there are multiple such indexes j, you can only jump to the smallest such index j.\n(It may be the case that for some index i, there are no legal jumps.)\n\nA starting index is good if, starting from that index, you can reach the end of the array (index A.length - 1) by jumping some number of times (possibly 0 or more than once.)\nReturn the number of good starting indexes.\n \nExample 1:\nInput: [10,13,12,14,15]\nOutput: 2\nExplanation: \nFrom starting index i = 0, we can jump to i = 2 (since A[2] is the smallest among A[1], A[2], A[3], A[4] that is greater or equal to A[0]), then we can't jump any more.\nFrom starting index i = 1 and i = 2, we can jump to i = 3, then we can't jump any more.\nFrom starting index i = 3, we can jump to i = 4, so we've reached the end.\nFrom starting index i = 4, we've reached the end already.\nIn total, there are 2 different starting indexes (i = 3, i = 4) where we can reach the end with some number of jumps.\n\n\nExample 2:\nInput: [2,3,1,1,4]\nOutput: 3\nExplanation: \nFrom starting index i = 0, we make jumps to i = 1, i = 2, i = 3:\n\nDuring our 1st jump (odd numbered), we first jump to i = 1 because A[1] is the smallest value in (A[1], A[2], A[3], A[4]) that is greater than or equal to A[0].\n\nDuring our 2nd jump (even numbered), we jump from i = 1 to i = 2 because A[2] is the largest value in (A[2], A[3], A[4]) that is less than or equal to A[1]. A[3] is also the largest value, but 2 is a smaller index, so we can only jump to i = 2 and not i = 3.\n\nDuring our 3rd jump (odd numbered), we jump from i = 2 to i = 3 because A[3] is the smallest value in (A[3], A[4]) that is greater than or equal to A[2].\n\nWe can't jump from i = 3 to i = 4, so the starting index i = 0 is not good.\n\nIn a similar manner, we can deduce that:\nFrom starting index i = 1, we jump to i = 4, so we reach the end.\nFrom starting index i = 2, we jump to i = 3, and then we can't jump anymore.\nFrom starting index i = 3, we jump to i = 4, so we reach the end.\nFrom starting index i = 4, we are already at the end.\nIn total, there are 3 different starting indexes (i = 1, i = 3, i = 4) where we can reach the end with some number of jumps.\n\n\nExample 3:\nInput: [5,1,3,4,2]\nOutput: 3\nExplanation: \nWe can reach the end from starting indexes 1, 2, and 4.\n\n\n\n \nNote:\n\n1 <= A.length <= 20000\n0 <= A[i] < 100000", "starter_code": "\nclass Solution:\n def oddEvenJumps(self, A: List[int]) -> int:\n ", "test_cases": {"inputs": [[[10, 13, 12, 14, 15]]], "outputs": [2], "fn_name": "oddEvenJumps"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "abe5e00489b5bacceec1dbdda5bf5ba9d5ee19f9", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "oddEvenJumps"} {"seed_id": "apps-00264", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array nums of integers, we need to find the maximum possible sum of elements of the array such that it is divisible by three.\n\n\n \nExample 1:\nInput: nums = [3,6,5,1,8]\nOutput: 18\nExplanation: Pick numbers 3, 6, 1 and 8 their sum is 18 (maximum sum divisible by 3).\nExample 2:\nInput: nums = [4]\nOutput: 0\nExplanation: Since 4 is not divisible by 3, do not pick any number.\n\nExample 3:\nInput: nums = [1,2,3,4,4]\nOutput: 12\nExplanation: Pick numbers 1, 3, 4 and 4 their sum is 12 (maximum sum divisible by 3).\n\n \nConstraints:\n\n1 <= nums.length <= 4 * 10^4\n1 <= nums[i] <= 10^4", "starter_code": "\nclass Solution:\n def maxSumDivThree(self, nums: List[int]) -> int:\n ", "test_cases": {"inputs": [[[3, 6, 5, 1, 8]]], "outputs": [18], "fn_name": "maxSumDivThree"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "8298651b7d296551deeb9c68a48b4fcfcdfc2842", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "maxSumDivThree"} {"seed_id": "apps-00269", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an integer array arr and a target value target, return the integer value such that when we change all the integers larger than value in the given array to be equal to value, the sum of the array gets as close as possible (in absolute difference) to target.\nIn case of a tie, return the minimum such integer.\nNotice that the answer is not neccesarilly a number from arr.\n \nExample 1:\nInput: arr = [4,9,3], target = 10\nOutput: 3\nExplanation: When using 3 arr converts to [3, 3, 3] which sums 9 and that's the optimal answer.\n\nExample 2:\nInput: arr = [2,3,5], target = 10\nOutput: 5\n\nExample 3:\nInput: arr = [60864,25176,27249,21296,20204], target = 56803\nOutput: 11361\n\n \nConstraints:\n\n1 <= arr.length <= 10^4\n1 <= arr[i], target <= 10^5", "starter_code": "\nclass Solution:\n def findBestValue(self, arr: List[int], target: int) -> int:\n ", "test_cases": {"inputs": [[[4, 9, 3], 10]], "outputs": [3], "fn_name": "findBestValue"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "6c519226f391b815dda8dce294ee994bbe09549e", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "findBestValue"} {"seed_id": "apps-00274", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a palindromic string palindrome, replace exactly one character by any lowercase English letter so that the string becomes the lexicographically smallest possible string that isn't a palindrome.\nAfter doing so, return the final string.  If there is no way to do so, return the empty string.\n \nExample 1:\nInput: palindrome = \"abccba\"\nOutput: \"aaccba\"\n\nExample 2:\nInput: palindrome = \"a\"\nOutput: \"\"\n\n \nConstraints:\n\n1 <= palindrome.length <= 1000\npalindrome consists of only lowercase English letters.", "starter_code": "\nclass Solution:\n def breakPalindrome(self, palindrome: str) -> str:\n ", "test_cases": {"inputs": [["\"abccba\""]], "outputs": ["aabccba\""], "fn_name": "breakPalindrome"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "c92d0b471f6674f79a902d471a449ddca4a1c61e", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "breakPalindrome"} {"seed_id": "apps-00279", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a positive integer n and you can do operations as follow:\n\n\n\n\nIf n is even, replace n with n/2.\nIf n is odd, you can replace n with either n + 1 or n - 1.\n\n\n\n\nWhat is the minimum number of replacements needed for n to become 1?\n\n\n\n\nExample 1:\n\nInput:\n8\n\nOutput:\n3\n\nExplanation:\n8 -> 4 -> 2 -> 1\n\n\n\nExample 2:\n\nInput:\n7\n\nOutput:\n4\n\nExplanation:\n7 -> 8 -> 4 -> 2 -> 1\nor\n7 -> 6 -> 3 -> 2 -> 1", "starter_code": "\nclass Solution:\n def integerReplacement(self, n: int) -> int:\n ", "test_cases": {"inputs": [[8]], "outputs": [3], "fn_name": "integerReplacement"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "e8980b5d0d4db4eba2591700463f4d63d54739a2", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "integerReplacement"} {"seed_id": "apps-00284", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an integer array arr and an integer difference, return the length of the longest subsequence in arr which is an arithmetic sequence such that the difference between adjacent elements in the subsequence equals difference.\n \nExample 1:\nInput: arr = [1,2,3,4], difference = 1\nOutput: 4\nExplanation: The longest arithmetic subsequence is [1,2,3,4].\nExample 2:\nInput: arr = [1,3,5,7], difference = 1\nOutput: 1\nExplanation: The longest arithmetic subsequence is any single element.\n\nExample 3:\nInput: arr = [1,5,7,8,5,3,4,2,1], difference = -2\nOutput: 4\nExplanation: The longest arithmetic subsequence is [7,5,3,1].\n\n \nConstraints:\n\n1 <= arr.length <= 10^5\n-10^4 <= arr[i], difference <= 10^4", "starter_code": "\nclass Solution:\n def longestSubsequence(self, arr: List[int], difference: int) -> int:\n ", "test_cases": {"inputs": [[[1, 2, 3, 4], 1]], "outputs": [4], "fn_name": "longestSubsequence"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "7821533b44b3e0ab3a429dd06da21c69ae4d86b7", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "longestSubsequence"} {"seed_id": "apps-00289", "original_id": null, "source": "apps", "domain": "code", "problem": "You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint that indicates how many digits in said guess match your secret number exactly in both digit and position (called \"bulls\") and how many digits match the secret number but locate in the wrong position (called \"cows\"). Your friend will use successive guesses and hints to eventually derive the secret number.\n\nWrite a function to return a hint according to the secret number and friend's guess, use A to indicate the bulls and B to indicate the cows. \n\nPlease note that both secret number and friend's guess may contain duplicate digits.\n\nExample 1:\n\n\nInput: secret = \"1807\", guess = \"7810\"\n\nOutput: \"1A3B\"\n\nExplanation: 1 bull and 3 cows. The bull is 8, the cows are 0, 1 and 7.\n\nExample 2:\n\n\nInput: secret = \"1123\", guess = \"0111\"\n\nOutput: \"1A1B\"\n\nExplanation: The 1st 1 in friend's guess is a bull, the 2nd or 3rd 1 is a cow.\n\nNote: You may assume that the secret number and your friend's guess only contain digits, and their lengths are always equal.", "starter_code": "\nclass Solution:\n def getHint(self, secret: str, guess: str) -> str:\n ", "test_cases": {"inputs": [["\"1807\"", "\"7810\""]], "outputs": ["3A3B"], "fn_name": "getHint"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "2aba7d8173ef1fd501fa005f77ad21b8724b44a9", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "getHint"} {"seed_id": "apps-00294", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a binary array nums, you should delete one element from it.\nReturn the size of the longest non-empty subarray containing only 1's in the resulting array.\nReturn 0 if there is no such subarray.\n \nExample 1:\nInput: nums = [1,1,0,1]\nOutput: 3\nExplanation: After deleting the number in position 2, [1,1,1] contains 3 numbers with value of 1's.\nExample 2:\nInput: nums = [0,1,1,1,0,1,1,0,1]\nOutput: 5\nExplanation: After deleting the number in position 4, [0,1,1,1,1,1,0,1] longest subarray with value of 1's is [1,1,1,1,1].\nExample 3:\nInput: nums = [1,1,1]\nOutput: 2\nExplanation: You must delete one element.\nExample 4:\nInput: nums = [1,1,0,0,1,1,1,0,1]\nOutput: 4\n\nExample 5:\nInput: nums = [0,0,0]\nOutput: 0\n\n \nConstraints:\n\n1 <= nums.length <= 10^5\nnums[i] is either 0 or 1.", "starter_code": "\nclass Solution:\n def longestSubarray(self, nums: List[int]) -> int:\n ", "test_cases": {"inputs": [[[1, 1, 0, 1]]], "outputs": [3], "fn_name": "longestSubarray"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "47add8af121bbd058c374e5fd67e0fa37a69d5a0", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "longestSubarray"} {"seed_id": "apps-00299", "original_id": null, "source": "apps", "domain": "code", "problem": "A subarray A[i], A[i+1], ..., A[j] of A is said to be turbulent if and only if:\n\nFor i <= k < j, A[k] > A[k+1] when k is odd, and A[k] < A[k+1] when k is even;\nOR, for i <= k < j, A[k] > A[k+1] when k is even, and A[k] < A[k+1] when k is odd.\n\nThat is, the subarray is turbulent if the comparison sign flips between each adjacent pair of elements in the subarray.\nReturn the length of a maximum size turbulent subarray of A.\n \n\nExample 1:\nInput: [9,4,2,10,7,8,8,1,9]\nOutput: 5\nExplanation: (A[1] > A[2] < A[3] > A[4] < A[5])\n\n\nExample 2:\nInput: [4,8,12,16]\nOutput: 2\n\n\nExample 3:\nInput: [100]\nOutput: 1\n\n\n\n\n \nNote:\n\n1 <= A.length <= 40000\n0 <= A[i] <= 10^9", "starter_code": "\nclass Solution:\n def maxTurbulenceSize(self, A: List[int]) -> int:\n ", "test_cases": {"inputs": [[[9, 4, 2, 10, 7, 8, 8, 1, 9]]], "outputs": [5], "fn_name": "maxTurbulenceSize"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "c62446b51b6a7ef9007725c9d16c846936796474", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "maxTurbulenceSize"} {"seed_id": "apps-00304", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array nums, you are allowed to choose one element of nums and change it by any value in one move.\nReturn the minimum difference between the largest and smallest value of nums after perfoming at most 3 moves.\n \nExample 1:\nInput: nums = [5,3,2,4]\nOutput: 0\nExplanation: Change the array [5,3,2,4] to [2,2,2,2].\nThe difference between the maximum and minimum is 2-2 = 0.\nExample 2:\nInput: nums = [1,5,0,10,14]\nOutput: 1\nExplanation: Change the array [1,5,0,10,14] to [1,1,0,1,1]. \nThe difference between the maximum and minimum is 1-0 = 1.\n\nExample 3:\nInput: nums = [6,6,0,1,1,4,6]\nOutput: 2\n\nExample 4:\nInput: nums = [1,5,6,14,15]\nOutput: 1\n\n \nConstraints:\n\n1 <= nums.length <= 10^5\n-10^9 <= nums[i] <= 10^9", "starter_code": "\nclass Solution:\n def minDifference(self, nums: List[int]) -> int:\n ", "test_cases": {"inputs": [[[2, 3, 4, 5]]], "outputs": [0], "fn_name": "minDifference"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "673a127e1881db3b43c036badb6ef20196d1ecfb", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "minDifference"} {"seed_id": "apps-00309", "original_id": null, "source": "apps", "domain": "code", "problem": "A character in UTF8 can be from 1 to 4 bytes long, subjected to the following rules:\n\nFor 1-byte character, the first bit is a 0, followed by its unicode code.\nFor n-bytes character, the first n-bits are all one's, the n+1 bit is 0, followed by n-1 bytes with most significant 2 bits being 10.\n\nThis is how the UTF-8 encoding would work:\n\n Char. number range | UTF-8 octet sequence\n (hexadecimal) | (binary)\n --------------------+---------------------------------------------\n 0000 0000-0000 007F | 0xxxxxxx\n 0000 0080-0000 07FF | 110xxxxx 10xxxxxx\n 0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx\n 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx\n\n\nGiven an array of integers representing the data, return whether it is a valid utf-8 encoding.\n\n\nNote:\nThe input is an array of integers. Only the least significant 8 bits of each integer is used to store the data. This means each integer represents only 1 byte of data.\n\n\n\nExample 1:\n\ndata = [197, 130, 1], which represents the octet sequence: 11000101 10000010 00000001.\n\nReturn true.\nIt is a valid utf-8 encoding for a 2-bytes character followed by a 1-byte character.\n\n\n\n\nExample 2:\n\ndata = [235, 140, 4], which represented the octet sequence: 11101011 10001100 00000100.\n\nReturn false.\nThe first 3 bits are all one's and the 4th bit is 0 means it is a 3-bytes character.\nThe next byte is a continuation byte which starts with 10 and that's correct.\nBut the second continuation byte does not start with 10, so it is invalid.", "starter_code": "\nclass Solution:\n def validUtf8(self, data: List[int]) -> bool:\n ", "test_cases": {"inputs": [[[197, 130, 1]]], "outputs": [true], "fn_name": "validUtf8"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "36b08f9cb54f2f243df46f7197d97215ce84f767", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "validUtf8"} {"seed_id": "apps-00314", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1.\nYou may assume that you have an infinite number of each kind of coin.\n \nExample 1:\nInput: coins = [1,2,5], amount = 11\nOutput: 3\nExplanation: 11 = 5 + 5 + 1\n\nExample 2:\nInput: coins = [2], amount = 3\nOutput: -1\n\nExample 3:\nInput: coins = [1], amount = 0\nOutput: 0\n\nExample 4:\nInput: coins = [1], amount = 1\nOutput: 1\n\nExample 5:\nInput: coins = [1], amount = 2\nOutput: 2\n\n \nConstraints:\n\n1 <= coins.length <= 12\n1 <= coins[i] <= 231 - 1\n0 <= amount <= 104", "starter_code": "\nclass Solution:\n def coinChange(self, coins: List[int], amount: int) -> int:\n ", "test_cases": {"inputs": [[[1, 2, 5], 11]], "outputs": [3], "fn_name": "coinChange"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "4ce4a509456c523171d24fad258bed9565f6acec", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "coinChange"} {"seed_id": "apps-00319", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given an integer array nums. The value of this array is defined as the sum of |nums[i]-nums[i+1]| for all 0 <= i < nums.length-1.\nYou are allowed to select any subarray of the given array and reverse it. You can perform this operation only once.\nFind maximum possible value of the final array.\n \nExample 1:\nInput: nums = [2,3,1,5,4]\nOutput: 10\nExplanation: By reversing the subarray [3,1,5] the array becomes [2,5,1,3,4] whose value is 10.\n\nExample 2:\nInput: nums = [2,4,9,24,2,1,10]\nOutput: 68\n\n \nConstraints:\n\n1 <= nums.length <= 3*10^4\n-10^5 <= nums[i] <= 10^5", "starter_code": "\nclass Solution:\n def maxValueAfterReverse(self, nums: List[int]) -> int:\n ", "test_cases": {"inputs": [[[2, 3, 1, 5, 4]]], "outputs": [10], "fn_name": "maxValueAfterReverse"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "6b7406e01731d3c661cf8969c889c70ec7206226", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "maxValueAfterReverse"} {"seed_id": "apps-00324", "original_id": null, "source": "apps", "domain": "code", "problem": "Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.\n\nIf the fractional part is repeating, enclose the repeating part in parentheses.\n\nExample 1:\n\n\nInput: numerator = 1, denominator = 2\nOutput: \"0.5\"\n\n\nExample 2:\n\n\nInput: numerator = 2, denominator = 1\nOutput: \"2\"\n\nExample 3:\n\n\nInput: numerator = 2, denominator = 3\nOutput: \"0.(6)\"", "starter_code": "\nclass Solution:\n def fractionToDecimal(self, numerator: int, denominator: int) -> str:\n ", "test_cases": {"inputs": [[1, 2]], "outputs": ["0.5"], "fn_name": "fractionToDecimal"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "8e0591609813ffe89e7e10eb4ae090a024f6ebdd", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "fractionToDecimal"} {"seed_id": "apps-00329", "original_id": null, "source": "apps", "domain": "code", "problem": "Given the array nums consisting of n positive integers. You computed the sum of all non-empty continous subarrays from the array and then sort them in non-decreasing order, creating a new array of n * (n + 1) / 2 numbers.\nReturn the sum of the numbers from index left to index right (indexed from 1), inclusive, in the new array. Since the answer can be a huge number return it modulo 10^9 + 7.\n \nExample 1:\nInput: nums = [1,2,3,4], n = 4, left = 1, right = 5\nOutput: 13 \nExplanation: All subarray sums are 1, 3, 6, 10, 2, 5, 9, 3, 7, 4. After sorting them in non-decreasing order we have the new array [1, 2, 3, 3, 4, 5, 6, 7, 9, 10]. The sum of the numbers from index le = 1 to ri = 5 is 1 + 2 + 3 + 3 + 4 = 13. \n\nExample 2:\nInput: nums = [1,2,3,4], n = 4, left = 3, right = 4\nOutput: 6\nExplanation: The given array is the same as example 1. We have the new array [1, 2, 3, 3, 4, 5, 6, 7, 9, 10]. The sum of the numbers from index le = 3 to ri = 4 is 3 + 3 = 6.\n\nExample 3:\nInput: nums = [1,2,3,4], n = 4, left = 1, right = 10\nOutput: 50\n\n \nConstraints:\n\n1 <= nums.length <= 10^3\nnums.length == n\n1 <= nums[i] <= 100\n1 <= left <= right <= n * (n + 1) / 2", "starter_code": "\nclass Solution:\n def rangeSum(self, nums: List[int], n: int, left: int, right: int) -> int:\n ", "test_cases": {"inputs": [[[1, 2, 3, 4], 4, 1, 5]], "outputs": [13], "fn_name": "rangeSum"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "e72c9c3ae97eea1d62f48135a74820550ef2e92d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "rangeSum"} {"seed_id": "apps-00334", "original_id": null, "source": "apps", "domain": "code", "problem": "You have a pointer at index 0 in an array of size arrLen. At each step, you can move 1 position to the left, 1 position to the right in the array or stay in the same place  (The pointer should not be placed outside the array at any time).\nGiven two integers steps and arrLen, return the number of ways such that your pointer still at index 0 after exactly steps steps.\nSince the answer may be too large, return it modulo 10^9 + 7.\n \nExample 1:\nInput: steps = 3, arrLen = 2\nOutput: 4\nExplanation: There are 4 differents ways to stay at index 0 after 3 steps.\nRight, Left, Stay\nStay, Right, Left\nRight, Stay, Left\nStay, Stay, Stay\n\nExample 2:\nInput: steps = 2, arrLen = 4\nOutput: 2\nExplanation: There are 2 differents ways to stay at index 0 after 2 steps\nRight, Left\nStay, Stay\n\nExample 3:\nInput: steps = 4, arrLen = 2\nOutput: 8\n\n \nConstraints:\n\n1 <= steps <= 500\n1 <= arrLen <= 10^6", "starter_code": "\nclass Solution:\n def numWays(self, steps: int, arrLen: int) -> int:\n ", "test_cases": {"inputs": [[3, 2]], "outputs": [4], "fn_name": "numWays"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "98d116b52c2f0377d69b04caa1ae4cc3760b99f9", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "numWays"} {"seed_id": "apps-00339", "original_id": null, "source": "apps", "domain": "code", "problem": "In an array A containing only 0s and 1s, a K-bit flip consists of choosing a (contiguous) subarray of length K and simultaneously changing every 0 in the subarray to 1, and every 1 in the subarray to 0.\nReturn the minimum number of K-bit flips required so that there is no 0 in the array.  If it is not possible, return -1.\n \nExample 1:\nInput: A = [0,1,0], K = 1\nOutput: 2\nExplanation: Flip A[0], then flip A[2].\n\n\nExample 2:\nInput: A = [1,1,0], K = 2\nOutput: -1\nExplanation: No matter how we flip subarrays of size 2, we can't make the array become [1,1,1].\n\n\nExample 3:\nInput: A = [0,0,0,1,0,1,1,0], K = 3\nOutput: 3\nExplanation:\nFlip A[0],A[1],A[2]: A becomes [1,1,1,1,0,1,1,0]\nFlip A[4],A[5],A[6]: A becomes [1,1,1,1,1,0,0,0]\nFlip A[5],A[6],A[7]: A becomes [1,1,1,1,1,1,1,1]\n\n \n\n\nNote:\n\n1 <= A.length <= 30000\n1 <= K <= A.length", "starter_code": "\nclass Solution:\n def minKBitFlips(self, A: List[int], K: int) -> int:\n ", "test_cases": {"inputs": [[[0, 1, 0], 1]], "outputs": [2], "fn_name": "minKBitFlips"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "15d02b37b99a438dda09669af0508875b4531451", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "minKBitFlips"} {"seed_id": "apps-00344", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and - as its new symbol.\n \n\nFind out how many ways to assign symbols to make sum of integers equal to target S. \n\n\nExample 1:\n\nInput: nums is [1, 1, 1, 1, 1], S is 3. \nOutput: 5\nExplanation: \n\n-1+1+1+1+1 = 3\n+1-1+1+1+1 = 3\n+1+1-1+1+1 = 3\n+1+1+1-1+1 = 3\n+1+1+1+1-1 = 3\n\nThere are 5 ways to assign symbols to make the sum of nums be target 3.\n\n\n\nNote:\n\nThe length of the given array is positive and will not exceed 20. \nThe sum of elements in the given array will not exceed 1000.\nYour output answer is guaranteed to be fitted in a 32-bit integer.", "starter_code": "\nclass Solution:\n def findTargetSumWays(self, nums: List[int], S: int) -> int:\n ", "test_cases": {"inputs": [[[1, 1, 1, 1, 1], 3]], "outputs": [5], "fn_name": "findTargetSumWays"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "bb0449b544738bceec44e972673974dde52255b1", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "findTargetSumWays"} {"seed_id": "apps-00349", "original_id": null, "source": "apps", "domain": "code", "problem": "You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That means the first house is the neighbor of the last one. Meanwhile, adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into on the same night.\n\nGiven a list of non-negative integers representing the amount of money of each house, determine the maximum amount of money you can rob tonight without alerting the police.\n\nExample 1:\n\n\nInput: [2,3,2]\nOutput: 3\nExplanation: You cannot rob house 1 (money = 2) and then rob house 3 (money = 2),\n  because they are adjacent houses.\n\n\nExample 2:\n\n\nInput: [1,2,3,1]\nOutput: 4\nExplanation: Rob house 1 (money = 1) and then rob house 3 (money = 3).\n  Total amount you can rob = 1 + 3 = 4.", "starter_code": "\nclass Solution:\n def rob(self, nums: List[int]) -> int:\n ", "test_cases": {"inputs": [[[2, 3, 2]]], "outputs": [3], "fn_name": "rob"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "e0005040a225ada9eef62a5b701ec8eecf811624", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "rob"} {"seed_id": "apps-00354", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a string s of '(' , ')' and lowercase English characters. \nYour task is to remove the minimum number of parentheses ( '(' or ')', in any positions ) so that the resulting parentheses string is valid and return any valid string.\nFormally, a parentheses string is valid if and only if:\n\nIt is the empty string, contains only lowercase characters, or\nIt can be written as AB (A concatenated with B), where A and B are valid strings, or\nIt can be written as (A), where A is a valid string.\n\n \nExample 1:\nInput: s = \"lee(t(c)o)de)\"\nOutput: \"lee(t(c)o)de\"\nExplanation: \"lee(t(co)de)\" , \"lee(t(c)ode)\" would also be accepted.\n\nExample 2:\nInput: s = \"a)b(c)d\"\nOutput: \"ab(c)d\"\n\nExample 3:\nInput: s = \"))((\"\nOutput: \"\"\nExplanation: An empty string is also valid.\n\nExample 4:\nInput: s = \"(a(b(c)d)\"\nOutput: \"a(b(c)d)\"\n\n \nConstraints:\n\n1 <= s.length <= 10^5\ns[i] is one of  '(' , ')' and lowercase English letters.", "starter_code": "\nclass Solution:\n def minRemoveToMakeValid(self, s: str) -> str:\n ", "test_cases": {"inputs": [["\"lee(t(c)o)de)\""]], "outputs": ["\"lee(t(c)o)de\""], "fn_name": "minRemoveToMakeValid"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "04a91dca588f0776cfcc5c762320db4056f424ae", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "minRemoveToMakeValid"} {"seed_id": "apps-00359", "original_id": null, "source": "apps", "domain": "code", "problem": "There are N Snuke Cats numbered 1, 2, \\ldots, N, where N is even.\nEach Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.\nRecently, they learned the operation called xor (exclusive OR).What is xor?\n\nFor n non-negative integers x_1, x_2, \\ldots, x_n, their xor, x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is defined as follows:\n\n - When x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. \nFor example, 3~\\textrm{xor}~5 = 6.\n\n\nThey wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf.\nWe know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i.\nUsing this information, restore the integer written on the scarf of each Snuke Cat.\n\n-----Constraints-----\n - All values in input are integers.\n - 2 \\leq N \\leq 200000\n - N is even.\n - 0 \\leq a_i \\leq 10^9\n - There exists a combination of integers on the scarfs that is consistent with the given information.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nN\na_1 a_2 \\ldots a_N\n\n-----Output-----\nPrint a line containing N integers separated with space.\nThe i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i.\nIf there are multiple possible solutions, you may print any of them.\n\n-----Sample Input-----\n4\n20 11 9 24\n\n-----Sample Output-----\n26 5 7 22\n\n - 5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n - 26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n - 26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n - 26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\nThus, this output is consistent with the given information.", "starter_code": "", "test_cases": {"inputs": ["4\n20 11 9 24\n"], "outputs": ["26 5 7 22\n"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "108e0cee91009dcdb241ef038e9b9f3872f64d7a", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00364", "original_id": null, "source": "apps", "domain": "code", "problem": "Finally, the pandemic is over in ChefLand, and the chef is visiting the school again. Chef likes to climb the stairs of his school's floor by skipping one step, sometimes chef climbs the stairs one by one. Simply, the chef can take one or 2 steps in one upward movement. There are N stairs between ground and next floor. The chef is on the ground floor and he wants to go to the next floor with Cheffina but, Cheffina asks chef in how many ways, the chef can reach the next floor normally or any combination of skipping one step, where order doesn't matter. \n\n-----Input:-----\n- First-line will contain $T$, the number of test cases. Then the test cases follow. \n- Each test case contains a single line of input, two integers $N$. \n\n-----Output:-----\nFor each test case, output in a single line answer as the number of ways.\n\n-----Constraints-----\n- $1 \\leq T \\leq 1000$\n- $1 \\leq N \\leq 10^5$\n\n-----Sample Input:-----\n1\n3\n\n-----Sample Output:-----\n2\n\n-----EXPLANATION:-----\nways: [1,1,1], here chef climb to the next floor, one by one stair.\n[1,2], here chef climb to the next floor, one step first and after that 2 stairs at once.\nNote, [2,1] consider the same as that of [1,2] hence ignored.", "starter_code": "", "test_cases": {"inputs": ["1\n3"], "outputs": ["2"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "4b6588e1a0d37d5e02db8e86baab0bcdb78b6819", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00369", "original_id": null, "source": "apps", "domain": "code", "problem": "There are total $N$ cars in a sequence with $ith$ car being assigned with an alphabet equivalent to the $ith$ alphabet of string $S$ . Chef has been assigned a task to calculate the total number of cars with alphabet having a unique even value in the given range X to Y (both inclusive)\n. The value of an alphabet is simply its position in alphabetical order e.g.: a=1, b=2, c=3…\nThe chef will be given $Q$\nsuch tasks having varying values of $X$ and $Y$\nNote: string $S$ contains only lowercase alphabets\n\n-----Input-----\nFirst line of input contains a string $S$ of length $N$.\nSecond line contains an integer denoting no. of queries $Q$.\nNext q lines contain two integers denoting values of $X$ and $Y$.\n\n-----Output-----\nFor each query print a single integer denoting total number of cars with alphabet having a unique even value in the given range $X$ to $Y$.\n\n-----Constraints-----\n- $1 \\leq n \\leq 10^5$\n- $1 \\leq q \\leq 10^5$\n\n-----Example Input-----\nbbccdd\n5\n1 2\n3 4\n5 6\n1 6\n2 5\n\n-----Example Output-----\n1\n0\n1\n2\n2\n\n-----Explanation:-----\nExample case 1: \nQuery 1: range 1 to 2 contains the substring $\"bb\"$ where each character has a value of 2. Since we will only be considering unique even values, the output will be 1", "starter_code": "", "test_cases": {"inputs": ["bbccdd\n5\n1 2\n3 4\n5 6\n1 6\n2 5"], "outputs": ["1\n0\n1\n2\n2"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "a6888b271acb2fa531a88595a4e18e71bc7bdb6f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00374", "original_id": null, "source": "apps", "domain": "code", "problem": "The median of a sequence is the element in the middle of the sequence after it is sorted. For a sequence with even size, the median is the average of the two middle elements of the sequence after sorting. For example, for a sequence $A = [1, 3, 3, 5, 4, 7, 11]$, the median is equal to $4$, and for $A = [2, 3, 4, 5]$, the median is equal to $(3+4)/2 = 3.5$.\nFulu is a famous programmer in his country. He wrote the following program (given in pseudocode) for finding the median in a sequence $A$ with length $N$:\nread(N)\nread(A[0], A[1], ..., A[N-1])\nsort(A)\n# simultaneously remove elements A[K] and A[N mod K] from the array A\n# the order of the remaining N-2 elements is unchanged\nremove(A[K], A[N mod K])\nreturn A[(N-2)/2] # integer division\n\nThe program takes an integer $K$ as a parameter. Fulu can choose this integer arbitrarily between $1$ and $N-1$ inclusive.\nLittle Lima, Fulu's friend, thinks Fulu's program is wrong (as always). As finding one counterexample would be an easy task for Lima (he has already found the sequence $A = [34, 23, 35, 514]$, which is a counterexample for any $K \\le 3$), Lima decided to make hacking more interesting. Fulu should give him four parameters $S, K, m, M$ (in addition to $N$) and Lima should find the lexicographically smallest proper sequence $A$ with length $N$ as a counterexample.\nWe say that a sequence $A$ with length $N$ ($0$-indexed) is proper if it satisfies the following conditions:\n- it contains only positive integers\n- $A_0 + A_1 +A_2 + \\dots + A_{N-1} = S$\n- $m \\le A_i \\le M$ for each $0 \\le i < N$\n- the number returned by Fulu's program, ran with the given parameter $K$, is different from the correct median of the sequence $A$\nCan you help Lima find the lexicographically smallest counterexample or determine that Fulu's program works perfectly for the given parameters?\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first and only line of each test case contains five space-separated integers $N$, $S$, $K$, $m$ and $M$.\n\n-----Output-----\nFor each test case, if there is no proper sequence, print a single line containing the integer $-1$; otherwise, print a single line containing $N$ space-separated integers — the lexicographically smallest proper sequence.\n\n-----Constraints-----\n- $1 \\le T \\le 8$\n- $3 \\le N \\le 10^5$\n- $1 \\le K \\le N-1$\n- $1 \\le S \\le 10^9$\n- $1 \\le m \\le M \\le S$\n\n-----Example Input-----\n2\n3 6 1 1 5\n4 4 2 1 3\n\n-----Example Output-----\n1 1 4\n-1\n\n-----Explanation-----\nExample case 1: For the sequence $A = [1, 1, 4]$, it is already sorted, so the program would just remove the first two elements ($K=1$, $N\\%K=0$) and return the only remaining element $4$. Obviously, the median of the original sequence is $1$. It can be shown that there is no lexicographically smaller proper sequence.\nExample case 2: The only possible sequence is $A = [1, 1, 1, 1]$, which is not proper, since Fulu's program will give the correct answer $1$ for it.", "starter_code": "", "test_cases": {"inputs": ["2\n3 6 1 1 5\n4 4 2 1 3\n"], "outputs": ["1 1 4\n-1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "5b6d527b1a6fc84dc0576687f6be3695b92ac7bb", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00379", "original_id": null, "source": "apps", "domain": "code", "problem": "Zonal Computing Olympiad 2015, 29 Nov 2014\n\nWe say that two integers x and y have a variation of at least K, if |x − y| ≥ K (the absolute value of their difference is at least K). Given a sequence of N integers a1,a2,...,aN and K, the total variation count is the number of pairs of elements in the sequence with variation at least K, i.e. it is the size of the set of pairs\n\n{(i,j)|1≤i 12\n2nd Laddu\n1 Unit power = 6 -> 12\nAfter using total 3 unit power sweetness of both laddus are same.", "starter_code": "", "test_cases": {"inputs": ["2\n2 2\n4 6"], "outputs": ["0\n3"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "aeea845fa7c2cc56766ab0669494e0fc8b39f335", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00459", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef has $K$ chocolates and he wants to distribute them to $N$ people (numbered $1$ through $N$). These people are standing in a line in such a way that for each $i$ ($1 \\le i \\le N-1$), person $i$ and person $i+1$ are adjacent.\nFirst, consider some way to distribute chocolates such that for each valid $i$, the number of chocolates the $i$-th person would receive from Chef is $A_i$ and the sum $S_1 = \\sum_{i=1}^{N-1} \\left|A_i - A_{i+1}\\right|$ is minimum possible. Of course, each person must receive a non-negative integer number of chocolates.\nThen, Chef wants to create a new sequence $B_1, B_2, \\ldots, B_N$ by rearranging (permuting) the elements of the sequence $A_1, A_2, \\ldots, A_N$. For each valid $i$, the number of chocolates the $i$-th person actually receives from Chef is $B_i$. Chef wants to distribute the chocolates (choose $B_1, B_2, \\ldots, B_N$ by permuting the sequence $A$ and give $B_i$ chocolates to the $i$-th person for each valid $i$) in such a way that $S_2 = \\sum_{i=1}^{N-1} \\left|B_i – B_{i+1}\\right|$ is maximum possible. You need to find the maximum value of $S_2$.\nIt is guaranteed that $S_2$ does not depend on the exact choice of the sequence $A_1, A_2, \\ldots, A_N$, as long as it is a sequence that minimises $S_1$.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains a single integer $N$.\n- The second line contains a single integer $K$.\n\n-----Output-----\nFor each test case, print a single line containing one integer — the maximum value of the sum $S_2$.\n\n-----Constraints-----\n- $1 \\le T \\le 10$\n- $2 \\le N \\le 10^5$\n- $2 \\le K \\le 10^{100,000}$\n\n-----Subtasks-----\nSubtask #1 (30 points): $2 \\le N, K \\le 1,000$\nSubtask #2 (70 points): original constraints\n\n-----Example Input-----\n1\n3\n2\n\n-----Example Output-----\n2\n\n-----Explanation-----\nExample case 1: To minimise $S_1$, Chef could give $1$ chocolate to person $1$ and $1$ chocolate to person $2$, so $S_1 = |1-1| + |1-0| = 1$.\nTo maximise $S_2$, Chef can give $1$ chocolate to person $1$ and $1$ chocolate to person $3$, since the sequence $B = (1, 0, 1)$ is a permutation of $A = (1, 1, 0)$. Then, $S_2 = |1-0| + |0-1| = 2$.", "starter_code": "", "test_cases": {"inputs": ["1\n3\n2"], "outputs": ["2"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "982654b54d7aee2f90d2f1f3c16c67d6d89617e2", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00464", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef is the event manager of his college. He has been assigned the task to manage the upcoming tech fest. There are $K$ rooms where the event can take place, and at a particular time only one event can be organized in a room for a particular time interval.\nEach event coordinator has their strictly preferred room $P_i$, and if the room is already occupied he simply cancels that event.Chef wants to maximize the total number of events,and so he allows or disallows certain events in order to achieve the task . Chef is busy handling his events so the chef needs your help .\nGiven a list of $N$ events with their start time $S_i$,end time $E_i$ and preferred room $P_i$,you need to calculate the maximum number of events that can take place.\nNote that the $i$th event wants to occupy the $p_i$ room from [$s_i$, $f_i$) .\n\n-----Input:-----\nThe first line contains an integer $T$ denoting the number of test cases . Each of the next $T$ lines contains two integers $N$ and $K$ , the number of events and the number of rooms respectively . Each of the next $N$ lines contains three integers $s_i$ ,$e_i$ and $p_i$,the start time ,end time and the preferred room of ith event.\n\n-----Output:-----\nPrint the maximum number of events that can take place.\n\n-----Constraints-----\n- $1 \\leq T \\leq 100$\n- $1 \\leq N \\leq 10^3$\n- $1 \\leq K \\leq 10^5$\n- $1 \\leq Si < Ei \\leq 10^9$\n- $1 \\leq Pi \\leq K$\n\n-----Sample Input:-----\n1\n\n4 2\n1 10 1\n10 20 2\n15 50 2\n20 30 2\n\n-----Sample Output:-----\n3\n\n-----EXPLANATION:-----\nChef can allow events 1st ,2nd and 4th,to get the maximum 3.", "starter_code": "", "test_cases": {"inputs": ["1\n4 2\n1 10 1\n10 20 2\n15 50 2\n20 30 2"], "outputs": ["3"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "229e7a10d6bf1276930bcc37f7aff1e50e209b03", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00469", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef had a sequence of positive integers with length $N + K$. He managed to calculate the arithmetic average of all elements of this sequence (let's denote it by $V$), but then, his little brother deleted $K$ elements from it. All deleted elements had the same value.\nChef still knows the remaining $N$ elements — a sequence $A_1, A_2, \\ldots, A_N$. Help him with restoring the original sequence by finding the value of the deleted elements or deciding that there is some mistake and the described scenario is impossible.\nNote that the if it is possible for the deleted elements to have the same value, then it can be proven that it is unique. Also note that this value must be a positive integer.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains three space-separated integers $N$, $K$ and $V$.\n- The second line contains $N$ space-separated integers $A_1, A_2, \\ldots, A_N$.\n\n-----Output-----\nFor each test case, print a single line containing one integer — the value of the deleted elements, or $-1$ if there is a mistake.\n\n-----Constraints-----\n- $1 \\le T \\le 100$\n- $1 \\le N, K \\le 100$\n- $1 \\le V \\le 10^5$\n- $1 \\le A_i \\le 10^5$ for each valid $i$\n\n-----Subtasks-----\nSubtask #1 (100 points): original constraints\n\n-----Example Input-----\n3\n3 3 4\n2 7 3\n3 1 4\n7 6 5\n3 3 4\n2 8 3\n\n-----Example Output-----\n4\n-1\n-1", "starter_code": "", "test_cases": {"inputs": ["3\n3 3 4\n2 7 3\n3 1 4\n7 6 5\n3 3 4\n2 8 3"], "outputs": ["4\n-1\n-1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "fa253d63650b470f3839a8509e83e06f2bfa9cdd", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00474", "original_id": null, "source": "apps", "domain": "code", "problem": "Kabir wants to impress Tara by showing her his problem solving skills. He has decided to give the correct answer to the next question which will be asked by his Algorithms teacher.\nThe question asked is:\nFind the sum of alternate consecutive d$d$ odd numbers from the range L$L$ to R$R$ inclusive.\nif d$d$ is 3 and L$L$ is 10 and R$R$ is 34, then the odd numbers between 10 and 34 are 11,13,15,17,19,21,23,25,27,29,31,33$11,13,15,17,19,21,23,25,27,29,31,33$, and the d$d$ alternate odd numbers are 11,13,15,23,25,27$11,13,15,23,25,27$.\nYou are a friend of Kabir, help him solve the question.\nNote:$Note:$ Number of odd number between L$L$ and R$R$ (both inclusive) is a multiple of d$d$.\n\n-----Input:-----\n- First line will contain T$T$, number of test cases. \n- First line of each test case contains one integer d$d$ . \n- Second line of each test case contains two space separated integer L$L$ and R$R$.\n\n-----Output:-----\nFor each test case, print the sum modulo 1000000007.\n\n-----Constraints:-----\n- 1≤T≤106$1 \\leq T \\leq 10^6$\n- 1≤d≤103$1 \\leq d \\leq 10^3$\n- 1≤Lc>b>a.\n\nCan you help him in this?\n\n-----Input:-----\n- The first line contain the integer N\n- The second line contains N space separated integers representing A[1], A[2] … A[N]\n\n-----Output:-----\nThe maximum score that is possible\n\n-----Constraints-----\n- $4 \\leq N \\leq 10^4$\n- $0 \\leq A[i] \\leq 10^5$\n\n-----Sample Input:-----\n6\n\n3 9 10 1 30 40\n\n-----Sample Output:-----\n46", "starter_code": "", "test_cases": {"inputs": ["6\n3 9 10 1 30 40"], "outputs": ["46"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "312c8ceca2d1a4221446372515cefe715381c534", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00519", "original_id": null, "source": "apps", "domain": "code", "problem": "Today is rose day, batch mates of Kabir and Tara decided to celebrate this day by exchanging roses with each other. \nNote:$Note:$ exchanging means both the boy and the girl will give rose to each other. \nIn the class there are B$B$ boys and G$G$ girls. \nExchange of rose will take place if and only if at least one of them hasn't received a rose from anyone else and a rose can be exchanged only once.\nTara has to bring maximum sufficient roses for everyone and is confused as she don't know how many roses to buy.You are a friend of Kabir, so help him to solve the problem so that he can impress Tara by helping her. \n\n-----Input:-----\n- First line will contain T$T$, number of test cases. \n- Each test case contains two space separated integers B$B$ (Number of boys) and G$G$ (Number of Girls).\n\n-----Output:-----\nFor each test case, output in a single line the total number of roses exchanged.\n\n-----Constraints:-----\n- 1≤T≤105$1 \\leq T \\leq 10^5$\n- 1≤B≤109$1 \\leq B \\leq 10^{9}$\n- 1≤G≤109$1 \\leq G \\leq 10^{9}$\n\n-----Sample Input:-----\n1\n2 3\n\n-----Sample Output:-----\n8", "starter_code": "", "test_cases": {"inputs": ["1\n2 3"], "outputs": ["8"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "0560ca2f6bc3326bebb974e9a7c7b6079fc2b6fa", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00524", "original_id": null, "source": "apps", "domain": "code", "problem": "Today, Chef decided to cook some delicious meals from the ingredients in his kitchen. There are $N$ ingredients, represented by strings $S_1, S_2, \\ldots, S_N$. Chef took all the ingredients, put them into a cauldron and mixed them up.\nIn the cauldron, the letters of the strings representing the ingredients completely mixed, so each letter appears in the cauldron as many times as it appeared in all the strings in total; now, any number of times, Chef can take one letter out of the cauldron (if this letter appears in the cauldron multiple times, it can be taken out that many times) and use it in a meal. A complete meal is the string \"codechef\". Help Chef find the maximum number of complete meals he can make!\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains a single integer $N$.\n- $N$ lines follow. For each $i$ ($1 \\le i \\le N$), the $i$-th of these lines contains a single string $S_i$.\n\n-----Output-----\nFor each test case, print a single line containing one integer — the maximum number of complete meals Chef can create.\n\n-----Constraints-----\n- $1 \\le T \\le 100$\n- $1 \\le N \\le 100$\n- $|S_1| + |S_2| + \\ldots + |S_N| \\le 1,000$\n- each string contains only lowercase English letters\n\n-----Example Input-----\n3\n6\ncplusplus\noscar\ndeck\nfee\nhat\nnear\n5\ncode\nhacker\nchef\nchaby\ndumbofe\n5\ncodechef\nchefcode\nfehcedoc\ncceeohfd\ncodechef\n\n-----Example Output-----\n1\n2\n5\n\n-----Explanation-----\nExample case 1: After mixing, the cauldron contains the letter 'c' 3 times, the letter 'e' 4 times, and each of the letters 'o', 'd', 'h' and 'f' once. Clearly, this is only enough for one \"codechef\" meal.\nExample case 2: After mixing, the cauldron contains the letter 'c' 4 times, 'o' 2 times, 'd' 2 times, 'e' 4 times, 'h' 3 times and 'f' 2 times, which is enough to make 2 meals.", "starter_code": "", "test_cases": {"inputs": ["3\n6\ncplusplus\noscar\ndeck\nfee\nhat\nnear\n5\ncode\nhacker\nchef\nchaby\ndumbofe\n5\ncodechef\nchefcode\nfehcedoc\ncceeohfd\ncodechef"], "outputs": ["1\n2\n5"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "ea978d0c4df1d5aac81cdc0d68726bf5105024d7", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00529", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a string consisting of only lowercase English alphabets, your task is to find the smallest palindromic substring.\nIn case there are multiple palindromic substrings of the same length present, print the lexicographically smallest substring. \nFormally, a substring is a contiguous sequence of characters within a string. So in a string \"abcdef\", \"abc\" is a substring whereas \"adf\" is not a substring.\nA palindrome is a word, phrase, or sequence that reads the same backwards as forwards, e.g. madam or mom.\n\n-----Input:-----\n- First-line will contain $T$, the number of test cases. Then the test cases follow. \n- Each test case contains of two lines of input, two integers.\n- First, we have a single integer $N$ which signifies the length of the substring.\n- Next, we have a string of length $N$ that only has lowercase English alphabets.\n\n-----Output:-----\nFor each testcase, output in a single line the shortest palindromic substring.\n\n-----Constraints-----\n- $1 \\leq T \\leq 100$\n- $2 \\leq N \\leq 10^5$\n\n-----Sample Input:-----\n2\n2\nzy\n1\ncd\n\n-----Sample Output:-----\ny\nc\n\n-----EXPLANATION:-----\nThere are only two possibilities. \"z\" and \"y\". Since both of them have the same length. We print the lexicographically smaller substring which is y.", "starter_code": "", "test_cases": {"inputs": ["2\n2\nzy\n1\ncd"], "outputs": ["y\nc"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "cfae8d72e07b83c1cf13bd6c8c3f08f4d7a3628d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00534", "original_id": null, "source": "apps", "domain": "code", "problem": "Calculate the power of an army of numbers from 1 to $N$, both included.\n\n-----Input:-----\n- First line will contain a single integer $N$.\n\n-----Output:-----\nFor each testcase, output in a single line containing the answer.\n\n-----Constraints-----\n- $1 \\leq N \\leq 5000$\n\n-----Sample Input:-----\n24\n\n-----Sample Output:-----\n5", "starter_code": "", "test_cases": {"inputs": ["24"], "outputs": ["5"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "f15d390de6e469b705114844a27e9657d3b54f3e", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00539", "original_id": null, "source": "apps", "domain": "code", "problem": "Yesterday, Chef found $K$ empty boxes in the cooler and decided to fill them with apples. He ordered $N$ apples, where $N$ is a multiple of $K$. Now, he just needs to hire someone who will distribute the apples into the boxes with professional passion. \nOnly two candidates passed all the interviews for the box filling job. In one minute, each candidate can put $K$ apples into boxes, but they do it in different ways: the first candidate puts exactly one apple in each box, while the second one chooses a random box with the smallest number of apples and puts $K$ apples in it.\nChef is wondering if the final distribution of apples can even depend on which candidate he hires. Can you answer that question?\nNote: The boxes are distinguishable (labeled), while the apples are not. Therefore, two distributions of apples are different if there is a box such that the number of apples in it when the first candidate finishes working can be different from the number of apples in it when the second candidate finishes working.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first and only line of each test case contains two space-separated integers $N$ and $K$. \n\n-----Output-----\nFor each test case, print a single line containing the string \"YES\" if the final distributions of apples can be different or \"NO\" if they will be the same (without quotes).\n\n-----Constraints-----\n- $1 \\le T \\le 250$\n- $1 \\le N, K \\le 10^{18}$\n- $N$ is divisible by $K$\n\n-----Subtasks-----\nSubtask #1 (30 points): $1 \\le N, K \\le 10^5$\nSubtask #2 (70 points): original constraints\n\n-----Example Input-----\n3\n5 1\n4 2\n10 10\n\n-----Example Output-----\nNO\nNO\nYES\n\n-----Explanation-----\nExample case 1: No matter who is hired, all apples will be in the only box at the end.\nExample case 2: At the end, there will be two apples in each box.\nExample case 3: If we hire the first candidate, there will be one apple in each box, but if we hire the second one, there will be $10$ apples in one box and none in all other boxes.", "starter_code": "", "test_cases": {"inputs": ["3\n5 1\n4 2\n10 10"], "outputs": ["NO\nNO\nYES"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "b03e8dd3bbf8ce5d5744ed5aae34779ab2d6ffe7", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00544", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef has a number N, Cheffina challenges the chef to check the divisibility of all the permutation of N by 2. If any of the permutations is divisible by 2 then print 1 else print 0.\n\n-----Input:-----\n- First-line will contain $T$, the number of test cases. Then the test cases follow. \n- Each test case contains a single line of input, $N$. \n\n-----Output:-----\nFor each test case, output in a single line answer 1 or 0.\n\n-----Constraints-----\n- $1 \\leq T \\leq 10^6$\n- $1 \\leq N \\leq 10^6$\n\n-----Sample Input:-----\n2\n19\n385\n\n-----Sample Output:-----\n0\n1", "starter_code": "", "test_cases": {"inputs": ["2\n19\n385"], "outputs": ["0\n1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "f76f34f2296ad956af83a0824720275636f4279c", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00549", "original_id": null, "source": "apps", "domain": "code", "problem": "Sereja has a string A consisting of n lower case English letters. \n\nSereja calls two strings X and Y each of length n similar if they can be made equal by applying the following operation at most once in each of them.\n\n- Chose any two position i, j in the string (i can be equal to j too). Swap the characters at position i with character at position j.\n\nFor example strings \"abcd\" and \"acbd\" are similar, strings \"ab\" and \"ab\" are similar, but strings \"abcde\" and \"bcdea\" are not similar. Note that strings \"abc\" and \"cab\" are also similar, as you can swap 'a' and 'c' in the first string to get \"cba\" and 'a' and 'b' in the second string to get \"cba\". \n\nNow Sereja is interested in finding number of ordered pairs of non similar strings X and Y such that they can be constructed from a given string A by permutation of its characters. As answer could be large, please output your answer modulo (109 + 7).\n\nNote \n\nA string s (of size n) is said to be constructed from string t (also of size n) by permutation of its characters if there exists a permutation P (of length n), such that s[i] = t[P[i]] for each i from 1 to n.\n\n-----Input-----\n- First line contain integer T - number of test cases. \n- For each of the next T lines: \n\t\n- Each line contains a string A as defined in the problem.\n\n-----Output-----\nFor each test case, output answer modulo 1000000007 (109 + 7) in separate line. \n\n-----Constraints-----\n- 1 ≤ T ≤ 10 \n- 1 ≤ n ≤ 10^5 \n\n-----Constraints-----\n- Subtask #1: 1 ≤ n ≤ 10 (25 points)\n- Subtask #2: 1 ≤ n ≤ 100 (25 points)\n- Subtask #3: 1 ≤ n ≤ 1000 (25 points)\n- Subtask #4: original constraints (25 points)\n\n-----Example-----\nInput:\n2\nz\nabcd\n\nOutput:\n0\n144", "starter_code": "", "test_cases": {"inputs": ["2\nz\nabcd\n\n"], "outputs": ["0\n144"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "ef5f2d2248204585b16c7b717f63903fc647e5ad", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00554", "original_id": null, "source": "apps", "domain": "code", "problem": "The MEX of a set of integers is defined as the smallest non-negative integer that does not belong to this set. For example, $\\mathrm{MEX}(\\{0,2,3\\}) = 1$ and $\\mathrm{MEX}(\\{1,3\\}) = 0$.\nChef has a tree with $N$ nodes (numbered $1$ through $N$). The tree is rooted at node $1$. Chef wants to assign a non-negative integer to each node in such a way that each integer between $0$ and $N-1$ (inclusive) is assigned to exactly one node.\nFor each node $u$, consider the integers assigned to the nodes in the subtree of $u$ (including $u$); let $a_u$ denote the MEX of these integers. Chef wants $a_1 + a_2 + \\ldots + a_N$ to be as large as possible. Find the maximum possible value of this sum.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains a single integer $N$.\n- The second line contains $N-1$ space-separated integers $p_1, p_2, \\ldots, p_{N-1}$. For each valid $i$, the node $p_i$ is the parent of the node $i+1$.\n\n-----Output-----\nFor each test case, print a single line containing one integer ― the maximum sum of subtree MEX-s which can be obtained if you assign the weights optimally.\n\n-----Constraints-----\n- $1 \\le T \\le 5$\n- $2 \\le N \\le 10^5$\n- $1 \\le p_i < i$ for each valid $i$\n\n-----Subtasks-----\nSubtask #1 (100 points): original constraints\n\n-----Example Input-----\n2\n3\n1 1\n5\n1 1 2 2\n\n-----Example Output-----\n4\n9", "starter_code": "", "test_cases": {"inputs": ["2\n3\n1 1\n5\n1 1 2 2\n"], "outputs": ["4\n9"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "d5d1b9f7e1fca4b70e960d90c92f4672a190e74c", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00559", "original_id": null, "source": "apps", "domain": "code", "problem": "A permutation of length n is an array of size n consisting of n distinct integers in the range [1, n]. For example, (3, 2, 4, 1) is a permutation of length 4, but (3, 3, 1, 4) and (2, 3, 4, 5) are not, as (3, 3, 1, 4) contains duplicate elements, and (2, 3, 4, 5) contains elements not in range [1,4].\nA permutation p of length n is good if and only if for any 1 ≤ i ≤ n, pi ≠ i.\nPlease find the lexicographically smallest good permutation p.\nDefinition for \"lexicographically smaller\":\nFor two permutations p and q, we say that p is lexicographically smaller than q if and only if there exists a index 1 ≤ l ≤ n such that:\n- For any 1 ≤ i < l, pi = qi. Note that if l = 1, this constraint means nothing.\n- and, pl < ql.\n\nFor example, (2, 3, 1, 4) < (2, 3, 4, 1) < (3, 4, 1, 2). The lexicographically smallest permutation is, of course, (1, 2, ..., n), though this one is not good.\n\n-----Input-----\nFirst line of the input contains an integer T denoting number of test cases.\nFor each test case, the only line contains an integer n.\n\n-----Output-----\nFor each test case, output the lexicographically smallest good permutation of length n. It's guaranteed that this permutation exists.\n\n-----Constraints-----\n- 1 ≤ T ≤ 10\n- 2 ≤ n ≤ 105\n\n-----Subtasks-----\n- Subtask #1 (17 points): 2 ≤ n ≤ 9\n- Subtask #2 (83 points): Original Constraints\n\n-----Example-----\nInput:\n4\n2\n3\n5\n6\n\nOutput:\n2 1\n2 3 1\n2 1 4 5 3\n2 1 4 3 6 5\n\n-----Explanation-----\nExample case 1. The only good permutation of length 2 is (2, 1).\nExample case 2. Consider all permutations of length 3, they are(in lexicographically order):\n- p = (1, 2, 3), it's not good since p[1] = 1, p[2] = 2 and p[3] = 3;\n- p = (1, 3, 2), it's not good since p[1] = 1;\n- p = (2, 1, 3), it's not good since p[3] = 3;\n- p = (2, 3, 1), it's good since p[1] ≠ 1, p[2] ≠ 2 and p[3] ≠ 3;\n- p = (3, 1, 2), it's good since p[1] ≠ 1, p[2] ≠ 2 and p[3] ≠ 3;\n- p = (3, 2, 1), it's not good since p[2] = 2.\nThus the minimum good one is (2, 3, 1).\nExample case 3. Consider two good permutations for third test case: p=(2, 1, 4, 5, 3) and q=(2, 4, 1, 5, 3), then p < q. You can check lexicographically condition as follows. Find the first index where the entries of two permutations are different, and compare those entries. For example, in this case, the first position where the entries differ is index 2. You can see that p[2] < q[2], as 1 < 4, so p is lexicographically smaller than q.", "starter_code": "", "test_cases": {"inputs": ["4\n2\n3\n5\n6\n\n"], "outputs": ["2 1\n2 3 1\n2 1 4 5 3\n2 1 4 3 6 5"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "9f634f5fb53551b0c48a4862fa7a6a1801b6f285", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00564", "original_id": null, "source": "apps", "domain": "code", "problem": "\"Ring Ring!!\" \nSherlock's phone suddenly started ringing. And it was none other than Jim Moriarty..\n\"Long time no see ! You miss me right ? Anyway we'll talk about it later . Let me first tell you something. Dr.Watson is with me . And you've got only one chance to save him . Here's your challenge:.\nGiven a number N and another number M, tell if the remainder of N%M is odd or even. If it's odd, then print \"ODD\" else print \"EVEN\" \n\nIf Sherlock can answer the query correctly, then Watson will be set free. He has approached you for help since you being a programmer.Can you help him? \n\n-----Input-----\nThe first line contains, T, the number of test cases..\nEach test case contains an integer, N and M\n\n-----Output-----\nOutput the minimum value for each test case \n\n-----Constraints-----\n1 = T = 20\n1 <= N <= 10^18 \n1 <= M<= 10^9 \n\n-----Subtasks-----\nSubtask #1 : (20 points)\n1 = T = 20\n1 <= N <= 100 \n1 <= M<= 100 \n\nSubtask 2 : (80 points) \n\n1 = T = 20\n1 <= N <= 10^18 \n1 <= M<= 10^9 \n\n-----Example-----\nInput:\n2\n4 4\n6 5\n\nOutput:\nEVEN\nODD", "starter_code": "", "test_cases": {"inputs": ["2\n4 4\n6 5"], "outputs": ["EVEN\nODD"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "97d01c64d6b212e8b98f78e4e07dcc6e2a6c76a3", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00569", "original_id": null, "source": "apps", "domain": "code", "problem": "The chef was not happy with the binary number system, so he designed a new machine which is having 6 different states, i.e. in binary there is a total of 2 states as 0 and 1. Now, the chef is confused about how to correlate this machine to get an interaction with Integer numbers, when N(Integer number) is provided to the system, what will be the Nth number that system will return(in Integer form), help the chef to design this system.\n\n-----Input:-----\n- First-line will contain $T$, the number of test cases. Then the test cases follow. \n- Each test case contains a single line of input, $N$. \n\n-----Output:-----\nFor each test case, output in a single line answer given by the system.\n\n-----Constraints-----\n- $1 \\leq T \\leq 10^5$\n- $1 \\leq N \\leq 10^5$\n\n-----Sample Input:-----\n2\n3\n5\n\n-----Sample Output:-----\n7\n37\n\n-----EXPLANATION:-----\nInitial numbers for system = [1, 6, 7, 36, 37, 42, 43, 216, …..\nFor 1) 3rd Number for the system will be 7.\nFor 2) 5th Number for the system will be 37.", "starter_code": "", "test_cases": {"inputs": ["2\n3\n5"], "outputs": ["7\n37"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "6250ddc835688655317c12777a3b59a2de08aea2", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00574", "original_id": null, "source": "apps", "domain": "code", "problem": "As lockdown is going on so no is allowed to go outside , so Chef has come with an innovative idea for food home delivery using drone. But there is an issue with it , the drone can move forward or backward a fix number of steps $x$ . \nAll the houses and chef restaurant are all in a straight line . Homes which need delivery are located at $H[i]$ and chef is located at $y$ coordinate . \nIf Drone is at a location $R$, then it can move to $R-x$ or $R+x$ . \nHelp chef find maximum value of $x$ to complete all the deliveries as he is busy managing the orders.\n\n-----Input:-----\n- First line will contain $n$ and $R$, number of houses that need delivery and the correct coordinate of chef (Drone).\n- Second line contains $n$ integers , the coordinate of all homes that need delivery. \n\n-----Output:-----\n- The maximum value of $x$ , so that drone delivers to all houses.\n\n-----Constraints-----\n- $1 \\leq n \\leq 1000$\n- $1 \\leq R \\leq 10^9$\n- $1 \\leq hi \\leq 10^9$\n- $1 \\leq x \\leq 10^9$\n\n-----Sample Input:-----\n3 1\n3 5 11\n\n-----Sample Output:-----\n2\n\n-----EXPLANATION:-----\nChef's drone is at 1 initially and he needs to visit 3,5,11 , so optimal solution will be (maximum value of x ) equal to 2.", "starter_code": "", "test_cases": {"inputs": ["3 1\n3 5 11"], "outputs": ["2"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "438e7f24230a62a1707bee7aab6362aff6a65f30", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00579", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef has provided with a sequence of integers of length $N$ arranged in an unsorted fashion.\nThe elements of the sequence are ordered as ${A1,A2,A3.....A'N}$\nThe task of the chef is to identify the highest and lowest value among the given sequence. It is assured that the sequence given contains the highest and the lowest value always\nPlease help chef in finding the desired value.\n\n-----Input:-----\n- First line will contain $N$, number of elements in the sequence. \n- Next line contains $N$ integers of the sequence . \n\n-----Output:-----\nPrint the HIGHEST and LOWEST value of the sequence respectively.\n\n-----Constraints-----\n- $1 \\leq N \\leq 100$\n- $2 \\leq {A1,A2,A3.....A'N} \\leq 10^4$\n\n-----Sample Input:-----\n5\n3 2 7 9 4\n\n-----Sample Output:-----\n9 2\n\n-----EXPLANATION:-----\nThis list is :\n[3,2,7,9,4] so the highest value is 9 and lowest is 2 respectively.", "starter_code": "", "test_cases": {"inputs": ["5\n3 2 7 9 4"], "outputs": ["9 2"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "8f7649ed3f595987e96b8536d812d2d61f8020f9", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00584", "original_id": null, "source": "apps", "domain": "code", "problem": "One day Chef was playing with numbers. He loves Lowest Common Multiple (LCM) too much and he is a very curious guy. He always try to do new things. Now he want to make a large number with it. But he doesn't want to take too many numbers.\n\nHe is willing to take only three numbers less than or equal to N (not necessarily distinct ) and from those three number he want get the maximum number by taking LCM of the numbers.\n\nAs he is busy in playing some more tricks of maths, he assign this task to you.\n\n-----Input-----\nFirst line of input contains an integer t ( t<=1000 ), Number of test cases.\n\nt line follows an integer N\n\n-----Output-----\nPrint t lines contains a single integer — the maximum possible LCM of three not necessarily distinct positive integers that are not greater than N.\n\n-----Constraints-----\n1<= N <= 10^6\n\n-----Example-----\nInput:\n2\n9\n7\n\nOutput:\n504\n210\n\n\n-----Explanation-----\nExample case 2. For the last example, we can chose numbers 7, 6, 5 and the LCM of them is 7•6•5 = 210. It is the maximum value we can get.", "starter_code": "", "test_cases": {"inputs": ["2\n9\n7"], "outputs": ["504\n210"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "34975487e4e95ebfb88b37cb20e57a67b6a7f744", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00589", "original_id": null, "source": "apps", "domain": "code", "problem": "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.\nHe has lost many books, since many of his friends borrow his books and never bother to return them. He does not want to lose any more books and has decided to keep a record of all books that he lends to his friends. To make the task of borrowing a book a little difficult, he has given the following instructions to his friends: when they borrow a book, they must record in a register its position from the left among the books currently on the shelf.\nSuppose there are $5$ books in the library and they are arranged as follows:\n261421532614215326 \\quad 1 \\quad 42 \\quad 15 \\quad 3\nIf someone walks in and borrows the book $42$, then he will record $3$ in the register because this book is the third from the left on the shelf. Now the shelf looks like this:\n26115326115326 \\quad 1 \\quad 15 \\quad 3\nIf the next person borrow the book $3$, he writes down $4$ in the register since this is currently the fourth book from the left on the shelf, and so on.\nIndraneel knows the initial arrangement of the books in his library at the time that he introduced the register system. After a while he examines his register and would like to know which books have been borrowed. Your task is to write a program to help Indraneel solve this problem.\n\n-----Input:-----\nThe first line of the input contains a single integer $M$ indicating the number of books in Indraneel's library. The next line contains $M$ distinct positive integers describing the sequence in which the books are arranged on the library shelf. The third line of input contains a single integer $N$ indicating the number of entries in the register. This, in turn, is followed by $N$ lines (lines $4$ to $N+3$), each containing one positive integer. The integer on line $3+i$ indicates the position from left of the book ith book borrowed. (You may assume that the number on line $3+i$ is at most $M-i+1$.)\n\n-----Output:-----\n$N$ lines with one positive integer on each line. The number on line $i$ is the book borrowed by the ith borrower.\n\n-----Constraints:-----\n- $1 \\leq M \\leq 1000000$.\n- $1 \\leq N \\leq 4000$.\n\n-----Sample Input-----\n5\n26 1 42 15 3 \n2\n3\n4\n\n-----Sample Output-----\n42\n3", "starter_code": "", "test_cases": {"inputs": ["5\n26 1 42 15 3\n2\n3\n4"], "outputs": ["42\n3"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "9553a7c0869d8f5ce8fcb07153f5f902cae90693", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00594", "original_id": null, "source": "apps", "domain": "code", "problem": "Doubleville, a small town in Texas, was attacked by the aliens. They have abducted some of the residents and taken them to the a spaceship orbiting around earth. After some (quite unpleasant) human experiments, the aliens cloned the victims, and released multiple copies of them back in Doubleville. So now it might happen that there are 6 identical person named Hugh F. Bumblebee: the original person and its 5 copies. The Federal Bureau of Unauthorized Cloning (FBUC) charged you with the task of determining how many copies were made from each person. To help you in your task, FBUC have collected a DNA sample from each person. All copies of the same person have the same DNA sequence, and different people have different sequences (we know that there are no identical twins in the town, this is not an issue).\n\n\n-----Input-----\n\nThe input contains several blocks of test cases. Each case begins with a line containing two integers: the number 1 <= n <= 20000 people, and the length 1 <= m <= 20 of the DNA sequences. The next n lines contain the DNA sequences: each line contains a sequence of m characters, where each character is either 'A', 'C', 'G' or 'T'.\n\nThe input is terminated by a block with n = m = 0 .\n\n-----Output-----\nFor each test case, you have to output n lines, each line containing a single integer. The first line contains the number of different people that were not copied. The second line contains the number of people that were copied only once (i.e., there are two identical copies for each such person.) The third line contains the number of people that are present in three identical copies, and so on: the i -th line contains the number of persons that are present in i identical copies. For example, if there are 11 samples, one of them is from John Smith, and all the others are from copies of Joe Foobar, then you have to print '1' in the first and the tenth lines, and '0' in all the other lines.\n\n-----Example-----\nInput:\n\n9 6\nAAAAAA\nACACAC\nGTTTTG\nACACAC\nGTTTTG\nACACAC\nACACAC\nTCCCCC\nTCCCCC\n0 0\n\nOutput:\n\n1\n2\n0\n1\n0\n0\n0\n0\n0", "starter_code": "", "test_cases": {"inputs": ["9 6\nAAAAAA\nACACAC\nGTTTTG\nACACAC\nGTTTTG\nACACAC\nACACAC\nTCCCCC\nTCCCCC\n0 0\n\n"], "outputs": ["1\n2\n0\n1\n0\n0\n0\n0\n0"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "442eeaaf5ca142e37114a975a17bfb7b9fbd1a0f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00599", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef lives in a big apartment in Chefland. The apartment charges maintenance fees that he is supposed to pay monthly on time. But Chef is a lazy person and sometimes misses the deadlines. The apartment charges 1000 Rs per month as maintenance fees. Also, they also charge a one-time fine of 100 Rs for each of the late payments. It does not matter how late the payment is done, the fine is fixed to be Rs.100.\nChef has been living in the apartment for N months. Now, he wants to switch the apartment, so he has to pay the entire dues to the apartment. The deadline for the N-th month is also over. From his bank statement, he finds the information whether he paid apartment rent for a particular month for not. You are given this information by an array A of size N, where Ai (can be either 0 or 1) specifies whether he has paid the 1000Rs in the i-th month or not. Assume that Chef paid the fees in the i-th month, then this fees will be considered for the earliest month for which Chef has not yet paid the fees.\n\nFor example, assume Chef did not pay any money in first month and 1000Rs in the second month. Then this rent of 1000Rs will be considered for 1st month. But this counts as late payment for the first month's fees, and hence he will have to pay Rs. 100 for that. And since the payment he made in the second month is not accounted for the second month, but rather for the first month, he will incur a fine of Rs.100 even for the second month. \n\nHe has not paid any of the fines so far. Can you please help in finding Chef total due (all the fines, plus all the unpaid maintenance fees) that he has to pay to apartment? \n\n-----Input-----\nFirst line of the input contains an integer T denoting number of test cases. The description of T test cases follows.\nThe first line of each test cases contains an integer N denoting the number of months for which you have to calculate the total amount of money that Chef has to pay at the end of the n month to clear all of his dues.\nNext line of each test case contains N space separated integers (each of them can be either 0 or 1) denoting whether Chef paid the 1000Rs fees in the corresponding month or not. If the corresponding integer is 1, it means that Chef paid the maintenance fees for that month, whereas 0 will mean that Chef did not pay the maintenance fees that month.\n\n-----Output-----\nFor each test case, output a single integer denoting the total amount including fine that Chef has to pay.\n\n-----Constraints-----Constraints\n- 1 ≤ T ≤ 25\n- 0 ≤ Ai ≤ 1\n\n-----Subtasks-----\nSubtask #1 (30 points)\n- 1 ≤ N ≤ 103\n\nSubtask #2 (70 points)\n- 1 ≤ N ≤ 105\n\n-----Example-----\nInput\n4\n2\n1 1\n2\n0 0\n3\n0 1 0\n2\n0 1\n\nOutput\n0\n2200\n2300\n1200\n\n-----Explanation-----\nExample case 1. Chef paid maintenance fees for both the months. So, he does not have any dues left.\nExample case 2. Chef did not pay the maintenance fees for any of the months. For the first month, he has to pay 1000Rs, and 100Rs fine as a late payment. For second month payments, he just have to pay 1100Rs. So, in total he has a due of 1100 + 1100 = 2200 Rs.\nExample case 3. In the first month, Chef did not pay his maintenance fees. He paid the maintenance of first in the second month. So, he paid a fine of 100Rs for first month. For second and third month, Chef did not pay the maintenance fees. So, he has to pay 1000Rs + 100Rs (of fine) for second month and only 1000Rs + 100Rs (of fine) for third month. In total, Chef has got to pay 100 + 1100 + 1100 = 2300 Rs. \nExample case 4. In the first month, Chef did not pay his maintenance fees. He paid the maintenance of first in the second month. So, he paid a fine of 100Rs for first month. For second month, Chef did not pay the maintenance fees. So, he has to pay 1000Rs + 100Rs (of fine) for second month. In total, Chef has got to pay 100 + 1100 = 1200 Rs.", "starter_code": "", "test_cases": {"inputs": ["4\n2\n1 1\n2\n0 0\n3\n0 1 0\n2\n0 1\n\n"], "outputs": ["0\n2200\n2300\n1200"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "9d5b222effbd12acdc56ffa8122b20f490b15474", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00604", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef is stuck in a two dimensional maze having N rows and M columns. He needs to get out of the maze as soon as possible and arrive at the kitchen in order to serve his hungry customers. But, he can get out of the maze only if he is able to successfully find any magical path in the given maze.\n\nA path is defined as magical if it starts from any of the cell (a,b) of the maze and ends at the cell (c,d) such that the following conditions are satisfied :-\n- |a - c| + |b - d| = 1\n- All the cells in the maze are traversed exactly once.\n- It is allowed to move only in the four directions - up, down, left and right from the current cell.\n\n-----Input-----\n- First line of the input contains an integer T denoting the number of different types of scenarios.\n- Each of the next T lines will contain two integers N, M denoting the dimensions of the maze.\n\n-----Output-----\nFor each of the T scenarios, output a single line containing \"Yes\" or \"No\" (without quotes) denoting whether the Chef can get out of the maze or not.\n\n-----Constraints-----\n- 1 ≤ T ≤ 105\n- 1 ≤ N, M ≤ 1018\n\n-----Subtasks-----\nSubtask #1 : (30 points)\n- 1 ≤ T ≤ 100\n- 1 ≤ N, M ≤ 10\n\nSubtask #2 : (70 points) \n\nOriginal Constraints\n\n-----Example-----\nInput:\n1\n2 2\n\nOutput:\nYes\n\n-----Explanation-----\nExample case 1.\n\nChef can start from (1,1), move down to (2,1), then move right to (2,2) and finally move upwards to reach (1,2). As, he is able to visit all the cells exactly once and sum of absolute differences of corresponding x and y dimension is 1, we can call this path a magical path.", "starter_code": "", "test_cases": {"inputs": ["1\n2 2"], "outputs": ["Yes"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "bc1a44f7e55f145830ee6115d3221c676a075349", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00609", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given N integer sequences A1, A2, ..., AN. Each of these sequences contains N elements. You should pick N elements, one from each sequence; let's denote the element picked from sequence Ai by Ei. For each i (2 ≤ i ≤ N), Ei should be strictly greater than Ei-1.\nCompute the maximum possible value of E1 + E2 + ... + EN. If it's impossible to pick the elements E1, E2, ..., EN, print -1 instead.\n\n-----Input-----\n\n- The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.\n- The first line of each test case contains a single integer N.\n- N lines follow. For each valid i, the i-th of these lines contains N space-separated integers Ai1, Ai2, ..., AiN denoting the elements of the sequence Ai.\n\n-----Output-----\nFor each test case, print a single line containing one integer — the maximum sum of picked elements.\n\n-----Constraints-----\n- 1 ≤ T ≤ 10\n- 1 ≤ N ≤ 700\n- 1 ≤ sum of N in all test-cases ≤ 3700\n- 1 ≤ Aij ≤ 109 for each valid i, j\n\n-----Subtasks-----\nSubtask #1 (18 points): 1 ≤ Aij ≤ N for each valid i, j\nSubtask #2 (82 points): original constraints\n\n-----Example-----\nInput:\n\n1\n3\n1 2 3\n4 5 6\n7 8 9\n\nOutput:\n\n18\n\n-----Explanation-----\nExample case 1: To maximise the score, pick 3 from the first row, 6 from the second row and 9 from the third row. The resulting sum is E1+E2+E3 = 3+6+9 = 18.", "starter_code": "", "test_cases": {"inputs": ["1\n3\n1 2 3\n4 5 6\n7 8 9"], "outputs": ["18"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "809b024e63bbf1d25cd741eaee7ffc32d3d0256b", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00614", "original_id": null, "source": "apps", "domain": "code", "problem": "We all know how great ABD aka AB-DE-VILLIERS is. However his team mates were jealous of him and posed a problem for him to solve.The problem description is as follows :\n\nGiven an array of integers,find the length of the largest subarray(contiguous) of the given array with the maximum possible GCD (Greatest Common Divisor).\n\nFor info on GCD ,see this link: https://en.wikipedia.org/wiki/Greatest_common_divisor\n\nGCD of the subarray is defined as the GCD of all the elements of the subarray.\nAs ABD is not aware of competitive programming he asks your help. Help him!\n\n-----Input-----\nFirst line will contain integer N denoting the size of array.\n\nSecond line will contain N integers denoting array elements.\n\n-----Output-----\nThe answer as specified in the problem statement .\n\n-----Constraints-----\n1 <= N <= 1000000\n\n1 <= array[i] <=100000000000\n\n-----Example-----\nInput:\n4\n2 4 8 3\n\nOutput:\n1\n\nExplanation\nGCD of all possible subarrays of the given array are : 2 , 2 , 2 , 1 , 4 , 4, 1 , 8 , 1 , 3\n\nLargest GCD possible : 8\n\nLength of the largest subarray with GCD as 8 is 1\n\nHence answer is 1 .", "starter_code": "", "test_cases": {"inputs": ["4\n2 4 8 3"], "outputs": ["1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "ec4f57535ae4006714a12ef9917c071a22d54bca", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00619", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given a dataset consisting of $N$ items. Each item is a pair of a word and a boolean denoting whether the given word is a spam word or not.\nWe want to use this dataset for training our latest machine learning model. Thus we want to choose some subset of this dataset as training dataset. We want to make sure that there are no contradictions in our training set, i.e. there shouldn't be a word included in the training set that's marked both as spam and not-spam. For example item {\"fck\", 1}, and item {\"fck, 0\"} can't be present in the training set, because first item says the word \"fck\" is a spam, whereas the second item says it is not, which is a contradiction.\nYour task is to select the maximum number of items in the training set.\nNote that same pair of {word, bool} can appear multiple times in input. The training set can also contain the same pair multiple times.\n\n-----Input-----\n- First line will contain $T$, number of test cases. Then the test cases follow.\n- The first line of each test case contains a single integer $N$.\n- $N$ lines follow. For each valid $i$, the $i$-th of these lines contains a string $w_i$, followed by a space and an integer(boolean) $s_i$, denoting the $i$-th item.\n\n-----Output-----\nFor each test case, output an integer corresponding to the maximum number of items that can be included in the training set in a single line.\n\n-----Constraints-----\n- $1 \\le T \\le 10$\n- $1 \\le N \\le 25,000$\n- $1 \\le |w_i| \\le 5$ for each valid $i$\n- $0 \\le s_i \\le 1$ for each valid $i$\n- $w_1, w_2, \\ldots, w_N$ contain only lowercase English letters\n\n-----Example Input-----\n3\n3\nabc 0\nabc 1\nefg 1\n7\nfck 1\nfck 0\nfck 1\nbody 0\nbody 0\nbody 0\nram 0\n5\nvv 1\nvv 0\nvv 0\nvv 1\nvv 1\n\n-----Example Output-----\n2\n6\n3\n\n-----Explanation-----\nExample case 1: You can include either of the first and the second item, but not both. The third item can also be taken. This way the training set can contain at the very max 2 items.\nExample case 2: You can include all the items except the second item in the training set.", "starter_code": "", "test_cases": {"inputs": ["3\n3\nabc 0\nabc 1\nefg 1\n7\nfck 1\nfck 0\nfck 1\nbody 0\nbody 0\nbody 0\nram 0\n5\nvv 1\nvv 0\nvv 0\nvv 1\nvv 1\n"], "outputs": ["2\n6\n3"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "7d8e53257a962185a5d6ca99b06538a142c25973", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00624", "original_id": null, "source": "apps", "domain": "code", "problem": "Recall the definition of the Fibonacci numbers:\n\n\nf1 := 1\n\nf2 := 2\n\nfn := fn-1 + fn-2 (n>=3)\n\nGiven two numbers a and b, calculate how many Fibonacci numbers are in the range [a,b].\n\n\n-----Input-----\n\nThe input contains several test cases. Each test case consists of two non-negative integer numbers a and b. Input is terminated by a=b=0. Otherwise, a<=b<=10^100. The numbers a and b are given with no superfluous leading zeros.\n\n-----Output-----\n\nFor each test case output on a single line the number of Fibonacci numbers fi with a<=fi<=b.\n\n-----Example-----\nInput:\n\n10 100\n1234567890 9876543210\n0 0\n\nOutput:\n\n5\n4", "starter_code": "", "test_cases": {"inputs": ["10 100\n1234567890 9876543210\n0 0"], "outputs": ["5\n4"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "e4915d0eb64fa254ec55b41c0fc95e6750b20718", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00629", "original_id": null, "source": "apps", "domain": "code", "problem": "For her next karate demonstration, Ada will break some bricks.\nAda stacked three bricks on top of each other. Initially, their widths (from top to bottom) are W1,W2,W3.\nAda's strength is S. Whenever she hits a stack of bricks, consider the largest k≥0 such that the sum of widths of the topmost k bricks does not exceed S; the topmost k bricks break and are removed from the stack. Before each hit, Ada may also decide to reverse the current stack of bricks, with no cost.\nFind the minimum number of hits Ada needs in order to break all bricks if she performs the reversals optimally. You are not required to minimise the number of reversals.\nInput\nThe first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.\nThe first and only line of each test case contains four space-separated integers S, W1, W2 and W3.Output\nFor each test case, print a single line containing one integer ― the minimum required number of hits.Constraints\n- 1≤T≤64\n- 1≤S≤8\n- 1≤Wi≤2 for each valid i\nit is guaranteed that Ada can break all bricksExample Input\n\n3\n\n3 1 2 2\n\n2 1 1 1\n\n3 2 2 1\nExample Output\n\n2\n\n2\n\n2\nExplanation\n\nExample case 1:\n\nAda can reverse the stack and then hit it two times. Before the first hit, the widths of bricks in the stack (from top to bottom) are (2,2,1). After the first hit, the topmost brick breaks and the stack becomes (2,1). The second hit breaks both remaining bricks.\n\nIn this particular case, it is also possible to hit the stack two times without reversing. Before the first hit, it is (1,2,2). The first hit breaks the two bricks at the top (so the stack becomes (2)) and the second hit breaks the last brick.", "starter_code": "", "test_cases": {"inputs": ["3\n3 1 2 2\n2 1 1 1\n3 2 2 1"], "outputs": ["2\n2\n2"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "e977098572ebdb65f63d0f7e7c7b5245294980ba", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00634", "original_id": null, "source": "apps", "domain": "code", "problem": "Appy and Chef are participating in a contest. There are $N$ problems in this contest; each problem has a unique problem code between $1$ and $N$ inclusive. Appy and Chef decided to split the problems to solve between them ― Appy should solve the problems whose problem codes are divisible by $A$ but not divisible by $B$, and Chef should solve the problems whose problem codes are divisible by $B$ but not divisible by $A$ (they decided to not solve the problems whose codes are divisible by both $A$ and $B$).\nTo win, it is necessary to solve at least $K$ problems. You have to tell Appy whether they are going to win or lose.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first and only line of each test case contains four space-separated integers $N$, $A$, $B$ and $K$.\n\n-----Output-----\nFor each test case, print a single line containing the string \"Win\" if they can solve at least $K$ problems or \"Lose\" otherwise (without quotes).\n\n-----Constraints-----\n- $1 \\le T \\le 15$\n- $1 \\le K \\le N \\le 10^{18}$\n- $1 \\le A, B \\le 10^9$\n\n-----Subtasks-----\nSubtask #1 (15 points):\n- $1 \\le T \\le 15$\n- $1 \\le K \\le N \\le 10^6$\n- $1 \\le A, B \\le 10^3$\nSubtask #2 (85 points): original constraints\n\n-----Example Input-----\n1\n6 2 3 3\n\n-----Example Output-----\nWin\n\n-----Explanation-----\nExample case 1: Appy is solving the problems with codes $2$ and $4$, Chef is solving the problem with code $3$. Nobody is solving problem $6$, since $6$ is divisible by both $2$ and $3$. Therefore, they can solve $3$ problems and win.", "starter_code": "", "test_cases": {"inputs": ["1\n6 2 3 3"], "outputs": ["Win"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "042470526fc9a2bbd2e54082f3ed4e9e887a009b", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00639", "original_id": null, "source": "apps", "domain": "code", "problem": "There is a big staircase with $N$ steps (numbered $1$ through $N$) in ChefLand. Let's denote the height of the top of step $i$ by $h_i$. Chef Ada is currently under the staircase at height $0$ and she wants to reach the top of the staircase (the top of the last step). However, she can only jump from height $h_i$ to the top of a step at height $h_f$ if $h_f-h_i \\le K$. To help Ada, we are going to construct some intermediate steps; each of them may be constructed between any two steps, or before the first step, and have any height. What is the minimum number of steps that need to be added to the staircase so that Ada could reach the top?\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains two space-separated integers $N$ and $K$.\n- The second line contains $N$ space-seperated integers $h_1, h_2, \\dots, h_N$.\n\n-----Output-----\nFor each test case, print a single line containing one integer — the minimum required number of steps.\n\n-----Constraints-----\n- $1 \\le T \\le 64$\n- $1 \\le N \\le 128$\n- $1 \\le K \\le 1,024$\n- $1 \\le h_i \\le 1,024$ for each valid $i$\n- $h_i < h_{i+1}$ for each valid $i$\n\n-----Example Input-----\n1\n4 3\n2 4 8 16\n\n-----Example Output-----\n3", "starter_code": "", "test_cases": {"inputs": ["1\n4 3\n2 4 8 16"], "outputs": ["3"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "4fd71a2baba58bbb80ed93d4f045d1f30c554604", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00644", "original_id": null, "source": "apps", "domain": "code", "problem": "Write a program that reads two numbers $X$ and $K$. The program first finds the factors of $X$ and then gives the sum of $K$th power of every factor. The program also finds the factor of $k$ and outputs the sum of $X$ times of every factor. \n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- Each testcase contains of a single line of input, two integers $X, R$. \n\n-----Output:-----\nFor each testcase, output in a single line the factors of $X$ and the $K$th power of every factor, seperated by a space.\n\n-----Constraints-----\n- $1 \\leq T \\leq 1000$\n- $2 \\leq X, K \\leq 10^9$\n\n-----Sample Input:-----\n1\n8 6\n\n-----Sample Output:-----\n266304 88\n\n-----EXPLANATION:-----\nFactors of x = 8 are 2, 4, and 8. Also, factors of k = 6 are 2, 3, and 6.\n2^6 + 4^6 + 8^6 = 266304 and 2 × 8 + 3 × 8 + 6 × 8 = 88.\n(Where a ^b denotes a raised to the power of b).", "starter_code": "", "test_cases": {"inputs": ["1\n8 6"], "outputs": ["266304 88"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "89f301caa1d5168c86ceeb1293f41edf0321bd84", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00649", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef is a brilliant university student that does not attend lectures because he believes that they are boring and coding is life! However, his university follows certain rules and regulations, and a student may only take an exam for a course if he has attended at least 75% of lectures for this course.\nSince you are Chef's best friend, you want to help him reach the attendance he needs to take exams. Unfortunately, Chef is still focused on his code and refuses to attend more lectures, so the only option is to have some of his friends mark him as present by proxy. This trick is well-known in the university, but only few have the talent to pull it off.\nIn a certain course, there is exactly one lesson per day over the course of $D$ days (numbered $1$ through $D$). You are given a string $S$ with length $D$ describing the lessons Chef attended — for each valid $i$, the $i$-th character of this string is either 'A' if Chef was absent on day $i$ or 'P' if Chef was actually present on day $i$.\nFor each day $d$ when Chef is absent, one of Chef's friends can mark him as present by proxy on this day only if he was present (if he was really present, not just marked as present) on at least one of the previous two days, i.e. days $d-1$ and $d-2$, and on at least one of the following two days, i.e. days $d+1$ and $d+2$. However, it is impossible to mark him as present by proxy on the first two days and the last two days.\nFind the minimum number of times Chef has to be marked as present by proxy so that his attendance becomes at least 75% ($0.75$). Chef's attendance is number of days when he was marked as present, either by proxy or by actually being present, divided by $D$.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains a single integer $D$.\n- The second line contains a single string $S$ with length $D$.\n\n-----Output-----\nFor each test case, print a single line containing one integer — the minimum number of times Chef needs to be marked as present by proxy, or $-1$ if it is impossible to make Chef achieve 75% attendance.\n\n-----Constraints-----\n- $1 \\le T \\le 200$\n- $1 \\le D \\le 1,000$\n- $S$ contains only characters 'A' and 'P'\n\n-----Subtasks-----\nSubtask #1 (100 points): original constraints\n\n-----Example Input-----\n1\n9\nPAAPPAPPP\n\n-----Example Output-----\n1\n\n-----Explanation-----\nExample case 1: With a proxy on the third day, the attendance string is \"PAPPPAPPP\". Now, Chef's attendance is at least 75%, so the minimum number of times Chef needs to be marked as present by proxy is $1$.", "starter_code": "", "test_cases": {"inputs": ["1\n9\nPAAPPAPPP"], "outputs": ["1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "01681c526aec89f6fd3b1f348b94e9384ac62d56", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00654", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef wants to teach a lesson of sharing to the students.\nThere are $N$ students (numbered from $1$ to $N$ from left to right) who are asked to stand in a row. Initially Chef gave $A$$i$ candies to the $i$$th$ child. In one operation any child can give any number of candies to the child standing to his immediate left (i.e. $i$$th$ child can give any amount of candies to the $(i-1)$$th$ child. In particular 1st child cannot give his candies to anyone). \nHe asked them to minimize the maximum value of candies a student can possess after performing any number of operations (possibly zero). \nHelp the students finding such maximum value.\n\n-----Input:-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- First line of each test case contains a single integer $N$ denoting the number of students.\n- Second line contains $N$ space-separated integers $A$$1$,$A$$2$,$.....$ $A$$N$ denoting the initial amount of candies chef gave to them.\n\n-----Output:-----\n- For each test case, print a single line containing one integer ― maximum value after sharing.\n\n-----Constraints-----\n- $1 \\leq T \\leq 100$\n- $1 \\leq N \\leq 10^5$\n- $0$ $\\leq$ $A$$i$ $\\leq$ $10^9$\n- Sum of $N$ over all Test Cases does not exceed $10^5$\n\n-----Sample Input-----\n2 \n5 \n1 2 3 4 5 \n5\n5 4 3 2 1\n\n-----Sample Output-----\n3 \n5 \n\n-----Explanation-----\n- \nFor First Test Case:\nThe $5$$th$ student will give $2$ candies to $4$$th$ student and $4$$th$ will give $3$ candies to $3$$rd$ and $3$$rd$ will give $3$ candies to $2$$nd$ and $2$$nd$ will give $2$ candies to $1$$st$. So finally the number of candies that they will have are \n$[3,3,3,3,3]$ and the value of maximum candies is $3$.\n- \nFor Second Test Case:\nSharing to the left student will not change the maximum value as $1$$st$ cannot share to anyone. So the maximum value will remain $5$.", "starter_code": "", "test_cases": {"inputs": ["2\n5\n1 2 3 4 5\n5\n5 4 3 2 1"], "outputs": ["3\n5"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "9ca4c82f9174597da1cfa4c4e2da4f07ca57a469", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00659", "original_id": null, "source": "apps", "domain": "code", "problem": "The most dangerous cyborg Jenish is finally entrapped on a narrow bridge over a valley. The bridge is $N$ meters long. For convenience, position $i$ represents a portion of bridge between whose left border is at distance $i-1$ meters from left end and right border is at distance $i$ meters from left end. \nThere are $N$ batteries placed at positions $1,2...N$. The $i^{th}$ one has energy $a[i]$.\nThere are two tanks of strength $X$ at positions $0$ and $N+1$. Initially Jenish has $0$ energy.\nFrom now at any second $t$ starting from $1$, \nfirst, Jenish can select any battery placed at position $i$ such that $(t \\leq i \\leq N-t+1)$ and add $a[i]$ to his energy (every battery can be used atmost once).\nThen both the tanks move one meter towards each other. If there are still any batteries present at positions where the tanks are heading, the battery gets destroyed. \nAt any moment if Jenish's total energy is greater than or equal to $X$, he destroys both the tanks and he escapes the cops. If by the end of $\\lfloor \\frac {(n+1)}{2}\\rfloor^{th}$ second, he can't destroy the tanks, he himself gets destroyed. Find out if he can escape.\n\n-----Input:-----\n- The first line consists of a single integer $T$, the number of test cases.\n- The first line of each test case contains two space separated integers which represents $N$ and $X$ for that test case respectively.\n- The second line of each test case contains $N$ space separated integers, $i^{th}$ of which represents $a[i]$.\n\n-----Output:-----\nFor each test case, print in a single line, $YES$ if Jenish can escape or $NO$ if he gets destroyed.\n\n-----Constraints:-----\n- $1 \\leq X \\leq 10^9$\n- $0 \\leq a[i] \\leq 10^6$\n- $ 1 \\leq N \\leq 10^5$\n- $\\Sigma$ $N$ over all the test cases does not exceed $10^5$\n\n-----Sample Input:-----\n3\n4 8\n5 1 4 2\n3 4\n3 1 2\n2 7\n5 5\n\n-----Sample Output:-----\nYES\nYES\nNO\n\n-----Explanation-----\nFor test $1$, in the 1st second, first Jenish will select battery at index $1$ and then the tanks from either side will move one meter closer, thus destroying the battery at index $4$.Then, in the next second, Jenish will select battery at index $3$.Then,tanks will move one meter closer again to destroy the remaining battery at index $2$.But now, Jenish has a total energy of $9$ units which is more than enough to destroy the tanks.\nFor test $2$, Jenish can use batteries at index $1$ and $2$ to get a total energy of $4$ units.\nFor test $3$, Jenish can use batteries at index $1$ or $2$ and get a maximum of $5$ units of energy which is less than required.", "starter_code": "", "test_cases": {"inputs": ["3\n4 8\n5 1 4 2\n3 4\n3 1 2\n2 7\n5 5"], "outputs": ["YES\nYES\nNO"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "4cc1d84da5d60601b82e234b17a18403f1aa53aa", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00664", "original_id": null, "source": "apps", "domain": "code", "problem": "There is a building with $N$ floors (numbered $1$ through $N$ from bottom to top); on each floor, there are $M$ windows (numbered $1$ through $M$ from left to right). Let's denote the $j$-th window on the $i$-th floor by $(i, j)$.\nAll windows in the building need to be cleaned one by one in a specific order. You are given this order as a matrix $A$ with $N$ rows and $M$ columns; for each valid $i$ and $j$, the window $(i, j)$ must be cleaned on the $A_{N-i+1,j}$-th turn. \nWhenever we clean a window $(i, j)$, it becomes clean, but the dirty water used for cleaning it flows down to windows $(i-1, j-1)$, $(i-1, j)$ and $(i-1, j+1)$ (more precisely, to all of these windows which exist), so these windows become dirty again. Then, the water flows further down, so the same applies for other windows below: whenever a window $(i, j)$ becomes dirty, windows $(i-1, j-1)$, $(i-1, j)$ and $(i-1, j+1)$ become dirty as well. For example, cleaning a window $(5, 3)$ will make the window $(3, 2)$ dirty. The next window is cleaned only after water flows down completely. Note that each window is cleaned only once and there may be dirty windows at the end.\nFor each window, determine whether it will be clean after the cleaning process ends.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains two space-separated integers $N$ and $M$. \n- $N$ lines follow. For each $i$ ($1 \\le i \\le N$), the $i$-th of these lines contains $M$ space-separated integers $A_{i, 1}, A_{i, 2}, \\ldots, A_{i, M}$.\n\n-----Output-----\nFor each test case, print $N$ lines; each of them should contain a string with length $M$. For each valid $i$ and $j$, the $j$-th character on the $i$-th line should be '1' if the window $(N-i+1, j)$ is clean or '0' if it is dirty.\n\n-----Constraints-----\n- $1 \\le T \\le 1,000$\n- $1 \\le N, M \\le 10^3$\n- $1 \\le A_{i, j} \\le N \\cdot M$ for each valid $i, j$\n- the elements of the matrix $A$ are pairwise distinct\n- the sum of $N \\cdot M$ over all test cases does not exceed $10^6$\n\n-----Subtasks-----\nSubtask #1 (50 points):\n- $N, M \\le 25$\n- the sum of $N \\cdot M$ over all test cases does not exceed $625$\nSubtask #2 (50 points): original constraints\n\n-----Example Input-----\n1\n3 4\n1 3 7 10\n9 2 4 11\n8 12 5 6 \n\n-----Example Output-----\n1111\n1001\n0100", "starter_code": "", "test_cases": {"inputs": ["1\n3 4\n1 3 7 10\n9 2 4 11\n8 12 5 6 \n"], "outputs": ["1111\n1001\n0100"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "1a406abeb50b4c999e32d5f98ca5f06e6b241fc4", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00669", "original_id": null, "source": "apps", "domain": "code", "problem": "Doctor Kunj installed new software on cyborg Shresth.\nThis software introduced Shresth to range minimum queries.\nCyborg Shresth thought of T$T$ different problems in each of which you will be given\nan array A$A$ of length N$N$ and an array B$B$ of length M$M$. In each of these problems, you have to calculate:\n∑mi=1∑mj=irangeMin(B[i],B[j])$\\sum_{i=1}^m \\sum_{j=i}^m rangeMin(B[i],B[j])$\nWhere rangeMin(i,j)$rangeMin(i,j)$ returns the minimum element in the range of indices i$i$ to j$j$ (both included) in array A$A$.\nIt is given that array B$B$ consists of pairwise distinct elements and is in ascending order.\n\n-----Input Format:-----\n- First line will contain T$T$, the number of different problems Cyborg Shresth thought of.\n- Each problem's input data will be given in three different lines. \n- The first line will contain N$N$ and M$M$, the length of array A$A$ and B$B$ respectively. \n- The second line will contain N$N$ space separated positive integers, which form the array A$A$. - \n- The third line will contain M$M$ space separated positive integers, which form the array B$B$.\n\n-----Output Format:-----\n- For each different problem, print on a new line the answer to the problem, i.e. the value of ∑mi=1∑mj=irangeMin(B[i],B[j])$\\sum_{i=1}^m \\sum_{j=i}^m rangeMin(B[i],B[j])$ .\n\n-----Constraints:-----\n- 1≤T≤105$1 \\leq T \\leq {10}^5$\n- 1≤N≤105$1 \\leq N \\leq {10}^5$\n- 1≤M≤105$1 \\leq M \\leq {10}^5$\n- 1≤A[i]≤109$1 \\leq A[i] \\leq 10^9$\n- 1≤B[i]≤N$1 \\leq B[i] \\leq N$\nIt is guaranteed that the sum of N$N$ over all test cases does not exceed 106${10}^6$ .\n\n-----Sample Input:-----\n1\n7 3\n10 3 7 9 1 19 2\n1 4 6\n\n-----Sample Output:-----\n43\n\n-----Explanation:-----\nFor the given array A$A$, we have to calculate rangeMin(1,1)+rangeMin(1,4)+rangeMin(1,6)+rangeMin(4,4)+rangeMin(4,6)+rangeMin(6,6)$rangeMin(1,1) + rangeMin(1,4) + rangeMin(1,6) + rangeMin(4,4) + rangeMin(4,6) + rangeMin(6,6) $.\nThis is equal to 10+3+1+9+1+19=43$10 + 3 + 1 + 9 + 1 +19 = 43$.", "starter_code": "", "test_cases": {"inputs": ["1\n7 3\n10 3 7 9 1 19 2\n1 4 6"], "outputs": ["43"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "afa1a4c331835a4455361013a16fc00a5f2fabe0", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00674", "original_id": null, "source": "apps", "domain": "code", "problem": "Being a crewmate in the Among Us game, you will have to solve a task to win against the imposter. \nThe task : You are given a certain number of bulbs(Say n) which are initially in OFF position. \nThe bulbs are numbered from 1 to n. There will be n current fluctuations in such a way that in the 1st fluctuation all bulbs are toggled, in the 2nd fluctuation every 2nd bulb is toggled, in the 3rd fluctuation every 3rd bulb is toggled and so on.\nYour job as a crewmate is to find the number of bulbs which are ON at the end of n fluctuations. But, the imposter has a special power which alerts it when a bulb with a number divisible by 3 is kept ON at the end of n fluctuations. \nSo, you will have to switch off the bulbs with numbers divisible by 3 and give the final result to complete the task and win the game.\n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- Each testcase contains of a single line of input, an integer $n$. \n\n-----Output:-----\n- For each testcase, output a single integer - the number of bulbs that will remain ON after $n$ fluctuations.\n\n-----Constraints :-----\n- $1 \\leq T \\leq 1000$\n- $2 \\leq n \\leq 10^9$\n\n-----Sample Input:-----\n2\n2\n20\n\n-----Sample Output:-----\n1\n\n3", "starter_code": "", "test_cases": {"inputs": ["2\n2\n20"], "outputs": ["1\n3"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "c6ce35acfd31e366832b09b360c55a065c8fe652", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00679", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef Two and Chef Ten are playing a game with a number $X$. In one turn, they can multiply $X$ by $2$. The goal of the game is to make $X$ divisible by $10$.\nHelp the Chefs find the smallest number of turns necessary to win the game (it may be possible to win in zero turns) or determine that it is impossible.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first and only line of each test case contains a single integer denoting the initial value of $X$. \n\n-----Output-----\nFor each test case, print a single line containing one integer — the minimum required number of turns or $-1$ if there is no way to win the game.\n\n-----Constraints-----\n- $1 \\le T \\le 1000$\n- $0 \\le X \\le 10^9$\n\n-----Subtasks-----\nSubtask #1 (100 points): original constraints\n\n-----Example Input-----\n3\n10\n25\n1\n\n-----Example Output-----\n0\n1\n-1", "starter_code": "", "test_cases": {"inputs": ["3\n10\n25\n1"], "outputs": ["0\n1\n-1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "5f56bc765dcdf45f7b61965d19a5089c00f6dba5", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00684", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef has a circular plot of land of radius $R$ on which he wants to construct a swimming pool.\nHe wants the swimming pool to be square in shape with maximum possible area,so that he along\nwith his friends can enjoy themselves during their summer vacations.\nHelp Chef to find out the maximum area of the swimming pool that can be constructed in his \ncircular plot.\n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- Each testcase contains of a single line of input, $R$ i.e the radius of the plot. \n\n-----Output:-----\nFor each testcase, output in a single line answer displaying the maximum possible area of the swimming pool.\n\n-----Constraints-----\n- $1 \\leq T \\leq 1000$\n- $1 \\leq R \\leq 10^8$\n\n-----Sample Input:-----\n2\n\n5\n\n10 \n\n-----Sample Output:-----\n50\n\n200", "starter_code": "", "test_cases": {"inputs": ["2\n5\n10"], "outputs": ["50\n200"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "3e4a19196fe1ca524e39d37bb99f3b7f3e552d81", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00689", "original_id": null, "source": "apps", "domain": "code", "problem": "In this problem we are concerned with words constructed using the lowercase letters of the English alphabet - that is, a,b,c,…,z. These words need not necessarily be meaningful: any sequence of letters forms a word. For example, abbca is a word.\nWe say that we can \"hop\" from the word $w_1$ to the word $w_2$ if they are \"sufficiently close\". We define $w_2$ to be sufficiently close to $w_1$ if one of the following holds:\n- $w_2$ is obtained from $w_1$ by deleting one letter.\n- $w_2$ is obtained from $w_1$ by replacing one of the letters in $w_1$ by some letter that appears to its right in $w_1$ and which is also to its right in alphabetical order.\nFor example, we can hop from abbca to abca by deleting the second (or third letter). We can hop from aabca to abbca by replacing the a in the second position by the letter b that appears to the right of the a in aabca and which is also to its right in alphabetical order. On the other hand we cannot hop from abbca to aabca since we would need to replace the b in the second position by a, but a is to the left of b in alphabetical order.\nYou will be given a collection of words $W$. Your task is to find the length of the longest sequence $w_1, w_2, \\ldots $ of distinct words from $W$ such that we may hop from $w_1$ to $w_2$, $w_2$ to $w_3$ and so on. We call this the hopping number for this set.\nFor example, if\n$W$ = {abacd, bcdada, dd, abcd,bcdd, adcd, addd, aa, ccd, add, ad}\nthen, the hopping number is 7 corresponding to the sequence\nabacd, abcd, adcd, addd, add, ad, dd\n\n-----Input Format:-----\n- The first line of the input contains one integer $N$ indicating the number of words in the input. \n- This is followed by $N$ lines of input, lines 2, 3,…, $N$+1, each containing one word over the letters {a,b,…, z}.\n\n-----Output Format:-----\nThe output should be a single integer, indicating the hopping number of the given set of words.\n\n-----Test Data:-----\n- $N \\leq 100$\n- You may assume that each word has at most 10 letters.\n\n-----Sample Input:-----\n11\nabacd\nbcdada\ndd\nabcd\nbcdd\nadcd\naddd\naa\nccd\nadd\nad\n\n-----Sample Output:-----\n7", "starter_code": "", "test_cases": {"inputs": ["11\nabacd\nbcdada\ndd\nabcd\nbcdd\nadcd\naddd\naa\nccd\nadd\nad"], "outputs": ["7"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "6d9559b2a683a64f7d14e48b94f5a2ea3d5228ca", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00694", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef has $N$ doggo (dogs) , Lets number them $1$ to $N$.\n\nChef decided to build houses for each, but he soon realizes that keeping so many dogs at one place may be messy. So he decided to divide them into several groups called doggo communities. Let the total no. of groups be $K$ . In a community, paths between pairs of houses can be made so that doggo can play with each other. But there cannot be a path between two houses of different communities for sure. Chef wanted to make maximum no. of paths such that the total path is not greater then $K$.\nLet’s visualize this problem in an engineer's way :)\nThe problem is to design a graph with max edge possible such that the total no. of edges should not be greater than the total no. of connected components.\n\n-----INPUT FORMAT-----\n- First line of each test case file contain $T$ , denoting total number of test cases.\n- $ith$ test case contain only one line with a single integer $N$ , denoting the number of dogs(vertex)\n\n-----OUTPUT FORMAT-----\n- For each test case print a line with a integer , denoting the maximum possible path possible.\n\n-----Constraints-----\n- $1 \\leq T \\leq 10000$\n- $1 \\leq N \\leq 10^9$ \n\n-----Sub-Tasks-----\n- $20 Points$\n- $1 \\leq N \\leq 10^6$ \n\n-----Sample Input-----\n1\n\n4\n\n-----Sample Output-----\n2\n\n-----Explanation-----\n4 houses can be made with like this:\n\ncommunity #1 : [1 - 2 ]\n\ncommunity #2 : [3 - 4 ]\n\nor [1 - 2 - 3] , [ 4 ]\n\nIn both cases the maximum possible path is 2.", "starter_code": "", "test_cases": {"inputs": ["1\n4"], "outputs": ["2"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "b7712653ea79a4363e25d8790d1bd52da37abc4e", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00699", "original_id": null, "source": "apps", "domain": "code", "problem": "The chef has one array of N natural numbers (might be in sorted order). Cheffina challenges chef to find the total number of inversions in the array.\n\n-----Input:-----\n- First-line will contain $T$, the number of test cases. Then the test cases follow. \n- Each test case contains two lines of input, $N$.\n- N space-separated natural numbers. \n\n-----Output:-----\nFor each test case, output in a single line answer as the total number of inversions.\n\n-----Constraints-----\n- $1 \\leq T \\leq 10$\n- $1 \\leq N \\leq 10^5$\n- $1 \\leq arr[i] \\leq 10^5$\n\n-----Sample Input:-----\n1\n5\n5 4 1 3 2\n\n-----Sample Output:-----\n8", "starter_code": "", "test_cases": {"inputs": ["1\n5\n5 4 1 3 2"], "outputs": ["8"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "86039c969e1b8a518d4d482353a8694dcedc854e", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00704", "original_id": null, "source": "apps", "domain": "code", "problem": "You may have helped Chef and prevented Doof from destroying the even numbers. But, it has only angered Dr Doof even further. However, for his next plan, he needs some time. Therefore, Doof has built $N$ walls to prevent Chef from interrupting him. You have to help Chef by telling him the number of walls he needs to destroy in order to reach Dr Doof.\nFormally, the whole area can be represented as the first quadrant with the origin at the bottom-left corner. Dr. Doof is located at the origin $(0, 0)$. There are $N$ walls, the i-th wall is a straight line segment joining the points $(a_i, 0)$ and $(0, a_i)$. For every initial position of Chef $(x_j, y_j)$, find the number of walls he needs to break before reaching Doof. Obviously, chef can't start from a point on the wall. Therefore, if $(x_j, y_j)$ lies on any of the given walls, print $-1$ in a new line.\n\n-----Input-----\n- First line contains $T$, denoting the number of testcases.\n- The first line of every test case contains a single integer $N$ denoting the number of walls Dr Doof has built.\n- The next line contains $N$ space separated distinct integers each denoting $a_i$.\n- The next line contains a single integer $Q$ denoting the number of times Chef asks for your help.\n- The next $Q$ lines contains two space separated integers $x_j$ and $y_j$, each denoting the co-ordinates of the starting point of Chef.\n\n-----Output-----\nFor each query, print the number of walls Chef needs to break in order to reach Dr Doof in a separate line. If Chef tries to start from a point on any of the walls, print $-1$.\n\n-----Constraints-----\n- $1 \\leq T \\leq 2 * 10^2$\n- $1 \\leq N, Q \\leq 2 * 10^5$\n- $1 \\leq a_i \\leq 10^9$\n- $0 \\leq x_j, y_j \\leq 10^9$\n- $a_1 < a_2 < a_3 < .... < a_N$\n- Sum of $N$ and $Q$ over all testcases for a particular test file does not exceed $2 * 10^5$\n\n-----Sample Input-----\n1\n2\n1 3\n5\n0 0\n2 0\n0 4\n1 1\n1 2\n\n-----Sample Output-----\n0\n1\n2\n1\n-1\n\n-----Explanation-----\nThe sample input can be represented by the graph given below:\n\nIf Chef starts from $(0, 0)$, he can reach Dr Doof without destroying any wall.\n\nIf Chef starts from $(2, 0)$, he has to destroy the $1st$ wall.\n\nIf Chef starts from $(0, 4)$, he has to destroy both the walls.\n\nIf Chef starts from $(1, 1)$, he has to destroy the $1st$ wall.\n\nAs $(1, 2)$ lies on the second wall, the answer is $-1$ for the last query.", "starter_code": "", "test_cases": {"inputs": ["1\n2\n1 3\n5\n0 0\n2 0\n0 4\n1 1\n1 2"], "outputs": ["0\n1\n2\n1\n-1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "8c824606e49f38bfb83b3f4cbe27e229aeafa651", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00709", "original_id": null, "source": "apps", "domain": "code", "problem": "The ZCO scholarship contest offers scholarships to first time ZCO participants. You are participating in it for the first time. So you want to know the number of participants who'll get the scholarship.\nYou know that the maximum number of scholarships offered is $R$ and there are a total of $N$ participants numbered from $1$ to $N$. Out of these, you know the set of people (denoted by $X$) who you know, had participated in previous year ZCOs and hence, they shall not get the scholarship.\nFurther, as the world isn't free from plagiarism, so is the case with the scholarship contest. And from your secret sources, you also know the set of people (denoted by set $Y$) who were involved in plagiarism and therefore aren't eligible for scholarship either.\nFind out the number of participants who shall get the scholarship.\nPS: Don't ask how so many scholarships are being offered when you see the constraints on $R$. You never questioned it when in mathematics classes, some person bought $80$ watermelons twice just to compare them and save $₹1$. \n\n-----Input:-----\n- The first line will contain a single integer, $T$, the number of testcases. Then the testcases follow. \n- The first line of each test case contains four integers; $N$, $R$, $|X|$ and $|Y|$ denoting the number of participants, maximum number of scholarships offered, number of old participants, and the number of participants involved in plagiarism, respectively.\n- The second line of each test case contains $|X|$ space separated integers $x_1, x_2 \\ldots x_{|X|}$ denoting the indices of people who participated in previous years. If $X$ is empty, this line is skipped and no empty line is in the input.\n- The third line of each test case contains $|Y|$ space separated integers $y_1, y_2 \\ldots y_{|Y|}$ denoting the indices of people who are involved in plagiarism. If $Y$ is empty, this line is skipped and no empty line is in input.\n\n-----Output:-----\nFor each testcase, print a single integer in a new line, denoting the number of participants who shall get the scholarship.\n\n-----Constraints-----\n- $1 \\leq T \\leq 1000$\n- $1 \\leq N \\leq 10^{15}$\n- $0 \\leq R \\leq 10^{15}$\n- $0 \\leq |X|, |Y| \\leq min(N, 2*10^5)$\n- $1 \\leq x_i, y_i \\leq N$\n- All $x_i$ are distinct\n- All $y_i$ are distinct\n- Sum of $|X|$ over all test cases does not exceed $5*10^5$\n- Sum of $|Y|$ over all test cases does not exceed $5*10^5$\n\n-----Subtasks-----\n- 20 points : $1 \\leq N \\leq 10^3$, and the sum of $N$ over all test cases does not exceed $3*10^3$\n- 30 points : $1 \\leq N \\leq 2*10^5$, and the sum of $N$ over all test cases does not exceed $5*10^5$\n- 50 points: Original constraints\n\n-----Sample Input:-----\n3\n5 3 0 1\n4\n10 2 4 6\n3 1 7 6\n4 3 1 5 9 7\n10 4 4 6\n3 1 7 6\n4 3 1 5 9 7\n\n-----Sample Output:-----\n3\n2\n3\n\n-----EXPLANATION:-----\n- In the first testcase, only participant $4$ is involved in plagiarism, and thus not eligible for the scholarship. No user has participated in previous years, and so no empty line is there in the sample. All participants except participant $4$ are eligible for the scholarship, but only three of them get it because $R = 3$.\n- Both second and third testcases are the same, except for $R$. In both samples, only participants $2$, $8$ and $10$ are eligible for scholarships.\n- In the second testcase, since the maximum number of scholarships is $2$, only $2$ participants get scholarships.\n- In the third testcase, all three eligible participants get scholarships.", "starter_code": "", "test_cases": {"inputs": ["3\n5 3 0 1\n4\n10 2 4 6\n3 1 7 6\n4 3 1 5 9 7\n10 4 4 6\n3 1 7 6\n4 3 1 5 9 7"], "outputs": ["3\n2\n3"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "3aaaf79faa5370da1db11b899c887b902ce5055a", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00714", "original_id": null, "source": "apps", "domain": "code", "problem": "Special Numbers \nMani has encountered a problem on Special numbers in Bytecode. A number S is called a special number if its digits are in an arithmetic progression modulo 10. He has an array consisting of all numbers from 1 to N and needs your help to find the number of special numbers in the array. He has promised you a significant share of the prize money if he wins the contest :p \nNote:\n123,99,802 are special numbers.\n146 is not a special number \n\n-----Input-----\n\nInput consists of 1 integer - the value of N\n\n-----Output-----\nPrint one integer in the first line - the solution to this problem\n\n-----Constraints-----\n- 1 ≤ Number of digits in N ≤ 105\n\nExample\n\nInput\n\n123\n\nOutput\n\n102", "starter_code": "", "test_cases": {"inputs": ["123"], "outputs": ["102"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "1ae7ce7d00a68a171b543d9c8a5b02d5b192aade", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00719", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given a sequence of non-negative integers $A_1, A_2, \\ldots, A_N$. At most once, you may choose a non-negative integer $X$ and for each valid $i$, change $A_i$ to $A_i \\oplus X$ ($\\oplus$ denotes bitwise XOR).\nFind the minimum possible value of the sum of all elements of the resulting sequence.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of the input contains a single integer $N$.\n- The second line contains $N$ space-separated integers $A_1, A_2, \\ldots, A_N$.\n\n-----Output-----\nFor each test case, print a single line containing one integer ― the minimum possible sum.\n\n-----Constraints-----\n- $1 \\le T \\le 1,000$\n- $1 \\le N \\le 10^5$\n- $1 \\le A_i \\le 10^9$ for each valid $i$\n- the sum of $N$ over all test cases does not exceed $10^6$\n\n-----Subtasks-----\nSubtask #1 (50 points):\n- $1 \\le N \\le 10^3$\n- $1 \\le A_i \\le 10^3$ for each valid $i$\nSubtask #2 (50 points): original constraints\n\n-----Example Input-----\n3\n5\n2 3 4 5 6\n4\n7 7 7 7\n3\n1 1 3\n\n-----Example Output-----\n14\n0\n2\n\n-----Explanation-----\nExample case 1: If we choose $X = 6$, the sequence becomes $(4, 5, 2, 3, 0)$.\nExample case 2: We can choose $X = 7$ to make all elements of the resulting sequence equal to $0$.\nExample case 3: We can choose $X = 1$. The sequence becomes $(0, 0, 2)$, with sum $2$.", "starter_code": "", "test_cases": {"inputs": ["3\n5\n2 3 4 5 6\n4\n7 7 7 7\n3\n1 1 3"], "outputs": ["14\n0\n2"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "155e461280705cf95494410611cec34909937779", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00724", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given an integer sequence $A_1, A_2, \\ldots, A_N$ and an integer $X$. Consider a $N \\times N$ matrix $B$, where $B_{i,j} = A_i + A_j$ for each valid $i$ and $j$.\nYou need to find the number of square submatrices of $B$ such that the sum of their elements is $X$. Formally, find the number of quartets $(x_1, y_1, x_2, y_2)$ such that $1 \\le x_1 \\le x_2 \\le N$, $1 \\le y_1 \\le y_2 \\le N$, $x_2-x_1 = y_2-y_1$ and $\\sum_{i=x_1}^{x_2}\\sum_{j=y_1}^{y_2} B_{i,j} = X$.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains two space-separated integers $N$ and $X$.\n- The second line contains $N$ space-separated integers $A_1, A_2, \\ldots, A_N$.\n\n-----Output-----\nFor each test case, print a single line containing one integer ― the number of square submatrices with sum $X$.\n\n-----Constraints-----\n- $1 \\le T \\le 100$\n- $1 \\le X \\le 10^6$\n- $1 \\le N \\le 10^5$\n- $1 \\le A_i \\le 10^6$ for each valid $i$\n- the sum of $N$ over all test cases does not exceed $10^6$\n\n-----Subtasks-----\nSubtask #1 (50 points): the sum of $N$ over all test cases does not exceed $1,000$\nSubtask #2 (50 points): original constraints\n\n-----Example Input-----\n2\n5 36\n1 2 3 1 12\n4 54\n3 3 3 3\n\n-----Example Output-----\n6\n4", "starter_code": "", "test_cases": {"inputs": ["2\n5 36\n1 2 3 1 12\n4 54\n3 3 3 3"], "outputs": ["6\n4"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "9c63a496d7726e6d9de1b2a8c1f17a114133547a", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00729", "original_id": null, "source": "apps", "domain": "code", "problem": "The activity of a panipuri seller is \"making a panipuri and putting it on the palte of his customer\". \n$N$ customers are eating panipuri, Given an array $A$ of length $N$, $i^{th}$ customer takes $A_i$ seconds to eat a panipuri. \nThe Speed of Panipuri seller refers to the number of customers served per second. Determine the minimum speed of panipuri seller so that no customer has to wait for panipuri after getting his/her first panipuri. \nAssume that the plate can hold infinite panipuris, and customer starts eating next panipuri just after finishing the current one. You would be provided with the time taken by each customer to eat a panipuri.\nPanpuri seller serves panipuri in round robin manner (first to last and then again first).\n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the test cases follow.\n- For each test case, the first line contains $N$ number of customers.\n- Then the second line will contain $N$ space separated integers, $A_1$ to $A_N$, eating time taken by each customer(in seconds).\n\n-----Output:-----\n- For each test case, print a single line containing the minimum integral speed of panipuri seller so that no customer has to wait. \n\n-----Constraints-----\n- $0 < T \\leq 100$\n- $0 < N \\leq 10^6$\n- $0 < A_i \\leq 10^9$\n- Sum of $N$ over all test cases does not exceed $10^6$\n\n-----Sample Input:-----\n2\n4\n2 4 6 3\n5\n2 3 4 6 5\n\n-----Sample Output:-----\n2\n\n3\n\n-----EXPLANATION:-----\n$Test case$ $1$:\n\nLet's assume speed of panipuri seller be 1.\n\nSo starting from $0^{th}$ second, in $0$ to $1$ second seller make a panipuri and put it into the plate of first customer, and first customer completely eat it in $1$ to $3$ second as he takes $2$ second to eat a panipuri. But in $3$ to $4$ second panipuri seller is serving to $4^{th}$ customer, and hence first customer have to wait, so 1 cannot be our answer.\n\nNext possible speed can be $2$ .\n\nStarting from $0^{th}$ second, at half second seller make a panipuri and put it into the plate of first customer, first customer completely eat it on $2.5$ second as he takes $2$ second to eat a panipuri. In $0.5$ to $1$ second, seller serve the second customer. similarly in $1$ to $2$ second $3^{rd}$ and $4^{th}$ customer will be serve, in $2$ to $2.5$ second, seller will again serve the first customer so at $2.5$ sec $1^{st}$ customer will have a panipuri to eat.\n\nSimilarly proceeding further we will find that no customer have to wait when speed is $2$.", "starter_code": "", "test_cases": {"inputs": ["2\n4\n2 4 6 3\n5\n2 3 4 6 5"], "outputs": ["2\n3"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "315c074c98a44ef5e4a84c80b0299a119456418c", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00734", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef Leonardo has a decimal integer $N$ and a non-zero decimal digit $d$. $N$ does not contain the digit zero; specifically, $N$ should always be treated as a decimal integer without leading zeroes.\nChef likes $d$ and does not like any other digit, so he decided to change $N$. He may apply the following operation any number of times (including zero): append the digit $d$ to the decimal representation of $N$ ($d$ becomes the least significant digit of $N$), then remove one occurrence of one digit from the decimal representation of $N$.\nChef has already changed a lot of numbers and he got bored. Now, he wants to know the smallest possible value of $N$ which can be obtained by performing the operation described above. Can you help him?\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first and only line of each test case contains two space-separated integers $N$ and $d$.\n\n-----Output-----\nFor each test case, print a single line containing one integer - the minimum number Chef can obtain.\n\n-----Constraints-----\n- $1 \\le T \\le 1,000$\n- $1 \\le N \\le 10^{18}$\n- $N$ does not contain the digit $0$\n- $1 \\le d \\le 9$\n\n-----Subtasks-----\nSubtask #1 (40 points):\n- $1 \\le T \\le 100$\n- $1 \\le N \\le 10^9$\nSubtask #2 (60 points): original constraints\n\n-----Example Input-----\n3\n35 4\n42 4\n24 9\n\n-----Example Output-----\n34\n24\n24\n\n-----Explanation-----\nExample case 1: Chef can remove the digit $5$ and add $4$ to the end of $N$. Then, $N$ becomes $34$.\nExample case 2: Chef can remove the digit $4$ from the beginning of $N$, add $4$ to the end of $N$ and get $N = 24$.\nExample case 3: Chef cannot make his number any smaller.", "starter_code": "", "test_cases": {"inputs": ["3\n35 4\n42 4\n24 9"], "outputs": ["34\n24\n24"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "b26f30c65a8836489686d26345d69c22bbaaf07c", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00739", "original_id": null, "source": "apps", "domain": "code", "problem": "Alice likes prime numbers. According to Alice, only those strings are nice whose sum of character values at a prime position is prime. She has a string $S$. Now, she has to count the number of nice strings which come before string $S$( including $S$) in the dictionary and are of the same length as $S$. \nStrings are zero-indexed from left to right.\nTo find the character value she uses the mapping {'a': 0, 'b':1, 'c':2 ……. 'y': 24, 'z':25} .\nFor example, for string $abcde$ Characters at prime positions are $'c'$ and $'d'$. c + d = 2 + 3 = 5. Since, 5 is a prime number, the string is $nice$.\nSince there could be many nice strings print the answer modulo $10^{9}+7$.\n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- Each testcase contains of a single line of input, the string $S$. \n\n-----Output:-----\nFor each testcase, output in a single line number of nice strings modulo $10^{9}+7$.\n\n-----Constraints-----\n- $1 \\leq T \\leq 10$\n- $2 \\leq |S| \\leq 10^2$\nString $S$ contains only lowercase letters.\n\n-----Sample Input:-----\n1\nabc\n\n-----Sample Output:-----\n10", "starter_code": "", "test_cases": {"inputs": ["1\nabc"], "outputs": ["10"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "9852c1cd0c266e67d9f8716549e906a6571dc651", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00744", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef has a garden with $N$ plants arranged in a line in decreasing order of height. Initially the height of the plants are $A_1, A_2, ..., A_N$.\nThe plants are growing, after each hour the height of the $i$-th plant increases by $i$ millimeters. Find the minimum number of integer hours that Chef must wait to have two plants of the same height.\n\n-----Input:-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains a single integer $N$.\n- The second line contains $N$ space separated integers $A_1,A_2,..A_N$. \n\n-----Output:-----\nFor each test case print a single line containing one integer, the minimum number of integer hours that Chef must wait to have two plants of the same height.\n\n-----Constraints-----\n- $1 \\leq T \\leq 1000$\n- $2 \\leq N \\leq 10^5$\n- $0\\leq A_i \\leq 10^{18}$\n- $A_i >A_{i+1}$, for each valid $i$\n- The Sum of $N$ over all test cases does not exceed $10^6$\n\n-----Sample Input:-----\n1\n3\n8 4 2\n\n-----Sample Output:-----\n2\n\n-----EXPLANATION:-----\nAfter $2$ hours there are two plants with the same height. \n$[8,4,2] \\rightarrow [9,6,5] \\rightarrow [10,8,8]$.", "starter_code": "", "test_cases": {"inputs": ["1\n3\n8 4 2"], "outputs": ["2"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "613b674a78eb10dc7e0c56b2deb332bd490df98d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00749", "original_id": null, "source": "apps", "domain": "code", "problem": "Note : This question carries $100$ $points$\nCodeLand is celebrating a festival by baking cakes! In order to avoid wastage, families follow a unique way of distributing cakes.\nFor $T$ families in the locality, $i$-th family (1 <= $i$ <= $T$) has $N$ members. They baked $S$ slices of cakes. The smallest member of the family gets $K$ slices of cakes. Each family has a lucky number of $R$ and they agree to distribute the slices such that the member gets $R$ times more slices than the member just smaller than them. Since the family is busy in festival preparations, find out if the number of slices would be sufficient for the family or not. Also, find how many extra slices they have or how many slices are they short of.\nAlso, the locality is kind and believes in sharing. So, you also need to determine if each family would have sufficient slices if families shared their cakes among each other!\n\n-----Input :-----\n- First line of input will have a single integer $T$ i.e. the number of families in the locality\n- For next $T$ lines, each line will describe one family through 4 integers i.e. $S$, $N$, $K$, $R$ separated by spaces\n\n-----Output-----\n- First $T$ lines of output will show if slices are enough for the family or not, followed by extra or required slices. For example, if slices are sufficient, the output would be $POSSIBLE$ $10$ which implies 10 slices are extra. If slices are insufficient, the output would be $IMPOSSIBLE$ $15$ which implies 15 slices are required to fulfill the requirement.\n- Last line of output would be $IMPOSSIBLE$ or $POSSIBLE$ depending on whether each family would get enough slices after sharing.\n\n-----Constraints:-----\n- 1 ≤ $T$ ≤ 50\n- 1 ≤ $N$ ≤ 15\n- 1 ≤ $S$ ≤ 10^9\n- 1 ≤ $K$ ≤ 5\n- 1 ≤ $R$ ≤ 5\n\n-----Sample Input:-----\n5\n100 4 2 2\n100 4 3 2\n100 4 3 3\n200 4 4 2\n10 3 2 2\n\n-----Sample Output:-----\nPOSSIBLE 70\nPOSSIBLE 55\nIMPOSSIBLE 20\nPOSSIBLE 140\nIMPOSSIBLE 4\nPOSSIBLE\n\n-----Explanation-----\nFor the first home, the youngest member has got 2 slices, the one older than them gets 2 times more slices, and so forth. So, first home needs 2 + 4 + 8 + 16 = 30 slices. But since they made 100, they have 70 extra, hence we print 'POSSIBLE 70'.\nDoing the same for other houses, we find 20 + 4 = 24 slices extra are required so that all families have enough slices. In this case we have 70 + 55 + 140 = 265 extra slices which is > 24, so we print 'POSSIBLE' in last line.", "starter_code": "", "test_cases": {"inputs": ["5\n100 4 2 2\n100 4 3 2\n100 4 3 3\n200 4 4 2\n10 3 2 2"], "outputs": ["POSSIBLE 70\nPOSSIBLE 55\nIMPOSSIBLE 20\nPOSSIBLE 140\nIMPOSSIBLE 4\nPOSSIBLE"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "06c55660f9c6b735c215b8dfc6f574bf372cc24c", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00754", "original_id": null, "source": "apps", "domain": "code", "problem": "Let's consider a rooted binary tree with the following properties:\n- The number of nodes and edges in the tree is infinite\n- The tree root is labeled by $1$\n- A node labeled by $v$ has two children: $2 \\cdot v$ (the left child of $v$), and $2 \\cdot v + 1$ (the right child of $v$).\nHere is an image of the first several layers of such a tree:\n\nLet's consider four operations that you are allowed to apply during the tree traversal:\n- move to the left child - move from $v$ to $2 \\cdot v$\n- move to the right child - move from $v$ to $2 \\cdot v + 1$\n- move to the parent as a left child - move from $v$ to $\\frac{v}{2}$ if $v$ is an even integer\n- move to the parent as a right child - move from $v$ to $\\frac{v - 1}{2}$ if $v$ is an odd integer\nIt can be proven, that for any pair of nodes $u$ and $v$, there is only one sequence of commands that moves from $u$ to $v$ and visits each node of the tree at most once. Let's call such a sequence of commands a path configuration for a pair of nodes $(u, v)$.\nYou are asked to process a series of the following queries: \nYou are given three integers $n$, $u$ and $v$ ($1 \\leq u, v \\leq n$). Count the pairs of nodes $(w, t)$ ($1 \\leq w, t \\leq n$) such that the path configuration for $(w, t)$ is the same with the path configuration for $(u, v)$.\n\n-----Input-----\n- The first line of input contains a single integer $Q$, denoting the number of queries to process.\n- Each of the next $Q$ lines contains three space-separated integers $n$, $u$ and $v$ denoting a query.\n\n-----Output-----\nFor each query, print the answer on a separate line.\n\n-----Constraints-----\n- $1 \\leq Q \\leq 2 \\cdot 10^4$\n- $1 \\leq u, v \\leq n \\leq 10^{9}$\n\n-----Example Input-----\n3\n11 9 11\n10 2 2\n8 1 8\n\n-----Example Output-----\n2\n10\n1\n\n-----Explanation-----\nIn the first query from the example test case, you should count pairs $(5, 7)$ and $(9, 11)$.\nIn the second query from the example test case, you should count the following pairs: $(1, 1)$, $(2, 2)$, $(3, 3)$, $(4, 4)$, $(5, 5)$, $(6, 6)$, $(7, 7)$, $(8, 8)$, $(9, 9)$ and $(10, 10)$.\nIn the third query from the example test case, you should only count a pair $(1, 8)$.", "starter_code": "", "test_cases": {"inputs": ["3\n11 9 11\n10 2 2\n8 1 8"], "outputs": ["2\n10\n1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "ed55eb20f13424652568310429847e9e54360020", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00759", "original_id": null, "source": "apps", "domain": "code", "problem": "Two's company, three's a crowd!\nIt's been one year since Chef met his brother. Last year, his younger brother came to visit him during this time of the year. This year, the Chef is planning to go visit his brother. Chef's brother has planned to throw a \"Welcome Party\" for him. He wants to invite people from his neighbourhood (i.e. from the street where he lives). There are N houses on the street in a single line (not considering the brother's house). He wants the party to be fun and he will not like to invite people who might spoil the mood of the party. If people are invited from three consecutive houses on the street, they might create trouble. As they say, three's a crowd! He doesn't want to ruin the Chef's Welcome Party and so he will not want to send invites to any three consecutive houses. He wants you to tell him how many ways are there for him to go wrong. Note that he can play safe by not inviting anyone to avoid a crowd.\n\n-----Input:-----\nFirst line of the input contains a single integer T, the number of test cases.\n\nEach test case contains a line containing a single integer N described above.\n\n-----Output:-----\nFor each test case output a single integer denoting the number of ways the brother can go wrong with planning the party.\n\nThe answer can get quite large. So output the total number of ways modulo 109+7.\n\n-----Constraints:-----\n1<=T<=10000\n1<=N<=1015\n\n-----Example:-----Input:\n2\n3\n4\n\nOutput:\n1\n3\n\nExplanation:\nCase 1: The only way he can go wrong is by inviting all the houses.\nCase 2: First way of getting wrong is by inviting houses (1,2,3). Second way to get wrong is by inviting houses (2,3,4). Third way of going wrong is by inviting all 4 houses i.e. (1,2,3,4).", "starter_code": "", "test_cases": {"inputs": ["2\n3\n4"], "outputs": ["1\n3"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "72898ba67f9c40b76a7bd067cb8a7bfb15a22a85", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00764", "original_id": null, "source": "apps", "domain": "code", "problem": "You're given an integer N. Write a program to calculate the sum of all the digits of N. \n\n-----Input-----\n\nThe first line contains an integer T, the total number of testcases. Then follow T lines, each line contains an integer N. \n\n-----Output-----\nFor each test case, calculate the sum of digits of N, and display it in a new line.\n\n-----Constraints-----\n- 1 ≤ T ≤ 1000\n- 1 ≤ N ≤ 1000000\n\n-----Example-----\nInput\n3 \n12345\n31203\n2123\nOutput\n15\n9\n8", "starter_code": "", "test_cases": {"inputs": ["3\n12345\n31203\n2123"], "outputs": ["15\n9\n8"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "b0a32c2d21c465847738f5e6053c315186efa7de", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00769", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef has a binary array in an unsorted manner. Cheffina challenges chef to find the transition point in the sorted (ascending) binary array. Here indexing is starting from 0.\nNote: Transition point always exists.\n\n-----Input:-----\n- First-line will contain $T$, the number of test cases. Then the test cases follow. \n- Each test case contains two lines of input, $N$.\n- N space-separated binary numbers. \n\n-----Output:-----\nFor each test case, output in a single line answer.\n\n-----Constraints-----\n- $1 \\leq T \\leq 10$\n- $1 \\leq N \\leq 10^5$\n\n-----Sample Input:-----\n1\n5\n0 1 0 0 1\n\n-----Sample Output:-----\n3\n\n-----EXPLANATION:-----\nbinary array in sorted form will look like = [0, 0, 0, 1, 1]", "starter_code": "", "test_cases": {"inputs": ["1\n5\n0 1 0 0 1\n"], "outputs": ["3"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "c4d3beeeca34071cb3ec9b7ae1ceef2b3a403ba3", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00774", "original_id": null, "source": "apps", "domain": "code", "problem": "You have an array A of size N containing only positive numbers. You have to output the maximum possible value of A[i]%A[j] where 1<=i,j<=N. \n\n-----Input-----\nThe first line of each test case contains a single integer N denoting the size of the array. The next N lines contains integers A1, A2, ..., AN denoting the numbers\n\n-----Output-----\nOutput a single integer answering what is asked in the problem.\n\n-----Subtask 1 (20 points)-----\n- 1 ≤ N ≤ 5000\n- 1 ≤ A[i] ≤ 2*(10^9)\n\n-----Subtask 2 (80 points)-----\n- 1 ≤ N ≤ 1000000\n- 1 ≤ A[i] ≤ 2*(10^9)\n\n-----Example-----\nInput:\n2\n1\n2\n\nOutput:\n1\n\n-----Explanation-----\nThere will be four values, A[0]%A[0] = 0, A[0]%A[1]=1, A[1]%A[0]=0, A[1]%A[1]=0, and hence the output will be the maximum among them all, that is 1.", "starter_code": "", "test_cases": {"inputs": ["2\n1\n2"], "outputs": ["1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "8a39ec7d5540c388b720d2c27ac6afb53d69ebf3", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00779", "original_id": null, "source": "apps", "domain": "code", "problem": "Chefland is a grid with N$N$ rows and M$M$ columns. Each cell of this grid is either empty or contains a house. The distance between a pair of houses is the Manhattan distance between the cells containing them.\nFor each d$d$ between 1$1$ and N+M−2$N+M-2$ inclusive, Chef wants to calculate the number of unordered pairs of distinct houses with distance equal to d$d$. Please help him!\n\n-----Input-----\n- The first line of the input contains a single integer T$T$ denoting the number of test cases. The description of T$T$ test cases follows.\n- The first line of each test case contains two space-separated integers N$N$ and M$M$.\n- N$N$ lines follow. For each i$i$ (1≤i≤N$1 \\le i \\le N$), the i$i$-th of these lines contains a binary string with length M$M$; for each j$j$ (1≤j≤M$1 \\le j \\le M$), the j$j$-th character of this string is '1' if the cell in the i$i$-th row and j$j$-th column contains a house or '0' if it is empty.\n\n-----Output-----\nFor each test case, print a single line containing N+M−2$N+M-2$ space-separated integers. For each valid i$i$, the i$i$-th integer should denote the number of pairs with distance i$i$.\n\n-----Constraints-----\n- 1≤T≤3$1 \\le T \\le 3$\n- 2≤N,M≤300$2 \\le N, M \\le 300$\n\n-----Subtasks-----\nSubtask #1 (50 points): N,M≤50$N, M \\le 50$\nSubtask #2 (50 points): original constraints\n\n-----Example Input-----\n1\n3 4\n0011\n0000\n0100\n\n-----Example Output-----\n1 0 1 1 0", "starter_code": "", "test_cases": {"inputs": ["1\n3 4\n0011\n0000\n0100"], "outputs": ["1 0 1 1 0"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "33114cc62be058ac6ed9584ae2d77c7ba821dca3", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00784", "original_id": null, "source": "apps", "domain": "code", "problem": "and Bengali as well.\nThere are N$N$ cats (numbered 1$1$ through N$N$) and M$M$ rats (numbered 1$1$ through M$M$) on a line. Each cat and each rat wants to move from some point to some (possibly the same) point on this line. Naturally, the cats also want to eat the rats when they get a chance. Both the cats and the rats can only move with constant speed 1$1$.\nFor each valid i$i$, the i$i$-th cat is initially sleeping at a point a_i$a_i$. At a time s_i$s_i$, this cat wakes up and starts moving to a final point b_i$b_i$ with constant velocity and without any detours (so it arrives at this point at the time e_i = s_i + |a_i-b_i|$e_i = s_i + |a_i-b_i|$). After it arrives at the point b_i$b_i$, it falls asleep again.\nFor each valid i$i$, the i$i$-th rat is initially hiding at a point c_i$c_i$. At a time r_i$r_i$, this rat stops hiding and starts moving to a final point d_i$d_i$ in the same way as the cats ― with constant velocity and without any detours, arriving at the time q_i = r_i + |c_i-d_i|$q_i = r_i + |c_i-d_i|$ (if it does not get eaten). After it arrives at the point d_i$d_i$, it hides again.\nIf a cat and a rat meet each other (they are located at the same point at the same time), the cat eats the rat, the rat disappears and cannot be eaten by any other cat. A sleeping cat cannot eat a rat and a hidden rat cannot be eaten ― formally, cat i$i$ can eat rat j$j$ only if they meet at a time t$t$ satisfying s_i \\le t \\le e_i$s_i \\le t \\le e_i$ and r_j \\le t \\le q_j$r_j \\le t \\le q_j$.\nYour task is to find out which rats get eaten by which cats. It is guaranteed that no two cats will meet a rat at the same time.\n\n-----Input-----\n- The first line of the input contains a single integer T$T$ denoting the number of test cases. The description of T$T$ test cases follows.\n- The first line of each test case contains two space-separated integers N$N$ and M$M$.\n- N$N$ lines follow. For each i$i$ (1 \\le i \\le N$1 \\le i \\le N$), the i$i$-th of these lines contains three space-separated integers a_i$a_i$, b_i$b_i$ and s_i$s_i$.\n- M$M$ more lines follow. For each i$i$ (1 \\le i \\le M$1 \\le i \\le M$), the i$i$-th of these lines contains three space-separated integers c_i$c_i$, d_i$d_i$ and r_i$r_i$.\n\n-----Output-----\nFor each test case, print M$M$ lines. For each valid i$i$, the i$i$-th of these lines should contain a single integer ― the number of the cat that will eat the i$i$-th rat, or -1$-1$ if no cat will eat this rat.\n\n-----Constraints-----\n- 1 \\le T \\le 10$1 \\le T \\le 10$\n- 0 \\le N \\le 1,000$0 \\le N \\le 1,000$\n- 1 \\le M \\le 1,000$1 \\le M \\le 1,000$\n- 1 \\le a_i, b_i, s_i \\le 10^9$1 \\le a_i, b_i, s_i \\le 10^9$ for each valid i$i$\n- 1 \\le c_i, d_i, r_i \\le 10^9$1 \\le c_i, d_i, r_i \\le 10^9$ for each valid i$i$\n- all initial and final positions of all cats and rats are pairwise distinct\n\n-----Example Input-----\n2\n8 7\n2 5 1\n1 4 1\n9 14 10\n20 7 9\n102 99 1\n199 202 1\n302 299 3\n399 402 3\n6 3 1\n10 15 10\n100 101 1\n201 200 1\n300 301 5\n401 400 5\n1000 1010 1020\n8 8\n2 8 2\n12 18 2\n22 28 4\n32 38 4\n48 42 2\n58 52 3\n68 62 1\n78 72 3\n3 6 3\n13 19 3\n21 25 3\n31 39 3\n46 43 4\n59 53 2\n65 61 4\n79 71 2\n\n-----Example Output-----\n1\n4\n5\n6\n7\n8\n-1\n1\n2\n3\n4\n5\n6\n7\n8", "starter_code": "", "test_cases": {"inputs": ["2\n8 7\n2 5 1\n1 4 1\n9 14 10\n20 7 9\n102 99 1\n199 202 1\n302 299 3\n399 402 3\n6 3 1\n10 15 10\n100 101 1\n201 200 1\n300 301 5\n401 400 5\n1000 1010 1020\n8 8\n2 8 2\n12 18 2\n22 28 4\n32 38 4\n48 42 2\n58 52 3\n68 62 1\n78 72 3\n3 6 3\n13 19 3\n21 25 3\n31 39 3\n46 43 4\n59 53 2\n65 61 4\n79 71 2"], "outputs": ["1\n4\n5\n6\n7\n8\n-1\n1\n2\n3\n4\n5\n6\n7\n8"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "6ba04e0493c3d9b88adaaf00f7401a97b59dd6f6", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00789", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given an unweighted tree with N$N$ nodes (numbered 1$1$ through N$N$). Let's denote the distance between any two nodes p$p$ and q$q$ by d(p,q)$d(p, q)$.\nYou should answer Q$Q$ queries. In each query, you are given parameters a$a$, da$d_a$, b$b$, db$d_b$, and you should find a node x$x$ such that d(x,a)=da$d(x, a) = d_a$ and d(x,b)=db$d(x, b) = d_b$, or determine that there is no such node.\n\n-----Input-----\n- The first line of the input contains a single integer T$T$ denoting the number of test cases. The description of T$T$ test cases follows.\n- The first line of each test case contains two space-separated integers N$N$ and Q$Q$.\n- Each of the next N−1$N-1$ lines contains two space-separated integers u$u$ and v$v$ denoting that nodes u$u$ and v$v$ are connected by an edge.\n- Each of the next Q$Q$ lines contains four space-separated integers a$a$, da$d_a$, b$b$ and db$d_b$ describing a query.\n\n-----Output-----\nFor each query, print a single line containing one integer ― the number of a node satisfying the given requirements, or −1$-1$ if no such node exists.\nIf there are multiple solutions, you may output any one.\n\n-----Constraints-----\n- 1≤T≤1,000$1 \\le T \\le 1,000$\n- 1≤N,Q≤106$1 \\le N, Q \\le 10^6$\n- 1≤u,v≤N$1 \\le u, v \\le N$\n- the graph on the input is a tree\n- 1≤a,b≤N$1 \\le a, b \\le N$\n- 1≤da,dblength$ and $S[i'...j']$ is a \"good\" group.\n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- $i^{th}$ testcase consist of a single line of input, a string $S$. \n\n-----Output:-----\nFor each testcase, output in a single line maximum possible size of a \"good\" group.\n\n-----Constraints-----\n$\\textbf{Subtask 1} (20 points)$\n- $1 \\leq T \\leq 10$\n- $S.length \\leq 10^{3}$\n$\\textbf{Subtask 2} (80 points)$\n- $1 \\leq T \\leq 10$\n- $S.length \\leq 10^{5}$\n\n-----Sample Input:-----\n1\n\n123343\n\n-----Sample Output:-----\n3\n\n-----EXPLANATION:-----\n1$\\textbf{$\\underline{2 3 3}$}$43\nUnderlined group is a “good” group because the second player(number 2 on T-Shirt) is the only player who is left unmatched and third and fourth player can form a pair, no other group has length greater than 3 that are “good”. However note that we have other “good” group also 12$\\textbf{$\\underline{334}$}$3 but length is 3 which is same as our answer.\n\n-----Sample Input:-----\n1\n\n95665\n\n-----Sample Output:-----\n5\n\n-----EXPLANATION:-----\n$\\textbf{$\\underline{95665}$}$ is “good” group because first player is the only player who is left unmatched second and fifth player can form pair and third and fourth player also form pair.\n\n-----Sample Input:-----\n2\n\n2323\n\n1234567\n\n-----Sample Output:-----\n4\n\n1\n\n-----EXPLANATION:-----\nFor first test case\n$\\textbf{$\\underline{2323}$}$ is a “good” group because there are no players who are left unmatched first and third player form pair and second and fourth player form pair.\n\nFor second test\n\nOnly length one \"good\" group is possible.", "starter_code": "", "test_cases": {"inputs": ["1\n123343"], "outputs": ["3"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "e90e29aede4b23a6c1eb0ae1811d54b9fb7c701c", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00909", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef loves to play with arrays by himself. Today, he has an array A consisting of N distinct integers. He wants to perform the following operation on his array A.\n\n- Select a pair of adjacent integers and remove the larger one of these two. This decreases the array size by 1. Cost of this operation will be equal to the smaller of them.\n\nFind out minimum sum of costs of operations needed to convert the array into a single element.\n\n-----Input-----\nFirst line of input contains a single integer T denoting the number of test cases. First line of each test case starts with an integer N denoting the size of the array A. Next line of input contains N space separated integers, where the ith integer denotes the value Ai.\n\n-----Output-----\nFor each test case, print the minimum cost required for the transformation.\n\n-----Constraints-----\n- 1 ≤ T ≤ 10 \n- 2 ≤ N ≤ 50000 \n- 1 ≤ Ai ≤ 105 \n\n-----Subtasks-----\n- Subtask 1 : 2 ≤ N ≤ 15 : 35 pts \n- Subtask 2 : 2 ≤ N ≤ 100 : 25 pts \n- Subtask 3 : 2 ≤ N ≤ 50000 : 40 pts \n\n-----Example-----\nInput\n2\n2\n3 4\n3\n4 2 5\n\nOutput\n3\n4\n\n-----Explanation-----Test 1 : Chef will make only 1 move: pick up both the elements (that is, 3 and 4), remove the larger one (4), incurring a cost equal to the smaller one (3).", "starter_code": "", "test_cases": {"inputs": ["2\n2\n3 4\n3\n4 2 5"], "outputs": ["3\n4"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "e9732d708781773c92a447578b795d01449008f5", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00914", "original_id": null, "source": "apps", "domain": "code", "problem": "Our chef has been assigned a task to make a necklace of length N, from gold, diamond and platinum.There is single kind of gold, two types of diamond and three types of platinum available.\nA necklace can be represented as strings of the form (G)∗(D1|D2)∗(P1|P2|P3)∗$ (G)*(D1|D2)*(P1|P2|P3)* $ where (x|y) means we can use x or y and ∗$ * $ means we can repeat the previous parenthesized expression 0 or more times.\nInstead of making necklace he choose to count all such distinct necklaces possible for a given length N.\n\n-----Input:-----\n-The first line of the input contains a single integer T$T$ denoting the number of test cases. The description of T$T$ test cases follows.\n-Only line of every test case contains an integer N$N$ denoting the length of the necklace required.\n\n-----Output:-----\nFor each test case, print the number of all such distinct necklaces, with given length. As the number can be really large, print it modulo 109+7$10^{9}+7$.\n\n-----Constraints-----\n- 1≤T≤10000$1 \\leq T \\leq 10000$\n- 2≤N≤1000000000$2 \\leq N \\leq 1000000000$\n- String S$S$ consists of only upper case english alphabets.\n\n-----Subtasks-----\n- 20 points : 1≤N≤5$1 \\leq N \\leq 5$\n- 70 points : Original$Original$ Constraints$Constraints$\n\n-----Sample Input:-----\n2\n1\n2\n\n-----Sample Output:-----\n6\n25", "starter_code": "", "test_cases": {"inputs": ["2\n1\n2"], "outputs": ["6\n25"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "5bdc3042d2a89133e3bac99739a65b0c6a1c1eac", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00919", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef Zidane likes the number 9. He has a number N, and he wants to turn it into a multiple of 9. He cannot add or remove digits, and he can only change one digit at a time. The only allowed operation is to increment or decrement a digit by one, and doing this takes exactly one second. Note that he cannot increase a digit 9 or decrease a digit 0, and the resulting number must not contain any leading zeroes unless N has a single digit.\n\nChef Zidane wants to know the minimum amount of time (in seconds) needed to accomplish this. Please help him, before his kitchen gets overwhelmed with mist!\n\n-----Input-----\nThe first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.\nEach test case consists of one line containing a single positive integer N.\n\n-----Output-----\nFor each test case, output a single line containing the answer.\n\n-----Constraints-----\n- 1 ≤ T ≤ 105\n- 1 ≤ N ≤ 10105\n- N will not contain leading zeroes.\n- Each test file is at most 3Mb in size.\n\n-----Example-----\nInput:4\n1989\n86236\n90210\n99999999999999999999999999999999999999988\n\nOutput:0\n2\n3\n2\n\n-----Explanation-----\nExample case 1. 1989 is already divisible by 9, so no operations are needed to be performed.\nExample case 2. 86236 can be turned into a multiple of 9 by incrementing the first and third digit (from the left), to get 96336. This takes 2 seconds.\nExample case 3. 90210 can be turned into a multiple of 9 by decrementing the third digit twice and the fourth digit once, to get 90000. This takes 3 seconds.", "starter_code": "", "test_cases": {"inputs": ["4\n1989\n86236\n90210\n99999999999999999999999999999999999999988"], "outputs": ["0\n2\n3\n2"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "61176cdb929a24d02e2538e3eae164b6244faa11", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00924", "original_id": null, "source": "apps", "domain": "code", "problem": "The chef was playing with numbers and he found that natural number N can be obtained by sum various unique natural numbers, For challenging himself chef wrote one problem statement, which he decided to solve in future.\nProblem statement: N can be obtained as the sum of Kth power of integers in multiple ways, find total number ways?\nAfter that Cheffina came and read what chef wrote in the problem statement, for having some fun Cheffina made some changes in the problem statement as.\nNew problem statement: N can be obtained as the sum of Kth power of unique +ve integers in multiple ways, find total number ways?\nBut, the chef is now confused, how to solve a new problem statement, help the chef to solve this new problem statement.\n\n-----Input:-----\n- First-line will contain $T$, the number of test cases. Then the test cases follow. \n- Each test case contains a single line of input, two integers $N, K$. \n\n-----Output:-----\nFor each test case, output in a single line answer to the problem statement.\n\n-----Constraints-----\n- $1 \\leq T \\leq 10$\n- $1 \\leq N \\leq 1000$\n- $1 \\leq K \\leq 6$\n\n-----Sample Input:-----\n2\n4 1\n38 2\n\n-----Sample Output:-----\n2\n1\n\n-----EXPLANATION:-----\nFor 1) 4 can be obtained by as [ 4^1 ], [1^1, 3^1], [2^1, 2^1]. (here ^ stands for power)\nBut here [2^1, 2^1] is not the valid way because it is not made up of unique +ve integers. \nFor 2) 38 can be obtained in the way which is [2^2, 3^2, 5^2] = 4 + 9 + 25", "starter_code": "", "test_cases": {"inputs": ["2\n4 1\n38 2"], "outputs": ["2\n1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "ce79409cb0a6cc7713e49b1a1545da66bca92f38", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00929", "original_id": null, "source": "apps", "domain": "code", "problem": "Get excited, folks, because it is time for the final match of Codechef Premier League (CPL)!\nMike and Tracy also want to watch the grand finale, but unfortunately, they could not get tickets to the match. However, Mike is not someone who gives up so easily — he has a plan to watch the match.\nThe field where the match is played is surrounded by a wall with height $K$. Outside, there are $N$ boxes (numbered $1$ through $N$). For each valid $i$, the $i$-th box has a height $H_i$.\nMike wants to take some boxes and stack them on top of each other to build two towers. The height of each tower is the sum of heights of all the boxes that form it. Of course, no box may be in both towers. The height of each tower should be at least $K$. Then Mike can climb on top of one tower and Tracy on top of the other, and they can watch the match uninterrupted!\nWhile Mike is busy stacking the boxes, Tracy would like to know the smallest number of boxes required to build two towers such that each of them has height at least $K$, or at least that it is impossible to build such towers. Can you help Tracy?\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains two space-separated integers $N$ and $K$.\n- The second line contains $N$ space-separated integers $H_1, H_2, \\ldots, H_N$.\n\n-----Output-----\nFor each test case, print a single line containing one integer — the smallest number of boxes required to build two towers, or $-1$ if it is impossible.\n\n-----Constraints-----\n- $1 \\leq T \\leq 5$\n- $1 \\leq N, K \\leq 4,000$\n- $1 \\leq H_i \\leq 10^5$ for each valid $i$\n\n-----Subtasks-----\nSubtask #1 (30 points):\n- $1 \\leq N, K \\leq 100$\n- $1 \\leq H_i \\leq 100$ for each valid $i$\nSubtask #2 (70 points): original constraints\n\n-----Example Input-----\n2\n8 38\n7 8 19 7 8 7 10 20\n4 5\n2 10 4 9\n\n-----Example Output-----\n7\n2\n\n-----Explanation-----\nExample case 1: The first tower can be built with boxes $8 + 10 + 20 = 38$ and the second tower with boxes $7 + 7 + 8 + 19 = 41$. In this case, the box with height $7$ is left unused.\nExample case 2: We only need the box with height $10$ for one tower and the box with height $9$ for the other tower.", "starter_code": "", "test_cases": {"inputs": ["2\n8 38\n7 8 19 7 8 7 10 20\n4 5\n2 10 4 9"], "outputs": ["7\n2"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "bd90123018b26042061433d437a126b9845d8465", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00934", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef likes all arrays equally. But he likes some arrays more equally than others. In particular, he loves Rainbow Arrays. \nAn array is Rainbow if it has the following structure:\n- First a1 elements equal 1. \n- Next a2 elements equal 2. \n- Next a3 elements equal 3. \n- Next a4 elements equal 4. \n- Next a5 elements equal 5. \n- Next a6 elements equal 6. \n- Next a7 elements equal 7. \n- Next a6 elements equal 6. \n- Next a5 elements equal 5. \n- Next a4 elements equal 4. \n- Next a3 elements equal 3. \n- Next a2 elements equal 2. \n- Next a1 elements equal 1. \n- ai can be any non-zero positive integer.\n- There are no other elements in array. \n\nHelp Chef in finding out if the given array is a Rainbow Array or not. \n\n-----Input-----\n- The first line of the input contains an integer T denoting the number of test cases.\n- The first line of each test case contains an integer N, denoting the number of elements in the given array. \n- The second line contains N space-separated integers A1, A2, ..., AN denoting the elements of array. \n\n-----Output-----\n- For each test case, output a line containing \"yes\" or \"no\" (without quotes) corresponding to the case if the array is rainbow array or not. \n\n-----Constraints-----\n- 1 ≤ T ≤ 100\n- 7 ≤ N ≤ 100\n- 1 ≤ Ai ≤ 10\n\n-----Subtasks-----\n- Subtask 1 (100 points) : Original constraints\n\n-----Example-----\nInput\n3\n19\n1 2 3 4 4 5 6 6 6 7 6 6 6 5 4 4 3 2 1\n14\n1 2 3 4 5 6 7 6 5 4 3 2 1 1\n13\n1 2 3 4 5 6 8 6 5 4 3 2 1\n\nOutput\nyes\nno\nno\n\n-----Explanation-----\nThe first example satisfies all the conditions. \nThe second example has 1 element of value 1 at the beginning and 2 elements of value 1 at the end. \nThe third one has no elements with value 7 after elements with value 6.", "starter_code": "", "test_cases": {"inputs": ["3\n19\n1 2 3 4 4 5 6 6 6 7 6 6 6 5 4 4 3 2 1\n14\n1 2 3 4 5 6 7 6 5 4 3 2 1 1\n13\n1 2 3 4 5 6 8 6 5 4 3 2 1"], "outputs": ["yes\nno\nno"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "54b13b08feebc045ef60493aa793422ae1264aa7", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00939", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given a string $s$. And you have a function $f(x)$ defined as:\nf(x) = 1, if $x$ is a vowel\nf(x) = 0, if $x$ is a constant\n\nYour task is to apply the above function on all the characters in the string s and convert \nthe obtained binary string in decimal number $M$.\nSince the number $M$ can be very large, compute it modulo $10^9+7$. \n\n-----Input:-----\n- The first line of the input contains a single integer $T$ i.e the no. of test cases. \n- Each test line contains one String $s$ composed of lowercase English alphabet letters. \n\n-----Output:-----\nFor each case, print a single line containing one integer $M$ modulo $10^9 + 7$.\n\n-----Constraints-----\n- $1 ≤ T ≤ 50$\n- $|s|≤10^5$\n\n-----Subtasks-----\n- 20 points : $|s|≤30$\n- 80 points : $ \\text{original constraints}$\n\n-----Sample Input:-----\n1\nhello\n\n-----Sample Output:-----\n9", "starter_code": "", "test_cases": {"inputs": ["1\nhello"], "outputs": ["9"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "82509a49f8d05cbc0d562cf5f36bf7a76d603a5b", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00944", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef and his friend Miron were getting bored and decided to play a game. \nMiron thinks of a sequence of N integers (A1, A2, …., AN) and gives Chef a matrix B, where Bi,j = |Ai - Aj|. He further tells Chef that A1 = 0. The game is for Chef to guess the sequence that Miron thought of. \nBut Miron is an adversarial player. Every time Chef tries to guess the sequence, he makes a change to the matrix. He makes such a change Q times. Each time, he replaces an entry in some row and the corresponding column with a new one leaving Chef to guess the sequence after each change. \nChef needs a friend to help him against such an adversarial player. Can you be that friend and help Chef find a suitable sequence A for the initial matrix B and also after each change Miron makes? \nNote that if several answers exist, then print the lexicographically smallest answer. Further, the numbers in the sequence can be negative.\n\n-----Input-----\n\nThe first line contains two space-separated integers N, Q. Each of the N subsequent lines contains N space-separated integers, denoting the matrix B.\n\nQ queries follow. Each query has two lines. The first line of each query contains an integer p, denoting the number of row and column that is changed. The second line of each query contains N space-separated integers F1, F2, F3, ... FN, denoting the new values to the corresponding cells of the matrix (you should make the following assignments Bi,p = Bp,i = Fi for all valid i). \n\n-----Output-----\nPrint Q + 1 lines which contain N space-separated integers, Miron's initial array and Miron's array after each query.\n\n-----Constraints-----\n- 3 ≤ N ≤ 1000 \n- 1 ≤ Q ≤ 1000 \n- 0 ≤ Bi,j ≤ 5000 \n- 1 ≤ p ≤ n \n- 0 ≤ Fi ≤ 5000 \n- it's guaranteed there's always an answer\n\n-----Example-----\nInput:\n3 2\n0 1 2\n1 0 1\n2 1 0\n1\n0 4 3\n2\n4 0 7\nOutput:\n0 -1 -2\n0 -4 -3\n0 -4 3\n\n-----Explanation-----\nExample case 1. Initially, sequence {0, 1, 2} is also suitable, but {0, -1, -2} is lexicografically smaller.", "starter_code": "", "test_cases": {"inputs": ["3 2\n0 1 2\n1 0 1\n2 1 0\n1\n0 4 3\n2\n4 0 7"], "outputs": ["0 -1 -2\n0 -4 -3\n0 -4 3"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "4231436df7ead29535c28cdc4f47893149525f4f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00949", "original_id": null, "source": "apps", "domain": "code", "problem": "Batman is about to face Superman so he decides to prepare for the battle by upgrading his Batmobile. He manufactures multiple duplicates of his standard Batmobile each tweaked in a different way such that the maximum speed of each is never less than that of the standard model.\nAfter carrying out this process, he wishes to know how many of his prototypes are faster than his standard Batmobile?\n\n-----Input-----\n- The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follow: \n- The first line of each test case contains a single integer N denoting the number of copies of the standard Batmobile.\n- The second line contains a sequence of N+1 space-separated integers, S0 to SN, sorted in non-decreasing order separated by space. S0 is the maximum speed of the standard Batmobile. S1 to SN denote the maximum speeds of the prototypes.\n\n-----Output-----\n- For each test case, output a single line containing an integer denoting the answer.\n\n-----Constraints-----\n- 1 ≤ T ≤ 1000\n- 1 ≤ N ≤ 1000\n- 1 ≤ Si ≤ 109\n\n-----Example-----\nInput:\n2\n4\n1 2 3 4 5\n5\n1 10 100 1000 10000 100000\n\nOutput:\n4\n5", "starter_code": "", "test_cases": {"inputs": ["2\n4\n1 2 3 4 5\n5\n1 10 100 1000 10000 100000"], "outputs": ["4\n5"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "39fd14b9aa9965edf854e9c47509196ac6d87d5d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00954", "original_id": null, "source": "apps", "domain": "code", "problem": "After the death of their mother, Alphonse and Edward now live with Pinako and Winry.\n\nPinako is worried about their obsession with Alchemy, and that they don't give attention to their studies.\nSo to improve their mathematical solving ability, every day she gives a mathematical problem to solve. They can go out to practice Alchemy only after they have solved the problem.\nHelp them by solving the given problem, so that they can go early today for their Alchemy practice. \nGiven an array A$A$ of N$N$ non-negative integers and two integers K$K$ and M$M$. Find the number of subsequences of array A$A$ of length K$K$ which satisfies the following property:\n\nSuppose the subsequence is S=S1S2…SK$S = S_1S_2 \\ldots S_K$, then for all i$i$ such that 1≤i≤K$1 \\leq i \\leq K$,\nSi%M=i%M S_i \\% M = i \\% M \nshould hold true, where Si$S_i$ denotes the i$i$-th element of the subsequence, using 1-based indexing.\nAs the number of subsequences may be very large, output the answer modulo 1000000007$1000000007$. \nPS: We also proposed the idea of making a look-alike clone through alchemy and keeping it in front of the study table. But it seems impossible to convince Edward to make a clone of his exact same height, and not taller than him. So solving the problem for him was a better choice. \n\n-----Input:-----\n- The first line contains T$T$, the number of test cases. Then the test cases follow. \n- For every test case, the first line contains N$N$, K$K$ and M$M$.\n- For every test case, the second line contains N$N$ integers Ai$A_{i}$ ( 1≤i≤N$1 \\leq i \\leq N$).\n\n-----Output:-----\nFor every test case, output in a single line an integer denoting the number of valid subsequences modulo 109+7$10^9+7$\n\n-----Constraints-----\n- 1≤T≤100$1 \\leq T \\leq 100$ \n- 1≤N≤104$1 \\leq N \\leq 10^{4}$ \n- 1≤K≤N$1 \\leq K \\leq N$ \n- ⌈K100⌉≤M≤100×K$\\lceil \\frac{K}{100}\\rceil \\leq M \\leq 100\\times K$ \n- 0≤Ai≤109$0 \\leq A_{i} \\leq 10^{9}$ \n\n-----Sample Input:-----\n1\n12 4 3\n4 5 6 7 1 4 6 9 0 0 10 2\n\n-----Sample Output:-----\n8\n\n-----Explanation:-----\nThe subsequences of length 4$4$, satisfying the given criteria are [4,5,6,7]$[4, 5, 6, 7]$, [4,5,6,10]$[4, 5, 6, 10]$, [4,5,6,10]$[4, 5, 6, 10]$, [4,5,6,1]$[4, 5, 6, 1]$, [4,5,9,10]$[4, 5, 9, 10]$ ,[4,5,6,4]$[4, 5, 6, 4]$ , [4,5,0,10]$[4, 5, 0, 10]$ and [4,5,0,10]$[4, 5, 0, 10]$. This accounts for a total of 8$8$ valid subsequences.\nLet us take one subsequence and see why it satisfies the given property. Consider [4,5,9,10]$[4, 5, 9, 10]$. \n- S1%M=4%3=1=1%3=1%M$ S_1 \\% M = 4 \\% 3 = 1 = 1 \\% 3 = 1 \\% M $\n- S2%M=5%3=2=2%3=2%M$ S_2 \\% M = 5 \\% 3 = 2 = 2 \\% 3 = 2 \\% M $\n- S3%M=9%3=0=3%3=3%M$ S_3 \\% M = 9 \\% 3 = 0 = 3 \\% 3 = 3 \\% M $\n- S4%M=10%3=1=4%3=4%M$ S_4 \\% M = 10 \\% 3 = 1 = 4 \\% 3 = 4 \\% M $\nAll the valid i$i$ satisfy the condition, and hence this is a valid subsequence.", "starter_code": "", "test_cases": {"inputs": ["1\n12 4 3\n4 5 6 7 1 4 6 9 0 0 10 2"], "outputs": ["8"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "5438bbc43783d0cc883a18c84bee04d1f8233f11", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00959", "original_id": null, "source": "apps", "domain": "code", "problem": "Bohan loves milk tea so much and he drinks one cup of milk tea every day. The local shop sells milk tea in two sizes: a Medium cup for $3 and a Large cup for $4. For every cup of milk tea purchased Bohan receives a promotional stamp. Bohan may redeem 6 stamps for a free drink of milk tea regardless of the size. No stamp will be given for a free drink.\n\n\nDetermine the amount of money Bohan have spent on milk tea, given a sequence of milk tea sizes he got in the past a few days. Assume Bohan had no stamps in the beginning and he always redeemed the stamps for the next drink once he had collected 6 stamps.\n\n-----Input-----\nThe input begins with the number of test cases T.\nEach test case has a single line of letters. The i-th letter is either 'M' or 'L' denoting a Medium cup or a Large cup of milk tea Bohan got on the i-th day.\n\n-----Output-----\nFor each case, output the amount of money in dollars Bohan have spent on milk tea.\n\n-----Constraints-----\n- T ≤ 100 \n- 1 ≤ length of each sequence ≤ 100 \n\n-----Example-----\nInput:\n3\nMLM\nMMLLMMLL\nMMMMMMML\n\nOutput:\n10\n24\n22\n\n-----Explanation-----\nExample 1: Bohan didn't redeem any stamps.\nExample 2: Bohan redeemed 6 stamps for the Large cup of milk tea on the 7th day.\nExample 3: Bohan redeemed 6 stamps for the Medium cup of milk tea on the 7th day.", "starter_code": "", "test_cases": {"inputs": ["3\nMLM\nMMLLMMLL\nMMMMMMML"], "outputs": ["10\n24\n22"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "16c8c61a1423ea1f066a2a5ebc0a318e83181108", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00964", "original_id": null, "source": "apps", "domain": "code", "problem": "A despotic king decided that his kingdom needed to be rid of corruption and disparity. He called his prime minister and ordered that all corrupt citizens be put to death. Moreover, he wanted this done quickly.\nThe wily prime minister realised that investigating every citizen to decide who was corrupt and who was not was rather difficult. So he decided on the following plan: He ordered all the citizens to appear in the court one by one and declare their wealth.\nThe king does not sit in the court all the time (he has other important business to attend to - for instance, meet dignitaries from neighbouring kingdoms, spend time with his family …) Whenever the king walks into the court, the prime minister pulls out the richest man who has appeared before the court so far and is still alive and beheads him for being corrupt. Since the rich are more likely to be corrupt, he hopes to get rid of most of the corrupt and the king is happy as he sees his policy being implemented enthusiastically.\nSuppose the wealth of the citizens trooping into the court is\n1376518911241376518911241\\; 3\\; 7\\; 6\\; 5\\; 18\\; 9\\; 11\\; 2\\; 4\nand the king walked in three times: the first time after the first four persons have seen the minister, the second time after the first five persons have seen the minister and, finally after the first nine persons have seen the minister.\nAt the king's first visit the richest person to have met the minister has wealth $7$ and he would be beheaded. At the second visit, the wealth of the richest person who has met the minister and is still alive has wealth $6$ and so he would be beheaded. At the third visit the richest person to have met the minister who is still alive has wealth $18$ and so he would be beheaded.\nYou may assume that the input is such that whenever the king walks in, it is always possible to behead someone.\nYour aim is to write a program that will enable the prime minister to identify the richest man to have met the minister and who is still alive quickly. You may assume that no two citizens have the same wealth.\n\n-----Input:-----\nThe first line of the input consists of two numbers $N$ and $M$, where $N$ is the number of citizens in the kingdom and M is the number of visits to the court by the king.\nThe next $N+M$ lines describe the order in which the $N$ citizens' appearances are interleaved with the $M$ visits by the king. A citizen's visit is denoted by a positive integer, signifying his wealth. You may assume that no two citizens have the same wealth. A visit by the king is denoted by $-1$.\n\n-----Output:-----\nYour output should consist of $M$ lines, where the $i^{th}$ line contains the wealth of the citizen who is beheaded at the $i^{th}$ visit of the king.\n\n-----Constraints:-----\n- $1 \\leq M \\leq 10000$.\n- $1 \\leq N \\leq 100000$.\n- You may assume that in $50 \\%$ of the inputs $1 \\leq M \\leq 1000$ and $1 \\leq N \\leq 8000$.\n\n-----Sample Input-----\n10 3\n1 \n3 \n7 \n6 \n-1 \n5 \n-1 \n18 \n9 \n11\n2\n-1\n4\n\n-----Sample Output-----\n7\n6\n18", "starter_code": "", "test_cases": {"inputs": ["10 3\n1\n3\n7\n6\n-1\n5\n-1\n18\n9\n11\n2\n-1\n4"], "outputs": ["7\n6\n18"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "0f8441e02180d8d9be1cfe3f8d22646e3f24e7bc", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00969", "original_id": null, "source": "apps", "domain": "code", "problem": "Gru wants to distribute $N$ bananas to $K$ minions on his birthday.\nGru does not like to just give everyone the same number of bananas, so instead, he wants to distribute bananas in such a way that each minion gets a $distinct$ amount of bananas. That is, no two minions should get the same number of bananas.\nGru also loves $gcd$. The higher the $gcd$, the happier Gru and the minions get. So help Gru in distributing the bananas in such a way that each Minion gets a distinct amount of bananas and gcd of this distribution is highest possible. Output this maximum gcd. If such a distribution is not possible output $-1$.\nNote: You have to distribute $all$ $N$ bananas. \n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- Each testcase consists of a single line of input, which has two integers: $N, K$. \n\n-----Output:-----\nFor each testcase, output in a single line the maximum gcd or -1.\n\n-----Constraints-----\n- $1 \\leq T \\leq 100$\n- $1 \\leq N, K \\leq 10^9$\n\n-----Sample Input:-----\n1\n6 3\n\n-----Sample Output:-----\n1\n\n-----EXPLANATION:-----\nThe only possible distribution is $[1, 2, 3]$. So the answer is 1.", "starter_code": "", "test_cases": {"inputs": ["1\n6 3"], "outputs": ["1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "10f46df4e0348ab33ecf91b677f91a739d450b11", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00974", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef has invited Alice for his birthday party. Now, Alice is thinking about what to give Chef as a present. She should obviously choose a sequence ― what could possibly be a better birthday gift than a sequence!\nAfter some thinking, Alice chose a sequence of integers $A_1, A_2, \\ldots, A_N$. However, she does not want to simply give this sequence to Chef. Instead, she decided to give Chef a sequence $B_1, B_2, \\ldots, B_N$, where $B_i = \\bigvee_{j=1}^i A_j$ for each valid $i$ and $\\bigvee$ denotes the bitwise OR operation. Chef can try to generate a sequence $A$ from $B$, but there could be more than one such possible sequence.\nNow, Alice is wondering how many sequences $A$ correspond to the given sequence $B$. Since this number could be very large, compute it modulo $10^9 + 7$. Note that it is not guaranteed that the given sequence $B$ was generated from some sequence $A$.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains a single integer $N$.\n- The second line contains $N$ space-separated integers $B_1, B_2, \\ldots, B_N$.\n\n-----Output-----\nFor each test case, print a single line containing one integer ― the number of possible sequences $A$ modulo $10^9 + 7$.\n\n-----Constraints-----\n- $1 \\le T \\le 25$\n- $1 \\le N \\le 5 \\cdot 10^4$\n- $0 \\le B_i < 2^{30}$ for each valid $i$\n\n-----Example Input-----\n2\n2\n2 3\n4\n2 6 7 7\n\n-----Example Output-----\n2\n64\n\n-----Explanation-----\nExample case 1: There are two possible options for $A$: $(2, 1)$ and $(2, 3)$.", "starter_code": "", "test_cases": {"inputs": ["2\n2\n2 3\n4\n2 6 7 7"], "outputs": ["2\n64"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "702aa9d791d453c1e81a37c087e21c0b4db405cf", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00979", "original_id": null, "source": "apps", "domain": "code", "problem": "Vasya learned about integer subtraction in school. He is still not very good at it, so he is only able to subtract any single digit number from any other number (which is not necessarily single digit).\nFor practice, Vasya chose a positive integer n$n$ and wrote it on the first line in his notepad. After that, on the second line he wrote the result of subtraction of the first digit of n$n$ from itself. For example, if n=968$n = 968$, then the second line would contain 968−9=959$968 - 9 = 959$, while with n=5$n = 5$ the second number would be 5−5=0$5 - 5 = 0$. If the second number was still positive, then Vasya would write the result of the same operation on the following line, and so on. For example, if n=91$n = 91$, then the sequence of numbers Vasya would write starts as follows: 91,82,74,67,61,55,50,…$91, 82, 74, 67, 61, 55, 50, \\ldots$. One can see that any such sequence eventually terminates with the number 0$0$.\nSince then, Vasya lost his notepad. However, he remembered the total number k$k$ of integers he wrote down (including the first number n$n$ and the final number 0$0$). What was the largest possible value of n$n$ Vasya could have started with?\n\n-----Input:-----\nThe first line contains T$T$ , number of test cases per file.\nThe only line in each testcase contains a single integer k−$k-$ the total number of integers in Vasya's notepad (2≤k≤1012$2 \\leq k \\leq 10^{12}$).\n\n-----Output:-----\nPrint a single integer−$-$ the largest possible value of the starting number n$n$. It is guaranteed that at least one such number n$n$ exists, and the largest possible value is finite.\n\n-----Constraints-----\n- 1≤T≤34$1 \\leq T \\leq 34 $\n- 2≤k≤1012$2 \\leq k \\leq 10^{12}$\n\n-----Sample Input-----\n3\n2\n3\n100\n\n-----Sample Output:-----\n9\n10\n170", "starter_code": "", "test_cases": {"inputs": ["3\n2\n3\n100"], "outputs": ["9\n10\n170"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "d527d018b30143131db13b04371b201b2d02a16f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00984", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef's love for Fibonacci numbers helps him to design following interesting problem.\nHe defines a function F for an array S as follows:\n\nwhere\n- Si denotes a non-empty subset of multiset S.\n- sum(Si) denotes the sum of all element of multiset Si.\n- Fibonacci(x) denotes the xth Fibonacci number.\nGiven an array A consisting of N elements. Chef asked you to process following two types of queries on this array accurately and efficiently.\n- C X Y: Change the value of Xth element of array to Y i.e AX = Y.\n- Q L R: Compute function F over the subarray defined by the elements of array A in the range L to R, both inclusive.\n\nPlease see the Note section if you need details regarding Fibonacci function.\n\n-----Input-----\nFirst line of input contains 2 space separated integer N and M denoting the size of array A and the number of queries to be performed. Next line of input contains N space separated integers denoting the elements of array A. Each of next M lines of input contains a query having one of the mentioned two types.\n\n-----Output-----\nFor each query of type Q, output the value of function F for the given range of array A.\n\n-----Constraints-----\n- 1 ≤ N, M ≤ 105\n- 1 ≤ Ai, Y ≤ 109\n- 1 ≤ L, R, X ≤ N\n- type = {'C', 'Q'} \n\n-----Subtasks-----\n- Subtask 1 (20 points) : 1 ≤ N, M ≤ 1000, 1 ≤ Ai, Y ≤ 106, type = { 'Q' } \n- Subtask 2 (20 points) : 1 ≤ N, M ≤ 50000, 1 ≤ Ai, Y ≤ 109, type = { 'C', Q' } \n- Subtask 3 (30 points) : 1 ≤ N, M ≤ 105, 1 ≤ Ai, Y ≤ 109, type = { 'Q' } \n- Subtask 4 (30 points) : 1 ≤ N, M ≤ 105, 1 ≤ Ai, Y ≤ 109, type = { 'C', Q' }\n\n-----Example-----\nInput\n3 5\n1 2 3\nQ 1 2\nQ 2 3\nC 1 2\nQ 1 2\nQ 1 3\n\nOutput\n4\n8\n5\n30\n\n-----Explanation:-----\n- Q1 : F = Fibonacci(1) + Fibonacci(2) + Fibonacci(1+2) = 4 % 1000000007 = 4\n- Q2 : F = Fibonacci(2) + Fibonacci(3) + Fibonacci(2+3) = 8 % 1000000007 = 8\n- Q3 : A = {2, 2, 3}\n- Q4 : F = Fibonacci(2) + Fibonacci(2) + Fibonacci(2+2) = 5 % 1000000007 = 5\n- Q5 : F = Fibonacci(2) + Fibonacci(2) + Fibonacci(3) + Fibonacci(2+2) + Fibonacci(2+3) + Fibonacci(2+3) + Fibonacci(2+2+3) = 30 % 1000000007 = 30\n\n-----Note-----\nFibonacciK denotes the Kth Fibonacci number. Fibonacci series is defined as follows:\n- For 1 ≤ K ≤ 2, FibonacciK = 1\n- Otherwise, FibonacciK = FibonacciK-1 + FibonacciK-2\nPlease check this link for more details about Fibonacci numbers.", "starter_code": "", "test_cases": {"inputs": ["3 5\n1 2 3\nQ 1 2\nQ 2 3\nC 1 2\nQ 1 2\nQ 1 3"], "outputs": ["4\n8\n5\n30"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "db1b842679f22838492f94ac125e72ad2546078b", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00989", "original_id": null, "source": "apps", "domain": "code", "problem": "There is a task in Among Us in which $N$ temperature scale with unique readings are given and you have to make all of them equal. In one second you can choose an odd number and add or subtract that number in any one temperature value. Find minimum time (in seconds) required to complete the task.\n$Note$: Equal value may or may not belong to array.\n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- First line of each testcase contains single integer $N$, the number of temperature scales\n- Next line contain $A_i$ for $1 \\leq i \\leq N$, reading of temperature scales\n\n-----Output:-----\nFor each testcase, output a single line the time (in seconds) required to complete the task.\n\n-----Constraints-----\n- $1 \\leq T \\leq 10^3$\n- $1 \\leq N \\leq 10^3$\n- $0 \\leq A_i \\leq 10^9$\n\n-----Sample Input:-----\n3\n\n5\n\n1 2 3 4 5\n\n4\n\n5 2 3 8\n\n2\n\n50 53 \n\n-----Sample Output:-----\n5\n\n4\n\n1 \n\n-----EXPLANATION:-----\n- In the $2^{nd}$ test case we need $2$ seconds to change $2$ to $8$ , $1$ second to change $3$ and $5$ to $8$ . So total time required is $2+1+1=4$ seconds.", "starter_code": "", "test_cases": {"inputs": ["3\n5\n1 2 3 4 5\n4\n5 2 3 8\n2\n50 53"], "outputs": ["5\n4\n1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "8b5fbf3697e978d77218b532ff0bab32c81d94c8", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00994", "original_id": null, "source": "apps", "domain": "code", "problem": "The students of Codechef Middle School are visiting an amusement park. The children want to go on a ride, however, there is a minimum height requirement of $X$ cm. Determine if the children are eligible to go on the ride. \nPrint \"Yes\" if they are eligible, \"No\" otherwise.\n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- Each testcase contains of a single line of input, two integers $H$ which is a child's height in cm and $X$ which is the minimum permissible height. \n\n-----Output:-----\nFor each testcase, output in a single line $\"Yes\"$ or $\"No\"$. You cannot give your answer as \"YeS\", \"YES\", \"yes\" or any other variation.\n\n-----Constraints-----\n- $1 \\leq T \\leq 10^4$\n- $50 \\leq H \\leq 200$\n- $50 \\leq X \\leq 200$\n\n-----Sample Input:-----\n2\n120 100\n90 100\n\n-----Sample Output:-----\nYes\nNo\n\n-----EXPLANATION:-----\nThe first child has height more than minimum permissible height, so he can go on the ride while the other person cannot!", "starter_code": "", "test_cases": {"inputs": ["2\n120 100\n90 100"], "outputs": ["Yes\nNo"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "6fcdc24270b62d6bbc541f13df1617cf27313b9d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00999", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef Hari has got a new obsession now: he has started playing chess (read about it here) and he is liking this game very much. Since Hari has spent several months playing chess with his friends, he has now decided to take part in some chess tournament in Cheftown.\n\nThere are currently two tournaments going on in Cheftown and each tournament has its own entry fee. Due to this economical restriction and his budget, Hari can take part in only one tournament.\n\nThe entry fee for first tournament is F1 units of money. The structure of tournament is as follows: first there will be group matches and then there will be finals. If Hari reaches in finals and wins it, he'll get R1 units of money. If after reaching in finals, Hari loses, he'll get R2 units of money. If Hari fails to reach in finals, he'll get nothing. The probability of reaching in finals of first tournament for Hari is p1 and probability of winning in finals after reaching is p2.\n\nThe entry fee for second tournament is F2 units of money. The structure of tournament is as follows: first there will be group matches and then there will be finals. If Hari reaches in finals, he'll immediately get R3 units of money, otherwise he'll get nothing. If after reaching in finals, Hari wins, he'll get R4 units of money. The probability of reaching in finals of second tournament for Hari is p3 and probability of winning in finals after reaching is p4.\n\nNow, Hari wants to maximise his profit. He wants to know which tournament he should participate in such that his expected profit is maximised. Help Hari in deciding this.\n\nNote:\nIn the tournaments of Cheftown, the game never ends with a draw. So, either Hari wins a game, or he loses.\n\n-----Input-----\n\nFirst line of the input contains T, the number of test cases. The description of each test case is as following:\n\nFirst line of each test case contains 6 integers F1, F2, R1, R2, R3 and R4.\n\nNext line of each test case contains 4 floating point numbers p1, p2, p3 and p4.\nEach number has exactly 2 digits after decimal point.\n\n-----Output-----\n\nFor each test case, output a single line having \"FIRST\" if expected profit of first tournament is maximum or \"SECOND\" if expected profit of second tournament is maximum or \"BOTH\" if expected profits of both the tournaments is exactly same.\n\n-----Constraints-----\n- 1 ≤ T ≤ 100\n- 1 ≤ F1, F2, R1, R2, R3, R4 ≤ 100\n- 0.00 ≤ p1, p2, p3, p4 ≤ 1.00\n\n-----Subtasks-----\nSubtask#1: 30 points\n- p1 = p3 and p2 = p4\n\nSubtask#2: 70 points\n- All usual constraints.\n\n-----Example-----\nInput:\n2\n30 50 70 10 40 30\n0.25 0.10 0.30 0.05\n50 36 80 38 65 32\n0.55 0.12 0.33 0.54\n\nOutput:\nFIRST\nSECOND\n\n-----Explanation-----\n\nIn the first case, the expected profit for first tournament is -26.00 and expected profit for second tournament is -37.55. So, first tournament has better expected profit.\n\nIn the second case, the expected profit for first tournament is -26.328 and expected profit for second tournament is -8.8476. So, second tournament has better expected profit.", "starter_code": "", "test_cases": {"inputs": ["2\n30 50 70 10 40 30\n0.25 0.10 0.30 0.05\n50 36 80 38 65 32\n0.55 0.12 0.33 0.54"], "outputs": ["FIRST\nSECOND"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "ceaa5b30f6f14ee0235989c1780082d2dda25aff", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01004", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef works as a cook in a restaurant. Each morning, he has to drive down a straight road with length K$K$ to reach the restaurant from his home. Let's describe this road using a coordinate X$X$; the position of Chef's home is X=0$X = 0$ and the position of the restaurant is X=K$X = K$.\nThe road has exactly two lanes (numbered 1$1$ and 2$2$), but there are N$N$ obstacles (numbered 1$1$ through N$N$) on it. For each valid i$i$, the i$i$-th obstacle blocks the lane Li$L_i$ at the position X=Xi$X = X_i$ and does not block the other lane.\nWhen driving, Chef cannot pass through an obstacle. He can switch lanes in zero time at any integer X$X$-coordinate which does not coincide with the X$X$-coordinate of any obstacle. However, whenever he switches lanes, he cannot switch again until driving for at least D$D$ units of distance, and he can travel only in the direction of increasing X$X$. Chef can start driving in any lane he wants. He can not switch lanes at non-integer X$X$-coordinate.\nSometimes, it is impossible to reach the restaurant without stopping at an obstacle. Find the maximum possible distance Chef can travel before he has to reach an obstacle which is in the same lane as him. If he can avoid all obstacles and reach the restaurant, the answer is K$K$.\n\n-----Input-----\n- The first line of the input contains a single integer T$T$ denoting the number of test cases. The description of T$T$ test cases follows.\n- The first line of each test case contains three space-separated integers N$N$, K$K$ and D$D$.\n- The second line contains N$N$ space-separated integers X1,X2,…,XN$X_1, X_2, \\ldots, X_N$.\n- The third line contains N$N$ space-separated integers L1,L2,…,LN$L_1, L_2, \\ldots, L_N$.\n\n-----Output-----\nFor each test case, print a single line containing one integer ― the maximum distance Chef can travel.\n\n-----Constraints-----\n- 1≤T≤1,000$1 \\le T \\le 1,000$\n- 1≤N≤105$1 \\le N \\le 10^5$\n- 2≤K≤109$2 \\le K \\le 10^9$\n- 1≤D≤109$1 \\le D \\le 10^9$\n- 1≤Xi≤K−1$1 \\le X_i \\le K-1$ for each valid i$i$\n- Xi (2, 1) -> (3, 1) -> (4, 1) -> (4, 2) -> (4, 3), and robot 2 can move (1, 4) -> (2, 4) -> (3, 4) -> (4, 4) -> (4, 3) -> (4, 3), they meet at cell (4, 3) after 5 moves.\nExample case 2. Because the movable range of both robots is 1, robot 1 can not move from (3, 1) to (4, 2), and robot 2 can not move from (3, 4) to (4, 3. Hence, they can not meet each other.", "starter_code": "", "test_cases": {"inputs": ["2\n4 4 1 1\n0 1 1 0\n0 1 1 0\n0 1 1 0\n0 0 0 0\n4 4 1 1\n0 1 1 0\n0 1 1 0\n0 1 1 0\n1 0 0 1"], "outputs": ["5\n-1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "8a85d87d5235a61584c32daee6c27b2e0b37c93b", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01064", "original_id": null, "source": "apps", "domain": "code", "problem": "You are participating in a contest which has $11$ problems (numbered $1$ through $11$). The first eight problems (i.e. problems $1, 2, \\ldots, 8$) are scorable, while the last three problems ($9$, $10$ and $11$) are non-scorable ― this means that any submissions you make on any of these problems do not affect your total score.\nYour total score is the sum of your best scores for all scorable problems. That is, for each scorable problem, you look at the scores of all submissions you made on that problem and take the maximum of these scores (or $0$ if you didn't make any submissions on that problem); the total score is the sum of the maximum scores you took.\nYou know the results of all submissions you made. Calculate your total score.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains a single integer $N$ denoting the number of submissions you made.\n- $N$ lines follow. For each $i$ ($1 \\le i \\le N$), the $i$-th of these lines contains two space-separated integers $p_i$ and $s_i$, denoting that your $i$-th submission was on problem $p_i$ and it received a score $s_i$.\n\n-----Output-----\nFor each test case, print a single line containing one integer ― your total score.\n\n-----Constraints-----\n- $1 \\le T \\le 10$\n- $1 \\le N \\le 1,000$\n- $1 \\le p_i \\le 11$ for each valid $i$\n- $0 \\le s_i \\le 100$ for each valid $i$\n\n-----Subtasks-----\nSubtask #1 (15 points): all submissions are on the same problem, i.e. $p_1 = p_2 = \\ldots = p_N$\nSubtask #2 (15 points): there is at most one submission made on each problem, i.e. $p_i \\neq p_j$ for each valid $i, j$ ($i \\neq j$)\nSubtask #3 (70 points): original constraints\n\n-----Example Input-----\n2\n5\n2 45\n9 100\n8 0\n2 15\n8 90\n1\n11 1\n\n-----Example Output-----\n135\n0\n\n-----Explanation-----\nExample case 1: The scorable problems with at least one submission are problems $2$ and $8$. For problem $2$, there are two submissions and the maximum score among them is $45$. For problem $8$, there are also two submissions and the maximum score is $90$. Hence, the total score is $45 + 90 = 135$.\nExample case 2: No scorable problem is attempted, so the total score is $0$.", "starter_code": "", "test_cases": {"inputs": ["2\n5\n2 45\n9 100\n8 0\n2 15\n8 90\n1\n11 1"], "outputs": ["135\n0"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "5762f0568972d72622d1ac06fd1c79bc6a84dc47", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01069", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef has a pepperoni pizza in the shape of a $N \\times N$ grid; both its rows and columns are numbered $1$ through $N$. Some cells of this grid have pepperoni on them, while some do not. Chef wants to cut the pizza vertically in half and give the two halves to two of his friends. Formally, one friend should get everything in the columns $1$ through $N/2$ and the other friend should get everything in the columns $N/2+1$ through $N$.\nBefore doing that, if Chef wants to, he may choose one row of the grid and reverse it, i.e. swap the contents of the cells in the $i$-th and $N+1-i$-th column in this row for each $i$ ($1 \\le i \\le N/2$).\nAfter the pizza is cut, let's denote the number of cells containing pepperonis in one half by $p_1$ and their number in the other half by $p_2$. Chef wants to minimise their absolute difference. What is the minimum value of $|p_1-p_2|$?\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains a single integer $N$.\n- $N$ lines follow. For each $i$ ($1 \\le i \\le N$), the $i$-th of these lines contains a string with length $N$ describing the $i$-th row of the grid; this string contains only characters '1' (denoting a cell with pepperonis) and '0' (denoting a cell without pepperonis).\n\n-----Output-----\nFor each test case, print a single line containing one integer — the minimum absolute difference between the number of cells with pepperonis in the half-pizzas given to Chef's friends.\n\n-----Constraints-----\n- $1 \\le T \\le 1,000$\n- $2 \\le N \\le 1,000$\n- $N$ is even\n- the sum of $N \\cdot N$ over all test cases does not exceed $2 \\cdot 10^6$\n\n-----Example Input-----\n2\n6\n100000\n100000\n100000\n100000\n010010\n001100\n4\n0011\n1100\n1110\n0001\n\n-----Example Output-----\n2\n0\n\n-----Explanation-----\nExample case 1: Initially, $|p_1-p_2| = 4$, but if Chef reverses any one of the first four rows from \"100000\" to \"000001\", $|p_1-p_2|$ becomes $2$.\nExample case 2: Initially, $|p_1-p_2| = 0$. We cannot make that smaller by reversing any row.", "starter_code": "", "test_cases": {"inputs": ["2\n6\n100000\n100000\n100000\n100000\n010010\n001100\n4\n0011\n1100\n1110\n0001"], "outputs": ["2\n0"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "b9bae4397ca67f6d9d336502cf835c6f513819c9", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01074", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef recently learned about ratios and proportions. He wrote some positive integers a, b, c, d on a paper. Chef wants to know whether he can shuffle these numbers so as to make some proportion? Formally, four numbers x, y, z, w are said to make a proportion if ratio of x : y is same as that of z : w.\n\n-----Input-----\nOnly line of the input contains four space separated positive integers - a, b, c, d.\n\n-----Output-----\nPrint \"Possible\" if it is possible to shuffle a, b, c, d to make proportion, otherwise \"Impossible\" (without quotes).\n\n-----Constraints-----\n- 1 ≤ a, b, c, d ≤ 1000\n\n-----Example-----\nInput:\n1 2 4 2\n\nOutput:\nPossible\n\n-----Explanation-----\nBy swapping 4 and the second 2, we get 1 2 2 4. Note that 1 2 2 4 make proportion as 1 : 2 = 2 : 4. Hence answer is \"Possible\"", "starter_code": "", "test_cases": {"inputs": ["1 2 4 2"], "outputs": ["Possible"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "e575efc713378d8535eb5e9cb14b1f8356b6b3a1", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01079", "original_id": null, "source": "apps", "domain": "code", "problem": "Divya's watch of worth Rs10 cr is abducted by N thieves(1,2....i...N). The fight over the watch leads to a final decision that it should belong to the thief who wins a simple game. The rules of the game state that every thief registers a time in the format HH:MM:SS . Accordingly the average A of three clockwise angles between the hours , minutes and seconds hands is calculated . Thus the ith thief with the maximum A wins the game and gets to keep the watch.\n\nThe thieves are poor in mathematics and will need your help . Given the number of thieves and their registered time resolves the conflict and help them in choosing the winner \n\n-----Input-----\nFirst line of input contains T which denotes the number of test cases.\n\nThe first line of each test case consists of an integer which denotes the number of thieves thereby N line follow which give the time choosen by each thieve in the format HH:MM:SS.\n\n-----Output:-----\nOutput single integer i which denotes the ith thief.\n\n-----Constraints:-----\n\n1<=T<=100\n\n1<=N<=50\n\n01<=HH<=12\n\n00<=MM<=60\n\n00<=SS<=60\n\n-----Example:-----\nInput:\n2\n3\n12:28:26\n07:26:04\n11:23:17\n2\n07:43:25\n06:23:34\n\nOutput:\n3\n1", "starter_code": "", "test_cases": {"inputs": ["2\n3\n12:28:26\n07:26:04\n11:23:17\n2\n07:43:25\n06:23:34"], "outputs": ["3\n1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "aa494c3bd3b42ba3efa4c309003c4a2160fffc7e", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01084", "original_id": null, "source": "apps", "domain": "code", "problem": "Santosh has a farm at Byteland. He has a very big family to look after. His life takes a sudden turn and he runs into a financial crisis. After giving all the money he has in his hand, he decides to sell his plots. The speciality of his land is that it is rectangular in nature. Santosh comes to know that he will get more money if he sells square shaped plots. So keeping this in mind, he decides to divide his land into minimum possible number of square plots, such that each plot has the same area, and the plots divide the land perfectly. He does this in order to get the maximum profit out of this. \nSo your task is to find the minimum number of square plots with the same area, that can be formed out of the rectangular land, such that they divide it perfectly.\n\n-----Input-----\n- The first line of the input contains $T$, the number of test cases. Then $T$ lines follow.\n- The first and only line of each test case contains two space-separated integers, $N$ and $M$, the length and the breadth of the land, respectively.\n\n-----Output-----\nFor each test case, print the minimum number of square plots with equal area, such that they divide the farm land perfectly, in a new line.\n\n-----Constraints-----\n$1 \\le T \\le 20$\n$1 \\le M \\le 10000$\n$1 \\le N \\le 10000$ \n\n-----Sample Input:-----\n2\n10 15\n4 6\n\n-----SampleOutput:-----\n6\n6", "starter_code": "", "test_cases": {"inputs": ["2\n10 15\n4 6"], "outputs": ["6\n6"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "d6ebf69b0a5537d33a3f32e75aea152fc0628d60", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01089", "original_id": null, "source": "apps", "domain": "code", "problem": "The Siruseri amusement park has a new attraction. It consists of a rectangular array of discs. Each disc is divided into four equal sectors and the four sectors are coloured with the colours Red, Blue, Green and Yellow (in some order). The ordering may be different in different discs. Here is a possible arrangment of the discs:\n\nYou start at the top left disc. Your task is to walk down to the bottom right disc. In each step, you can rotate the current disc by $90$ degrees in the clockwise direction or move to a neighbouring disc. However, you can move to a neighbouring disc only if adjacent sectors of these two discs have the same colour. For example, in the figure above, you can move from the disc at position ($1$, $1$) to either of its neighbours. However, from the disc at position ($1$, $2$) you can only move to the disc at position ($1$, $1$). If you wish to move from ($1$, $2$) to ($1$, $3$) then you would have to rotate this disc three times so that the colour (red) on the adjacent sectors are the same.\nFor each rotate move, a penalty point is added to the score. The aim is to reach the bottom right with as few penalty points as possible. For example, in the arrangement described in the above figure, the best possible score is $2$, corresponding to the following path: Move from ($1$, $1$) to ($2$, $1$). Move from ($2$, $1$) to ($2$, $2$). Rotate. Rotate. Move from ($2$, $2$) to ($2$, $3$). Move from ($2$, $3$) to ($1$, $3$). Move from ($1$, $3$) to ($1$, $4$). Finally, move from ($1$, $4$) to ($2$, $4$).\nYour task is to determine the minimum number of penalty points required to go from the top left disc to the bottom right disc for the given arrangement of discs.\n\n-----Input:-----\nThe first line contains two integers $M$ and $N$. $M$ is the number of rows and $N$ is the number of columns in the given arrangment. This is followed by $M \\times N$ lines of input. Lines $2$ to $N+1$, describe the colours on the discs on the first row, Lines $N+2$ to $2 \\cdot N+1$ describe the colours on discs in the second row and so on. Each of these lines contain a permutation of the set {R, G, B, Y} giving the colours in the top, right, bottom and left sectors in that order.\n\n-----Output:-----\nA single integer on a single line indicating the minimum number of penalty points required to go from the top left disc to the bottom right disc for the given arrangement of discs.\n\n-----Constraints:-----\n- In $80 \\%$ of the input, $1 \\leq M,N \\leq 60$.\n- In all the inputs $1 \\leq M,N \\leq 1000$.\n\n-----Sample Input-----\n2 4\nG Y B R\nB G R Y\nG Y B R\nG R B Y\nB Y G R\nG B R Y\nB R G Y\nB R G Y\n\n-----Sample Output-----\n2", "starter_code": "", "test_cases": {"inputs": ["2 4\nG Y B R\nB G R Y\nG Y B R\nG R B Y\nB Y G R\nG B R Y\nB R G Y\nB R G Y"], "outputs": ["2"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "2d93ed6e4655b0f84cb6b0e1101dd0b7f52f5dfd", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01094", "original_id": null, "source": "apps", "domain": "code", "problem": "Chefina is always interested to play with string. But due to exam pressure she has no time to solve a string problem. She wants your help. Can you help her to solve that problem?\nYou are given a string. You have to find out the $Wonder$ $Sum$ of the string. $Wonder$ $Sum$ of a string is defined as the sum of the value of each character of the string. \nThe value of each character means:\n- If the string is started with \"a\" , then the value of each character of the string is like \"a\"=100, \"b\"=101, \"c\"=\"102\" ………\"z\"=125.\n- If the string is started with \"z\" , then the value of each character of the string is like \"a\"=2600, \"b\"=2601, \"c\"=\"2602\" ………\"z\"=2625.\nSince even the $Wonder$ $Sum$ can be large, output $Wonder$ $Sum$ modulo ($10^9 + 7$).\n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- Each testcase contains of a single line of input, a string $S$ with lower case alphabet \nonly.\n\n-----Output:-----\nFor each testcase, output in a single line integer i.e. $Wonder$ $Sum$ modulo ($10^9 + 7$).\n\n-----Constraints-----\n- $1 \\leq T \\leq 1000$\n- $1 \\leq |S| \\leq 10^5$\n\n-----Sample Input:-----\n$2$$cab$\n$sdef$\n\n-----Sample Output:-----\n$903$\n$7630$\n\n-----EXPLANATION:-----\ni) For the first test case, since the string is started with \"$c$\", so output is ($302$+$300$+$301$)=$903$\nii)For the second test case, since the string is started with \"$s$\", so output is ($1918$+$1903$+$1904$+$1905$)=$7630$", "starter_code": "", "test_cases": {"inputs": ["2\ncab\nsdef"], "outputs": ["903\n7630"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "05550084ea5cb0bd37cadb22941692ee902e368a", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01099", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array of n$n$ integers : A1,A2,...,An$ A_1, A_2,... , A_n$, find the longest size subsequence which satisfies the following property: The xor of adjacent integers in the subsequence must be non-decreasing.\n\n-----Input:-----\n- First line contains an integer n$n$, denoting the length of the array. \n- Second line will contain n$n$ space separated integers, denoting the elements of the array.\n\n-----Output:-----\nOutput a single integer denoting the longest size of subsequence with the given property.\n\n-----Constraints-----\n- 1≤n≤103$1 \\leq n \\leq 10^3$\n- 0≤Ai≤1018$0 \\leq A_i \\leq 10^{18}$\n\n-----Sample Input:-----\n8\n1 200 3 0 400 4 1 7\n\n-----Sample Output:-----\n6\n\n-----EXPLANATION:-----\nThe subsequence of maximum length is {1, 3, 0, 4, 1, 7} with Xor of adjacent indexes as {2,3,4,5,6} (non-decreasing)", "starter_code": "", "test_cases": {"inputs": ["8\n1 200 3 0 400 4 1 7"], "outputs": ["6"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "e02824e76bfa2321bef99128530b8cc0d366b9ed", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01104", "original_id": null, "source": "apps", "domain": "code", "problem": "Today is Chef's birthday. His mom decided to surprise him with a truly fantastic gift: his favourite binary string B. But, unfortunately, all the stocks of binary string B have been sold out, and only a binary string A (A ≠ B) is available in the market.\nShe purchases the string A and tries to convert it to string B by applying any of following three operations zero or more times.\nAND Operation:\nShe will choose a pair of indices i and j such that i != j and perform following sequence of operations.\n\n- result = Ai & Aj \n- Ai = result & Ai \n- Aj = result & Aj \n\nOR Operation:\nShe will choose a pair of indices i and j such that i != j and perform following sequence of operations.\n\n- result = Ai | Aj \n- Ai = result | Ai \n- Aj = result | Aj \n\nXOR Operation:\nShe will choose a pair of indices i and j such that i != j and perform following sequence of operations.\n\n- result = Ai ^ Aj \n- Ai = result ^ Ai \n- Aj = result ^ Aj \n\nChef's mom is eagerly waiting to surprise him with his favourite gift and therefore, she wants to convert string A to string B as fast as possible. Can you please help her by telling her the minimum number of operations she will require? If it is impossible to do so, then let Chef's mom know about it.\n\n-----Input-----\nFirst line of input contains a single integer T denoting the number of test cases. T test cases follow.\nFirst line of each test case, will contain binary string A.\nSecond line of each test case, will contain binary string B.\n\n-----Output-----\nFor each test case, Print \"Lucky Chef\" (without quotes) in first line and minimum number of operations required to convert string A to sting B in second line if conversion is possible. Print \"Unlucky Chef\" (without quotes) in a new line otherwise.\n\n-----Constraints-----\n- 1 ≤ T ≤ 105\n- 1 ≤ |A| ≤ 106\n- 1 ≤ |B| ≤ 106\n- A != B\n- |A| = |B|\n- sum of |A| over all test cases does not exceed 106\n- sum of |B| over all test cases does not exceed 106\n\n-----Subtasks-----\n- Subtask #1 (40 points) : Sum of |A| & |B| over all test cases does not exceed 103\n- Subtask #2 (60 points) : Sum of |A| & |B| over all test cases does not exceed 106\n\n-----Example-----\nInput\n2\n101\n010\n1111\n1010\nOutput\nLucky Chef\n2\nUnlucky Chef\n\n-----Explanation-----\nExample case 1.\n- Applying XOR operation with indices i = 1 and j = 2. Resulting string will be 011.\n- Then, Applying AND operation with indices i = 1 and j = 3. Resulting string will be 010.\n\nExample case 2.\n- It is impossible to convert string A to string B.", "starter_code": "", "test_cases": {"inputs": ["2\n101\n010\n1111\n1010"], "outputs": ["Lucky Chef\n2\nUnlucky Chef"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "bb0e25b8281da37dcc9bba560a26874772367150", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01109", "original_id": null, "source": "apps", "domain": "code", "problem": "Sereja has two integers — A and B — in 7-ary system. He wants to calculate the number C, such that B * C = A. It is guaranteed that B is a divisor of A.\n\nPlease, help Sereja calculate the number C modulo 7L.\n\n-----Input-----\n\nFirst line of input contains an integer T — the number of test cases. T tests follow.\n\nFor each test case, the first line contains the integer A, and the second line contains the integer B, and the third line contains the integer L. A and B are given in 7-ary system.\n\n-----Output-----\nOutput the answer in 7-ary system.\n\n-----Constraints-----\n- 1 ≤ T ≤ 10\n- A and B are both positive integers.\n- Length of A is a positive integer and doesn't exceed 106.\n- L and length of B are positive integers and do not exceed 10000.\n\n-----Subtasks-----\n- Sub task #1 (20 points): Length of A is a positive integer and doesn't exceed 20.\n- Sub task #2 (30 points): Length of A is a positive integer and doesn't exceed 2000.\n- Sub task #3 (50 points): Original constraints.\n\n-----Example-----\nInput:3\n21\n5\n10\n202\n13\n1\n202\n13\n2\n\nOutput:3\n3\n13", "starter_code": "", "test_cases": {"inputs": ["3\n21\n5\n10\n202\n13\n1\n202\n13\n2"], "outputs": ["3\n3\n13"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "eb9c3022c470f334a0721f5d0ce073b8aa4ad38b", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01114", "original_id": null, "source": "apps", "domain": "code", "problem": "There are total N friends went to Chef's Pizza shop. There they bought a pizza. Chef divided the pizza into K equal slices. Now you have to check whether these K pizza slices can be distributed equally among the friends. Also given that every person should get at least one slice. If the above conditions are possible then print \"YES\" otherwise print \"NO\".\n\n-----Input:-----\nThe first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.\nThe first line of each test case contains a integers N.\nThe second line of each test case contains K.\n\n-----Output:-----\nFor each test case, print a single line containing \"YES\" if the given conditions are true else \"NO\" if the given conditions are false.\n\n-----Constraints-----\n1<=T<=10\n1<=N<=10^6\n1<=K<=10^6\n\n-----Sample Input:-----\n2\n10\n20\n12\n5\n\n-----Sample Output:-----\nYES\nNO\n\n-----EXPLANATION:-----\nExplanation case 1: since there are 10 friends and 20 pizza slice, so each can get 2 slices, so \"YES\".\nExplanation case 2: Since there are 12 friends and only 5 pizza slice, so there is no way pizza slices can be distributed equally and each friend gets at least one pizza slice, so \"NO\".", "starter_code": "", "test_cases": {"inputs": ["2\n10\n20\n12\n5"], "outputs": ["YES\nNO"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "9a6a91f204a69c8df1d2dd04a170cb0f967f15ef", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01119", "original_id": null, "source": "apps", "domain": "code", "problem": "Increasing COVID cases have created panic amongst the people of Chefland, so the government is starting to push for production of a vaccine. It has to report to the media about the exact date when vaccines will be available.\nThere are two companies which are producing vaccines for COVID. Company A starts producing vaccines on day $D_1$ and it can produce $V_1$ vaccines per day. Company B starts producing vaccines on day $D_2$ and it can produce $V_2$ vaccines per day. Currently, we are on day $1$.\nWe need a total of $P$ vaccines. How many days are required to produce enough vaccines? Formally, find the smallest integer $d$ such that we have enough vaccines at the end of the day $d$.\n\n-----Input-----\n- The first and only line of the input contains five space-separated integers $D_1$, $V_1$, $D_2$, $V_2$ and $P$.\n\n-----Output-----\nPrint a single line containing one integer ― the smallest required number of days.\n\n-----Constraints-----\n- $1 \\le D_1, V_1, D_2, V_2 \\le 100$\n- $1 \\le P \\le 1,000$\n\n-----Subtasks-----\nSubtask #1 (30 points): $D_1 = D_2$\nSubtask #2 (70 points): original constraints\n\n-----Example Input 1-----\n1 2 1 3 14\n\n-----Example Output 1-----\n3\n\n-----Explanation-----\nSince $D_1 = D_2 = 1$, we can produce $V_1 + V_2 = 5$ vaccines per day. In $3$ days, we produce $15$ vaccines, which satisfies our requirement of $14$ vaccines.\n\n-----Example Input 2-----\n5 4 2 10 100\n\n-----Example Output 2-----\n9\n\n-----Explanation-----\nThere are $0$ vaccines produced on the first day, $10$ vaccines produced on each of days $2$, $3$ and $4$, and $14$ vaccines produced on the fifth and each subsequent day. In $9$ days, it makes a total of $0 + 10 \\cdot 3 + 14 \\cdot 5 = 100$ vaccines.", "starter_code": "", "test_cases": {"inputs": ["1 2 1 3 14"], "outputs": ["3"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "1fa0cf4a7ba63c06a69dab53d4646680ac4c20a9", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01124", "original_id": null, "source": "apps", "domain": "code", "problem": "The GoC Timber Mafia is notorious for its deforestation\nactivities in the forests near Siruseri. These activities have\nincreased multifold after the death of the bandit who used to\nlord over these jungles. Having lost the battle to prevent the\nMafia from illegally felling the teak trees in this forest, the\ngovernment of Siruseri came up with a novel idea. Why not\nlegalise the deforestation activity and at least make some money\nin the process? So the Government decided to lease out parts of\nthe forest to the Timber Mafia.\nMost of the teak trees in the forests of Siruseri were planted\nduring the colonial times, after the native trees had been cut.\nLike everything European, the forest is very regular and\norderly. It is rectangular in shape and the trees are arranged in\nuniformly spaced rows and coloumns.\nSince the trees differ in height and girth, the timber value\ndiffers from tree to tree. The forest department has collected\ndata on each tree and knows the volume of wood (in cubic feet)\navailable in each tree in the forest.\nThe forest department maintains this information in the form of\nan $M \\times N$ array of integers, where the\n$(i, j)$th entry is the volume, in cubic feet, of the\n$i^{th}$ tree on the $i^{th}$ row (or, equivalently, the\n$i^{th}$ tree on the $i^{th}$ column). We assume that\nour rows are numbered top to bottom and the columns are numbered\nfrom left to right. For example, such an array could look like\n\nThis array tells us that the volume of the tree at position $(3,4)$ is $15$\ncubic feet and so on.\nAny rectangular piece of land with trees at each corner can be\nleased out. In order to fix the lease price for any rectangular\nplot of the forest the forest department needs to know the amount\nof wood available inside the plot.\nA rectangular plot is described by the positions of the trees in\nits top left corner and the bottom right corner. For example the\npositions $(2,2)$ and $(3,4)$ describes the following part\nrectangular part of the above forest.\n\nThe total amount of wood available in this rectangular plot is $76$\ncubic feet. Similarly $(4,2)$ and $(4,2)$ describes the rectangle\nwith just one tree and its volume is $20$ cubic feet.\nYour task is to write a program that helps the forest department\nto compute the total volume of the trees insides any specfied\nrectangular plot.\n\n-----Input:-----\n- The first line of the input contains two integers $M$ and $N$ indicating the number of rows and columns of trees in the forest. \n- The following $M$ lines have $N$ integers each. The $j^{th}$ integer on line $i+1$ denotes the volume (in cubic feet) of the $j^{th}$ tree on the $i^{th}$ row. \n- Line $M+2$ contains a single integer $C$ indicating the number of rectangles for which the total volume is to be computed. \n- Each of the following $C$ lines (line $M+2+1 ... M+2+C$) contain four integers $x_1, y_1, x_2$ and $y_2$ (with $x_1 \\leq x_2$ and $y_1 \\leq y_2$) and describes a rectangle. The rectangle has its top left corner at the tree in position $(x_1,y_1)$ and its bottom right corner at the tree at position $(x_2,y_2)$.\n\n-----Output:-----\nYour output must contain $C$ lines with one integer on each line. Line $i$ must contain the total volume of wood in the rectangle described on line $M+2+i$ in the input.\n\n-----Constraints-----\n- In $30 \\%$ of inputs, $1 \\leq C \\leq 100$.\n- In all inputs, $2 \\leq N, M \\leq 1000$ and $1 \\leq C \\leq 1000000$\n- $0 \\leq$ volume of wood in each tree $\\leq 1000$\n- $1 \\leq x_1 \\leq x_2 \\leq M$\n- $1 \\leq y_1 \\leq y_2 \\leq N$\n\n-----Sample Input-----\n4 4 \n3 4 15 23 \n14 20 12 9\n3 8 12 15\n12 20 7 5\n2\n2 2 3 4 \n4 2 4 2\n\n-----Sample Output-----\n76\n20", "starter_code": "", "test_cases": {"inputs": ["4 4\n3 4 15 23\n14 20 12 9\n3 8 12 15\n12 20 7 5\n2\n2 2 3 4\n4 2 4 2"], "outputs": ["76\n20"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "ee2eaeaa73321b2349b2d94d66ab5d1d87cded9e", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01129", "original_id": null, "source": "apps", "domain": "code", "problem": "Scheme? - Too loudly said. Just a new idea. Now Chef is expanding his business. He wants to make some new restaurants in the big city of Lviv. To make his business competitive he should interest customers. Now he knows how. But don't tell anyone - it is a secret plan. Chef knows four national Ukrainian dishes - salo, borsch, varenyky and galushky. It is too few, of course, but enough for the beginning. Every day in his restaurant will be a dish of the day among these four ones. And dishes of the consecutive days must be different. To make the scheme more refined the dish of the first day and the dish of the last day must be different too. Now he wants his assistant to make schedule for some period. Chef suspects that there is more than one possible schedule. Hence he wants his assistant to prepare all possible plans so that he can choose the best one among them. He asks you for help. At first tell him how many such schedules exist. Since the answer can be large output it modulo 109 + 7, that is, you need to output the remainder of division of the actual answer by 109 + 7.\n\n-----Input-----\n\nThe first line of the input contains an integer T, the number of test cases. Each of the following T lines contains a single integer N denoting the number of days for which the schedule should be made.\n\n-----Output-----\n\nFor each test case output a single integer in a separate line, the answer for the corresponding test case.\n\n-----Constraints-----1 ≤ T ≤ 100\n2 ≤ N ≤ 109\n\n-----Example-----\nInput:\n3\n2\n3\n5\n\nOutput:\n12\n24\n240\n\n-----Explanation-----\nCase 1. For N = 2 days we have the following 12 schedules:\nFirst day Second day salo borsch salo varenyky salo galushky borsch salo borsch varenyky borsch galushky varenyky salo varenyky borsch varenyky galushky galushky salo galushky borsch galushky varenyky \n\nCase 2. For N = 3 we have the following 24 schedules:\nFirst daySecond dayThird day salo borsch varenyky salo borsch galushky salo varenyky borsch salo varenyky galushky salo galushky borsch salo galushky varenyky borsch salo varenyky borsch salo galushky borsch varenyky salo borsch varenyky galushky borsch galushky salo borsch galushky varenyky varenyky salo borsch varenyky salo galushky varenyky borsch salo varenyky borsch galushky varenyky galushky salo varenyky galushky borsch galushky salo borsch galushky salo varenyky galushky borsch salo galushky borsch varenyky galushky varenyky salo galushky varenyky borsch \n\nCase 3. Don't be afraid. This time we will not provide you with a table of 240 schedules. The only thing we want to mention here is that apart from the previous two cases schedules for other values of N can have equal dishes (and even must have for N > 4). For example the schedule (salo, borsch, salo, borsch) is a correct schedule for N = 4 while the schedule (varenyky, salo, galushky, verynky, salo) is a correct schedule for N = 5.", "starter_code": "", "test_cases": {"inputs": ["3\n2\n3\n5"], "outputs": ["12\n24\n240"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "95c836914f75b42215eb4146ce93a4b22c094ccf", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01134", "original_id": null, "source": "apps", "domain": "code", "problem": "Sergey recently learned about country codes - two letter strings, denoting countries. For example, BY stands for Belarus and IN stands for India. Mesmerized by this new discovery, Sergey now looks for country codes everywhere!\nSergey has recently found a string S consisting of uppercase Latin letters. He wants to find the number of different country codes that appear in S as contiguous substrings. For the purpose of this problem, consider that every 2-letter uppercase string is a valid country code.\n\n-----Input-----\nThe first line of input contains an integer T denoting the number of test cases. The description of T test cases follows.\nThe first and only line of each test case contains a string S, consisting of uppercase Latin letters.\n\n-----Output-----\nFor each test case, output a single line containing the number of different country codes appearing in the given string.\n\n-----Constraints-----\n\n- 1 ≤ T ≤ 100\n- Subtask 1 (35 points): 2 ≤ |S| ≤ 3\n- Subtask 2 (65 points): 2 ≤ |S| ≤ 104\n\n-----Example-----\nInput:2\nINBY\nBYBY\n\nOutput:3\n2\n\n-----Explanation-----\nExample case 1. The codes are IN, NB and BY.\nExample case 2. The codes are BY and YB.", "starter_code": "", "test_cases": {"inputs": ["2\nINBY\nBYBY"], "outputs": ["3\n2"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "ac8777ee76c8d258299b28d7a1d816dfb22ad8d8", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01139", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef is making polygon cakes in his kitchen today! \nSince the judge panel is very strict, Chef's cakes must be beautiful and have sharp and precise $internal$ angles in arithmetic progression. \nGiven the number of sides, $N$, of the cake Chef is baking today and also the measure of its first angle(smallest angle), $A$, find the measure of the $K^{th}$ angle.\n\n-----Input:-----\n- The first line contains a single integer $T$, the number of test cases. \n- The next $T$ lines contain three space separated integers $N$, $A$ and $K$, the number of sides of polygon, the first angle and the $K^{th}$ angle respectively. \n\n-----Output:-----\nFor each test case, print two space separated integers $X$ and $Y$, such that the $K^{th}$ angle can be written in the form of $X/Y$ and $gcd(X, Y) = 1$\n\n-----Constraints-----\n- $1 \\leq T \\leq 50$\n- $3 \\leq N \\leq 1000$\n- $1 \\leq A \\leq 1000000000$\n- $1 \\leq K \\leq N$\n- It is guaranteed the answer is always valid.\n\n-----Sample Input:-----\n1\n3 30 2\n\n-----Sample Output:-----\n60 1", "starter_code": "", "test_cases": {"inputs": ["1\n3 30 2"], "outputs": ["60 1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "235b67112fada481e18e88f07c81a83992832484", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01144", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an alphanumeric string made up of digits and lower case Latin characters only, find the sum of all the digit characters in the string.\n\n-----Input-----\n- The first line of the input contains an integer T denoting the number of test cases. Then T test cases follow.\n- Each test case is described with a single line containing a string S, the alphanumeric string.\n\n-----Output-----\n- For each test case, output a single line containing the sum of all the digit characters in that string.\n\n-----Constraints-----\n- 1 ≤ T ≤ 1000\n- 1 ≤ |S| ≤ 1000, where |S| is the length of the string S.\n\n-----Example-----\nInput:\n1\nab1231da\n\nOutput:\n7\n\n-----Explanation-----\nThe digits in this string are 1, 2, 3 and 1. Hence, the sum of all of them is 7.", "starter_code": "", "test_cases": {"inputs": ["1\nab1231da"], "outputs": ["7"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "9fd740fdadddb750c3da7dd43d2f331d5e0f659b", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01149", "original_id": null, "source": "apps", "domain": "code", "problem": "-----Problem Statement-----\nYou all must have played the game candy crush. So here is a bomb which works much the fruit bomb in candy crush. A designer, Anton, designed a very powerful bomb. The bomb, when placed on a location $(x, y)$ in a $R \\times C$ grid, wipes out the row $x$ and column $y$ completely.\nYou are given a $R\\times C$ grid with $N$ targets. You have only one bomb. Your aim is to maximize the damage and hence destroy most number of targets. Given the location of targets on the grid, find out the number of targets that can destroyed.\nThe grid system uses index starting with $0$.\n\n-----Input-----\n- First line contains three space separated integers, $R$, $C$ and $N$. Then, $N$ lines follow.\n- Each line contains space separated integers $r$ and $c$ mentioning the location of the target.\n\n-----Output-----\nA single integer giving the number of targets that can be destroyed.\n\n-----Constraints-----\n- $1 \\leq R, C \\leq 3 \\times 10^5$\n- $1 \\leq N \\leq min(R \\times C, 3 \\times 10^5)$\n- $0 \\leq r < R$\n- $0 \\leq c < C$\n- Any input pair $(r, c)$ is not repeated.\n\n-----Subtasks-----\nThe total marks will be divided into:\n- 20% : $R, C \\leq 10^3$\n- 80% : Original Constraints\n\n-----Sample Input-----\n2 3 3\n1 1\n0 0\n0 2\n\n-----Sample Output-----\n3\n\n-----EXPLANATION-----\nIt is possible to destroy all the targets if we place the bomb at $(0, 1)$. Hence, total number of targets destroyed is $3$, which is our answer.", "starter_code": "", "test_cases": {"inputs": ["2 3 3\n1 1\n0 0\n0 2"], "outputs": ["3"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "6582f9a62541daa20d0df9c2e2842745f9ec596c", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01154", "original_id": null, "source": "apps", "domain": "code", "problem": "Master Oogway has forseen that a panda named Po will be the dragon warrior, and the master of Chi. But he did not tell anyone about the spell that would make him the master of Chi, and has left Po confused. Now Po has to defeat Kai, who is the super villian, the strongest of them all. Po needs to master Chi, and he finds a spell which unlocks his powerful Chi. But the spell is rather strange. It asks Po to calculate the factorial of a number! Po is very good at mathematics, and thinks that this is very easy. So he leaves the spell, thinking it's a hoax. But little does he know that this can give him the ultimate power of Chi. Help Po by solving the spell and proving that it's not a hoax.\n\n-----Input-----\nFirst line of input contains an integer T denoting the number of test cases.\nThe next T lines contain an integer N.\n\n-----Output-----\nFor each test case, print a single line containing the solution to the spell which is equal to factorial of N, i.e. N!. Since the output could be large, output it modulo 1589540031(Grand Master Oogway's current age).\n\n-----Constraints-----\n- 1 ≤ T ≤ 100000\n- 1 ≤ N ≤ 100000\n\n-----Example-----\nInput:\n4\n1\n2\n3\n4\n\nOutput:\n1\n2\n6\n24", "starter_code": "", "test_cases": {"inputs": ["4\n1\n2\n3\n4"], "outputs": ["1\n2\n6\n24"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "720d569a607059aa7dd3f71d2d5d2cb580523461", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01159", "original_id": null, "source": "apps", "domain": "code", "problem": "Mr. Das is a teacher teaching for several years in a school. He is not computer savvy. Due to lockdown, now he has to take classes online. Recently he took an online exam for students of different classes. Now, he will call parents of all the students who scored lower than average marks for the class. He has requested you to give the name $X$, parent's phone number $P$, and marks obtained $M$ to him.\n\n-----Input:-----\n- First line contains $T$ no. of test cases\n- for every test case, first line contains an integer $N$, no. of students of his class \n- Next $N$ lines contain $X$, $P$ , and $M$ separated by space\n\n-----Output:-----\nFor every test case, find details of the students who scored below average, then print $X, P, M$ separated by space on a new line as per the increasing order of their marks. In case there are multiple students with the same marks, print them as per the order of their occurrence in the input\n\n-----Constraints-----\n- $1 \\leq T \\leq 20$\n- X contains characters between a-z and A-Z with a maximum length of 20\n- $1 \\leq N \\leq 100$\n- P is 10 digits\n- $0 \\leq M \\leq 100$\n\n-----Sample Input:-----\n2 \n3\nRahul 1345964789 47\nRupendra 1457856987 58\nPriya 1478569820 45\n2\nTanuja 4310779415 97\nAkash 3689781245 43\n\n-----Sample Output:-----\nPriya 1478569820 45\nRahul 1345964789 47\nAkash 3689781245 43\n\n-----EXPLANATION:-----\nIn #1, Priya and Rahul's number was lower than average.\nIn #2, Akash's number was lower than average", "starter_code": "", "test_cases": {"inputs": ["2\n3\nRahul 1345964789 47\nRupendra 1457856987 58\nPriya 1478569820 45\n2\nTanuja 4310779415 97\nAkash 3689781245 43"], "outputs": ["Priya 1478569820 45\nRahul 1345964789 47\nAkash 3689781245 43"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "079920953d5b79dcd66d1608f97b65457ddddbbb", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01164", "original_id": null, "source": "apps", "domain": "code", "problem": "Write a function called `sumIntervals`/`sum_intervals()` that accepts an array of intervals, and returns the sum of all the interval lengths. Overlapping intervals should only be counted once.\n\n### Intervals\n\nIntervals are represented by a pair of integers in the form of an array. The first value of the interval will always be less than the second value. Interval example: `[1, 5]` is an interval from 1 to 5. The length of this interval is 4.\n\n### Overlapping Intervals\n\nList containing overlapping intervals:\n\n```\n[\n [1,4],\n [7, 10],\n [3, 5]\n]\n```\n\nThe sum of the lengths of these intervals is 7. Since [1, 4] and [3, 5] overlap, we can treat the interval as [1, 5], which has a length of 4.\n\n### Examples:\n\n```C#\n// empty intervals\nIntervals.SumIntervals(new (int, int)[]{ }); // => 0\nIntervals.SumIntervals(new (int, int)[]{ (2, 2), (5, 5)}); // => 0\n\n// disjoined intervals\nIntervals.SumIntervals(new (int, int)[]{\n (1, 2), (3, 5)\n}); // => (2-1) + (5-3) = 3\n\n// overlapping intervals\nIntervals.SumIntervals(new (int, int)[]{\n (1, 4), (3, 6), (2, 8)\n}); // (1,8) => 7\n```", "starter_code": "\ndef sum_of_intervals(intervals):\n\t", "test_cases": {"inputs": [[[[1, 5]]]], "outputs": [[4]], "fn_name": "sum_of_intervals"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "33de9cd8d2a5b2816f9db15549bbbd2ce004db46", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "sum_of_intervals"} {"seed_id": "apps-01169", "original_id": null, "source": "apps", "domain": "code", "problem": "### Lyrics...\n\nPyramids are amazing! Both in architectural and mathematical sense. If you have a computer, you can mess with pyramids even if you are not in Egypt at the time. For example, let's consider the following problem. Imagine that you have a pyramid built of numbers, like this one here:\n\n```\n /3/\n \\7\\ 4 \n 2 \\4\\ 6 \n8 5 \\9\\ 3\n```\n\n### Here comes the task...\n\nLet's say that the *'slide down'* is the maximum sum of consecutive numbers from the top to the bottom of the pyramid. As you can see, the longest *'slide down'* is `3 + 7 + 4 + 9 = 23`\n\nYour task is to write a function `longestSlideDown` (in ruby: `longest_slide_down`) that takes a pyramid representation as argument and returns its' __largest__ *'slide down'*. For example,\n\n```python\nlongestSlideDown([[3], [7, 4], [2, 4, 6], [8, 5, 9, 3]]) => 23\n```\n\n### By the way...\n\nMy tests include some extraordinarily high pyramids so as you can guess, brute-force method is a bad idea unless you have a few centuries to waste. You must come up with something more clever than that.\n\n(c) This task is a lyrical version of the __Problem 18__ and/or __Problem 67__ on [ProjectEuler](https://projecteuler.net).", "starter_code": "\ndef longest_slide_down(pyramid):\n\t", "test_cases": {"inputs": [[[[3], [7, 4], [2, 4, 6], [8, 5, 9, 3]]], [[[75], [95, 64], [17, 47, 82], [18, 35, 87, 10], [20, 4, 82, 47, 65], [19, 1, 23, 75, 3, 34], [88, 2, 77, 73, 7, 63, 67], [99, 65, 4, 28, 6, 16, 70, 92], [41, 41, 26, 56, 83, 40, 80, 70, 33], [41, 48, 72, 33, 47, 32, 37, 16, 94, 29], [53, 71, 44, 65, 25, 43, 91, 52, 97, 51, 14], [70, 11, 33, 28, 77, 73, 17, 78, 39, 68, 17, 57], [91, 71, 52, 38, 17, 14, 91, 43, 58, 50, 27, 29, 48], [63, 66, 4, 68, 89, 53, 67, 30, 73, 16, 69, 87, 40, 31], [4, 62, 98, 27, 23, 9, 70, 98, 73, 93, 38, 53, 60, 4, 23]]], [[[59], [73, 41], [52, 40, 9], [26, 53, 6, 34], [10, 51, 87, 86, 81], [61, 95, 66, 57, 25, 68], [90, 81, 80, 38, 92, 67, 73], [30, 28, 51, 76, 81, 18, 75, 44], [84, 14, 95, 87, 62, 81, 17, 78, 58], [21, 46, 71, 58, 2, 79, 62, 39, 31, 9], [56, 34, 35, 53, 78, 31, 81, 18, 90, 93, 15], [78, 53, 4, 21, 84, 93, 32, 13, 97, 11, 37, 51], [45, 3, 81, 79, 5, 18, 78, 86, 13, 30, 63, 99, 95], [39, 87, 96, 28, 3, 38, 42, 17, 82, 87, 58, 7, 22, 57], [6, 17, 51, 17, 7, 93, 9, 7, 75, 97, 95, 78, 87, 8, 53], [67, 66, 59, 60, 88, 99, 94, 65, 55, 77, 55, 34, 27, 53, 78, 28], [76, 40, 41, 4, 87, 16, 9, 42, 75, 69, 23, 97, 30, 60, 10, 79, 87], [12, 10, 44, 26, 21, 36, 32, 84, 98, 60, 13, 12, 36, 16, 63, 31, 91, 35], [70, 39, 6, 5, 55, 27, 38, 48, 28, 22, 34, 35, 62, 62, 15, 14, 94, 89, 86], [66, 56, 68, 84, 96, 21, 34, 34, 34, 81, 62, 40, 65, 54, 62, 5, 98, 3, 2, 60], [38, 89, 46, 37, 99, 54, 34, 53, 36, 14, 70, 26, 2, 90, 45, 13, 31, 61, 83, 73, 47], [36, 10, 63, 96, 60, 49, 41, 5, 37, 42, 14, 58, 84, 93, 96, 17, 9, 43, 5, 43, 6, 59], [66, 57, 87, 57, 61, 28, 37, 51, 84, 73, 79, 15, 39, 95, 88, 87, 43, 39, 11, 86, 77, 74, 18], [54, 42, 5, 79, 30, 49, 99, 73, 46, 37, 50, 2, 45, 9, 54, 52, 27, 95, 27, 65, 19, 45, 26, 45], [71, 39, 17, 78, 76, 29, 52, 90, 18, 99, 78, 19, 35, 62, 71, 19, 23, 65, 93, 85, 49, 33, 75, 9, 2], [33, 24, 47, 61, 60, 55, 32, 88, 57, 55, 91, 54, 46, 57, 7, 77, 98, 52, 80, 99, 24, 25, 46, 78, 79, 5], [92, 9, 13, 55, 10, 67, 26, 78, 76, 82, 63, 49, 51, 31, 24, 68, 5, 57, 7, 54, 69, 21, 67, 43, 17, 63, 12], [24, 59, 6, 8, 98, 74, 66, 26, 61, 60, 13, 3, 9, 9, 24, 30, 71, 8, 88, 70, 72, 70, 29, 90, 11, 82, 41, 34], [66, 82, 67, 4, 36, 60, 92, 77, 91, 85, 62, 49, 59, 61, 30, 90, 29, 94, 26, 41, 89, 4, 53, 22, 83, 41, 9, 74, 90], [48, 28, 26, 37, 28, 52, 77, 26, 51, 32, 18, 98, 79, 36, 62, 13, 17, 8, 19, 54, 89, 29, 73, 68, 42, 14, 8, 16, 70, 37], [37, 60, 69, 70, 72, 71, 9, 59, 13, 60, 38, 13, 57, 36, 9, 30, 43, 89, 30, 39, 15, 2, 44, 73, 5, 73, 26, 63, 56, 86, 12], [55, 55, 85, 50, 62, 99, 84, 77, 28, 85, 3, 21, 27, 22, 19, 26, 82, 69, 54, 4, 13, 7, 85, 14, 1, 15, 70, 59, 89, 95, 10, 19], [4, 9, 31, 92, 91, 38, 92, 86, 98, 75, 21, 5, 64, 42, 62, 84, 36, 20, 73, 42, 21, 23, 22, 51, 51, 79, 25, 45, 85, 53, 3, 43, 22], [75, 63, 2, 49, 14, 12, 89, 14, 60, 78, 92, 16, 44, 82, 38, 30, 72, 11, 46, 52, 90, 27, 8, 65, 78, 3, 85, 41, 57, 79, 39, 52, 33, 48], [78, 27, 56, 56, 39, 13, 19, 43, 86, 72, 58, 95, 39, 7, 4, 34, 21, 98, 39, 15, 39, 84, 89, 69, 84, 46, 37, 57, 59, 35, 59, 50, 26, 15, 93], [42, 89, 36, 27, 78, 91, 24, 11, 17, 41, 5, 94, 7, 69, 51, 96, 3, 96, 47, 90, 90, 45, 91, 20, 50, 56, 10, 32, 36, 49, 4, 53, 85, 92, 25, 65], [52, 9, 61, 30, 61, 97, 66, 21, 96, 92, 98, 90, 6, 34, 96, 60, 32, 69, 68, 33, 75, 84, 18, 31, 71, 50, 84, 63, 3, 3, 19, 11, 28, 42, 75, 45, 45], [61, 31, 61, 68, 96, 34, 49, 39, 5, 71, 76, 59, 62, 67, 6, 47, 96, 99, 34, 21, 32, 47, 52, 7, 71, 60, 42, 72, 94, 56, 82, 83, 84, 40, 94, 87, 82, 46], [1, 20, 60, 14, 17, 38, 26, 78, 66, 81, 45, 95, 18, 51, 98, 81, 48, 16, 53, 88, 37, 52, 69, 95, 72, 93, 22, 34, 98, 20, 54, 27, 73, 61, 56, 63, 60, 34, 63], [93, 42, 94, 83, 47, 61, 27, 51, 79, 79, 45, 1, 44, 73, 31, 70, 83, 42, 88, 25, 53, 51, 30, 15, 65, 94, 80, 44, 61, 84, 12, 77, 2, 62, 2, 65, 94, 42, 14, 94], [32, 73, 9, 67, 68, 29, 74, 98, 10, 19, 85, 48, 38, 31, 85, 67, 53, 93, 93, 77, 47, 67, 39, 72, 94, 53, 18, 43, 77, 40, 78, 32, 29, 59, 24, 6, 2, 83, 50, 60, 66], [32, 1, 44, 30, 16, 51, 15, 81, 98, 15, 10, 62, 86, 79, 50, 62, 45, 60, 70, 38, 31, 85, 65, 61, 64, 6, 69, 84, 14, 22, 56, 43, 9, 48, 66, 69, 83, 91, 60, 40, 36, 61], [92, 48, 22, 99, 15, 95, 64, 43, 1, 16, 94, 2, 99, 19, 17, 69, 11, 58, 97, 56, 89, 31, 77, 45, 67, 96, 12, 73, 8, 20, 36, 47, 81, 44, 50, 64, 68, 85, 40, 81, 85, 52, 9], [91, 35, 92, 45, 32, 84, 62, 15, 19, 64, 21, 66, 6, 1, 52, 80, 62, 59, 12, 25, 88, 28, 91, 50, 40, 16, 22, 99, 92, 79, 87, 51, 21, 77, 74, 77, 7, 42, 38, 42, 74, 83, 2, 5], [46, 19, 77, 66, 24, 18, 5, 32, 2, 84, 31, 99, 92, 58, 96, 72, 91, 36, 62, 99, 55, 29, 53, 42, 12, 37, 26, 58, 89, 50, 66, 19, 82, 75, 12, 48, 24, 87, 91, 85, 2, 7, 3, 76, 86], [99, 98, 84, 93, 7, 17, 33, 61, 92, 20, 66, 60, 24, 66, 40, 30, 67, 5, 37, 29, 24, 96, 3, 27, 70, 62, 13, 4, 45, 47, 59, 88, 43, 20, 66, 15, 46, 92, 30, 4, 71, 66, 78, 70, 53, 99], [67, 60, 38, 6, 88, 4, 17, 72, 10, 99, 71, 7, 42, 25, 54, 5, 26, 64, 91, 50, 45, 71, 6, 30, 67, 48, 69, 82, 8, 56, 80, 67, 18, 46, 66, 63, 1, 20, 8, 80, 47, 7, 91, 16, 3, 79, 87], [18, 54, 78, 49, 80, 48, 77, 40, 68, 23, 60, 88, 58, 80, 33, 57, 11, 69, 55, 53, 64, 2, 94, 49, 60, 92, 16, 35, 81, 21, 82, 96, 25, 24, 96, 18, 2, 5, 49, 3, 50, 77, 6, 32, 84, 27, 18, 38], [68, 1, 50, 4, 3, 21, 42, 94, 53, 24, 89, 5, 92, 26, 52, 36, 68, 11, 85, 1, 4, 42, 2, 45, 15, 6, 50, 4, 53, 73, 25, 74, 81, 88, 98, 21, 67, 84, 79, 97, 99, 20, 95, 4, 40, 46, 2, 58, 87], [94, 10, 2, 78, 88, 52, 21, 3, 88, 60, 6, 53, 49, 71, 20, 91, 12, 65, 7, 49, 21, 22, 11, 41, 58, 99, 36, 16, 9, 48, 17, 24, 52, 36, 23, 15, 72, 16, 84, 56, 2, 99, 43, 76, 81, 71, 29, 39, 49, 17], [64, 39, 59, 84, 86, 16, 17, 66, 3, 9, 43, 6, 64, 18, 63, 29, 68, 6, 23, 7, 87, 14, 26, 35, 17, 12, 98, 41, 53, 64, 78, 18, 98, 27, 28, 84, 80, 67, 75, 62, 10, 11, 76, 90, 54, 10, 5, 54, 41, 39, 66], [43, 83, 18, 37, 32, 31, 52, 29, 95, 47, 8, 76, 35, 11, 4, 53, 35, 43, 34, 10, 52, 57, 12, 36, 20, 39, 40, 55, 78, 44, 7, 31, 38, 26, 8, 15, 56, 88, 86, 1, 52, 62, 10, 24, 32, 5, 60, 65, 53, 28, 57, 99], [3, 50, 3, 52, 7, 73, 49, 92, 66, 80, 1, 46, 8, 67, 25, 36, 73, 93, 7, 42, 25, 53, 13, 96, 76, 83, 87, 90, 54, 89, 78, 22, 78, 91, 73, 51, 69, 9, 79, 94, 83, 53, 9, 40, 69, 62, 10, 79, 49, 47, 3, 81, 30], [71, 54, 73, 33, 51, 76, 59, 54, 79, 37, 56, 45, 84, 17, 62, 21, 98, 69, 41, 95, 65, 24, 39, 37, 62, 3, 24, 48, 54, 64, 46, 82, 71, 78, 33, 67, 9, 16, 96, 68, 52, 74, 79, 68, 32, 21, 13, 78, 96, 60, 9, 69, 20, 36], [73, 26, 21, 44, 46, 38, 17, 83, 65, 98, 7, 23, 52, 46, 61, 97, 33, 13, 60, 31, 70, 15, 36, 77, 31, 58, 56, 93, 75, 68, 21, 36, 69, 53, 90, 75, 25, 82, 39, 50, 65, 94, 29, 30, 11, 33, 11, 13, 96, 2, 56, 47, 7, 49, 2], [76, 46, 73, 30, 10, 20, 60, 70, 14, 56, 34, 26, 37, 39, 48, 24, 55, 76, 84, 91, 39, 86, 95, 61, 50, 14, 53, 93, 64, 67, 37, 31, 10, 84, 42, 70, 48, 20, 10, 72, 60, 61, 84, 79, 69, 65, 99, 73, 89, 25, 85, 48, 92, 56, 97, 16], [3, 14, 80, 27, 22, 30, 44, 27, 67, 75, 79, 32, 51, 54, 81, 29, 65, 14, 19, 4, 13, 82, 4, 91, 43, 40, 12, 52, 29, 99, 7, 76, 60, 25, 1, 7, 61, 71, 37, 92, 40, 47, 99, 66, 57, 1, 43, 44, 22, 40, 53, 53, 9, 69, 26, 81, 7], [49, 80, 56, 90, 93, 87, 47, 13, 75, 28, 87, 23, 72, 79, 32, 18, 27, 20, 28, 10, 37, 59, 21, 18, 70, 4, 79, 96, 3, 31, 45, 71, 81, 6, 14, 18, 17, 5, 31, 50, 92, 79, 23, 47, 9, 39, 47, 91, 43, 54, 69, 47, 42, 95, 62, 46, 32, 85], [37, 18, 62, 85, 87, 28, 64, 5, 77, 51, 47, 26, 30, 65, 5, 70, 65, 75, 59, 80, 42, 52, 25, 20, 44, 10, 92, 17, 71, 95, 52, 14, 77, 13, 24, 55, 11, 65, 26, 91, 1, 30, 63, 15, 49, 48, 41, 17, 67, 47, 3, 68, 20, 90, 98, 32, 4, 40, 68], [90, 51, 58, 60, 6, 55, 23, 68, 5, 19, 76, 94, 82, 36, 96, 43, 38, 90, 87, 28, 33, 83, 5, 17, 70, 83, 96, 93, 6, 4, 78, 47, 80, 6, 23, 84, 75, 23, 87, 72, 99, 14, 50, 98, 92, 38, 90, 64, 61, 58, 76, 94, 36, 66, 87, 80, 51, 35, 61, 38], [57, 95, 64, 6, 53, 36, 82, 51, 40, 33, 47, 14, 7, 98, 78, 65, 39, 58, 53, 6, 50, 53, 4, 69, 40, 68, 36, 69, 75, 78, 75, 60, 3, 32, 39, 24, 74, 47, 26, 90, 13, 40, 44, 71, 90, 76, 51, 24, 36, 50, 25, 45, 70, 80, 61, 80, 61, 43, 90, 64, 11], [18, 29, 86, 56, 68, 42, 79, 10, 42, 44, 30, 12, 96, 18, 23, 18, 52, 59, 2, 99, 67, 46, 60, 86, 43, 38, 55, 17, 44, 93, 42, 21, 55, 14, 47, 34, 55, 16, 49, 24, 23, 29, 96, 51, 55, 10, 46, 53, 27, 92, 27, 46, 63, 57, 30, 65, 43, 27, 21, 20, 24, 83], [81, 72, 93, 19, 69, 52, 48, 1, 13, 83, 92, 69, 20, 48, 69, 59, 20, 62, 5, 42, 28, 89, 90, 99, 32, 72, 84, 17, 8, 87, 36, 3, 60, 31, 36, 36, 81, 26, 97, 36, 48, 54, 56, 56, 27, 16, 91, 8, 23, 11, 87, 99, 33, 47, 2, 14, 44, 73, 70, 99, 43, 35, 33], [90, 56, 61, 86, 56, 12, 70, 59, 63, 32, 1, 15, 81, 47, 71, 76, 95, 32, 65, 80, 54, 70, 34, 51, 40, 45, 33, 4, 64, 55, 78, 68, 88, 47, 31, 47, 68, 87, 3, 84, 23, 44, 89, 72, 35, 8, 31, 76, 63, 26, 90, 85, 96, 67, 65, 91, 19, 14, 17, 86, 4, 71, 32, 95], [37, 13, 4, 22, 64, 37, 37, 28, 56, 62, 86, 33, 7, 37, 10, 44, 52, 82, 52, 6, 19, 52, 57, 75, 90, 26, 91, 24, 6, 21, 14, 67, 76, 30, 46, 14, 35, 89, 89, 41, 3, 64, 56, 97, 87, 63, 22, 34, 3, 79, 17, 45, 11, 53, 25, 56, 96, 61, 23, 18, 63, 31, 37, 37, 47], [77, 23, 26, 70, 72, 76, 77, 4, 28, 64, 71, 69, 14, 85, 96, 54, 95, 48, 6, 62, 99, 83, 86, 77, 97, 75, 71, 66, 30, 19, 57, 90, 33, 1, 60, 61, 14, 12, 90, 99, 32, 77, 56, 41, 18, 14, 87, 49, 10, 14, 90, 64, 18, 50, 21, 74, 14, 16, 88, 5, 45, 73, 82, 47, 74, 44], [22, 97, 41, 13, 34, 31, 54, 61, 56, 94, 3, 24, 59, 27, 98, 77, 4, 9, 37, 40, 12, 26, 87, 9, 71, 70, 7, 18, 64, 57, 80, 21, 12, 71, 83, 94, 60, 39, 73, 79, 73, 19, 97, 32, 64, 29, 41, 7, 48, 84, 85, 67, 12, 74, 95, 20, 24, 52, 41, 67, 56, 61, 29, 93, 35, 72, 69], [72, 23, 63, 66, 1, 11, 7, 30, 52, 56, 95, 16, 65, 26, 83, 90, 50, 74, 60, 18, 16, 48, 43, 77, 37, 11, 99, 98, 30, 94, 91, 26, 62, 73, 45, 12, 87, 73, 47, 27, 1, 88, 66, 99, 21, 41, 95, 80, 2, 53, 23, 32, 61, 48, 32, 43, 43, 83, 14, 66, 95, 91, 19, 81, 80, 67, 25, 88], [8, 62, 32, 18, 92, 14, 83, 71, 37, 96, 11, 83, 39, 99, 5, 16, 23, 27, 10, 67, 2, 25, 44, 11, 55, 31, 46, 64, 41, 56, 44, 74, 26, 81, 51, 31, 45, 85, 87, 9, 81, 95, 22, 28, 76, 69, 46, 48, 64, 87, 67, 76, 27, 89, 31, 11, 74, 16, 62, 3, 60, 94, 42, 47, 9, 34, 94, 93, 72], [56, 18, 90, 18, 42, 17, 42, 32, 14, 86, 6, 53, 33, 95, 99, 35, 29, 15, 44, 20, 49, 59, 25, 54, 34, 59, 84, 21, 23, 54, 35, 90, 78, 16, 93, 13, 37, 88, 54, 19, 86, 67, 68, 55, 66, 84, 65, 42, 98, 37, 87, 56, 33, 28, 58, 38, 28, 38, 66, 27, 52, 21, 81, 15, 8, 22, 97, 32, 85, 27], [91, 53, 40, 28, 13, 34, 91, 25, 1, 63, 50, 37, 22, 49, 71, 58, 32, 28, 30, 18, 68, 94, 23, 83, 63, 62, 94, 76, 80, 41, 90, 22, 82, 52, 29, 12, 18, 56, 10, 8, 35, 14, 37, 57, 23, 65, 67, 40, 72, 39, 93, 39, 70, 89, 40, 34, 7, 46, 94, 22, 20, 5, 53, 64, 56, 30, 5, 56, 61, 88, 27], [23, 95, 11, 12, 37, 69, 68, 24, 66, 10, 87, 70, 43, 50, 75, 7, 62, 41, 83, 58, 95, 93, 89, 79, 45, 39, 2, 22, 5, 22, 95, 43, 62, 11, 68, 29, 17, 40, 26, 44, 25, 71, 87, 16, 70, 85, 19, 25, 59, 94, 90, 41, 41, 80, 61, 70, 55, 60, 84, 33, 95, 76, 42, 63, 15, 9, 3, 40, 38, 12, 3, 32], [9, 84, 56, 80, 61, 55, 85, 97, 16, 94, 82, 94, 98, 57, 84, 30, 84, 48, 93, 90, 71, 5, 95, 90, 73, 17, 30, 98, 40, 64, 65, 89, 7, 79, 9, 19, 56, 36, 42, 30, 23, 69, 73, 72, 7, 5, 27, 61, 24, 31, 43, 48, 71, 84, 21, 28, 26, 65, 65, 59, 65, 74, 77, 20, 10, 81, 61, 84, 95, 8, 52, 23, 70], [47, 81, 28, 9, 98, 51, 67, 64, 35, 51, 59, 36, 92, 82, 77, 65, 80, 24, 72, 53, 22, 7, 27, 10, 21, 28, 30, 22, 48, 82, 80, 48, 56, 20, 14, 43, 18, 25, 50, 95, 90, 31, 77, 8, 9, 48, 44, 80, 90, 22, 93, 45, 82, 17, 13, 96, 25, 26, 8, 73, 34, 99, 6, 49, 24, 6, 83, 51, 40, 14, 15, 10, 25, 1], [54, 25, 10, 81, 30, 64, 24, 74, 75, 80, 36, 75, 82, 60, 22, 69, 72, 91, 45, 67, 3, 62, 79, 54, 89, 74, 44, 83, 64, 96, 66, 73, 44, 30, 74, 50, 37, 5, 9, 97, 70, 1, 60, 46, 37, 91, 39, 75, 75, 18, 58, 52, 72, 78, 51, 81, 86, 52, 8, 97, 1, 46, 43, 66, 98, 62, 81, 18, 70, 93, 73, 8, 32, 46, 34], [96, 80, 82, 7, 59, 71, 92, 53, 19, 20, 88, 66, 3, 26, 26, 10, 24, 27, 50, 82, 94, 73, 63, 8, 51, 33, 22, 45, 19, 13, 58, 33, 90, 15, 22, 50, 36, 13, 55, 6, 35, 47, 82, 52, 33, 61, 36, 27, 28, 46, 98, 14, 73, 20, 73, 32, 16, 26, 80, 53, 47, 66, 76, 38, 94, 45, 2, 1, 22, 52, 47, 96, 64, 58, 52, 39], [88, 46, 23, 39, 74, 63, 81, 64, 20, 90, 33, 33, 76, 55, 58, 26, 10, 46, 42, 26, 74, 74, 12, 83, 32, 43, 9, 2, 73, 55, 86, 54, 85, 34, 28, 23, 29, 79, 91, 62, 47, 41, 82, 87, 99, 22, 48, 90, 20, 5, 96, 75, 95, 4, 43, 28, 81, 39, 81, 1, 28, 42, 78, 25, 39, 77, 90, 57, 58, 98, 17, 36, 73, 22, 63, 74, 51], [29, 39, 74, 94, 95, 78, 64, 24, 38, 86, 63, 87, 93, 6, 70, 92, 22, 16, 80, 64, 29, 52, 20, 27, 23, 50, 14, 13, 87, 15, 72, 96, 81, 22, 8, 49, 72, 30, 70, 24, 79, 31, 16, 64, 59, 21, 89, 34, 96, 91, 48, 76, 43, 53, 88, 1, 57, 80, 23, 81, 90, 79, 58, 1, 80, 87, 17, 99, 86, 90, 72, 63, 32, 69, 14, 28, 88, 69], [37, 17, 71, 95, 56, 93, 71, 35, 43, 45, 4, 98, 92, 94, 84, 96, 11, 30, 31, 27, 31, 60, 92, 3, 48, 5, 98, 91, 86, 94, 35, 90, 90, 8, 48, 19, 33, 28, 68, 37, 59, 26, 65, 96, 50, 68, 22, 7, 9, 49, 34, 31, 77, 49, 43, 6, 75, 17, 81, 87, 61, 79, 52, 26, 27, 72, 29, 50, 7, 98, 86, 1, 17, 10, 46, 64, 24, 18, 56], [51, 30, 25, 94, 88, 85, 79, 91, 40, 33, 63, 84, 49, 67, 98, 92, 15, 26, 75, 19, 82, 5, 18, 78, 65, 93, 61, 48, 91, 43, 59, 41, 70, 51, 22, 15, 92, 81, 67, 91, 46, 98, 11, 11, 65, 31, 66, 10, 98, 65, 83, 21, 5, 56, 5, 98, 73, 67, 46, 74, 69, 34, 8, 30, 5, 52, 7, 98, 32, 95, 30, 94, 65, 50, 24, 63, 28, 81, 99, 57], [19, 23, 61, 36, 9, 89, 71, 98, 65, 17, 30, 29, 89, 26, 79, 74, 94, 11, 44, 48, 97, 54, 81, 55, 39, 66, 69, 45, 28, 47, 13, 86, 15, 76, 74, 70, 84, 32, 36, 33, 79, 20, 78, 14, 41, 47, 89, 28, 81, 5, 99, 66, 81, 86, 38, 26, 6, 25, 13, 60, 54, 55, 23, 53, 27, 5, 89, 25, 23, 11, 13, 54, 59, 54, 56, 34, 16, 24, 53, 44, 6], [13, 40, 57, 72, 21, 15, 60, 8, 4, 19, 11, 98, 34, 45, 9, 97, 86, 71, 3, 15, 56, 19, 15, 44, 97, 31, 90, 4, 87, 87, 76, 8, 12, 30, 24, 62, 84, 28, 12, 85, 82, 53, 99, 52, 13, 94, 6, 65, 97, 86, 9, 50, 94, 68, 69, 74, 30, 67, 87, 94, 63, 7, 78, 27, 80, 36, 69, 41, 6, 92, 32, 78, 37, 82, 30, 5, 18, 87, 99, 72, 19, 99], [44, 20, 55, 77, 69, 91, 27, 31, 28, 81, 80, 27, 2, 7, 97, 23, 95, 98, 12, 25, 75, 29, 47, 71, 7, 47, 78, 39, 41, 59, 27, 76, 13, 15, 66, 61, 68, 35, 69, 86, 16, 53, 67, 63, 99, 85, 41, 56, 8, 28, 33, 40, 94, 76, 90, 85, 31, 70, 24, 65, 84, 65, 99, 82, 19, 25, 54, 37, 21, 46, 33, 2, 52, 99, 51, 33, 26, 4, 87, 2, 8, 18, 96], [54, 42, 61, 45, 91, 6, 64, 79, 80, 82, 32, 16, 83, 63, 42, 49, 19, 78, 65, 97, 40, 42, 14, 61, 49, 34, 4, 18, 25, 98, 59, 30, 82, 72, 26, 88, 54, 36, 21, 75, 3, 88, 99, 53, 46, 51, 55, 78, 22, 94, 34, 40, 68, 87, 84, 25, 30, 76, 25, 8, 92, 84, 42, 61, 40, 38, 9, 99, 40, 23, 29, 39, 46, 55, 10, 90, 35, 84, 56, 70, 63, 23, 91, 39], [52, 92, 3, 71, 89, 7, 9, 37, 68, 66, 58, 20, 44, 92, 51, 56, 13, 71, 79, 99, 26, 37, 2, 6, 16, 67, 36, 52, 58, 16, 79, 73, 56, 60, 59, 27, 44, 77, 94, 82, 20, 50, 98, 33, 9, 87, 94, 37, 40, 83, 64, 83, 58, 85, 17, 76, 53, 2, 83, 52, 22, 27, 39, 20, 48, 92, 45, 21, 9, 42, 24, 23, 12, 37, 52, 28, 50, 78, 79, 20, 86, 62, 73, 20, 59], [54, 96, 80, 15, 91, 90, 99, 70, 10, 9, 58, 90, 93, 50, 81, 99, 54, 38, 36, 10, 30, 11, 35, 84, 16, 45, 82, 18, 11, 97, 36, 43, 96, 79, 97, 65, 40, 48, 23, 19, 17, 31, 64, 52, 65, 65, 37, 32, 65, 76, 99, 79, 34, 65, 79, 27, 55, 33, 3, 1, 33, 27, 61, 28, 66, 8, 4, 70, 49, 46, 48, 83, 1, 45, 19, 96, 13, 81, 14, 21, 31, 79, 93, 85, 50, 5], [92, 92, 48, 84, 59, 98, 31, 53, 23, 27, 15, 22, 79, 95, 24, 76, 5, 79, 16, 93, 97, 89, 38, 89, 42, 83, 2, 88, 94, 95, 82, 21, 1, 97, 48, 39, 31, 78, 9, 65, 50, 56, 97, 61, 1, 7, 65, 27, 21, 23, 14, 15, 80, 97, 44, 78, 49, 35, 33, 45, 81, 74, 34, 5, 31, 57, 9, 38, 94, 7, 69, 54, 69, 32, 65, 68, 46, 68, 78, 90, 24, 28, 49, 51, 45, 86, 35], [41, 63, 89, 76, 87, 31, 86, 9, 46, 14, 87, 82, 22, 29, 47, 16, 13, 10, 70, 72, 82, 95, 48, 64, 58, 43, 13, 75, 42, 69, 21, 12, 67, 13, 64, 85, 58, 23, 98, 9, 37, 76, 5, 22, 31, 12, 66, 50, 29, 99, 86, 72, 45, 25, 10, 28, 19, 6, 90, 43, 29, 31, 67, 79, 46, 25, 74, 14, 97, 35, 76, 37, 65, 46, 23, 82, 6, 22, 30, 76, 93, 66, 94, 17, 96, 13, 20, 72], [63, 40, 78, 8, 52, 9, 90, 41, 70, 28, 36, 14, 46, 44, 85, 96, 24, 52, 58, 15, 87, 37, 5, 98, 99, 39, 13, 61, 76, 38, 44, 99, 83, 74, 90, 22, 53, 80, 56, 98, 30, 51, 63, 39, 44, 30, 91, 91, 4, 22, 27, 73, 17, 35, 53, 18, 35, 45, 54, 56, 27, 78, 48, 13, 69, 36, 44, 38, 71, 25, 30, 56, 15, 22, 73, 43, 32, 69, 59, 25, 93, 83, 45, 11, 34, 94, 44, 39, 92], [12, 36, 56, 88, 13, 96, 16, 12, 55, 54, 11, 47, 19, 78, 17, 17, 68, 81, 77, 51, 42, 55, 99, 85, 66, 27, 81, 79, 93, 42, 65, 61, 69, 74, 14, 1, 18, 56, 12, 1, 58, 37, 91, 22, 42, 66, 83, 25, 19, 4, 96, 41, 25, 45, 18, 69, 96, 88, 36, 93, 10, 12, 98, 32, 44, 83, 83, 4, 72, 91, 4, 27, 73, 7, 34, 37, 71, 60, 59, 31, 1, 54, 54, 44, 96, 93, 83, 36, 4, 45], [30, 18, 22, 20, 42, 96, 65, 79, 17, 41, 55, 69, 94, 81, 29, 80, 91, 31, 85, 25, 47, 26, 43, 49, 2, 99, 34, 67, 99, 76, 16, 14, 15, 93, 8, 32, 99, 44, 61, 77, 67, 50, 43, 55, 87, 55, 53, 72, 17, 46, 62, 25, 50, 99, 73, 5, 93, 48, 17, 31, 70, 80, 59, 9, 44, 59, 45, 13, 74, 66, 58, 94, 87, 73, 16, 14, 85, 38, 74, 99, 64, 23, 79, 28, 71, 42, 20, 37, 82, 31, 23], [51, 96, 39, 65, 46, 71, 56, 13, 29, 68, 53, 86, 45, 33, 51, 49, 12, 91, 21, 21, 76, 85, 2, 17, 98, 15, 46, 12, 60, 21, 88, 30, 92, 83, 44, 59, 42, 50, 27, 88, 46, 86, 94, 73, 45, 54, 23, 24, 14, 10, 94, 21, 20, 34, 23, 51, 4, 83, 99, 75, 90, 63, 60, 16, 22, 33, 83, 70, 11, 32, 10, 50, 29, 30, 83, 46, 11, 5, 31, 17, 86, 42, 49, 1, 44, 63, 28, 60, 7, 78, 95, 40], [44, 61, 89, 59, 4, 49, 51, 27, 69, 71, 46, 76, 44, 4, 9, 34, 56, 39, 15, 6, 94, 91, 75, 90, 65, 27, 56, 23, 74, 6, 23, 33, 36, 69, 14, 39, 5, 34, 35, 57, 33, 22, 76, 46, 56, 10, 61, 65, 98, 9, 16, 69, 4, 62, 65, 18, 99, 76, 49, 18, 72, 66, 73, 83, 82, 40, 76, 31, 89, 91, 27, 88, 17, 35, 41, 35, 32, 51, 32, 67, 52, 68, 74, 85, 80, 57, 7, 11, 62, 66, 47, 22, 67], [65, 37, 19, 97, 26, 17, 16, 24, 24, 17, 50, 37, 64, 82, 24, 36, 32, 11, 68, 34, 69, 31, 32, 89, 79, 93, 96, 68, 49, 90, 14, 23, 4, 4, 67, 99, 81, 74, 70, 74, 36, 96, 68, 9, 64, 39, 88, 35, 54, 89, 96, 58, 66, 27, 88, 97, 32, 14, 6, 35, 78, 20, 71, 6, 85, 66, 57, 2, 58, 91, 72, 5, 29, 56, 73, 48, 86, 52, 9, 93, 22, 57, 79, 42, 12, 1, 31, 68, 17, 59, 63, 76, 7, 77], [73, 81, 14, 13, 17, 20, 11, 9, 1, 83, 8, 85, 91, 70, 84, 63, 62, 77, 37, 7, 47, 1, 59, 95, 39, 69, 39, 21, 99, 9, 87, 2, 97, 16, 92, 36, 74, 71, 90, 66, 33, 73, 73, 75, 52, 91, 11, 12, 26, 53, 5, 26, 26, 48, 61, 50, 90, 65, 1, 87, 42, 47, 74, 35, 22, 73, 24, 26, 56, 70, 52, 5, 48, 41, 31, 18, 83, 27, 21, 39, 80, 85, 26, 8, 44, 2, 71, 7, 63, 22, 5, 52, 19, 8, 20], [17, 25, 21, 11, 72, 93, 33, 49, 64, 23, 53, 82, 3, 13, 91, 65, 85, 2, 40, 5, 42, 31, 77, 42, 5, 36, 6, 54, 4, 58, 7, 76, 87, 83, 25, 57, 66, 12, 74, 33, 85, 37, 74, 32, 20, 69, 3, 97, 91, 68, 82, 44, 19, 14, 89, 28, 85, 85, 80, 53, 34, 87, 58, 98, 88, 78, 48, 65, 98, 40, 11, 57, 10, 67, 70, 81, 60, 79, 74, 72, 97, 59, 79, 47, 30, 20, 54, 80, 89, 91, 14, 5, 33, 36, 79, 39], [60, 85, 59, 39, 60, 7, 57, 76, 77, 92, 6, 35, 15, 72, 23, 41, 45, 52, 95, 18, 64, 79, 86, 53, 56, 31, 69, 11, 91, 31, 84, 50, 44, 82, 22, 81, 41, 40, 30, 42, 30, 91, 48, 94, 74, 76, 64, 58, 74, 25, 96, 57, 14, 19, 3, 99, 28, 83, 15, 75, 99, 1, 89, 85, 79, 50, 3, 95, 32, 67, 44, 8, 7, 41, 62, 64, 29, 20, 14, 76, 26, 55, 48, 71, 69, 66, 19, 72, 44, 25, 14, 1, 48, 74, 12, 98, 7], [64, 66, 84, 24, 18, 16, 27, 48, 20, 14, 47, 69, 30, 86, 48, 40, 23, 16, 61, 21, 51, 50, 26, 47, 35, 33, 91, 28, 78, 64, 43, 68, 4, 79, 51, 8, 19, 60, 52, 95, 6, 68, 46, 86, 35, 97, 27, 58, 4, 65, 30, 58, 99, 12, 12, 75, 91, 39, 50, 31, 42, 64, 70, 4, 46, 7, 98, 73, 98, 93, 37, 89, 77, 91, 64, 71, 64, 65, 66, 21, 78, 62, 81, 74, 42, 20, 83, 70, 73, 95, 78, 45, 92, 27, 34, 53, 71, 15], [30, 11, 85, 31, 34, 71, 13, 48, 5, 14, 44, 3, 19, 67, 23, 73, 19, 57, 6, 90, 94, 72, 57, 69, 81, 62, 59, 68, 88, 57, 55, 69, 49, 13, 7, 87, 97, 80, 89, 5, 71, 5, 5, 26, 38, 40, 16, 62, 45, 99, 18, 38, 98, 24, 21, 26, 62, 74, 69, 4, 85, 57, 77, 35, 58, 67, 91, 79, 79, 57, 86, 28, 66, 34, 72, 51, 76, 78, 36, 95, 63, 90, 8, 78, 47, 63, 45, 31, 22, 70, 52, 48, 79, 94, 15, 77, 61, 67, 68], [23, 33, 44, 81, 80, 92, 93, 75, 94, 88, 23, 61, 39, 76, 22, 3, 28, 94, 32, 6, 49, 65, 41, 34, 18, 23, 8, 47, 62, 60, 3, 63, 33, 13, 80, 52, 31, 54, 73, 43, 70, 26, 16, 69, 57, 87, 83, 31, 3, 93, 70, 81, 47, 95, 77, 44, 29, 68, 39, 51, 56, 59, 63, 7, 25, 70, 7, 77, 43, 53, 64, 3, 94, 42, 95, 39, 18, 1, 66, 21, 16, 97, 20, 50, 90, 16, 70, 10, 95, 69, 29, 6, 25, 61, 41, 26, 15, 59, 63, 35]]]], "outputs": [[23], [1074], [7273]], "fn_name": "longest_slide_down"}, "test_case_format": "function_call", "n_test_cases_total": 3, "n_test_cases_kept": 3, "test_cases_truncated": false, "problem_sha1": "e4352ae3339fe145c494b05a2bdf4103b6c7a504", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "longest_slide_down"} {"seed_id": "apps-01174", "original_id": null, "source": "apps", "domain": "code", "problem": "Write a function that counts how many different ways you can make change for an amount of money, given an array of coin denominations. For example, there are 3 ways to give change for 4 if you have coins with denomination 1 and 2: \n```\n1+1+1+1, 1+1+2, 2+2.\n```\nThe order of coins does not matter:\n```\n1+1+2 == 2+1+1\n```\nAlso, assume that you have an infinite amount of coins.\n\nYour function should take an amount to change and an array of unique denominations for the coins:\n\n```python\n count_change(4, [1,2]) # => 3\n count_change(10, [5,2,3]) # => 4\n count_change(11, [5,7]) # => 0\n```", "starter_code": "\ndef count_change(money, coins):\n\t", "test_cases": {"inputs": [[4, [1, 2]], [10, [5, 2, 3]], [11, [5, 7]], [98, [3, 14, 8]], [199, [3, 5, 9, 15]], [300, [5, 10, 20, 50, 100, 200, 500]], [301, [5, 10, 20, 50, 100, 200, 500]], [419, [2, 5, 10, 20, 50]]], "outputs": [[3], [4], [0], [19], [760], [1022], [0], [18515]], "fn_name": "count_change"}, "test_case_format": "function_call", "n_test_cases_total": 8, "n_test_cases_kept": 8, "test_cases_truncated": false, "problem_sha1": "c8bb9da8131646577cfc4933f5a7d422ad3ebd9f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "count_change"} {"seed_id": "apps-01179", "original_id": null, "source": "apps", "domain": "code", "problem": "## Snail Sort\n\nGiven an `n x n` array, return the array elements arranged from outermost elements to the middle element, traveling clockwise.\n\n```\narray = [[1,2,3],\n [4,5,6],\n [7,8,9]]\nsnail(array) #=> [1,2,3,6,9,8,7,4,5]\n```\n\nFor better understanding, please follow the numbers of the next array consecutively:\n\n```\narray = [[1,2,3],\n [8,9,4],\n [7,6,5]]\nsnail(array) #=> [1,2,3,4,5,6,7,8,9]\n```\n\nThis image will illustrate things more clearly:\n\n\n\nNOTE: The idea is not sort the elements from the lowest value to the highest; the idea is to traverse the 2-d array in a clockwise snailshell pattern.\n\nNOTE 2: The 0x0 (empty matrix) is represented as en empty array inside an array `[[]]`.", "starter_code": "\ndef snail(array):\n\t", "test_cases": {"inputs": [[[[]]], [[[1]]], [[[1, 2, 3], [4, 5, 6], [7, 8, 9]]], [[[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]], [[[1, 2, 3, 4, 5, 6], [20, 21, 22, 23, 24, 7], [19, 32, 33, 34, 25, 8], [18, 31, 36, 35, 26, 9], [17, 30, 29, 28, 27, 10], [16, 15, 14, 13, 12, 11]]]], "outputs": [[[]], [[1]], [[1, 2, 3, 6, 9, 8, 7, 4, 5]], [[1, 2, 3, 4, 5, 10, 15, 20, 25, 24, 23, 22, 21, 16, 11, 6, 7, 8, 9, 14, 19, 18, 17, 12, 13]], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]]], "fn_name": "snail"}, "test_case_format": "function_call", "n_test_cases_total": 5, "n_test_cases_kept": 5, "test_cases_truncated": false, "problem_sha1": "4e299951c7b9b1b25766202116d152e5a53388d3", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "snail"} {"seed_id": "apps-01184", "original_id": null, "source": "apps", "domain": "code", "problem": "# Longest Palindromic Substring (Linear)\n\nA palindrome is a word, phrase, or sequence that reads the same backward as forward, e.g.,\n'madam' or 'racecar'. Even the letter 'x' is considered a palindrome. \n\nFor this Kata, you are given a string ```s```. Write a function that returns the longest _contiguous_ palindromic substring in ```s``` (it could be the entire string). In the event that there are multiple longest palindromic substrings, return the first to occur.\n\nI'm not trying to trick you here:\n- You can assume that all inputs are valid strings.\n- Only the letters a-z will be used, all lowercase (your solution should, in theory, extend to more than just the letters a-z though). \n\n**NOTE:** Quadratic asymptotic complexity _(O(N^2))_ or above will __NOT__ work here.\n\n-----\n\n## Examples\n\n### Basic Tests\n\n```\nInput: \"babad\"\nOutput: \"bab\"\n(Note: \"bab\" occurs before \"aba\")\n```\n```\nInput: \"abababa\"\nOutput: \"abababa\"\n```\n```\nInput: \"cbbd\"\nOutput: \"bb\"\n```\n\n### Edge Cases\n\n```\nInput: \"ab\"\nOutput: \"a\"\n```\n```\nInput: \"\"\nOutput: \"\"\n```\n-----\n\n## Testing\n\nAlong with the example tests given:\n\n - There are **500** tests using strings of length in range [1 - 1,000]\n - There are **50** tests using strings of length in range [1,000 - 10,000]\n - There are **5** tests using strings of length in range [10,000 - 100,000]\n \nAll test cases can be passed within 10 seconds, but non-linear solutions will time out every time. _Linear performance is essential_. \n\n## Good Luck!\n\n-----\n\nThis problem was inspired by [this](https://leetcode.com/problems/longest-palindromic-substring/) challenge on LeetCode. Except this is the performance version :^)", "starter_code": "\ndef longest_palindrome(s):\n\t", "test_cases": {"inputs": [["babad"], ["madam"], ["dde"], ["ababbab"], ["abababa"], ["banana"], ["abba"], ["cbbd"], ["zz"], ["dddd"], [""], ["abcdefghijklmnopqrstuvwxyz"], ["ttaaftffftfaafatf"], ["bbaaacc"], ["m"]], "outputs": [["bab"], ["madam"], ["dd"], ["babbab"], ["abababa"], ["anana"], ["abba"], ["bb"], ["zz"], ["dddd"], [""], ["a"], ["aaftffftfaa"], ["aaa"], ["m"]], "fn_name": "longest_palindrome"}, "test_case_format": "function_call", "n_test_cases_total": 15, "n_test_cases_kept": 15, "test_cases_truncated": false, "problem_sha1": "760350f535d0f9d37e2f3159cbb8b34fb1f3a95d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "longest_palindrome"} {"seed_id": "apps-01189", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given 2 numbers is `n` and `k`. You need to find the number of integers between 1 and n (inclusive) that contains exactly `k` non-zero digit.\n\nExample1 \n\n`\nalmost_everywhere_zero(100, 1) return 19`\n\nby following condition we have 19 numbers that have k = 1 digits( not count zero ) \n` [1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100]`\n\n\nExample2 \n\n`\nalmost_everywhere_zero(11, 2) return 1`\n\nwe have only `11` that has 2 digits(ten not count because zero is not count) \n` 11`\n\n\n\n\n\nconstrains\n\n\n`1≤n` means application of `simplify`):\n\n- All possible sums and subtraction of equivalent monomials (\"xy==yx\") has been done, e.g.: `\"cb+cba\" -> \"bc+abc\"`, `\"2xy-yx\" -> \"xy\"`, `\"-a+5ab+3a-c-2a\" -> \"-c+5ab\"`\n\n- All monomials appears in order of increasing number of variables, e.g.: `\"-abc+3a+2ac\" -> \"3a+2ac-abc\"`, `\"xyz-xz\" -> \"-xz+xyz\"`\n \n- If two monomials have the same number of variables, they appears in lexicographic order, e.g.: `\"a+ca-ab\" -> \"a-ab+ac\"`, `\"xzy+zby\" ->\"byz+xyz\"`\n \n- There is no leading `+` sign if the first coefficient is positive, e.g.: `\"-y+x\" -> \"x-y\"`, but no restrictions for `-`: `\"y-x\" ->\"-x+y\"`\n\n---\n\n__N.B.__ to keep it simplest, the string in input is restricted to represent only *multilinear non-constant polynomials*, so you won't find something like `-3+yx^2'. **Multilinear** means in this context: **of degree 1 on each variable**.\n\n**Warning**: the string in input can contain arbitrary variables represented by lowercase characters in the english alphabet.\n\n__Good Work :)__", "starter_code": "\ndef simplify(poly):\n\t", "test_cases": {"inputs": [["dc+dcba"], ["2xy-yx"], ["-a+5ab+3a-c-2a"], ["-abc+3a+2ac"], ["xyz-xz"], ["a+ca-ab"], ["xzy+zby"], ["-y+x"], ["y-x"], ["3a+b+4ac+bc-ab+3a-cb-a-a"], ["+n-5hn+7tjhn-4nh-3n-6hnjt+2jhn+9hn"], ["-8fk+5kv-4yk+7kf-qk+yqv-3vqy+4ky+4kf+yvqkf"]], "outputs": [["cd+abcd"], ["xy"], ["-c+5ab"], ["3a+2ac-abc"], ["-xz+xyz"], ["a-ab+ac"], ["byz+xyz"], ["x-y"], ["-x+y"], ["4a+b-ab+4ac"], ["-2n+2hjn+hjnt"], ["3fk-kq+5kv-2qvy+fkqvy"]], "fn_name": "simplify"}, "test_case_format": "function_call", "n_test_cases_total": 12, "n_test_cases_kept": 12, "test_cases_truncated": false, "problem_sha1": "7b02fc2cb3a353f9f0f60fea6d3ffc99ed928696", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "simplify"} {"seed_id": "apps-01204", "original_id": null, "source": "apps", "domain": "code", "problem": "# Unflatten a list (Harder than easy)\n\nThis is the harder version of Unflatten a list (Easy)\n\nSo you have again to build a method, that creates new arrays, that can be flattened!\n\n# Shorter: You have to unflatten a list/an array.\n\nYou get an array of integers and have to unflatten it by these rules:\n```\n- You have to do several runs. The depth is the number of runs, you have to do.\n- In every run you have to switch the direction. First run from left, next run from right. Next left...\nEvery run has these rules:\n- You start at the first number (from the direction).\n- Take for every number x the remainder of the division by the number of still available elements (from \n this position!) to have the number for the next decision.\n- If the remainder-value is smaller than 3, take this number x (NOT the remainder-Value) direct\n for the new array and continue with the next number.\n- If the remainder-value (e.g. 3) is greater than 2, take the next remainder-value-number (e.g. 3)\n elements/numbers (inclusive the number x, NOT the remainder-value) as a sub-array in the new array.\n Continue with the next number/element AFTER this taken elements/numbers.\n- Every sub-array in the array is independent and is only one element for the progress on the array. \n For every sub-array you have to follow the same rules for unflatten it.\n The direction is always the same as the actual run.\n```\n\nSounds complicated? Yeah, thats why, this is the harder version...\nMaybe an example will help.\n\n```\n Array: [4, 5, 1, 7, 1] Depth: 2 -> [[ 4, [ 5, 1, 7 ] ], 1]\n \nSteps: \nFirst run: (start from left side!)\n1. The first number is 4. The number is smaller than the number of remaining elements, so it is the remainder-value (4 / 5 -> remainder 4).\n So 4 numbers (4, 5, 1, 7) are added as sub-array in the new array.\n2. The next number is 1. It is smaller than 3, so the 1 is added direct to the new array.\nNow we have --> [[4, 5, 1, 7], 1]\n\nSecond run: (start from right side!)\n1. The last number (first from other side) is 1. So the 1 is added direct to the new array.\n2. The next element is the sub-array. So we use the rules for this.\n2a.The last number is 7. There are 4 elements in the array. So for the next decision you have to\n take the remainder from 7 / 4 -> 3. So 3 numbers (5, 1, 7) are added as sub-array in the \n new array.\n2b.Now there is the 4 and only one element last in this array. 4 / 1 -> remainder 0. It is smaller\n than 3. So the 4 is added direct to the new array.\nNow we have --> [[ 4, [ 5, 1, 7 ] ], 1]\n```\n\nThe given array will always contain numbers. There will only be numbers > 0.\n\n\nHave fun coding it and please don't forget to vote and rank this kata! :-) \n\nI have created other katas. Have a look if you like coding and challenges.", "starter_code": "\ndef unflatten(flat_array, depth):\n\t", "test_cases": {"inputs": [[[4, 5, 1, 7, 1], 2], [[12, 1, 5, 3, 1, 55, 2, 3, 7, 8, 1], 3]], "outputs": [[[[4, [5, 1, 7]], 1]], [[12, 1, [5, [3, 1, 55], 2], [3, 7, 8], 1]]], "fn_name": "unflatten"}, "test_case_format": "function_call", "n_test_cases_total": 2, "n_test_cases_kept": 2, "test_cases_truncated": false, "problem_sha1": "399af6e7a5c99a073687ddbdaf222f9a26af4ca8", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "unflatten"} {"seed_id": "apps-01209", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' $\\rightarrow$ 'y' $\\rightarrow$ 'x' $\\rightarrow \\ldots \\rightarrow$ 'b' $\\rightarrow$ 'a' $\\rightarrow$ 'z'. In other words, each character is replaced with the previous character of English alphabet and 'a' is replaced with 'z'.\n\nWhat is the lexicographically minimum string that can be obtained from s by performing this shift exactly once?\n\n\n-----Input-----\n\nThe only line of the input contains the string s (1 ≤ |s| ≤ 100 000) consisting of lowercase English letters.\n\n\n-----Output-----\n\nPrint the lexicographically minimum string that can be obtained from s by shifting letters of exactly one non-empty substring.\n\n\n-----Examples-----\nInput\ncodeforces\n\nOutput\nbncdenqbdr\n\nInput\nabacaba\n\nOutput\naaacaba\n\n\n\n-----Note-----\n\nString s is lexicographically smaller than some other string t of the same length if there exists some 1 ≤ i ≤ |s|, such that s_1 = t_1, s_2 = t_2, ..., s_{i} - 1 = t_{i} - 1, and s_{i} < t_{i}.", "starter_code": "", "test_cases": {"inputs": ["codeforces\n", "abacaba\n", "babbbabaababbaa\n", "bcbacaabcababaccccaaaabacbbcbbaa\n", "cabaccaacccabaacdbdcbcdbccbccbabbdadbdcdcdbdbcdcdbdadcbcda\n", "a\n", "eeeedddccbceaabdaecaebaeaecccbdeeeaadcecdbeacecdcdcceabaadbcbbadcdaeddbcccaaeebccecaeeeaebcaaccbdaccbdcadadaaeacbbdcbaeeaecedeeeedadec\n", "fddfbabadaadaddfbfecadfaefaefefabcccdbbeeabcbbddefbafdcafdfcbdffeeaffcaebbbedabddeaecdddffcbeaafffcddccccfffdbcddcfccefafdbeaacbdeeebdeaaacdfdecadfeafaeaefbfdfffeeaefebdceebcebbfeaccfafdccdcecedeedadcadbfefccfdedfaaefabbaeebdebeecaadbebcfeafbfeeefcfaecadfe\n", "aaaaaaaaaa\n", "abbabaaaaa\n", "bbbbbbbbbbbb\n", "aabaaaaaaaaaaaa\n", "aaaaaaaaaaaaaaaaaaaa\n", "abaabaaaaaabbaaaaaaabaaaaaaaaabaaaabaaaaaaabaaaaaaaaaabaaaaaaaaaaaaaaabaaaabbaaaaabaaaaaaaabaaaaaaaa\n", "abbbbbbbabbbbbbbbbbbbbbbbbbbbbbbabbabbbbbabbbbbbbbbbbabbbbbbbbabbabbbbbbbbbbbbbbabbabbbaababbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbabbbbbbbbbbbbbbbbabbbbabbbbbbbbbbbbbbbabbbbbbbbbaababbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbabbabbbbbbbbbbbbbbbbabbbabbbbbaabbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbaabbbbbbbbbbbbababbabbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbabbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbabbbbbbbabbbbbbb\n", "aaaaa\n", "aaa\n", "aa\n"], "outputs": ["bncdenqbdr\n", "aaacaba\n", "aabbbabaababbaa\n", "abaacaabcababaccccaaaabacbbcbbaa\n", "babaccaacccabaacdbdcbcdbccbccbabbdadbdcdcdbdbcdcdbdadcbcda\n", "z\n", "ddddcccbbabdaabdaecaebaeaecccbdeeeaadcecdbeacecdcdcceabaadbcbbadcdaeddbcccaaeebccecaeeeaebcaaccbdaccbdcadadaaeacbbdcbaeeaecedeeeedadec\n", "ecceaabadaadaddfbfecadfaefaefefabcccdbbeeabcbbddefbafdcafdfcbdffeeaffcaebbbedabddeaecdddffcbeaafffcddccccfffdbcddcfccefafdbeaacbdeeebdeaaacdfdecadfeafaeaefbfdfffeeaefebdceebcebbfeaccfafdccdcecedeedadcadbfefccfdedfaaefabbaeebdebeecaadbebcfeafbfeeefcfaecadfe\n", "aaaaaaaaaz\n", "aaaabaaaaa\n", "aaaaaaaaaaaa\n", "aaaaaaaaaaaaaaa\n", "aaaaaaaaaaaaaaaaaaaz\n", "aaaabaaaaaabbaaaaaaabaaaaaaaaabaaaabaaaaaaabaaaaaaaaaabaaaaaaaaaaaaaaabaaaabbaaaaabaaaaaaaabaaaaaaaa\n", "aaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbabbabbbbbabbbbbbbbbbbabbbbbbbbabbabbbbbbbbbbbbbbabbabbbaababbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbabbbbbbbbbbbbbbbbabbbbabbbbbbbbbbbbbbbabbbbbbbbbaababbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbabbabbbbbbbbbbbbbbbbabbbabbbbbaabbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbaabbbbbbbbbbbbababbabbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbabbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbabbbbbbbabbbbbbb\n", "aaaaz\n", "aaz\n", "az\n"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 18, "n_test_cases_kept": 18, "test_cases_truncated": false, "problem_sha1": "d5ffd36e2e6199b7e3c63acbc94de5e114674c39", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01214", "original_id": null, "source": "apps", "domain": "code", "problem": "Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn them as soon as possible. There are n watchmen on a plane, the i-th watchman is located at point (x_{i}, y_{i}).\n\nThey need to arrange a plan, but there are some difficulties on their way. As you know, Doctor Manhattan considers the distance between watchmen i and j to be |x_{i} - x_{j}| + |y_{i} - y_{j}|. Daniel, as an ordinary person, calculates the distance using the formula $\\sqrt{(x_{i} - x_{j})^{2} +(y_{i} - y_{j})^{2}}$.\n\nThe success of the operation relies on the number of pairs (i, j) (1 ≤ i < j ≤ n), such that the distance between watchman i and watchmen j calculated by Doctor Manhattan is equal to the distance between them calculated by Daniel. You were asked to compute the number of such pairs.\n\n\n-----Input-----\n\nThe first line of the input contains the single integer n (1 ≤ n ≤ 200 000) — the number of watchmen.\n\nEach of the following n lines contains two integers x_{i} and y_{i} (|x_{i}|, |y_{i}| ≤ 10^9).\n\nSome positions may coincide.\n\n\n-----Output-----\n\nPrint the number of pairs of watchmen such that the distance between them calculated by Doctor Manhattan is equal to the distance calculated by Daniel.\n\n\n-----Examples-----\nInput\n3\n1 1\n7 5\n1 5\n\nOutput\n2\n\nInput\n6\n0 0\n0 1\n0 2\n-1 1\n0 1\n1 1\n\nOutput\n11\n\n\n\n-----Note-----\n\nIn the first sample, the distance between watchman 1 and watchman 2 is equal to |1 - 7| + |1 - 5| = 10 for Doctor Manhattan and $\\sqrt{(1 - 7)^{2} +(1 - 5)^{2}} = 2 \\cdot \\sqrt{13}$ for Daniel. For pairs (1, 1), (1, 5) and (7, 5), (1, 5) Doctor Manhattan and Daniel will calculate the same distances.", "starter_code": "", "test_cases": {"inputs": ["3\n1 1\n7 5\n1 5\n", "6\n0 0\n0 1\n0 2\n-1 1\n0 1\n1 1\n", "10\n46 -55\n46 45\n46 45\n83 -55\n46 45\n83 -55\n46 45\n83 45\n83 45\n46 -55\n", "1\n-5 -90\n", "2\n315 845\n-669 -762\n", "3\n8911 7861\n-6888 7861\n8911 7861\n", "2\n-1 1000000000\n0 -1\n", "2\n1000000000 0\n-7 1\n", "2\n1 4\n2 1\n", "2\n1 0\n0 2333333\n", "2\n2 1\n1 2\n", "2\n1 1000000000\n2 -1000000000\n", "2\n0 1000000000\n1 -7\n", "2\n1 0\n0 19990213\n"], "outputs": ["2\n", "11\n", "33\n", "0\n", "0\n", "3\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 14, "n_test_cases_kept": 14, "test_cases_truncated": false, "problem_sha1": "e1c2ba79e603d9f9188a1dc89acfceb66c6c1bca", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01219", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given an array $a$ consisting of $n$ non-negative integers. You have to choose a non-negative integer $x$ and form a new array $b$ of size $n$ according to the following rule: for all $i$ from $1$ to $n$, $b_i = a_i \\oplus x$ ($\\oplus$ denotes the operation bitwise XOR).\n\nAn inversion in the $b$ array is a pair of integers $i$ and $j$ such that $1 \\le i < j \\le n$ and $b_i > b_j$.\n\nYou should choose $x$ in such a way that the number of inversions in $b$ is minimized. If there are several options for $x$ — output the smallest one.\n\n\n-----Input-----\n\nFirst line contains a single integer $n$ ($1 \\le n \\le 3 \\cdot 10^5$) — the number of elements in $a$.\n\nSecond line contains $n$ space-separated integers $a_1$, $a_2$, ..., $a_n$ ($0 \\le a_i \\le 10^9$), where $a_i$ is the $i$-th element of $a$.\n\n\n-----Output-----\n\nOutput two integers: the minimum possible number of inversions in $b$, and the minimum possible value of $x$, which achieves those number of inversions.\n\n\n-----Examples-----\nInput\n4\n0 1 3 2\n\nOutput\n1 0\n\nInput\n9\n10 7 9 10 7 5 5 3 5\n\nOutput\n4 14\n\nInput\n3\n8 10 3\n\nOutput\n0 8\n\n\n\n-----Note-----\n\nIn the first sample it is optimal to leave the array as it is by choosing $x = 0$.\n\nIn the second sample the selection of $x = 14$ results in $b$: $[4, 9, 7, 4, 9, 11, 11, 13, 11]$. It has $4$ inversions:\n\n $i = 2$, $j = 3$; $i = 2$, $j = 4$; $i = 3$, $j = 4$; $i = 8$, $j = 9$. \n\nIn the third sample the selection of $x = 8$ results in $b$: $[0, 2, 11]$. It has no inversions.", "starter_code": "", "test_cases": {"inputs": ["4\n0 1 3 2\n", "9\n10 7 9 10 7 5 5 3 5\n", "3\n8 10 3\n", "5\n1000000000 1000000000 1000000000 0 0\n", "1\n0\n", "3\n2 24 18\n", "7\n23 18 5 10 29 33 36\n", "19\n1 32 25 40 18 32 5 23 38 1 35 24 39 26 0 9 26 37 0\n", "96\n79 50 37 49 30 58 90 41 77 73 31 10 8 57 73 90 86 73 72 5 43 15 11 2 59 31 38 66 19 63 33 17 14 16 44 3 99 89 11 43 14 86 10 37 1 100 84 81 57 88 37 80 65 11 18 91 18 94 76 26 73 47 49 73 21 60 69 20 72 7 5 86 95 11 93 30 84 37 34 7 15 24 95 79 47 87 64 40 2 24 49 36 83 25 71 17\n", "100\n74 88 64 8 9 27 63 64 79 97 92 38 26 1 4 4 2 64 53 62 24 82 76 40 48 58 40 59 3 56 35 37 0 30 93 71 14 97 49 37 96 59 56 55 70 88 77 99 51 55 71 25 10 31 26 50 61 18 35 55 49 33 86 25 65 74 89 99 5 27 2 9 67 29 76 68 66 22 68 59 63 16 62 25 35 57 63 35 41 68 86 22 91 67 61 3 92 46 96 74\n", "94\n89 100 92 24 4 85 63 87 88 94 68 14 61 59 5 77 82 6 13 13 25 43 80 67 29 42 89 35 72 81 35 0 12 35 53 54 63 37 52 33 11 84 64 33 65 58 89 37 59 32 23 92 14 12 30 61 5 78 39 73 21 37 64 50 10 97 12 94 20 65 63 41 86 60 47 72 79 65 31 56 23 5 85 44 4 34 66 1 92 91 60 43 18 58\n"], "outputs": ["1 0\n", "4 14\n", "0 8\n", "0 536870912\n", "0 0\n", "0 8\n", "3 16\n", "65 49\n", "2045 43\n", "2290 10\n", "1961 87\n"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 11, "n_test_cases_kept": 11, "test_cases_truncated": false, "problem_sha1": "1e657f77ecfb86af7c61c6dee8f26ac46dfd2987", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01224", "original_id": null, "source": "apps", "domain": "code", "problem": "Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days.\n\nIn Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day.\n\nDu will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu with fun factor $a_i$. But after that, he may be muzzled depending on Boboniu's mood. Otherwise, Du won't do anything. \n\nBoboniu's mood is a constant $m$. On the $i$-th day: If Du can speak and $a_i>m$, then Boboniu will be angry and muzzle him for $d$ days, which means that Du won't be able to speak on the $i+1, i+2, \\cdots, \\min(i+d,n)$-th days. Otherwise, Boboniu won't do anything. \n\nThe total fun factor is the sum of the fun factors on the days when Du can speak.\n\nDu asked you to find the maximum total fun factor among all possible permutations of $a$.\n\n\n-----Input-----\n\nThe first line contains three integers $n$, $d$ and $m$ ($1\\le d\\le n\\le 10^5,0\\le m\\le 10^9$).\n\nThe next line contains $n$ integers $a_1, a_2, \\ldots,a_n$ ($0\\le a_i\\le 10^9$).\n\n\n-----Output-----\n\nPrint one integer: the maximum total fun factor among all permutations of $a$.\n\n\n-----Examples-----\nInput\n5 2 11\n8 10 15 23 5\n\nOutput\n48\n\nInput\n20 2 16\n20 5 8 2 18 16 2 16 16 1 5 16 2 13 6 16 4 17 21 7\n\nOutput\n195\n\n\n\n-----Note-----\n\nIn the first example, you can set $a'=[15, 5, 8, 10, 23]$. Then Du's chatting record will be: Make fun of Boboniu with fun factor $15$. Be muzzled. Be muzzled. Make fun of Boboniu with fun factor $10$. Make fun of Boboniu with fun factor $23$. \n\nThus the total fun factor is $48$.", "starter_code": "", "test_cases": {"inputs": ["5 2 11\n8 10 15 23 5\n", "20 2 16\n20 5 8 2 18 16 2 16 16 1 5 16 2 13 6 16 4 17 21 7\n", "1 1 0\n0\n", "100 61 71\n11 18 0 47 33 75 91 13 8 21 73 64 50 97 62 50 2 36 68 32 64 74 32 77 81 41 23 44 40 36 45 33 21 68 57 79 75 23 67 37 99 27 30 56 75 62 75 63 46 19 79 42 11 66 21 25 2 12 89 48 75 7 57 85 80 14 82 29 66 47 29 10 1 84 79 39 33 81 73 51 80 67 52 25 38 68 57 53 38 83 83 3 86 29 50 46 3 68 88 10\n", "10 3 10\n17 17 17 8 7 6 5 4 1 1\n", "79 14 68\n55 91 81 39 60 85 43 53 41 12 23 70 26 61 51 92 52 23 78 41 20 49 38 57 86 77 59 74 86 12 8 79 32 70 69 43 78 37 88 71 22 0 21 21 30 3 76 87 98 52 83 66 79 60 56 31 19 89 73 81 79 16 76 79 94 23 65 7 53 81 21 63 11 31 35 17 31 65 89\n", "39 37 39\n38 56 198 166 86 51 13 54 101 143 82 138 122 146 86 198 81 177 92 56 107 58 124 82 41 126 79 47 191 41 188 108 38 12 18 57 68 134 79\n", "4 4 8\n84 25 75 21\n", "5 3 3\n8 5 5 1 14\n", "1 1 1\n2\n"], "outputs": ["48\n", "195\n", "0\n", "2765\n", "64\n", "2038\n", "396\n", "84\n", "22\n", "2\n"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 10, "n_test_cases_kept": 10, "test_cases_truncated": false, "problem_sha1": "31b8d0b8ee49e0c7316bd785058d73821d74dcb8", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01229", "original_id": null, "source": "apps", "domain": "code", "problem": "Everybody seems to think that the Martians are green, but it turns out they are metallic pink and fat. Ajs has two bags of distinct nonnegative integers. The bags are disjoint, and the union of the sets of numbers in the bags is $\\{0,1,…,M-1\\}$, for some positive integer $M$. Ajs draws a number from the first bag and a number from the second bag, and then sums them modulo $M$.\n\nWhat are the residues modulo $M$ that Ajs cannot obtain with this action?\n\n\n-----Input-----\n\nThe first line contains two positive integer $N$ ($1 \\leq N \\leq 200\\,000$) and $M$ ($N+1 \\leq M \\leq 10^{9}$), denoting the number of the elements in the first bag and the modulus, respectively.\n\nThe second line contains $N$ nonnegative integers $a_1,a_2,\\ldots,a_N$ ($0 \\leq a_1 str:\n ", "test_cases": {"inputs": [["\"Let's take LeetCode contest\""]], "outputs": ["s'teL\" ekat edoCteeL \"tsetnoc"], "fn_name": "reverseWords"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "e28cdd62c4a575f7e10dc61358600a5cc2ab6279", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "reverseWords"} {"seed_id": "apps-01289", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an integer number n, return the difference between the product of its digits and the sum of its digits.\n \nExample 1:\nInput: n = 234\nOutput: 15 \nExplanation: \nProduct of digits = 2 * 3 * 4 = 24 \nSum of digits = 2 + 3 + 4 = 9 \nResult = 24 - 9 = 15\n\nExample 2:\nInput: n = 4421\nOutput: 21\nExplanation: \nProduct of digits = 4 * 4 * 2 * 1 = 32 \nSum of digits = 4 + 4 + 2 + 1 = 11 \nResult = 32 - 11 = 21\n\n \nConstraints:\n\n1 <= n <= 10^5", "starter_code": "\nclass Solution:\n def subtractProductAndSum(self, n: int) -> int:\n ", "test_cases": {"inputs": [[234]], "outputs": [15], "fn_name": "subtractProductAndSum"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "4342d97c4ddf21002d5822b77e1ad0e21d7d47ee", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "subtractProductAndSum"} {"seed_id": "apps-01294", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a string S of lowercase letters, a duplicate removal consists of choosing two adjacent and equal letters, and removing them.\nWe repeatedly make duplicate removals on S until we no longer can.\nReturn the final string after all such duplicate removals have been made.  It is guaranteed the answer is unique.\n \nExample 1:\nInput: \"abbaca\"\nOutput: \"ca\"\nExplanation: \nFor example, in \"abbaca\" we could remove \"bb\" since the letters are adjacent and equal, and this is the only possible move.  The result of this move is that the string is \"aaca\", of which only \"aa\" is possible, so the final string is \"ca\".\n\n \nNote:\n\n1 <= S.length <= 20000\nS consists only of English lowercase letters.", "starter_code": "\nclass Solution:\n def removeDuplicates(self, S: str) -> str:\n ", "test_cases": {"inputs": [["\"abbaca\""]], "outputs": ["\"ca\""], "fn_name": "removeDuplicates"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "c27a114b6c3eef983dcd5a85d2479194c5326519", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "removeDuplicates"} {"seed_id": "apps-01299", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array of integers, find if the array contains any duplicates.\n\nYour function should return true if any value appears at least twice in the array, and it should return false if every element is distinct.\n\nExample 1:\n\n\nInput: [1,2,3,1]\nOutput: true\n\nExample 2:\n\n\nInput: [1,2,3,4]\nOutput: false\n\nExample 3:\n\n\nInput: [1,1,1,3,3,4,3,2,4,2]\nOutput: true", "starter_code": "\nclass Solution:\n def containsDuplicate(self, nums: List[int]) -> bool:\n ", "test_cases": {"inputs": [[[1, 2, 3, 1]]], "outputs": [true], "fn_name": "containsDuplicate"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "f2bdac500d999eed813be6e0ba418c422007ca55", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "containsDuplicate"} {"seed_id": "apps-01304", "original_id": null, "source": "apps", "domain": "code", "problem": "Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters.\n\nPlease note that the string does not contain any non-printable characters.\n\nExample:\n\nInput: \"Hello, my name is John\"\nOutput: 5", "starter_code": "\nclass Solution:\n def countSegments(self, s: str) -> int:\n ", "test_cases": {"inputs": [["\"Hello, my name is John\""]], "outputs": [5], "fn_name": "countSegments"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "5847ffec0e8bf7d1ceaaf671f3aeafcf0ea9754d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "countSegments"} {"seed_id": "apps-01309", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an integer pair (i, j), where i and j are both numbers in the array and their absolute difference is k.\n\n\n\nExample 1:\n\nInput: [3, 1, 4, 1, 5], k = 2\nOutput: 2\nExplanation: There are two 2-diff pairs in the array, (1, 3) and (3, 5).Although we have two 1s in the input, we should only return the number of unique pairs.\n\n\n\nExample 2:\n\nInput:[1, 2, 3, 4, 5], k = 1\nOutput: 4\nExplanation: There are four 1-diff pairs in the array, (1, 2), (2, 3), (3, 4) and (4, 5).\n\n\n\nExample 3:\n\nInput: [1, 3, 1, 5, 4], k = 0\nOutput: 1\nExplanation: There is one 0-diff pair in the array, (1, 1).\n\n\n\nNote:\n\nThe pairs (i, j) and (j, i) count as the same pair.\nThe length of the array won't exceed 10,000.\nAll the integers in the given input belong to the range: [-1e7, 1e7].", "starter_code": "\nclass Solution:\n def findPairs(self, nums: List[int], k: int) -> int:\n ", "test_cases": {"inputs": [[[3, 1, 4, 1, 5], 2]], "outputs": [2], "fn_name": "findPairs"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "49575b3e14bef1d6395641117cac30f0f1261cc2", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "findPairs"} {"seed_id": "apps-01314", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array of positive integers arr,  find a pattern of length m that is repeated k or more times.\nA pattern is a subarray (consecutive sub-sequence) that consists of one or more values, repeated multiple times consecutively without overlapping. A pattern is defined by its length and the number of repetitions.\nReturn true if there exists a pattern of length m that is repeated k or more times, otherwise return false.\n \nExample 1:\nInput: arr = [1,2,4,4,4,4], m = 1, k = 3\nOutput: true\nExplanation: The pattern (4) of length 1 is repeated 4 consecutive times. Notice that pattern can be repeated k or more times but not less.\n\nExample 2:\nInput: arr = [1,2,1,2,1,1,1,3], m = 2, k = 2\nOutput: true\nExplanation: The pattern (1,2) of length 2 is repeated 2 consecutive times. Another valid pattern (2,1) is also repeated 2 times.\n\nExample 3:\nInput: arr = [1,2,1,2,1,3], m = 2, k = 3\nOutput: false\nExplanation: The pattern (1,2) is of length 2 but is repeated only 2 times. There is no pattern of length 2 that is repeated 3 or more times.\n\nExample 4:\nInput: arr = [1,2,3,1,2], m = 2, k = 2\nOutput: false\nExplanation: Notice that the pattern (1,2) exists twice but not consecutively, so it doesn't count.\n\nExample 5:\nInput: arr = [2,2,2,2], m = 2, k = 3\nOutput: false\nExplanation: The only pattern of length 2 is (2,2) however it's repeated only twice. Notice that we do not count overlapping repetitions.\n\n \nConstraints:\n\n2 <= arr.length <= 100\n1 <= arr[i] <= 100\n1 <= m <= 100\n2 <= k <= 100", "starter_code": "\nclass Solution:\n def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n ", "test_cases": {"inputs": [[[1, 2, 4, 4, 4, 4], 1, 3]], "outputs": [true], "fn_name": "containsPattern"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "7aa81a00516a45575e44c4ad461e0f38f85488c2", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "containsPattern"} {"seed_id": "apps-01319", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a string s. You should re-order the string using the following algorithm:\n\nPick the smallest character from s and append it to the result.\nPick the smallest character from s which is greater than the last appended character to the result and append it.\nRepeat step 2 until you cannot pick more characters.\nPick the largest character from s and append it to the result.\nPick the largest character from s which is smaller than the last appended character to the result and append it.\nRepeat step 5 until you cannot pick more characters.\nRepeat the steps from 1 to 6 until you pick all characters from s.\n\nIn each step, If the smallest or the largest character appears more than once you can choose any occurrence and append it to the result.\nReturn the result string after sorting s with this algorithm.\n \nExample 1:\nInput: s = \"aaaabbbbcccc\"\nOutput: \"abccbaabccba\"\nExplanation: After steps 1, 2 and 3 of the first iteration, result = \"abc\"\nAfter steps 4, 5 and 6 of the first iteration, result = \"abccba\"\nFirst iteration is done. Now s = \"aabbcc\" and we go back to step 1\nAfter steps 1, 2 and 3 of the second iteration, result = \"abccbaabc\"\nAfter steps 4, 5 and 6 of the second iteration, result = \"abccbaabccba\"\n\nExample 2:\nInput: s = \"rat\"\nOutput: \"art\"\nExplanation: The word \"rat\" becomes \"art\" after re-ordering it with the mentioned algorithm.\n\nExample 3:\nInput: s = \"leetcode\"\nOutput: \"cdelotee\"\n\nExample 4:\nInput: s = \"ggggggg\"\nOutput: \"ggggggg\"\n\nExample 5:\nInput: s = \"spo\"\nOutput: \"ops\"\n\n \nConstraints:\n\n1 <= s.length <= 500\ns contains only lower-case English letters.", "starter_code": "\nclass Solution:\n def sortString(self, s: str) -> str:\n ", "test_cases": {"inputs": [["\"aaaabbbbcccc\""]], "outputs": ["\"abccba\"abccba"], "fn_name": "sortString"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "aad03352a4b8110df796cf11521a66c54381db68", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "sortString"} {"seed_id": "apps-01324", "original_id": null, "source": "apps", "domain": "code", "problem": "Write a function that takes a string as input and reverse only the vowels of a string.\n\n\nExample 1:\nGiven s = \"hello\", return \"holle\".\n\n\n\nExample 2:\nGiven s = \"leetcode\", return \"leotcede\".\n\n\n\nNote:\nThe vowels does not include the letter \"y\".", "starter_code": "\nclass Solution:\n def reverseVowels(self, s: str) -> str:\n ", "test_cases": {"inputs": [["\"hello\""]], "outputs": ["\"holle\""], "fn_name": "reverseVowels"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "36626b58861b53ae7a765fa50ccae2b82ecbcca0", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "reverseVowels"} {"seed_id": "apps-01329", "original_id": null, "source": "apps", "domain": "code", "problem": "We have a collection of stones, each stone has a positive integer weight.\nEach turn, we choose the two heaviest stones and smash them together.  Suppose the stones have weights x and y with x <= y.  The result of this smash is:\n\nIf x == y, both stones are totally destroyed;\nIf x != y, the stone of weight x is totally destroyed, and the stone of weight y has new weight y-x.\n\nAt the end, there is at most 1 stone left.  Return the weight of this stone (or 0 if there are no stones left.)\n \nExample 1:\nInput: [2,7,4,1,8,1]\nOutput: 1\nExplanation: \nWe combine 7 and 8 to get 1 so the array converts to [2,4,1,1,1] then,\nwe combine 2 and 4 to get 2 so the array converts to [2,1,1,1] then,\nwe combine 2 and 1 to get 1 so the array converts to [1,1,1] then,\nwe combine 1 and 1 to get 0 so the array converts to [1] then that's the value of last stone.\n \nNote:\n\n1 <= stones.length <= 30\n1 <= stones[i] <= 1000", "starter_code": "\nclass Solution:\n def lastStoneWeight(self, stones: List[int]) -> int:\n ", "test_cases": {"inputs": [[[2, 7, 4, 1, 8, 1]]], "outputs": [1], "fn_name": "lastStoneWeight"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "06cd947d21747ea7485c5f647ac1491bd587b808", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "lastStoneWeight"} {"seed_id": "apps-01334", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.\n\nWe define the pivot index as the index where the sum of the numbers to the left of the index is equal to the sum of the numbers to the right of the index.\n\nIf no such index exists, we should return -1. If there are multiple pivot indexes, you should return the left-most pivot index.\n\n\nExample 1:\n\nInput: \nnums = [1, 7, 3, 6, 5, 6]\nOutput: 3\nExplanation: \nThe sum of the numbers to the left of index 3 (nums[3] = 6) is equal to the sum of numbers to the right of index 3.\nAlso, 3 is the first index where this occurs.\n\n\n\nExample 2:\n\nInput: \nnums = [1, 2, 3]\nOutput: -1\nExplanation: \nThere is no index that satisfies the conditions in the problem statement.\n\n\n\nNote:\nThe length of nums will be in the range [0, 10000].\nEach element nums[i] will be an integer in the range [-1000, 1000].", "starter_code": "\nclass Solution:\n def pivotIndex(self, nums: List[int]) -> int:\n ", "test_cases": {"inputs": [[[1, 7, 3, 6, 5, 6]]], "outputs": [3], "fn_name": "pivotIndex"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "75795c0076d6adbd453055170cccb3792850034d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "pivotIndex"} {"seed_id": "apps-01339", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a column title as appear in an Excel sheet, return its corresponding column number.\n\nFor example:\n\n\n A -> 1\n B -> 2\n C -> 3\n ...\n Z -> 26\n AA -> 27\n AB -> 28 \n ...\n\n\nExample 1:\n\n\nInput: \"A\"\nOutput: 1\n\n\nExample 2:\n\n\nInput: \"AB\"\nOutput: 28\n\n\nExample 3:\n\n\nInput: \"ZY\"\nOutput: 701", "starter_code": "\nclass Solution:\n def titleToNumber(self, s: str) -> int:\n ", "test_cases": {"inputs": [["\"A\""]], "outputs": [-20284], "fn_name": "titleToNumber"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "643bb843164a87cbd199f0903d58902692685d52", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "titleToNumber"} {"seed_id": "apps-01344", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array arr of integers, check if there exists two integers N and M such that N is the double of M ( i.e. N = 2 * M).\nMore formally check if there exists two indices i and j such that :\n\ni != j\n0 <= i, j < arr.length\narr[i] == 2 * arr[j]\n\n \nExample 1:\nInput: arr = [10,2,5,3]\nOutput: true\nExplanation: N = 10 is the double of M = 5,that is, 10 = 2 * 5.\n\nExample 2:\nInput: arr = [7,1,14,11]\nOutput: true\nExplanation: N = 14 is the double of M = 7,that is, 14 = 2 * 7.\n\nExample 3:\nInput: arr = [3,1,7,11]\nOutput: false\nExplanation: In this case does not exist N and M, such that N = 2 * M.\n\n \nConstraints:\n\n2 <= arr.length <= 500\n-10^3 <= arr[i] <= 10^3", "starter_code": "\nclass Solution:\n def checkIfExist(self, arr: List[int]) -> bool:\n ", "test_cases": {"inputs": [[[10, 2, 5, 3]]], "outputs": [true], "fn_name": "checkIfExist"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "c6d12c75b4bc2d3aa6673a995db003507be7b918", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "checkIfExist"} {"seed_id": "apps-01349", "original_id": null, "source": "apps", "domain": "code", "problem": "We are given an array A of N lowercase letter strings, all of the same length.\nNow, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices.\nFor example, if we have an array A = [\"abcdef\",\"uvwxyz\"] and deletion indices {0, 2, 3}, then the final array after deletions is [\"bef\", \"vyz\"], and the remaining columns of A are [\"b\",\"v\"], [\"e\",\"y\"], and [\"f\",\"z\"].  (Formally, the c-th column is [A[0][c], A[1][c], ..., A[A.length-1][c]]).\nSuppose we chose a set of deletion indices D such that after deletions, each remaining column in A is in non-decreasing sorted order.\nReturn the minimum possible value of D.length.\n \nExample 1:\nInput: A = [\"cba\",\"daf\",\"ghi\"]\nOutput: 1\nExplanation: \nAfter choosing D = {1}, each column [\"c\",\"d\",\"g\"] and [\"a\",\"f\",\"i\"] are in non-decreasing sorted order.\nIf we chose D = {}, then a column [\"b\",\"a\",\"h\"] would not be in non-decreasing sorted order.\n\nExample 2:\nInput: A = [\"a\",\"b\"]\nOutput: 0\nExplanation: D = {}\n\nExample 3:\nInput: A = [\"zyx\",\"wvu\",\"tsr\"]\nOutput: 3\nExplanation: D = {0, 1, 2}\n\n \nConstraints:\n\n1 <= A.length <= 100\n1 <= A[i].length <= 1000", "starter_code": "\nclass Solution:\n def minDeletionSize(self, A: List[str]) -> int:\n ", "test_cases": {"inputs": [[["\"cba\"", "\"daf\"", "\"ghi\""]]], "outputs": [1], "fn_name": "minDeletionSize"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "fdfccf619ae066c62cfb34b0a568052a00687b0b", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "minDeletionSize"} {"seed_id": "apps-01354", "original_id": null, "source": "apps", "domain": "code", "problem": "We have n chips, where the position of the ith chip is position[i].\nWe need to move all the chips to the same position. In one step, we can change the position of the ith chip from position[i] to:\n\nposition[i] + 2 or position[i] - 2 with cost = 0.\nposition[i] + 1 or position[i] - 1 with cost = 1.\n\nReturn the minimum cost needed to move all the chips to the same position.\n \nExample 1:\n\nInput: position = [1,2,3]\nOutput: 1\nExplanation: First step: Move the chip at position 3 to position 1 with cost = 0.\nSecond step: Move the chip at position 2 to position 1 with cost = 1.\nTotal cost is 1.\n\nExample 2:\n\nInput: position = [2,2,2,3,3]\nOutput: 2\nExplanation: We can move the two chips at poistion 3 to position 2. Each move has cost = 1. The total cost = 2.\n\nExample 3:\nInput: position = [1,1000000000]\nOutput: 1\n\n \nConstraints:\n\n1 <= position.length <= 100\n1 <= position[i] <= 10^9", "starter_code": "\nclass Solution:\n def minCostToMoveChips(self, position: List[int]) -> int:\n ", "test_cases": {"inputs": [[[1, 2, 3]]], "outputs": [1], "fn_name": "minCostToMoveChips"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "3a8447b558b324f74487c7aa7e41b1a70c309ba5", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "minCostToMoveChips"} {"seed_id": "apps-01359", "original_id": null, "source": "apps", "domain": "code", "problem": "Given two non-negative integers low and high. Return the count of odd numbers between low and high (inclusive).\n \nExample 1:\nInput: low = 3, high = 7\nOutput: 3\nExplanation: The odd numbers between 3 and 7 are [3,5,7].\nExample 2:\nInput: low = 8, high = 10\nOutput: 1\nExplanation: The odd numbers between 8 and 10 are [9].\n \nConstraints:\n\n0 <= low <= high <= 10^9", "starter_code": "\nclass Solution:\n def countOdds(self, low: int, high: int) -> int:\n ", "test_cases": {"inputs": [[3, 7]], "outputs": [3], "fn_name": "countOdds"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "820916fa0e1aff37f0d8b841119c76a8c1000364", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "countOdds"} {"seed_id": "apps-01364", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an integer n and an integer start.\nDefine an array nums where nums[i] = start + 2*i (0-indexed) and n == nums.length.\nReturn the bitwise XOR of all elements of nums.\n \nExample 1:\nInput: n = 5, start = 0\nOutput: 8\nExplanation: Array nums is equal to [0, 2, 4, 6, 8] where (0 ^ 2 ^ 4 ^ 6 ^ 8) = 8.\nWhere \"^\" corresponds to bitwise XOR operator.\n\nExample 2:\nInput: n = 4, start = 3\nOutput: 8\nExplanation: Array nums is equal to [3, 5, 7, 9] where (3 ^ 5 ^ 7 ^ 9) = 8.\nExample 3:\nInput: n = 1, start = 7\nOutput: 7\n\nExample 4:\nInput: n = 10, start = 5\nOutput: 2\n\n \nConstraints:\n\n1 <= n <= 1000\n0 <= start <= 1000\nn == nums.length", "starter_code": "\nclass Solution:\n def xorOperation(self, n: int, start: int) -> int:\n ", "test_cases": {"inputs": [[5, 0]], "outputs": [8], "fn_name": "xorOperation"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "30f2c56c9be2a71a82d62cb2f45777498e0fe6af", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "xorOperation"} {"seed_id": "apps-01369", "original_id": null, "source": "apps", "domain": "code", "problem": "Given two integer arrays of equal length target and arr.\nIn one step, you can select any non-empty sub-array of arr and reverse it. You are allowed to make any number of steps.\nReturn True if you can make arr equal to target, or False otherwise.\n \nExample 1:\nInput: target = [1,2,3,4], arr = [2,4,1,3]\nOutput: true\nExplanation: You can follow the next steps to convert arr to target:\n1- Reverse sub-array [2,4,1], arr becomes [1,4,2,3]\n2- Reverse sub-array [4,2], arr becomes [1,2,4,3]\n3- Reverse sub-array [4,3], arr becomes [1,2,3,4]\nThere are multiple ways to convert arr to target, this is not the only way to do so.\n\nExample 2:\nInput: target = [7], arr = [7]\nOutput: true\nExplanation: arr is equal to target without any reverses.\n\nExample 3:\nInput: target = [1,12], arr = [12,1]\nOutput: true\n\nExample 4:\nInput: target = [3,7,9], arr = [3,7,11]\nOutput: false\nExplanation: arr doesn't have value 9 and it can never be converted to target.\n\nExample 5:\nInput: target = [1,1,1,1,1], arr = [1,1,1,1,1]\nOutput: true\n\n \nConstraints:\n\ntarget.length == arr.length\n1 <= target.length <= 1000\n1 <= target[i] <= 1000\n1 <= arr[i] <= 1000", "starter_code": "\nclass Solution:\n def canBeEqual(self, target: List[int], arr: List[int]) -> bool:\n ", "test_cases": {"inputs": [[[1, 2, 3, 4], [2, 4, 1, 3]]], "outputs": [true], "fn_name": "canBeEqual"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "9a01143efdf93b694073b4618992bb34695410db", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "canBeEqual"} {"seed_id": "apps-01374", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a string s, the power of the string is the maximum length of a non-empty substring that contains only one unique character.\nReturn the power of the string.\n \nExample 1:\nInput: s = \"leetcode\"\nOutput: 2\nExplanation: The substring \"ee\" is of length 2 with the character 'e' only.\n\nExample 2:\nInput: s = \"abbcccddddeeeeedcba\"\nOutput: 5\nExplanation: The substring \"eeeee\" is of length 5 with the character 'e' only.\n\nExample 3:\nInput: s = \"triplepillooooow\"\nOutput: 5\n\nExample 4:\nInput: s = \"hooraaaaaaaaaaay\"\nOutput: 11\n\nExample 5:\nInput: s = \"tourist\"\nOutput: 1\n\n \nConstraints:\n\n1 <= s.length <= 500\ns contains only lowercase English letters.", "starter_code": "\nclass Solution:\n def maxPower(self, s: str) -> int:\n ", "test_cases": {"inputs": [["\"leetcode\""]], "outputs": [2], "fn_name": "maxPower"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "88cec1448acdc961fe2caba5173a96eca7b00613", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "maxPower"} {"seed_id": "apps-01379", "original_id": null, "source": "apps", "domain": "code", "problem": "An axis-aligned rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) is the coordinate of its bottom-left corner, and (x2, y2) is the coordinate of its top-right corner. Its top and bottom edges are parallel to the X-axis, and its left and right edges are parallel to the Y-axis.\nTwo rectangles overlap if the area of their intersection is positive. To be clear, two rectangles that only touch at the corner or edges do not overlap.\nGiven two axis-aligned rectangles rec1 and rec2, return true if they overlap, otherwise return false.\n \nExample 1:\nInput: rec1 = [0,0,2,2], rec2 = [1,1,3,3]\nOutput: true\nExample 2:\nInput: rec1 = [0,0,1,1], rec2 = [1,0,2,1]\nOutput: false\nExample 3:\nInput: rec1 = [0,0,1,1], rec2 = [2,2,3,3]\nOutput: false\n\n \nConstraints:\n\nrect1.length == 4\nrect2.length == 4\n-109 <= rec1[i], rec2[i] <= 109\nrec1[0] <= rec1[2] and rec1[1] <= rec1[3]\nrec2[0] <= rec2[2] and rec2[1] <= rec2[3]", "starter_code": "\nclass Solution:\n def isRectangleOverlap(self, rec1: List[int], rec2: List[int]) -> bool:\n ", "test_cases": {"inputs": [[[0, 0, 2, 2], [1, 1, 3, 3]]], "outputs": [true], "fn_name": "isRectangleOverlap"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "6cecc40fc1c39ca78bdfa0099a859bfa6a96f209", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "isRectangleOverlap"} {"seed_id": "apps-01384", "original_id": null, "source": "apps", "domain": "code", "problem": "You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the winner. You will take the first turn to remove the stones.\n\nBoth of you are very clever and have optimal strategies for the game. Write a function to determine whether you can win the game given the number of stones in the heap.\n\nExample:\n\n\nInput: 4\nOutput: false \nExplanation: If there are 4 stones in the heap, then you will never win the game;\n  No matter 1, 2, or 3 stones you remove, the last stone will always be \n  removed by your friend.", "starter_code": "\nclass Solution:\n def canWinNim(self, n: int) -> bool:\n ", "test_cases": {"inputs": [[4]], "outputs": [false], "fn_name": "canWinNim"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "12ac1870c8e84ec2e56df8fe5b13bd7732d41b79", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "canWinNim"} {"seed_id": "apps-01389", "original_id": null, "source": "apps", "domain": "code", "problem": "A sentence S is given, composed of words separated by spaces. Each word consists of lowercase and uppercase letters only.\nWe would like to convert the sentence to \"Goat Latin\" (a made-up language similar to Pig Latin.)\nThe rules of Goat Latin are as follows:\n\nIf a word begins with a vowel (a, e, i, o, or u), append \"ma\" to the end of the word.\n For example, the word 'apple' becomes 'applema'.\n  \nIf a word begins with a consonant (i.e. not a vowel), remove the first letter and append it to the end, then add \"ma\".\n For example, the word \"goat\" becomes \"oatgma\".\n  \nAdd one letter 'a' to the end of each word per its word index in the sentence, starting with 1.\n For example, the first word gets \"a\" added to the end, the second word gets \"aa\" added to the end and so on.\n\nReturn the final sentence representing the conversion from S to Goat Latin. \n \nExample 1:\nInput: \"I speak Goat Latin\"\nOutput: \"Imaa peaksmaaa oatGmaaaa atinLmaaaaa\"\n\nExample 2:\nInput: \"The quick brown fox jumped over the lazy dog\"\nOutput: \"heTmaa uickqmaaa rownbmaaaa oxfmaaaaa umpedjmaaaaaa overmaaaaaaa hetmaaaaaaaa azylmaaaaaaaaa ogdmaaaaaaaaaa\"\n\n \nNotes:\n\nS contains only uppercase, lowercase and spaces. Exactly one space between each word.\n1 <= S.length <= 150.", "starter_code": "\nclass Solution:\n def toGoatLatin(self, S: str) -> str:\n ", "test_cases": {"inputs": [["\"I speak Goat Latin\""]], "outputs": ["I\"maa peaksmaaa oatGmaaaa atin\"Lmaaaaa"], "fn_name": "toGoatLatin"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "e814d638118f95b9462cff884cffa22ee04f3d4f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "toGoatLatin"} {"seed_id": "apps-01394", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a 32-bit signed integer, reverse digits of an integer.\n\nExample 1:\n\n\nInput: 123\nOutput: 321\n\n\nExample 2:\n\n\nInput: -123\nOutput: -321\n\n\nExample 3:\n\n\nInput: 120\nOutput: 21\n\n\nNote:\nAssume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231,  231 − 1]. For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows.", "starter_code": "\nclass Solution:\n def reverse(self, x: int) -> int:\n ", "test_cases": {"inputs": [[123]], "outputs": [321], "fn_name": "reverse"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "08a40f7274c3f89b1c553da5231223d70b0df03d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "reverse"} {"seed_id": "apps-01399", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an integer n, return the number of trailing zeroes in n!.\n\nExample 1:\n\n\nInput: 3\nOutput: 0\nExplanation: 3! = 6, no trailing zero.\n\nExample 2:\n\n\nInput: 5\nOutput: 1\nExplanation: 5! = 120, one trailing zero.\n\nNote: Your solution should be in logarithmic time complexity.", "starter_code": "\nclass Solution:\n def trailingZeroes(self, n: int) -> int:\n ", "test_cases": {"inputs": [[3]], "outputs": [0], "fn_name": "trailingZeroes"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "bb9390a405a063db022f778324107d36c6093d83", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "trailingZeroes"} {"seed_id": "apps-01404", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an integer n, add a dot (\".\") as the thousands separator and return it in string format.\n \nExample 1:\nInput: n = 987\nOutput: \"987\"\n\nExample 2:\nInput: n = 1234\nOutput: \"1.234\"\n\nExample 3:\nInput: n = 123456789\nOutput: \"123.456.789\"\n\nExample 4:\nInput: n = 0\nOutput: \"0\"\n\n \nConstraints:\n\n0 <= n < 2^31", "starter_code": "\nclass Solution:\n def thousandSeparator(self, n: int) -> str:\n ", "test_cases": {"inputs": [[987]], "outputs": ["987"], "fn_name": "thousandSeparator"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "8b57a5d12727b4756bfa3dbd840fefcaf8573a76", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "thousandSeparator"} {"seed_id": "apps-01409", "original_id": null, "source": "apps", "domain": "code", "problem": "A bus has n stops numbered from 0 to n - 1 that form a circle. We know the distance between all pairs of neighboring stops where distance[i] is the distance between the stops number i and (i + 1) % n.\nThe bus goes along both directions i.e. clockwise and counterclockwise.\nReturn the shortest distance between the given start and destination stops.\n \nExample 1:\n\nInput: distance = [1,2,3,4], start = 0, destination = 1\nOutput: 1\nExplanation: Distance between 0 and 1 is 1 or 9, minimum is 1.\n \nExample 2:\n\nInput: distance = [1,2,3,4], start = 0, destination = 2\nOutput: 3\nExplanation: Distance between 0 and 2 is 3 or 7, minimum is 3.\n\n \nExample 3:\n\nInput: distance = [1,2,3,4], start = 0, destination = 3\nOutput: 4\nExplanation: Distance between 0 and 3 is 6 or 4, minimum is 4.\n\n \nConstraints:\n\n1 <= n <= 10^4\ndistance.length == n\n0 <= start, destination < n\n0 <= distance[i] <= 10^4", "starter_code": "\nclass Solution:\n def distanceBetweenBusStops(self, distance: List[int], start: int, destination: int) -> int:\n ", "test_cases": {"inputs": [[[1, 2, 3, 4], 0, 1]], "outputs": [1], "fn_name": "distanceBetweenBusStops"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "365c9a6c100eeb303f1bb2d75a4c0ffe8fda95bd", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "distanceBetweenBusStops"} {"seed_id": "apps-01414", "original_id": null, "source": "apps", "domain": "code", "problem": "An array is monotonic if it is either monotone increasing or monotone decreasing.\nAn array A is monotone increasing if for all i <= j, A[i] <= A[j].  An array A is monotone decreasing if for all i <= j, A[i] >= A[j].\nReturn true if and only if the given array A is monotonic.\n \n\n\n\nExample 1:\nInput: [1,2,2,3]\nOutput: true\n\n\nExample 2:\nInput: [6,5,4,4]\nOutput: true\n\n\nExample 3:\nInput: [1,3,2]\nOutput: false\n\n\nExample 4:\nInput: [1,2,4,5]\nOutput: true\n\n\nExample 5:\nInput: [1,1,1]\nOutput: true\n\n \nNote:\n\n1 <= A.length <= 50000\n-100000 <= A[i] <= 100000", "starter_code": "\nclass Solution:\n def isMonotonic(self, A: List[int]) -> bool:\n ", "test_cases": {"inputs": [[[1, 2, 2, 3]]], "outputs": [true], "fn_name": "isMonotonic"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "88e6176a050757f13c7c5850e661544a658c344a", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "isMonotonic"} {"seed_id": "apps-01419", "original_id": null, "source": "apps", "domain": "code", "problem": "Write a program to check whether a given number is an ugly number.\n\nUgly numbers are positive numbers whose prime factors only include 2, 3, 5.\n\nExample 1:\n\n\nInput: 6\nOutput: true\nExplanation: 6 = 2 × 3\n\nExample 2:\n\n\nInput: 8\nOutput: true\nExplanation: 8 = 2 × 2 × 2\n\n\nExample 3:\n\n\nInput: 14\nOutput: false \nExplanation: 14 is not ugly since it includes another prime factor 7.\n\n\nNote:\n\n\n 1 is typically treated as an ugly number.\n Input is within the 32-bit signed integer range: [−231,  231 − 1].", "starter_code": "\nclass Solution:\n def isUgly(self, num: int) -> bool:\n ", "test_cases": {"inputs": [[6]], "outputs": [true], "fn_name": "isUgly"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "5fe382c18ce39be03696237d21c1aa32692cf5d6", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "isUgly"} {"seed_id": "apps-01424", "original_id": null, "source": "apps", "domain": "code", "problem": "Return the number of permutations of 1 to n so that prime numbers are at prime indices (1-indexed.)\n(Recall that an integer is prime if and only if it is greater than 1, and cannot be written as a product of two positive integers both smaller than it.)\nSince the answer may be large, return the answer modulo 10^9 + 7.\n \nExample 1:\nInput: n = 5\nOutput: 12\nExplanation: For example [1,2,5,4,3] is a valid permutation, but [5,2,3,4,1] is not because the prime number 5 is at index 1.\n\nExample 2:\nInput: n = 100\nOutput: 682289015\n\n \nConstraints:\n\n1 <= n <= 100", "starter_code": "\nclass Solution:\n def numPrimeArrangements(self, n: int) -> int:\n ", "test_cases": {"inputs": [[5]], "outputs": [12], "fn_name": "numPrimeArrangements"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "8e92b3cc9674f8dbad3f6e1245d9872295a00d6b", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "numPrimeArrangements"} {"seed_id": "apps-01429", "original_id": null, "source": "apps", "domain": "code", "problem": "=====Problem Statement=====\nYou are given an integer, N. Your task is to print an alphabet rangoli of size N. (Rangoli is a form of Indian folk art based on creation of patterns.)\n\nDifferent sizes of alphabet rangoli are shown below:\n\n#size 3\n\n----c----\n--c-b-c--\nc-b-a-b-c\n--c-b-c--\n----c----\n\n#size 5\n\n--------e--------\n------e-d-e------\n----e-d-c-d-e----\n--e-d-c-b-c-d-e--\ne-d-c-b-a-b-c-d-e\n--e-d-c-b-c-d-e--\n----e-d-c-d-e----\n------e-d-e------\n--------e--------\n\n#size 10\n\n------------------j------------------\n----------------j-i-j----------------\n--------------j-i-h-i-j--------------\n------------j-i-h-g-h-i-j------------\n----------j-i-h-g-f-g-h-i-j----------\n--------j-i-h-g-f-e-f-g-h-i-j--------\n------j-i-h-g-f-e-d-e-f-g-h-i-j------\n----j-i-h-g-f-e-d-c-d-e-f-g-h-i-j----\n--j-i-h-g-f-e-d-c-b-c-d-e-f-g-h-i-j--\nj-i-h-g-f-e-d-c-b-a-b-c-d-e-f-g-h-i-j\n--j-i-h-g-f-e-d-c-b-c-d-e-f-g-h-i-j--\n----j-i-h-g-f-e-d-c-d-e-f-g-h-i-j----\n------j-i-h-g-f-e-d-e-f-g-h-i-j------\n--------j-i-h-g-f-e-f-g-h-i-j--------\n----------j-i-h-g-f-g-h-i-j----------\n------------j-i-h-g-h-i-j------------\n--------------j-i-h-i-j--------------\n----------------j-i-j----------------\n------------------j------------------\n\nThe center of the rangoli has the first alphabet letter a, and the boundary has the Nth alphabet letter (in alphabetical order).\n\n=====Input Format=====\nOnly one line of input containing N, the size of the rangoli.\n\n=====Constraints=====\n0 < N < 27\n\n=====Output Format=====\nPrint the alphabet rangoli in the format explained above.", "starter_code": "\ndef print_rangoli(size):\n # your code goes here\n\nif __name__ == '__main__':\n n = int(input())\n print_rangoli(n)", "test_cases": {"inputs": ["5"], "outputs": ["--------e--------\n------e-d-e------\n----e-d-c-d-e----\n--e-d-c-b-c-d-e--\ne-d-c-b-a-b-c-d-e\n--e-d-c-b-c-d-e--\n----e-d-c-d-e----\n------e-d-e------\n--------e--------"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "3fb12d7952c398e9907f9bd506df8c5b9476723f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01434", "original_id": null, "source": "apps", "domain": "code", "problem": "=====Problem Statement=====\nA valid email address meets the following criteria:\n\nIt's composed of a username, domain name, and extension assembled in this format: username@domain.extension\nThe username starts with an English alphabetical character, and any subsequent characters consist of one or more of the following: alphanumeric characters, -,., and _.\nThe domain and extension contain only English alphabetical characters.\nThe extension is 1, 2, or 3 characters in length.\n\nGiven n pairs of names and email addresses as input, print each name and email address pair having a valid email address on a new line.\n\nHint: Try using Email.utils() to complete this challenge. For example, this code:\n\nimport email.utils\nprint email.utils.parseaddr('DOSHI ')\nprint email.utils.formataddr(('DOSHI', 'DOSHI@hackerrank.com'))\n\nproduces this output:\n\n('DOSHI', 'DOSHI@hackerrank.com')\nDOSHI \n\n=====Input Format=====\nThe first line contains a single integer, n, denoting the number of email address.\nEach line i of the n subsequent lines contains a name and an email address as two space-separated values following this format:\nname \n\n=====Constraints=====\n0\n\nYou must print each valid email address in the same order as it was received as input.", "starter_code": "\n# Enter your code here. Read input from STDIN. Print output to STDOUT", "test_cases": {"inputs": ["2\nDEXTER \nVIRUS "], "outputs": ["DEXTER "]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "9912e22d2e9f5b3e996cd786ee98be77ef301de0", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01439", "original_id": null, "source": "apps", "domain": "code", "problem": "=====Problem Statement=====\nThe included code stub will read an integer, n, from STDIN.\nWithout using any string methods, try to print the following:\n123...n\nNote that \"\" represents the consecutive values in between.\n\n=====Example=====\nn = 5\nPrint the string 12345.\n\n=====Input Format=====\nThe first line contains an integer n.\n\n=====Constraints=====\n1≤n≤150\n\n=====Output Format=====\nPrint the list of integers from 1 through n as a string, without spaces.", "starter_code": "\nif __name__ == '__main__':\n n = int(input())", "test_cases": {"inputs": ["3"], "outputs": ["123"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "95c33c4786d847b783c06c224fc8ec314690a10f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01444", "original_id": null, "source": "apps", "domain": "code", "problem": "=====Problem Statement=====\nYou and Fredrick are good friends. Yesterday, Fredrick received\n\ncredit cards from ABCD Bank. He wants to verify whether his credit card numbers are valid or not. You happen to be great at regex so he is asking for your help!\n\nA valid credit card from ABCD Bank has the following characteristics:\n\n► It must start with a 4, 5 or 6.\n► It must contain exactly 16 digits.\n► It must only consist of digits (0-9).\n► It may have digits in groups of 4, separated by one hyphen \"-\".\n► It must NOT use any other separator like ' ' , '_', etc.\n► It must NOT have 4 or more consecutive repeated digits.\n\n=====Example=====\n\nValid Credit Card Numbers\n\n4253625879615786\n4424424424442444\n5122-2368-7954-3214\n\nInvalid Credit Card Numbers\n\n42536258796157867 #17 digits in card number → Invalid \n4424444424442444 #Consecutive digits are repeating 4 or more times → Invalid\n5122-2368-7954 - 3214 #Separators other than '-' are used → Invalid\n44244x4424442444 #Contains non digit characters → Invalid\n0525362587961578 #Doesn't start with 4, 5 or 6 → Invalid\n\n\n=====Input Format=====\nThe first line of input contains an integer N.\nThe next N lines contain credit card numbers. \n\n\n=====Constraints=====\n0>> from itertools import combinations_with_replacement\n>>> \n>>> print list(combinations_with_replacement('12345',2))\n[('1', '1'), ('1', '2'), ('1', '3'), ('1', '4'), ('1', '5'), ('2', '2'), ('2', '3'), ('2', '4'), ('2', '5'), ('3', '3'), ('3', '4'), ('3', '5'), ('4', '4'), ('4', '5'), ('5', '5')]\n>>> \n>>> A = [1,1,3,3,3]\n>>> print list(combinations(A,2))\n[(1, 1), (1, 3), (1, 3), (1, 3), (1, 3), (1, 3), (1, 3), (3, 3), (3, 3), (3, 3)]\n\n=====Problem Statement=====\nYou are given a string S.\nYour task is to print all possible size k replacement combinations of the string in lexicographic sorted order.\n\n=====Input Format=====\nA single line containing the string S and integer value k separated by a space.\n\n=====Constraints=====\n0 [[1, 4, 5] , [2, 4, 6], [2, 3, 5]]\n 8\n \neach value in the result array contains one part from each of the arguments.\n```\n\n### Testing\nA function `compare_array` is given. This function takes two arrays and compares them invariant of sort order.\n\n```python\ntest.expect(compare_arrays(addsup([1,2], [3,1], [5,4]), [[1,3,4], [2,3,5]]))\n```\n\n### Greater goal\nFor extra honor try and make it as effective as possible. Discuss whats the most effective way of doing this. The fastest way i can do this is in *O(n^2)*. Can you do it quicker?", "starter_code": "\ndef addsup(a1, a2, a3):\n\t", "test_cases": {"inputs": [[[], [1, 2, 3], [5, 2, 3]], [[1, 3, 4], [], [4, 6, 5]], [[1, 2, 3], [4, 5, 6], []]], "outputs": [[[]], [[]], [[]]], "fn_name": "addsup"}, "test_case_format": "function_call", "n_test_cases_total": 3, "n_test_cases_kept": 3, "test_cases_truncated": false, "problem_sha1": "9152002581e899b05e538432f3e2e1916b037969", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "addsup"} {"seed_id": "apps-01509", "original_id": null, "source": "apps", "domain": "code", "problem": "Step through my `green glass door`.\n\nYou can take the `moon`, but not the `sun`.\n\nYou can take your `slippers`, but not your `sandals`.\n\nYou can go through `yelling`, but not `shouting`.\n\nYou can't run through `fast`, but you can run with `speed`.\n\nYou can take a `sheet`, but not your `blanket`.\n\nYou can wear your `glasses`, but not your `contacts`.\n\nHave you figured it out? Good! Then write a program that can figure it out as well.", "starter_code": "\ndef step_through_with(s):\n\t", "test_cases": {"inputs": [["moon"], ["test"], ["glasses"], ["airplane"], ["free"], ["branch"], ["aardvark"]], "outputs": [[true], [false], [true], [false], [true], [false], [true]], "fn_name": "step_through_with"}, "test_case_format": "function_call", "n_test_cases_total": 7, "n_test_cases_kept": 7, "test_cases_truncated": false, "problem_sha1": "295755c01fc1cd06855858521eca66c5e9662754", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "step_through_with"} {"seed_id": "apps-01514", "original_id": null, "source": "apps", "domain": "code", "problem": "You will be given a vector of strings. You must sort it alphabetically (case-sensitive, and based on the ASCII values of the chars) and then return the first value.\n\nThe returned value must be a string, and have `\"***\"` between each of its letters.\n\nYou should not remove or add elements from/to the array.", "starter_code": "\ndef two_sort(array):\n\t", "test_cases": {"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"]]], "outputs": [["b***i***t***c***o***i***n"], ["a***r***e"], ["a***b***o***u***t"], ["c***o***d***e"], ["L***e***t***s"]], "fn_name": "two_sort"}, "test_case_format": "function_call", "n_test_cases_total": 5, "n_test_cases_kept": 5, "test_cases_truncated": false, "problem_sha1": "afc760393c38ebd7daa5cdfc5f58ea16874cf18e", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "two_sort"} {"seed_id": "apps-01519", "original_id": null, "source": "apps", "domain": "code", "problem": "You drop a ball from a given height. After each bounce, the ball returns to some fixed proportion of its previous height. If the ball bounces to height 1 or less, we consider it to have stopped bouncing. Return the number of bounces it takes for the ball to stop moving.\n\n```\nbouncingBall(initialHeight, bouncingProportion)\n\nboucingBall(4, 0.5)\nAfter first bounce, ball bounces to height 2\nAfter second bounce, ball bounces to height 1\nTherefore answer is 2 bounces\n\nboucingBall(30, 0.3)\nAfter first bounce, ball bounces to height 9\nAfter second bounce, ball bounces to height 2.7\nAfter third bounce, ball bounces to height 0.81\nTherefore answer is 3 bounces\n\n\n```\n\nInitial height is an integer in range [2,1000]\n\nBouncing Proportion is a decimal in range [0, 1)", "starter_code": "\ndef bouncing_ball(initial, proportion):\n\t", "test_cases": {"inputs": [[2, 0.5], [4, 0.5], [10, 0.1], [100, 0.1], [9, 0.3], [30, 0.3]], "outputs": [[1], [2], [1], [2], [2], [3]], "fn_name": "bouncing_ball"}, "test_case_format": "function_call", "n_test_cases_total": 6, "n_test_cases_kept": 6, "test_cases_truncated": false, "problem_sha1": "160962e8b2b4015258d84a0a1767ff205922ddb3", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "bouncing_ball"} {"seed_id": "apps-01524", "original_id": null, "source": "apps", "domain": "code", "problem": "Complete the method so that it formats the words into a single comma separated value. The last word should be separated by the word 'and' instead of a comma. The method takes in an array of strings and returns a single formatted string. Empty string values should be ignored. Empty arrays or null/nil values being passed into the method should result in an empty string being returned. \n\n```Python\nformat_words(['ninja', 'samurai', 'ronin']) # should return \"ninja, samurai and ronin\"\nformat_words(['ninja', '', 'ronin']) # should return \"ninja and ronin\"\nformat_words([]) # should return \"\"\n```\n```Haskell\nformatWords [\"ninja\", \"samurai\", \"ronin\"] -- should return \"ninja, samurai and ronin\"\nformatWords [\"ninja\", \"\", \"ronin\"] -- should return \"ninja and ronin\"\nformatWords [] -- should return \"\"\n```", "starter_code": "\ndef format_words(words):\n\t", "test_cases": {"inputs": [[["one", "two", "three", "four"]], [["one"]], [["one", "", "three"]], [["", "", "three"]], [["one", "two", ""]], [[]], [null], [[""]]], "outputs": [["one, two, three and four"], ["one"], ["one and three"], ["three"], ["one and two"], [""], [""], [""]], "fn_name": "format_words"}, "test_case_format": "function_call", "n_test_cases_total": 8, "n_test_cases_kept": 8, "test_cases_truncated": false, "problem_sha1": "a97a8474787fdf536b0b6ca41bf34bb5d9d50196", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "format_words"} {"seed_id": "apps-01529", "original_id": null, "source": "apps", "domain": "code", "problem": "Paul is an excellent coder and sits high on the CW leaderboard. He solves kata like a banshee but would also like to lead a normal life, with other activities. But he just can't stop solving all the kata!!\n\nGiven an array (x) you need to calculate the Paul Misery Score. The values are worth the following points:\n\nkata = 5\nPetes kata = 10\nlife = 0\neating = 1\n\nThe Misery Score is the total points gained from the array. Once you have the total, return as follows:\n\n<40 = 'Super happy!'<70 >=40 = 'Happy!'<100 >=70 = 'Sad!'\\>=100 = 'Miserable!'", "starter_code": "\ndef paul(x):\n\t", "test_cases": {"inputs": [[["life", "eating", "life"]], [["life", "Petes kata", "Petes kata", "Petes kata", "eating"]], [["Petes kata", "Petes kata", "eating", "Petes kata", "Petes kata", "eating"]]], "outputs": [["Super happy!"], ["Super happy!"], ["Happy!"]], "fn_name": "paul"}, "test_case_format": "function_call", "n_test_cases_total": 3, "n_test_cases_kept": 3, "test_cases_truncated": false, "problem_sha1": "3d2f5737ba0a856cbaea5e9b79e62ac3ea4d2ff3", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "paul"} {"seed_id": "apps-01534", "original_id": null, "source": "apps", "domain": "code", "problem": "# A History Lesson\n\nTetris is a puzzle video game originally designed and programmed by Soviet Russian software engineer Alexey Pajitnov. The first playable version was completed on June 6, 1984. Pajitnov derived its name from combining the Greek numerical prefix tetra- (the falling pieces contain 4 segments) and tennis, Pajitnov's favorite sport.\n\n# About scoring system\n\nThe scoring formula is built on the idea that more difficult line clears should be awarded more points. For example, a single line clear is worth `40` points, clearing four lines at once (known as a Tetris) is worth `1200`.\n\nA level multiplier is also used. The game starts at level `0`. The level increases every ten lines you clear. Note that after increasing the level, the total number of cleared lines is not reset.\n\nFor our task you can use this table:\n\n\n .demo {\n width:70%;\n border:1px solid #C0C0C0;\n border-collapse:collapse;\n padding:5px;\n }\n .demo th {\n border:1px solid #C0C0C0;\n padding:5px;\n }\n .demo td {\n border:1px solid #C0C0C0;\n padding:5px;\n }\n\n\n\nLevel\nPoints for 1 line\nPoints for 2 lines\nPoints for 3 lines\nPoints for 4 lines\n\n\n0\n40\n100\n300\n1200\n\n\n1\n80\n200\n600\n2400\n\n\n2\n120\n300\n900\n3600\n\n\n3\n160\n400\n1200\n4800\n\n\n...\n\n\n7\n320\n800\n2400\n9600\n\n\n...\nFor level n you must determine the formula by yourself using given examples from the table.\n\n\n\n# Task\n\nCalculate the final score of the game using original Nintendo scoring system\n\n# Input\n\nArray with cleaned lines. \nExample: `[4, 2, 2, 3, 3, 4, 2]` \nInput will always be valid: array of random length (from `0` to `5000`) with numbers from `0` to `4`.\n\n# Ouput\n\nCalculated final score. \n`def get_score(arr) -> int: return 0`\n\n# Example\n```python\nget_score([4, 2, 2, 3, 3, 4, 2]); # returns 4900\n```\nStep 1: `+1200` points for 4 lines (current level `0`). Score: `0+1200=1200`;\\\nStep 2: `+100` for 2 lines. Score: `1200+100=1300`;\\\nStep 3: `+100`. Score: `1300+100=1400`;\\\nStep 4: `+300` for 3 lines (current level still `0`). Score: `1400+300=1700`.\\\nTotal number of cleaned lines 11 (`4 + 2 + 2 + 3`), so level goes up to `1` (level ups each 10 lines);\\\nStep 5: `+600` for 3 lines (current level `1`). Score: `1700+600=2300`;\\\nStep 6: `+2400`. Score: `2300+2400=4700`;\\\nStep 7: `+200`. Total score: `4700+200=4900` points.\n\n# Other \n\nIf you like the idea: leave feedback, and there will be more katas in the Tetris series.\n\n* 7 kyuTetris Series #1 — Scoring System\n* 6 kyuTetris Series #2 — Primitive Gameplay\n* 6 kyuTetris Series #3 — Adding Rotation (TBA)\n* 5 kyuTetris Series #4 — New Block Types (TBA)\n* 4 kyuTetris Series #5 — Complex Block Types (TBA?)", "starter_code": "\ndef get_score(arr) -> int:\n\t", "test_cases": {"inputs": [[[0, 1, 2, 3, 4]], [[0, 1, 1, 3, 0, 2, 1, 2]], [[2, 0, 4, 2, 2, 3, 0, 0, 3, 3]], [[0]], [[]]], "outputs": [[1640], [620], [3300], [0], [0]], "fn_name": "get_score"}, "test_case_format": "function_call", "n_test_cases_total": 5, "n_test_cases_kept": 5, "test_cases_truncated": false, "problem_sha1": "eb9f4a748198db4aa990fec595ee90c7c820248b", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "get_score"} {"seed_id": "apps-01539", "original_id": null, "source": "apps", "domain": "code", "problem": "# Story&Task\n There are three parties in parliament. The \"Conservative Party\", the \"Reformist Party\", and a group of independants.\n\n You are a member of the “Conservative Party” and you party is trying to pass a bill. The “Reformist Party” is trying to block it.\n\n In order for a bill to pass, it must have a majority vote, meaning that more than half of all members must approve of a bill before it is passed . The \"Conservatives\" and \"Reformists\" always vote the same as other members of thier parties, meaning that all the members of each party will all vote yes, or all vote no .\n\n However, independants vote individually, and the independant vote is often the determining factor as to whether a bill gets passed or not.\n\n Your task is to find the minimum number of independents that have to vote for your party's (the Conservative Party's) bill so that it is passed .\n\n In each test case the makeup of the Parliament will be different . In some cases your party may make up the majority of parliament, and in others it may make up the minority. If your party is the majority, you may find that you do not neeed any independants to vote in favor of your bill in order for it to pass . If your party is the minority, it may be possible that there are not enough independants for your bill to be passed . If it is impossible for your bill to pass, return `-1`.\n\n# Input/Output\n\n\n - `[input]` integer `totalMembers`\n\n The total number of members.\n\n\n - `[input]` integer `conservativePartyMembers`\n\n The number of members in the Conservative Party.\n\n\n - `[input]` integer `reformistPartyMembers`\n\n The number of members in the Reformist Party.\n\n \n - `[output]` an integer\n\n The minimum number of independent members that have to vote as you wish so that the bill is passed, or `-1` if you can't pass it anyway.\n \n# Example\n\n For `n = 8, m = 3 and k = 3`, the output should be `2`.\n \n It means: \n ```\n Conservative Party member --> 3\n Reformist Party member --> 3\n the independent members --> 8 - 3 - 3 = 2\n If 2 independent members change their minds\n 3 + 2 > 3\n the bill will be passed.\n If 1 independent members change their minds\n perhaps the bill will be failed\n (If the other independent members is against the bill).\n 3 + 1 <= 3 + 1\n ```\n \n For `n = 13, m = 4 and k = 7`, the output should be `-1`.\n ```\n Even if all 2 independent members support the bill\n there are still not enough votes to pass the bill\n 4 + 2 < 7\n So the output is -1\n ```", "starter_code": "\ndef pass_the_bill(total_members, conservative_party_members, reformist_party_members):\n\t", "test_cases": {"inputs": [[8, 3, 3], [13, 4, 7], [7, 4, 3], [11, 4, 1], [11, 5, 1], [11, 6, 1], [11, 4, 4], [11, 5, 4], [11, 5, 5], [11, 4, 6], [11, 4, 5], [15, 9, 3], [16, 7, 8], [16, 8, 7], [16, 1, 8]], "outputs": [[2], [-1], [0], [2], [1], [0], [2], [1], [1], [-1], [2], [0], [-1], [1], [-1]], "fn_name": "pass_the_bill"}, "test_case_format": "function_call", "n_test_cases_total": 15, "n_test_cases_kept": 15, "test_cases_truncated": false, "problem_sha1": "e7c75a5964c8c51a6a700cae80e97a2de9d227db", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "pass_the_bill"} {"seed_id": "apps-01544", "original_id": null, "source": "apps", "domain": "code", "problem": "There are just some things you can't do on television. In this case, you've just come back from having a \"delicious\" Barth burger and you're set to give an interview. The Barth burger has made you queezy, and you've forgotten some of the import rules of the \"You Can't Do That on Television\" set.\n\nIf you say any of the following words a large bucket of \"water\" will be dumped on you:\n\"water\", \"wet\", \"wash\"\nThis is true for any form of those words, like \"washing\", \"watered\", etc.\n\nIf you say any of the following phrases you will be doused in \"slime\":\n\"I don't know\", \"slime\"\n\nIf you say both in one sentence, a combination of water and slime, \"sludge\", will be dumped on you.\n\nWrite a function, bucketOf(str), that takes a string and determines what will be dumped on your head. If you haven't said anything you shouldn't have, the bucket should be filled with \"air\". The words should be tested regardless of case.\n\nExamples:\n\n\nCheck out my other 80's Kids Katas:\n\n\n80's Kids #1: How Many Licks Does It Take\n80's Kids #2: Help Alf Find His Spaceship\n80's Kids #3: Punky Brewster's Socks\n80's Kids #4: Legends of the Hidden Temple\n80's Kids #5: You Can't Do That on Television\n80's Kids #6: Rock 'Em, Sock 'Em Robots\n80's Kids #7: She's a Small Wonder\n80's Kids #8: The Secret World of Alex Mack\n80's Kids #9: Down in Fraggle Rock \n80's Kids #10: Captain Planet", "starter_code": "\ndef bucket_of(said):\n\t", "test_cases": {"inputs": [["water"], ["wet"], ["wash"], ["i don't know"], ["slime"], ["wet water"], ["slime water"], ["I don't know if this will work"], ["I don't know if this will work without watering it first."], [""], ["is there SLIME in that?!"], ["i won't say anything"], ["WaTeR?"], ["but i can say sludge?"], ["i'm just going to wash my hands of this"], ["you know what, i don't know what was in that Barth burger"], ["slimeslimeslimeslimewater"], ["air"], ["w-w-w-w-wet!"], ["wat errrr i mean.. nothing"], ["sludge"]], "outputs": [["water"], ["water"], ["water"], ["slime"], ["slime"], ["water"], ["sludge"], ["slime"], ["sludge"], ["air"], ["slime"], ["air"], ["water"], ["air"], ["water"], ["slime"], ["sludge"], ["air"], ["water"], ["air"], ["air"]], "fn_name": "bucket_of"}, "test_case_format": "function_call", "n_test_cases_total": 21, "n_test_cases_kept": 21, "test_cases_truncated": false, "problem_sha1": "7c9edbb89819f389ebc0a2de467d74561d9b711e", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "bucket_of"} {"seed_id": "apps-01549", "original_id": null, "source": "apps", "domain": "code", "problem": "This kata is all about adding numbers.\n\nYou will create a function named add. This function will return the sum of all the arguments. Sounds easy, doesn't it??\n\nWell here's the twist. The inputs will gradually increase with their index as parameter to the function.\n\n```python\n add(3,4,5) #returns (3*1)+(4*2)+(5*3)=26\n```\nRemember the function will return 0 if no arguments are passed.\n\n## Example\n\n```python\n add() #=> 0\n add(1,2,3) #=> 14\n add(1,4,-5,5) #=> 14\n```", "starter_code": "\ndef add(*args):\n\t", "test_cases": {"inputs": [[100, 200, 300], [2], [4, -3, -2], [-1, -2, -3, -4]], "outputs": [[1400], [2], [-8], [-30]], "fn_name": "add"}, "test_case_format": "function_call", "n_test_cases_total": 4, "n_test_cases_kept": 4, "test_cases_truncated": false, "problem_sha1": "942610effb12db86a949c8f1986c1096e26f9cbc", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "add"} {"seed_id": "apps-01554", "original_id": null, "source": "apps", "domain": "code", "problem": "As a part of this Kata, you need to create a function that when provided with a triplet, returns the index of the numerical element that lies between the other two elements.\n\nThe input to the function will be an array of three distinct numbers (Haskell: a tuple).\n\nFor example:\n\n gimme([2, 3, 1]) => 0\n\n*2* is the number that fits between *1* and *3* and the index of *2* in the input array is *0*.\n\nAnother example (just to make sure it is clear):\n\n gimme([5, 10, 14]) => 1\n \n*10* is the number that fits between *5* and *14* and the index of *10* in the input array is *1*.", "starter_code": "\ndef gimme(input_array):\n\t", "test_cases": {"inputs": [[[2, 3, 1]], [[5, 10, 14]], [[1, 3, 4]], [[15, 10, 14]], [[-0.41, -23, 4]], [[-15, -10, 14]]], "outputs": [[0], [1], [1], [2], [0], [1]], "fn_name": "gimme"}, "test_case_format": "function_call", "n_test_cases_total": 6, "n_test_cases_kept": 6, "test_cases_truncated": false, "problem_sha1": "93b766197377c240e9a87367789e666d0a661325", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "gimme"} {"seed_id": "apps-01559", "original_id": null, "source": "apps", "domain": "code", "problem": "## Task\n\nYou will receive a string consisting of lowercase letters, uppercase letters and digits as input. Your task is to return this string as blocks separated by dashes (`\"-\"`). The elements of a block should be sorted with respect to the hierarchy listed below, and each block cannot contain multiple instances of the same character. Elements should be put into the first suitable block.\n\nThe hierarchy is:\n1. lowercase letters (`a - z`), in alphabetical order\n2. uppercase letters (`A - Z`), in alphabetical order\n3. digits (`0 - 9`), in ascending order\n\n## Examples\n\n* `\"21AxBz\" -> \"xzAB12\"` - since input does not contain repeating characters, you only need 1 block\n* `\"abacad\" -> \"abcd-a-a\"` - character \"a\" repeats 3 times, thus 3 blocks are needed\n* `\"\" -> \"\"` - an empty input should result in an empty output\n* `\"hbh420sUUW222IWOxndjn93cdop69NICEep832\" -> \"bcdehjnopsxCEINOUW0234689-dhnpIUW239-2-2-2\"` - a more sophisticated example\n\nGood luck!", "starter_code": "\ndef blocks(s):\n\t", "test_cases": {"inputs": [["heyitssampletestkk"], ["dasf6ds65f45df65gdf651vdf5s1d6g5f65vqweAQWIDKsdds"], ["SDF45648374RHF8BFVYg378rg3784rf87g3278bdqG"], [""], ["aaaaaaaaaa"]], "outputs": [["aehiklmpsty-ekst-est"], ["adefgqsvwADIKQW1456-dfgsv156-dfs56-dfs56-dfs56-df56-d5-d"], ["bdfgqrBDFGHRSVY2345678-grF3478-gF3478-3478-78-8"], [""], ["a-a-a-a-a-a-a-a-a-a"]], "fn_name": "blocks"}, "test_case_format": "function_call", "n_test_cases_total": 5, "n_test_cases_kept": 5, "test_cases_truncated": false, "problem_sha1": "a7d9be6549c50942068ef60c4536149671f5d376", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "blocks"} {"seed_id": "apps-01564", "original_id": null, "source": "apps", "domain": "code", "problem": "Find the sum of the odd numbers within an array, after cubing the initial integers. The function should return `undefined`/`None`/`nil`/`NULL` if any of the values aren't numbers. \n\n~~~if:java,csharp\nNote: There are ONLY integers in the JAVA and C# versions of this Kata.\n~~~\n\n~~~if:python\nNote: Booleans should not be considered as numbers.\n~~~", "starter_code": "\ndef cube_odd(arr):\n\t", "test_cases": {"inputs": [[[1, 2, 3, 4]], [[-3, -2, 2, 3]], [["a", 12, 9, "z", 42]], [[true, false, 2, 4, 1]]], "outputs": [[28], [0], [null], [null]], "fn_name": "cube_odd"}, "test_case_format": "function_call", "n_test_cases_total": 4, "n_test_cases_kept": 4, "test_cases_truncated": false, "problem_sha1": "f18538fda12e9abff06edd7a2ed734da2a60a91b", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "cube_odd"} {"seed_id": "apps-01569", "original_id": null, "source": "apps", "domain": "code", "problem": "Create a function that interprets code in the esoteric language **Poohbear**\n\n## The Language\n\nPoohbear is a stack-based language largely inspired by Brainfuck. It has a maximum integer value of 255, and 30,000 cells. The original intention of Poohbear was to be able to send messages that would, to most, be completely indecipherable: \nPoohbear Wiki\n\n* For the purposes of this kata, you will make a version of Poohbear that has **infinite** memory cells in **both directions** (so you do not need to limit cells to 30,000)\n* Cells have a default value of 0\n* Each cell can hold one byte of data. Once a cell's value goes above 255, it wraps around to 0. If a cell's value goes below 0, it wraps to 255.\n* If the result of an operation isn't an int, round the result down to the nearest one.\n* Your interpreter should ignore any non-command characters in the code.\n* If you come to a `W` in the code and the current cell is equal to 0, jump to the corresponding `E`.\n* If you come to an `E` in the code and the current cell is **not** 0, jump back to the corresponding `W`.\n\nHere are the Poohbear commands: \n\n| Command | Definition\n|---| -------------------------\n| + | Add 1 to the current cell\n| - | Subtract 1 from the current cell\n| > | Move the cell pointer 1 space to the right\n| < | Move the cell pointer 1 space to the left\n| c | \"Copy\" the current cell\n| p | Paste the \"copied\" cell into the current cell\n| W | While loop - While the current cell is not equal to 0\n| E | Closing character for loops\n| P | Output the current cell's value as ascii\n| N | Output the current cell's value as an integer\n| T | Multiply the current cell by 2\n| Q | Square the current cell\n| U | Square root the current cell's value\n| L | Add 2 to the current cell\n| I | Subtract 2 from the current cell\n| V | Divide the current cell by 2\n| A | Add the copied value to the current cell's value\n| B | Subtract the copied value from the current cell's value\n| Y | Multiply the current cell's value by the copied value\n| D | Divide the current cell's value by the copied value.", "starter_code": "\ndef poohbear(s):\n\t", "test_cases": {"inputs": [["LQTcQAP>pQBBTAI-PA-PPL+PPL+PBLPBPLLLc+QIT-P AAAP P"], ["LLQT>+WN+

E"], ["cW>LQQT+PLQQT+P<-E"], ["+LTQII>+WN

+E"], ["+LTQIITTIWP-E"], ["LILcABNBpYDYYYYLLL+P-+W-EQNW-ELLQUTTTT+P"], ["++W-NE"], ["W>UQLIPNPPP45vSDFJLLIPNPqwVMTLcIpIL+TQYDABANPAPIIIITUNNQV+++P"], ["+c BANANA BANANA BANANA BANANA BANANA"], ["L sfdg ghjk kl LQTT++++P tt W w - E wewewe N"]], "outputs": [["Hello World!"], ["!]oo"], ["1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 "], [""], ["!"], ["1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 "], ["~}|{zyxwvutsrqponmlkjihgfedcba`_^]\\[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#\"! \u001f\u001e\u001d\u001c\u001b\u001a\u0019\u0018\u0017\u0016\u0015\u0014\u0013\u0012\u0011\u0010\u000f\u000e\r\f\u000b\n\t\b\u0007\u0006\u0005\u0004\u0003\u0002\u0001"], ["2'0A"], ["10"], [""], [""], ["0001!33"], ["!\"#$%&"], ["38&(88#"], ["12345678910"], ["D0"]], "fn_name": "poohbear"}, "test_case_format": "function_call", "n_test_cases_total": 16, "n_test_cases_kept": 16, "test_cases_truncated": false, "problem_sha1": "f13c0be03e6012575af00cdc036f70e531bf0236", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "poohbear"} {"seed_id": "apps-01574", "original_id": null, "source": "apps", "domain": "code", "problem": "In this Kata, you will be given an array and your task will be to determine if an array is in ascending or descending order and if it is rotated or not. \n\nConsider the array `[1,2,3,4,5,7,12]`. This array is sorted in `Ascending` order. If we rotate this array once to the left, we get `[12,1,2,3,4,5,7]` and twice-rotated we get `[7,12,1,2,3,4,5]`. These two rotated arrays are in `Rotated Ascending` order.\n\nSimilarly, the array `[9,6,5,3,1]` is in `Descending` order, but we can rotate it to get an array in `Rotated Descending` order: `[1,9,6,5,3]` or `[3,1,9,6,5]` etc.\n\nArrays will never be unsorted, except for those that are rotated as shown above. Arrays will always have an answer, as shown in the examples below.\n\nMore examples:\n```Haskell\nsolve([1,2,3,4,5,7]) = \"A\" -- Ascending\nsolve([7,1,2,3,4,5]) = \"RA\" -- Rotated ascending\nsolve([4,5,6,1,2,3]) = \"RA\" -- Rotated ascending\nsolve([9,8,7,6]) = \"D\" -- Descending\nsolve([5,9,8,7,6]) = \"RD\" -- Rotated Descending\n```\nMore examples in the test cases. \n\nGood luck!", "starter_code": "\ndef solve(arr):\n\t", "test_cases": {"inputs": [[[1, 2, 3, 4, 5, 7]], [[7, 1, 2, 3, 4, 5]], [[2, 3, 4, 5, 7, 12]], [[7, 12, 1, 2, 3, 4, 5]], [[4, 5, 6, 1, 2, 3]], [[9, 8, 7, 6, 5]], [[5, 9, 8, 7, 6]], [[6, 5, 9, 8, 7]], [[9, 6, 7]], [[10, 12, 11]], [[13, 10, 11]]], "outputs": [["A"], ["RA"], ["A"], ["RA"], ["RA"], ["D"], ["RD"], ["RD"], ["RA"], ["RD"], ["RA"]], "fn_name": "solve"}, "test_case_format": "function_call", "n_test_cases_total": 11, "n_test_cases_kept": 11, "test_cases_truncated": false, "problem_sha1": "8fbe8aa37ad405112c3fff98a089623c3b2b58e2", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "solve"} {"seed_id": "apps-01579", "original_id": null, "source": "apps", "domain": "code", "problem": "Return a new array consisting of elements which are multiple of their own index in input array (length > 1).\n\nSome cases: \n\n```\n[22, -6, 32, 82, 9, 25] => [-6, 32, 25]\n\n[68, -1, 1, -7, 10, 10] => [-1, 10]\n\n[-56,-85,72,-26,-14,76,-27,72,35,-21,-67,87,0,21,59,27,-92,68] => [-85, 72, 0, 68]\n```", "starter_code": "\ndef multiple_of_index(arr):\n\t", "test_cases": {"inputs": [[[22, -6, 32, 82, 9, 25]], [[68, -1, 1, -7, 10, 10]], [[11, -11]], [[-56, -85, 72, -26, -14, 76, -27, 72, 35, -21, -67, 87, 0, 21, 59, 27, -92, 68]], [[28, 38, -44, -99, -13, -54, 77, -51]], [[-1, -49, -1, 67, 8, -60, 39, 35]]], "outputs": [[[-6, 32, 25]], [[-1, 10]], [[-11]], [[-85, 72, 0, 68]], [[38, -44, -99]], [[-49, 8, -60, 35]]], "fn_name": "multiple_of_index"}, "test_case_format": "function_call", "n_test_cases_total": 6, "n_test_cases_kept": 6, "test_cases_truncated": false, "problem_sha1": "9860d2bf85bf6a3649e2d66e942d7af44203d7d9", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "multiple_of_index"} {"seed_id": "apps-01584", "original_id": null, "source": "apps", "domain": "code", "problem": "How many licks does it take to get to the tootsie roll center of a tootsie pop?\n\nA group of engineering students from Purdue University reported that its licking machine, modeled after a human tongue, took an average of 364 licks to get to the center of a Tootsie Pop. Twenty of the group's volunteers assumed the licking challenge-unassisted by machinery-and averaged 252 licks each to the center.\n\nYour task, if you choose to accept it, is to write a function that will return the number of licks it took to get to the tootsie roll center of a tootsie pop, given some environmental variables.\n\nEveryone knows it's harder to lick a tootsie pop in cold weather but it's easier if the sun is out. You will be given an object of environmental conditions for each trial paired with a value that will increase or decrease the number of licks. The environmental conditions all apply to the same trial.\n\nAssuming that it would normally take 252 licks to get to the tootsie roll center of a tootsie pop, return the new total of licks along with the condition that proved to be most challenging (causing the most added licks) in that trial.\n\nExample:\n```\ntotalLicks({ \"freezing temps\": 10, \"clear skies\": -2 });\n```\nShould return:\n```\n\"It took 260 licks to get to the tootsie roll center of a tootsie pop. The toughest challenge was freezing temps.\"\n```\nOther cases:\nIf there are no challenges, the toughest challenge sentence should be omitted. If there are multiple challenges with the highest toughest amount, the first one presented will be the toughest.\nIf an environment variable is present, it will be either a positive or negative integer. No need to validate.\n\n\nCheck out my other 80's Kids Katas:\n\n\n80's Kids #1: How Many Licks Does It Take\n80's Kids #2: Help Alf Find His Spaceship\n80's Kids #3: Punky Brewster's Socks\n80's Kids #4: Legends of the Hidden Temple\n80's Kids #5: You Can't Do That on Television\n80's Kids #6: Rock 'Em, Sock 'Em Robots\n80's Kids #7: She's a Small Wonder\n80's Kids #8: The Secret World of Alex Mack\n80's Kids #9: Down in Fraggle Rock \n80's Kids #10: Captain Planet", "starter_code": "\ndef total_licks(env):\n\t", "test_cases": {"inputs": [[{"freezing temps": 10, "clear skies": -2}], [{"happiness": -5, "clear skies": -2}], [{}], [{"dragons": 100, "evil wizards": 110, "trolls": 50}], [{"white magic": -250}]], "outputs": [["It took 260 licks to get to the tootsie roll center of a tootsie pop. The toughest challenge was freezing temps."], ["It took 245 licks to get to the tootsie roll center of a tootsie pop."], ["It took 252 licks to get to the tootsie roll center of a tootsie pop."], ["It took 512 licks to get to the tootsie roll center of a tootsie pop. The toughest challenge was evil wizards."], ["It took 2 licks to get to the tootsie roll center of a tootsie pop."]], "fn_name": "total_licks"}, "test_case_format": "function_call", "n_test_cases_total": 5, "n_test_cases_kept": 5, "test_cases_truncated": false, "problem_sha1": "efa96b1ad8e6aa3d010a9732dfd6b37eaa35d117", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "total_licks"} {"seed_id": "apps-01589", "original_id": null, "source": "apps", "domain": "code", "problem": "Cascading Style Sheets (CSS) is a style sheet language used for describing the look and formatting of a document written in a markup language. A style sheet consists of a list of rules. Each rule or rule-set consists of one or more selectors, and a declaration block. Selector describes which element it matches.\n\nSometimes element is matched to multiple selectors. In this case, element inherits multiple styles, from each rule it matches. Rules can override each other. To solve this problem, each selector has it's own 'specificity' - e.g. weight. The selector with greater specificity overrides the other selector.\n\nYour task is to calculate the weights of two selectors and determine which of them will beat the other one.\n\n```python\ncompare(\"body p\", \"div\") # returns \"body p\"\ncompare(\".class\", \"#id\") # returns \"#id\"\ncompare(\"div.big\", \".small\") # returns \"div.big\"\ncompare(\".big\", \".small\") # returns \".small\" (because it appears later)\n```\n\nFor simplicity, all selectors in test cases are CSS1-compatible, test cases don't include pseudoclasses, pseudoelements, attribute selectors, etc. Below is an explanation on how to weight two selectors. You can read more about specificity here.\n\nThe simplest selector type is ``tagname`` selector. It writes as a simple alphanumeric identifier: eg ``body``, ``div``, ``h1``, etc. It has the least weight. If selectors have multiple elements - the selector with more elements win. For example, ``body p`` beats ``div``, because it refers to 2 (nested) elements rather than 1.\n\nAnother simple selector is ``.class`` selector. It begins with dot and refer to element with specific ``class`` attribute. Class selectors can also be applied to tagname selectors, so ``div.red`` refer to ```` element. They can be grouped, for example, ``.red.striped``. Class selector beats tagname selector.\n\nThe most weighted selector type in stylesheet is ``#id`` selector. It begins with hash sign and refer to element with specific ``id`` attribute. It can also be standalone, or applied to an element. Id selector beats both selector types.\n\nAnd the least weighted selector is ``*``, which has no specificity and can be beat by any other selector.\n\nSelectors can be combined, for example, ``body #menu ul li.active`` refers to ``li`` element with ``class=\"active\"``, placed inside ``ul`` element, placed inside element width ``id=\"menu\"``, placed inside ``body``.\n\nSpecificity calculation is simple. \n\nSelector with more #id selectors wins\nIf both are same, the winner is selector with more .class selectors\nIf both are same, selector with more elements wins\nIf all of above values are same, the winner is selector that appear last\n\n\nFor example, let's represent the number of ``#id`` , ``.class``, ``tagname`` selectors as array (in order from worst to best):\n\nSelectorSpecificity (#id,.class,tagname)\n*0, 0, 0\nspan0, 0, 1\nbody p0, 0, 2\n.green0, 1, 0\napple.yellow0, 1, 1\ndiv.menu li0, 1, 2\n.red .orange0, 2, 0\ndiv.big .first0, 2, 1\n#john1, 0, 0\ndiv#john1, 0, 1\nbody #john span1, 0, 2\nmenu .item #checkout.active1, 2, 1\n#foo div#bar.red .none2, 2, 1", "starter_code": "\ndef compare(a, b):\n\t", "test_cases": {"inputs": [["body p", "div"], ["body", "html"], ["p a", "span"], ["div p span a", "div p span a b"], ["strong", "p b"], [".first", ".last"], [".foo.bar", ".x .y"], [".x .y", ".foo.bar"], [".red.apple", ".red"], [".test1 .test2.test3", ".test1 .test4 .test5 .test6"], [".box.box-first", ".box"], ["#header", "#footer"], ["#header #menu", "#menu"], [".red", "div"], ["apple", "#SteveJobs"], [".item", "div ul li a"], ["div.article", "div b.blue"], [".item", "#menu div ul li a"], ["p", "*"]], "outputs": [["body p"], ["html"], ["p a"], ["div p span a b"], ["p b"], [".last"], [".x .y"], [".foo.bar"], [".red.apple"], [".test1 .test4 .test5 .test6"], [".box.box-first"], ["#footer"], ["#header #menu"], [".red"], ["#SteveJobs"], [".item"], ["div b.blue"], ["#menu div ul li a"], ["p"]], "fn_name": "compare"}, "test_case_format": "function_call", "n_test_cases_total": 19, "n_test_cases_kept": 19, "test_cases_truncated": false, "problem_sha1": "a35a4db1cff6cb471178895189caa3a5f3fa10ab", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "compare"} {"seed_id": "apps-01594", "original_id": null, "source": "apps", "domain": "code", "problem": "One suggestion to build a satisfactory password is to start with a memorable phrase or sentence and make a password by extracting the first letter of each word. \n\nEven better is to replace some of those letters with numbers (e.g., the letter `O` can be replaced with the number `0`):\n\n* instead of including `i` or `I` put the number `1` in the password;\n* instead of including `o` or `O` put the number `0` in the password;\n* instead of including `s` or `S` put the number `5` in the password.\n\n\n## Examples:\n```\n\"Give me liberty or give me death\" --> \"Gml0gmd\"\n\"Keep Calm and Carry On\" --> \"KCaC0\"\n```", "starter_code": "\ndef make_password(phrase):\n\t", "test_cases": {"inputs": [["Give me liberty or give me death"], ["Keep Calm and Carry On"]], "outputs": [["Gml0gmd"], ["KCaC0"]], "fn_name": "make_password"}, "test_case_format": "function_call", "n_test_cases_total": 2, "n_test_cases_kept": 2, "test_cases_truncated": false, "problem_sha1": "c8f7a04209c3332e2985a999400c9f8abf17ef1c", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "make_password"} {"seed_id": "apps-01599", "original_id": null, "source": "apps", "domain": "code", "problem": "A faro shuffle of a deck of playing cards is a shuffle in which the deck is split exactly in half and then the cards in the two halves are perfectly interwoven, such that the original bottom card is still on the bottom and the original top card is still on top.\n\nFor example, faro shuffling the list\n```python\n['ace', 'two', 'three', 'four', 'five', 'six']\n```\ngives\n```python\n['ace', 'four', 'two', 'five', 'three', 'six' ]\n```\n\nIf 8 perfect faro shuffles are performed on a deck of 52 playing cards, the deck is restored to its original order.\n\nWrite a function that inputs an integer n and returns an integer representing the number of faro shuffles it takes to restore a deck of n cards to its original order.\n\nAssume n is an even number between 2 and 2000.", "starter_code": "\ndef faro_cycles(deck_size):\n\t", "test_cases": {"inputs": [[2], [52], [542], [1250], [1954]], "outputs": [[1], [8], [540], [156], [30]], "fn_name": "faro_cycles"}, "test_case_format": "function_call", "n_test_cases_total": 5, "n_test_cases_kept": 5, "test_cases_truncated": false, "problem_sha1": "39778d5a2682f98cebab3e5867ff373fbd07a931", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "faro_cycles"}