messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "Easy and hard versions are actually different problems, so we advise you to read both statements carefully.\n\nYou are given a weighted rooted tree, vertex 1 is the root of this tree. Also, each edge has its own cost.\n\nA tree is a connected graph without cycles. A rooted tree has a special verte... | [{"input": "4\n4 18\n2 1 9 2\n3 2 4 1\n4 1 1 2\n3 20\n2 1 8 1\n3 1 7 2\n5 50\n1 3 100 1\n1 5 10 2\n2 3 123 2\n5 4 55 1\n2 000\n1 2 409 2\n", "output": "0\n0\n11\n18\n"}, {"input": "4\n4 18\n2 1 18 2\n3 2 4 1\n4 1 2 2\n3 20\n2 1 2 1\n3 1 8 2\n5 50\n1 3 100 1\n1 5 10 2\n2 3 123 2\n5 4 55 2\n1 100\n1 2 409 2\n", "output":... | code_stdio |
[
{
"content": "Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:\n\n* 1 \\leq x,y,z\n* x^2 + y^2 + z^2 + xy + yz + zx = n\n\n\n\nGiven an integer N, find each of f(1),f(2),f(3),\\ldots,f(N).\n\nConstraints\n\n* All values in input are integers.\n* 1 \\leq N \\le... | [{"input": "743", "output": "0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n0\n0\n0\n1\n6\n0\n3\n0\n0\n0\n0\n0\n3\n3\n6\n0\n0\n3\n0\n0\n0\n0\n3\n3\n6\n0\n6\n0\n0\n0\n3\n0\n0\n1\n6\n0\n6\n6\n0\n0\n6\n0\n0\n0\n0\n3\n3\n3\n6\n0\n6\n3\n6\n0\n0\n0\n6\n0\n0\n0\n3\n3\n9\n0\n6\n3\n6\n0\n3\n6\n0\n0\n0\n0\n6\n1\n6\n... | code_stdio |
[
{
"content": "You already know that Valery's favorite sport is biathlon. Due to your help, he learned to shoot without missing, and his skills are unmatched at the shooting range. But now a smaller task is to be performed, he should learn to complete the path fastest.\n\nThe track's map is represented by a rect... | [{"input": "20 20 2\nbaaaaaaaaaaaaaaaaaaa\nbfffffffacfffffffffa\nbgggggggaccgggggggga\nbhhhhhhhaccchhhhhhha\nbiiiiiiiacccciiiiiia\nbjjjjjjjacccccjjjjja\nbkkkkkkkacccccckkkka\nblllllllacccccccllla\nbbbbbbbbSccccccccmma\nbddddddddddcccccccna\nbodddddddcccccccccca\nbppddddddddTaaaaaaaa\nbqqqdddddddbqqqqqqqa\nbrrrrddddddbr... | code_stdio |
[
{
"content": "Quick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, inturn, less than or equal to each e... | [{"input": "12\n40 19 12 2 12 7 0 5 21 -1 10 22", "output": "19 12 2 12 7 0 5 21 -1 10 [22] 40\n"}, {"input": "12\n40 19 12 2 12 11 0 5 21 -1 1 37", "output": "19 12 2 12 11 0 5 21 -1 1 [37] 40\n"}, {"input": "12\n40 19 22 2 12 11 0 5 21 -1 1 37", "output": "19 22 2 12 11 0 5 21 -1 1 [37] 40\n"}, {"input": "12\n40 19 2... | code_stdio |
[
{
"content": "Santa Claus is the first who came to the Christmas Olympiad, and he is going to be the first to take his place at a desk! In the classroom there are n lanes of m desks each, and there are two working places at each of the desks. The lanes are numbered from 1 to n from the left to the right, the de... | [{"input": "10000 10000 199999999\n", "output": "10000 10000 L\n"}, {"input": "10000 10000 200000000\n", "output": "10000 10000 R\n"}, {"input": "10000 10000 199999999\n", "output": "10000 10000 L\n"}, {"input": "10000 10000 200000000\n", "output": "10000 10000 R\n"}, {"input": "10000 16759 186450844\n", "output": "556... | code_stdio |
[
{
"content": "There are $n$ points on a coordinate axis $OX$. The $i$-th point is located at the integer point $x_i$ and has a speed $v_i$. It is guaranteed that no two points occupy the same coordinate. All $n$ points move with the constant speed, the coordinate of the $i$-th point at the moment $t$ ($t$ can b... | [{"input": "5\n2 1 4 3 5\n2 2 2 3 4\n", "output": "19\n"}, {"input": "5\n2 1 4 3 5\n0 2 2 3 4\n", "output": "18\n"}, {"input": "5\n2 1 4 3 5\n2 2 2 3 4\n", "output": "19\n"}, {"input": "3\n1 3 2\n-100 2 10\n", "output": "3\n"}, {"input": "3\n1 3 2\n-100 2 3\n", "output": "3\n"}, {"input": "3\n1 3 2\n-100 2 6\n", "outpu... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nSometimes mysteries happen. Chef found a directed graph with N vertices and M edges in his kitchen! \nThe evening was boring and chef has nothing else to do, so to entertain himself, Chef thought about a question \"What is the minimum ... | [{"input": "12 7\n1 2 \n4 2\n3 4\n7 12\n2 2\n9 9\n10 1", "output": "-1\n"}, {"input": "12 7\n1 2 \n4 2\n3 4\n8 12\n2 2\n9 9\n10 1", "output": "-1\n"}, {"input": "12 7\n1 2 \n4 2\n3 4\n7 7\n2 1\n11 2\n11 1", "output": "-1\n"}, {"input": "12 7\n1 2 \n4 2\n3 4\n7 7\n3 1\n11 2\n11 1", "output": "-1\n"}, {"input": "12 7\n1 ... | code_stdio |
[
{
"content": "You are walking through a parkway near your house. The parkway has $n+1$ benches in a row numbered from $1$ to $n+1$ from left to right. The distance between the bench $i$ and $i+1$ is $a_i$ meters.\n\nInitially, you have $m$ units of energy. To walk $1$ meter of distance, you spend $1$ unit of yo... | [{"input": "1\n100 7773\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100... | code_stdio |
[
{
"content": "Slime has a sequence of positive integers $a_1, a_2, \\ldots, a_n$.\n\nIn one operation Orac can choose an arbitrary subsegment $[l \\ldots r]$ of this sequence and replace all values $a_l, a_{l + 1}, \\ldots, a_r$ to the value of median of $\\{a_l, a_{l + 1}, \\ldots, a_r\\}$.\n\nIn this problem,... | [{"input": "5\n5 3\n1 5 2 6 1\n1 6\n6\n3 2\n1 2 3\n4 3\n3 1 2 3\n10 3\n1 2 3 4 5 6 7 8 9 10\n", "output": "no\nyes\nyes\nno\nyes\n"}, {"input": "5\n5 3\n1 5 2 6 1\n1 6\n6\n3 2\n1 2 3\n4 3\n3 1 2 3\n10 3\n1 2 3 4 8 6 7 8 9 10\n", "output": "no\nyes\nyes\nno\nyes\n"}, {"input": "5\n5 3\n1 5 2 6 1\n1 6\n6\n3 2\n1 2 3\n4 3... | code_stdio |
[
{
"content": "Aizu is famous for its buckwheat. There are many people who make buckwheat noodles by themselves.\n\nOne day, you went shopping to buy buckwheat flour. You can visit three shops, A, B and C. The amount in a bag and its unit price for each shop is determined by the follows table. Note that it is di... | [{"input": "500\n1000\n0", "output": "850\n1520\n"}, {"input": "500\n1100\n0", "output": "850\n1950\n"}, {"input": "500\n2200\n0", "output": "850\n3390"}, {"input": "500\n0000\n-12", "output": "850\n"}, {"input": "500\n0000\n119", "output": "850\n"}, {"input": "500\n0000\n-16", "output": "850\n"}, {"input": "500\n0000\... | code_stdio |
[
{
"content": "problem\n\nGiven $ N $ different natural numbers $ a_i $. I decided to make a pair by choosing a different natural number from the given natural numbers. Output one pair that can be created with a value difference that is a multiple of $ N -1 $.\n\nIt should be noted that such a pair always exists... | [{"input": "5\n0 2 11 13 37", "output": "13 37\n"}, {"input": "5\n1 -1 6 11 22", "output": "-1 11\n"}, {"input": "5\n-2 0 1 10 41", "output": "-2 10\n"}, {"input": "5\n1 2 11 13 35", "output": "1 13\n"}, {"input": "5\n1 2 11 4 35", "output": "11 35\n"}, {"input": "5\n2 8 11 13 28", "output": "8 28\n"}, {"input": "5\n2 ... | code_stdio |
[
{
"content": "There are N cards placed face down in a row. On each card, an integer 1 or 2 is written.\nLet A_i be the integer written on the i-th card.\nYour objective is to guess A_1, A_2, ..., A_N correctly.\nYou know the following facts:\n - For each i = 1, 2, ..., M, the value A_{X_i} + A_{Y_i} + Z_i is an... | [{"input": "6 5\n1 2 1\n2 3 2\n1 3 3\n4 5 4\n5 6 5\n", "output": "2\n"}, {"input": "6 5\n1 2 1\n2 3 2\n1 6 3\n4 5 4\n1 4 5", "output": "1\n"}, {"input": "6 5\n1 2 1\n2 3 2\n1 3 3\n4 5 4\n3 6 5", "output": "2\n"}, {"input": "6 5\n1 2 1\n2 3 2\n1 3 3\n4 5 4\n1 6 5", "output": "2\n"}, {"input": "6 5\n1 2 1\n2 3 2\n1 6 3\n... | code_stdio |
[
{
"content": "The famous joke programming language HQ9+ has only 4 commands. In this problem we will explore its subset — a language called HQ...\n\n\n-----Input-----\n\nThe only line of the input is a string between 1 and 10^6 characters long.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Exampl... | [{"input": "HQQQQQQQHQQQQHQHQQQHHQHHHQQHQQQQHHQHHQHHHHHHQQQQQQQQHHQQQQQHHQQQQHHHQQQQQQQQHQQQHQHQQQQQQHHHQHHQHQHHQQQQQHQQHQHQQQHQHQHHHHQQHQHQQQQQHQQQHQQQHQQHQHQQHQQQQQQ\n", "output": "No\n"}, {"input": "HQQQQQQQHQQQQHQHQQQHHQHHHQQHQQQQHHQHHQHHHHHHQQQQQQQQHHQQQQQHHQQQQHHHQQQQQQQQHQQQHQHQQQQQQHHHQHHQHQHHQQQQQHQQHQHQQQHQHQ... | code_stdio |
[
{
"content": "This problem is same as the next one, but has smaller constraints.\n\nShiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.\n\nFor each of the $n$ days since ... | [{"input": "10\n30518 30518 30518 30518 30518 30518 30518 30518 30518 30518\n", "output": "10\n"}, {"input": "10\n30518 96518 74071 59971 50121 4862 43967 73607 19138 90754\n", "output": "10\n"}, {"input": "10\n63649 14562 779 31060 84730 3390 1402 70955 27426 79066\n", "output": "10\n"}, {"input": "10\n4131 4373 75721... | code_stdio |
[
{
"content": "This is simplified version of the problem used on the original contest. The original problem seems to have too difiicult solution. The constraints for input data have been reduced.\n\nPolycarp likes to play computer role-playing game «Lizards and Basements». At the moment he is playing it as a mag... | [{"input": "10 2 1\n14 15 15 14 14 15 14 15 14 15\n", "output": "50\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 4 4 4 4 5 5 5 5 5 5 5 6 7 7 7 7 7 7 7 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 \n"}, {"input": "10 2 1\n14 15 15 14 15 14 15 14 15 15\n", "output": "50\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 4 4 4 4 5 5 5 5 5 5 5 7 7 7 7 7 7 7 7 9 9 9 9 9... | code_stdio |
[
{
"content": "Problem statement\n\nThere is an unsigned $ 2 $ decimal integer $ X $ with $ N $ in digits including Leading-zeros. Output the largest non-negative integer that can be expressed in $ 2 $ base in $ N $ digits where the Hamming distance from $ X $ is $ D $.\n\nThe Hamming distance between integers e... | [{"input": "5\n00001\n4", "output": "11111\n"}, {"input": "5\n00000\n3", "output": "11100\n"}, {"input": "5\n00001\n1", "output": "10001\n"}, {"input": "5\n10001\n1", "output": "11001\n"}, {"input": "5\n10001\n2", "output": "11101\n"}, {"input": "5\n10001\n4", "output": "11110\n"}, {"input": "5\n10000\n1", "output": "1... | code_stdio |
[
{
"content": "You are given two strings $s$ and $t$. The string $s$ consists of lowercase Latin letters and at most one wildcard character '*', the string $t$ consists only of lowercase Latin letters. The length of the string $s$ equals $n$, the length of the string $t$ equals $m$.\n\nThe wildcard character '*'... | [{"input": "5 102\neyw*y\neywsnxcwslfyiqbbeoaawtmioksfdndptxxcwzfmrpcixjbzvicijofjrbcvzaedglifuoczgjlqylddnsvsjfmfsccxbdveqguyfk\n", "output": "NO\n"}, {"input": "5 102\neyw*y\neywsnxcwslfyiqbbeoaawtmioksfdndptxxcwzfmrpcixjbzvicijofjrbcvzaedglifuoczgjlqylddnsvsjfmfsccxbdveqguyfk\n", "output": "NO\n"}, {"input": "5 102\... | code_stdio |
[
{
"content": "Example\n\nInput\n\nACM\n\n\nOutput\n\n0\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to stdout. Enclose your complete solution in a single ```python code block.",
"role": "user"
}
] | [{"input": "ABM", "output": "0\n"}, {"input": "BIB", "output": "2\n"}, {"input": "1MI", "output": "1\n"}, {"input": "MCA", "output": "0\n"}, {"input": "MAC", "output": "0\n"}, {"input": "M@C", "output": "0\n"}, {"input": "C@M", "output": "0\n"}, {"input": "@MC", "output": "0\n"}, {"input": "?MC", "output": "0\n"}, {"in... | code_stdio |
[
{
"content": "The programming competition season has already started and it's time to train for ICPC. Sereja coaches his teams for a number of year and he knows that to get ready for the training session it's not enough to prepare only problems and editorial. As the training sessions lasts for several hours, te... | [{"input": "100\n56 22 13 79 28 73 16 55 34 0 97 19 22 36 22 80 30 19 36 92 9 38 24 10 61 43 19 12 18 34 21 36 1 17 0 97 72 37 74 70 51 34 33 87 27 33 45 97 38 56 2 32 88 92 64 51 74 94 86 98 57 62 83 3 87 61 9 65 57 13 64 10 50 35 7 75 41 3 70 66 6 55 69 42 91 75 14 22 68 93 2 53 22 98 45 2 78 58 18 13\n", "output": "... | code_stdio |
[
{
"content": "Little penguin Polo loves his home village. The village has n houses, indexed by integers from 1 to n. Each house has a plaque containing an integer, the i-th house has a plaque containing integer p_{i} (1 ≤ p_{i} ≤ n).\n\nLittle penguin Polo loves walking around this village. The walk looks like ... | [{"input": "1000 8\n", "output": "339760446\n"}, {"input": "1000 1\n", "output": "760074701\n"}, {"input": "1000 2\n", "output": "675678679\n"}, {"input": "1000 3\n", "output": "330155123\n"}, {"input": "1000 4\n", "output": "660270610\n"}, {"input": "1000 5\n", "output": "583047503\n"}, {"input": "1000 6\n", "output":... | code_stdio |
[
{
"content": "Jzzhu has invented a kind of sequences, they meet the following property:$f_{1} = x ; f_{2} = y ; \\forall i(i \\geq 2), f_{i} = f_{i - 1} + f_{i + 1}$\n\nYou are given x and y, please calculate f_{n} modulo 1000000007 (10^9 + 7).\n\n\n-----Input-----\n\nThe first line contains two integers x and ... | [{"input": "-1000000000 1000000000\n2000000000\n", "output": "1000000000\n"}, {"input": "-1000000000 1000000000\n2000000000\n", "output": "1000000000\n"}, {"input": "-1030333966 -143148799\n1287886520\n", "output": "856851208\n"}, {"input": "-1048223347 -1308375581\n154879215\n", "output": "739847773\n"}, {"input": "-5... | code_stdio |
[
{
"content": "After you had helped George and Alex to move in the dorm, they went to help their friend Fedor play a new computer game «Call of Soldiers 3».\n\nThe game has (m + 1) players and n types of soldiers in total. Players «Call of Soldiers 3» are numbered form 1 to (m + 1). Types of soldiers are numbere... | [{"input": "13 27 7\n1893\n370\n7320\n5753\n4418\n2146\n2702\n5013\n5959\n1929\n7611\n7013\n540\n3454\n4271\n2887\n4724\n3520\n2111\n5845\n1868\n7659\n3040\n3775\n6507\n4917\n7506\n2515\n", "output": "20\n"}, {"input": "13 27 7\n1893\n370\n7320\n5753\n4418\n2146\n2702\n5013\n5959\n1929\n7611\n7013\n540\n3454\n4271\n288... | code_stdio |
[
{
"content": "Nowadays the one-way traffic is introduced all over the world in order to improve driving safety and reduce traffic jams. The government of Berland decided to keep up with new trends. Formerly all n cities of Berland were connected by n two-way roads in the ring, i. e. each city was connected dire... | [{"input": "50\n30 34 48\n11 30 15\n11 5 179\n4 5 57\n43 4 21\n14 43 74\n14 19 52\n45 19 60\n45 28 52\n24 28 94\n24 26 2\n48 26 34\n48 13 53\n13 42 7\n42 37 23\n37 17 70\n17 7 29\n20 7 93\n33 20 21\n33 2 53\n21 2 83\n49 21 33\n46 49 28\n18 46 1\n36 18 99\n47 36 52\n47 29 41\n41 29 40\n31 41 45\n31 38 25\n38 25 41\n25 8... | code_stdio |
[
{
"content": "Catherine received an array of integers as a gift for March 8. Eventually she grew bored with it, and she started calculated various useless characteristics for it. She succeeded to do it for each one she came up with. But when she came up with another one — xor of all pairwise sums of elements in... | [{"input": "100\n1 2 3 4 5 6 7 15 11 10 11 5 13 14 15 16 17 18 19 20 3 22 23 24 16 26 27 28 29 29 43 32 33 34 35 36 37 38 39 40 41 76 43 44 45 46 47 48 41 50 51 52 53 54 55 97 57 58 59 60 61 62 63 64 65 66 67 68 30 70 71 72 73 74 75 76 77 78 79 80 81 88 83 84 85 86 87 88 265 90 91 92 93 94 95 96 97 98 99 100\n", "outpu... | code_stdio |
[
{
"content": "Little Petya loves inequations. Help him find n positive integers a1, a2, ..., an, such that the following two conditions are satisfied:\n\n * a12 + a22 + ... + an2 ≥ x\n * a1 + a2 + ... + an ≤ y\n\nInput\n\nThe first line contains three space-separated integers n, x and y (1 ≤ n ≤ 105, 1 ≤ x ≤ ... | [{"input": "45678 783917268558 931068\n", "output": "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n... | code_stdio |
[
{
"content": "You have the `radius` of a circle with the center in point `(0,0)`.\n\nWrite a function that calculates the number of points in the circle where `(x,y)` - the cartesian coordinates of the points - are `integers`.\n\nExample: for `radius = 2` the result should be `13`.\n\n`0 <= radius <= 1000`\n\n!... | [{"input": "1000", "output": "[3141549]", "fn_name": "points"}, {"input": "99", "output": "[30757]", "fn_name": "points"}, {"input": "55", "output": "[9477]", "fn_name": "points"}, {"input": "33", "output": "[3409]", "fn_name": "points"}, {"input": "42", "output": "[5525]", "fn_name": "points"}, {"input": "15", "output... | code_functional |
[
{
"content": "You are given two squares, one with sides parallel to the coordinate axes, and another one with sides at 45 degrees to the coordinate axes. Find whether the two squares intersect.\n\nThe interior of the square is considered to be part of the square, i.e. if one square is completely inside another,... | [{"input": "-17 -91 -17 -27 -81 -27 -81 -91\n-48 -21 -12 -57 -48 -93 -84 -57\n", "output": "YES\n"}, {"input": "-17 -91 -17 -27 -81 -27 -81 -91\n-48 -21 -12 -57 -48 -93 -84 -57\n", "output": "YES\n"}, {"input": "-100 -100 -100 -99 -99 -99 -99 -100\n-10 -10 -9 -9 -10 -8 -11 -9\n", "output": "NO\n"}, {"input": "-100 -100... | code_stdio |
[
{
"content": "Mr. Chanek gives you a sequence a indexed from 1 to n. Define f(a) as the number of indices where a_i = i. \n\nYou can pick an element from the current sequence and remove it, then concatenate the remaining elements together. For example, if you remove the 3-rd element from the sequence [4, 2, 3, ... | [{"input": "7\n2 1 4 2 5 3 7\n", "output": "3\n"}, {"input": "4\n4 3 3 1\n", "output": "1\n"}, {"input": "4\n4 2 3 1\n", "output": "2\n"}, {"input": "1\n200000\n", "output": "0\n"}, {"input": "1\n69861\n", "output": "0\n"}, {"input": "1\n70524\n", "output": "0\n"}, {"input": "1\n46702\n", "output": "0\n"}, {"input": "1... | code_stdio |
[
{
"content": "We're giving away nice huge bags containing number tiles! A bag we want to present to you contains n tiles. Each of them has a single number written on it — either 1 or 2.\n\nHowever, there is one condition you must fulfill in order to receive the prize. You will need to put all the tiles from the... | [{"input": "214\n1 2 2 1 1 1 2 2 2 2 1 1 1 2 2 2 2 2 2 1 2 1 1 2 2 1 1 2 2 2 2 1 2 2 2 1 1 2 2 2 1 1 2 2 1 2 2 2 1 1 2 1 1 2 1 1 1 2 2 2 2 1 2 2 2 1 2 1 2 1 1 2 2 1 1 2 1 2 2 2 2 2 2 2 1 2 1 2 2 1 2 2 2 1 2 2 1 2 2 1 2 2 2 2 1 2 2 2 1 1 2 2 2 2 2 2 1 2 2 2 2 1 1 1 2 2 2 1 2 1 2 1 1 2 1 1 1 2 2 2 1 2 2 2 2 2 2 2 1 2 2 1... | code_stdio |
[
{
"content": "problem\n\nThere is a mysterious device $ M $, and if you put Tanuki and Fox in this device, one animal will come out from the device (hereinafter, Tanuki will be $ T $ and Fox will be $ F $).\n\n$ M (x, y) $ represents an animal that came out by putting animals in the device $ M $ in the order of... | [{"input": "3\nF S T", "output": "T\n"}, {"input": "3\nF R T", "output": "T\n"}, {"input": "3\nG S T", "output": "T\n"}, {"input": "3\nG R T", "output": "T\n"}, {"input": "3\nH R T", "output": "T\n"}, {"input": "3\nF U T", "output": "T\n"}, {"input": "3\nE S T", "output": "T\n"}, {"input": "3\nE T T", "output": "T\n"},... | code_stdio |
[
{
"content": "You are given an integer $x$ and an array of integers $a_1, a_2, \\ldots, a_n$. You have to determine if the number $a_1! + a_2! + \\ldots + a_n!$ is divisible by $x!$.\n\nHere $k!$ is a factorial of $k$ — the product of all positive integers less than or equal to $k$. For example, $3! = 1 \\cdot ... | [{"input": "79 6\n2 2 4 3 5 1 2 2 1 5 5 3 2 1 3 4 2 1 2 1 2 2 3 1 6 6 6 3 1 3 6 3 4 5 1 2 2 3 1 5 3 4 1 3 1 3 1 1 5 2 3 3 2 2 3 1 3 5 5 1 1 3 3 4 3 1 5 4 1 4 4 1 3 1 2 1 1 1 1\n", "output": "Yes\n"}, {"input": "10 5\n4 3 2 1 4 3 2 4 3 4\n", "output": "No\n"}, {"input": "2 500000\n499999 499999\n", "output": "No\n"}, {"... | code_stdio |
[
{
"content": "You have array a_1, a_2, ..., a_{n}. Segment [l, r] (1 ≤ l ≤ r ≤ n) is good if a_{i} = a_{i} - 1 + a_{i} - 2, for all i (l + 2 ≤ i ≤ r).\n\nLet's define len([l, r]) = r - l + 1, len([l, r]) is the length of the segment [l, r]. Segment [l_1, r_1], is longer than segment [l_2, r_2], if len([l_1, r_1... | [{"input": "51\n1 -1 1 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 1 -1 0 -1 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0\n", "output": "16\n"}, {"input": "51\n1 -1 1 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 1 -1 0 -1 0 0 0 0 0 0 -1 1 0 0 0 0 0 0 0\n", "output": "16\n"}, {"input": "51\n1 -1 1 0 0 0... | code_stdio |
[
{
"content": "Chef is very fond of horses. He enjoys watching them race. As expected, he has a stable full of horses. He, along with his friends, goes to his stable during the weekends to watch a few of these horses race. Chef wants his friends to enjoy the race and so he wants the race to be close. This can ha... | [{"input": "1\n5\n16 10 -2 29 41", "output": "6\n"}, {"input": "1\n5\n16 7 -1 29 41", "output": "8\n"}, {"input": "1\n5\n16 7 -2 29 41", "output": "9\n"}, {"input": "1\n5\n1 13 -1 12 14", "output": "1\n"}, {"input": "1\n5\n1 13 -2 12 14", "output": "1\n"}, {"input": "1\n5\n11 7 0 29 24", "output": "4\n"}, {"input": "1\... | code_stdio |
[
{
"content": "You are given a permutation p_1, p_2, ... , p_n (an array where each integer from 1 to n appears exactly once). The weight of the i-th element of this permutation is a_i.\n\nAt first, you separate your permutation into two non-empty sets — prefix and suffix. More formally, the first set contains e... | [{"input": "6\n2 6 1 4 3 5\n4 1 1 1 1 13\n", "output": "1\n"}, {"input": "6\n3 5 6 1 2 4\n10 5 4 5 9 2\n", "output": "2\n"}, {"input": "6\n2 6 1 4 3 5\n4 1 1 1 1 18\n", "output": "1\n"}, {"input": "6\n3 5 6 1 2 4\n7 5 4 5 9 2\n", "output": "2\n"}, {"input": "6\n2 6 1 4 3 5\n4 1 1 1 1 9\n", "output": "1\n"}, {"input": "... | code_stdio |
[
{
"content": "George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer b_{i}.\n\nTo make the round good, he needs to put at least n problems there. Besides, he needs t... | [{"input": "29 100\n20 32 41 67 72 155 331 382 399 412 465 644 484 511 515 529 690 637 679 715 733 763 826 843 862 903 276 979 989\n15 15 15 17 18 22 19 20 21 21 22 8 25 26 26 27 28 31 32 32 37 42 38 39 39 40 41 42 43 43 35 45 46 47 49 49 50 50 50 51 52 53 53 55 56 57 24 59 59 60 60 62 62 63 63 64 64 64 66 67 69 69 70 ... | code_stdio |
[
{
"content": "You are given a string s, consisting of small Latin letters. Let's denote the length of the string as |s|. The characters in the string are numbered starting from 1. \n\nYour task is to find out if it is possible to rearrange characters in string s so that for any prime number p ≤ |s| and for any ... | [{"input": "xxxxxxxxxxfxxxxxxxxxxxxxxxxxxxxxxxxxxxrxtxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxexxxxmxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxoxxxxxxxxxxexxxxxxxxixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxoxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxtxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxuxxxxxxxxxxxxxxxxxxxxxxxxxxxx... | code_stdio |
[
{
"content": "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 co... | [{"input": "2\n101\n011\n1111\n1010", "output": "Lucky Chef\n1\nUnlucky Chef\n"}, {"input": "2\n001\n111\n1111\n1010", "output": "Lucky Chef\n2\nUnlucky Chef\n"}, {"input": "2\n111\n110\n1111\n1010", "output": "Unlucky Chef\nUnlucky Chef\n"}, {"input": "2\n110\n110\n1111\n1010", "output": "Lucky Chef\n0\nUnlucky Chef\n... | code_stdio |
[
{
"content": "I have a plan to go on a school trip at a school. I conducted a questionnaire survey for that purpose. Students have student numbers from 1 to n, and the locations of travel candidates are represented by numbers from 1 to m, and where they want to go ○ , Mark the places you don't want to go with a... | [{"input": "4 6\n0 0 1 0 1 1\n2 2 0 1 0 0\n1 1 2 0 2 1\n1 0 1 -1 1 0\n4 6\n1 0 1 0 1 1\n0 1 -1 2 -1 0\n1 1 1 0 -1 0\n1 0 1 0 1 0\n0 0", "output": "1 3 5 2 6 4\n1 2 3 4 6 5\n"}, {"input": "4 6\n1 0 1 0 1 1\n2 2 0 1 0 0\n1 1 2 0 2 1\n1 0 1 -1 0 0\n4 6\n1 0 1 0 1 1\n0 1 -1 2 -1 0\n1 1 1 0 -1 0\n1 0 1 0 1 0\n0 0", "output"... | code_stdio |
[
{
"content": "Takahashi has a string S of length N consisting of lowercase English letters. On this string, he will perform the following operation K times:\n\n* Let T be the string obtained by reversing S, and U be the string obtained by concatenating S and T in this order.\n* Let S' be some contiguous substri... | [{"input": "10 2\nbbbabbbaaa", "output": "aaaaaaaaaa\n"}, {"input": "10 3\nbbaabbbaab", "output": "aaaaaaaabb\n"}, {"input": "10 2\nbaabbbaabb", "output": "aaaabbbaab\n"}, {"input": "10 2\nbaabbaaabb", "output": "aaaaaabbbb\n"}, {"input": "10 2\nbbaaabbbab", "output": "aaaaaabbba\n"}, {"input": "10 2\nbabbbbaabb", "out... | code_stdio |
[
{
"content": "It's another Start[c]up finals, and that means there is pizza to order for the onsite contestants. There are only 2 types of pizza (obviously not, but let's just pretend for the sake of the problem), and all pizzas contain exactly S slices.\n\nIt is known that the i-th contestant will eat s_{i} sl... | [{"input": "25 6\n1 10 5\n1 8 4\n1 8 2\n4 8 9\n3 2 8\n1 9 5\n2 10 10\n1 9 6\n3 5 4\n2 7 8\n2 3 2\n2 6 8\n3 7 8\n4 3 7\n1 8 1\n3 6 4\n3 2 8\n2 2 1\n4 8 8\n4 13 4\n3 10 2\n3 6 6\n2 2 5\n1 6 2\n4 1 5\n", "output": "451\n"}, {"input": "25 6\n1 10 5\n1 8 4\n1 5 2\n4 8 9\n3 2 8\n1 9 5\n2 10 10\n1 9 6\n3 5 4\n2 7 8\n2 3 2\n2 ... | code_stdio |
[
{
"content": "Polycarp plans to conduct a load testing of its new project Fakebook. He already agreed with his friends that at certain points in time they will send requests to Fakebook. The load testing will last n minutes and in the i-th minute friends will send a_{i} requests.\n\nPolycarp plans to test Fakeb... | [{"input": "100\n9997 9615 4045 2846 7656 2941 2233 9214 837 3312 5832 578 6146 8773 164 7303 3260 8684 1732 6608 9061 9224 7263 7279 1361 1823 8075 5946 2236 6529 6783 7494 510 1217 1135 8745 6517 141 8180 1948 6827 6091 2730 897 1254 705 1990 1806 1957 2571 8355 5542 5536 1527 886 2093 1532 4868 2348 7387 5218 3181 3... | code_stdio |
[
{
"content": "Suppose you are living with two cats: A and B. There are $n$ napping spots where both cats usually sleep.\n\nYour cats like to sleep and also like all these spots, so they change napping spot each hour cyclically:\n\nCat A changes its napping place in order: $n, n - 1, n - 2, \\dots, 3, 2, 1, n, n... | [{"input": "7\n2 1\n2 2\n3 1\n3 2\n3 3\n5 5\n69 1337\n", "output": "\n1\n2\n1\n3\n2\n2\n65\n"}, {"input": "7\n2 1\n2 2\n3 1\n3 2\n3 3\n5 5\n69 1337\n", "output": "1\n2\n1\n3\n2\n2\n65\n"}, {"input": "7\n2 1\n2 2\n3 1\n3 2\n3 3\n5 5\n69 1154\n", "output": "1\n2\n1\n3\n2\n2\n14\n"}, {"input": "7\n2 1\n2 2\n3 1\n3 2\n5 3\... | code_stdio |
[
{
"content": "One day Mr. Takahashi picked up a dictionary containing all of the N! permutations of integers 1 through N. The dictionary has N! pages, and page i (1 ≤ i ≤ N!) contains the i-th permutation in the lexicographical order.\n\nMr. Takahashi wanted to look up a certain permutation of length N in this ... | [{"input": "10\n0 3 0 0 1 0 6 0 0 0", "output": "422479810\n"}, {"input": "10\n0 5 0 0 1 0 6 0 0 0", "output": "248297410\n"}, {"input": "10\n0 3 0 0 1 0 2 0 0 0", "output": "509059163\n"}, {"input": "10\n0 3 0 0 1 0 8 0 0 0", "output": "891629577\n"}, {"input": "10\n0 3 0 0 2 0 4 0 0 0", "output": "688254850\n"}, {"in... | code_stdio |
[
{
"content": "There are N squares arranged in a row from left to right.\nThe height of the i-th square from the left is H_i.\nYou will land on a square of your choice, then repeat moving to the adjacent square on the right as long as the height of the next square is not greater than that of the current square.\... | [{"input": "9449\n43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482505 43482... | code_stdio |
[
{
"content": "You are given two sequences $a_1, a_2, \\dots, a_n$ and $b_1, b_2, \\dots, b_n$. Each element of both sequences is either $0$, $1$ or $2$. The number of elements $0$, $1$, $2$ in the sequence $a$ is $x_1$, $y_1$, $z_1$ respectively, and the number of elements $0$, $1$, $2$ in the sequence $b$ is $... | [{"input": "1\n45094381 58629867 47778466\n33028864 48902149 69571701\n", "output": "46602292\n"}, {"input": "1\n45094381 58629867 47778466\n33028864 48902149 69571701\n", "output": "46602292\n"}, {"input": "3\n2 3 2\n3 3 1\n4 0 1\n2 3 0\n0 0 1\n0 0 1\n", "output": "4\n2\n0\n"}, {"input": "3\n2 3 2\n3 3 1\n4 0 1\n3 3 0... | code_stdio |
[
{
"content": "Draw a frame which has a height of H cm and a width of W cm. For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm.\n\n\n\n........#\n........#\n........#\n........#\n\n\n\nConstraints\n\n* 3 ≤ H ≤ 300\n* 3 ≤ W ≤ 300\n\nInput\n\nThe input consists of multi... | [{"input": "5 7\n2 1\n17 12\n0 0", "output": "#######\n#.....#\n#.....#\n#.....#\n#######\n\n#\n#\n\n############\n#..........#\n#..........#\n#..........#\n#..........#\n#..........#\n#..........#\n#..........#\n#..........#\n#..........#\n#..........#\n#..........#\n#..........#\n#..........#\n#..........#\n#........... | code_stdio |
[
{
"content": "You are given string s. Let's call word any largest sequence of consecutive symbols without symbols ',' (comma) and ';' (semicolon). For example, there are four words in string \"aba,123;1a;0\": \"aba\", \"123\", \"1a\", \"0\". A word can be empty: for example, the string s=\";;\" contains three e... | [{"input": ";.,;,.;,.;,.;,.,,.,.,,,,,....;;...;..,,;,aa,00a,01a,0,0.,.,,.0.;10.1;1b1,A,A.n,000000;00,0000.0,0.0000;;;;;;;;...\n", "output": "\"0\"\n\",.,,,.,,.,,.,,.,,.,.,,,,,....,,...,..,,,,aa,00a,01a,0.,.,,.0.,10.1,1b1,A,A.n,000000,00,0000.0,0.0000,,,,,,,,...\"\n"}, {"input": ";.,;,.;,.;,.;,.,,.,.,,,,,....;;...;..,,;... | code_stdio |
[
{
"content": "Write a program to find the remainder when an integer A is divided by an integer B.\n\n-----Input-----\n\nThe first line contains an integer T, the total number of test cases. Then T lines follow, each line contains two Integers A and B. \n\n-----Output-----\nFor each test case, find the remainder... | [{"input": "3 \n1 4\n111 1167\n12 36", "output": "1\n111\n12\n"}, {"input": "3 \n1 4\n111 1167\n20 36", "output": "1\n111\n20\n"}, {"input": "3 \n2 4\n111 1167\n20 65", "output": "2\n111\n20\n"}, {"input": "3 \n0 2\n100 200\n10 40", "output": "0\n100\n10\n"}, {"input": "3 \n1 2\n100 136\n10 40", "output": "1\n100\n10\n... | code_stdio |
[
{
"content": "You are given an integer N. Consider all possible segments on the coordinate axis with endpoints at integer points with coordinates between 0 and N, inclusive; there will be $\\frac{n(n + 1)}{2}$ of them.\n\nYou want to draw these segments in several layers so that in each layer the segments don't... | [{"input": "100\n", "output": "2550\n"}, {"input": "100\n", "output": "2550\n"}, {"input": "63\n", "output": "1024\n"}, {"input": "64\n", "output": "1056\n"}, {"input": "65\n", "output": "1089\n"}, {"input": "66\n", "output": "1122\n"}, {"input": "67\n", "output": "1156\n"}, {"input": "68\n", "output": "1190\n"}, {"inp... | code_stdio |
[
{
"content": "Let there be an array $b_1, b_2, \\ldots, b_k$. Let there be a partition of this array into segments $[l_1; r_1], [l_2; r_2], \\ldots, [l_c; r_c]$, where $l_1 = 1$, $r_c = k$, and for any $2 \\leq i \\leq c$ holds that $r_{i-1} + 1 = l_i$. In other words, each element of the array belongs to exact... | [{"input": "30\n1\n0\n2\n0 0\n2\n0 1\n2\n1 0\n1\n1000000000\n2\n1000000000 1000000000\n2\n999999999 1000000000\n2\n1000000000 999999999\n5\n0 1 2 3 4\n5\n4 3 2 1 0\n5\n1 0 0 0 2\n1\n0\n5\n0 0 0 3 0\n1\n1\n1\n0\n1\n0\n1\n1\n2\n2 2\n5\n4 4 5 5 3\n4\n2 1 1 1\n5\n2 1 2 0 2\n1\n0\n1\n0\n4\n0 1 0 0\n2\n0 0\n4\n1 0 0 0\n4\n0 ... | code_stdio |
[
{
"content": "In Fire City, there are n intersections and m one-way roads. The i-th road goes from intersection a_i to b_i and has length l_i miles. \n\nThere are q cars that may only drive along those roads. The i-th car starts at intersection v_i and has an odometer that begins at s_i, increments for each mil... | [{"input": "4 4\n1 2 0\n2 3 1\n3 1 2\n1 4 3\n3\n1 1 2\n1 2 1\n4 0 1\n", "output": "YES\nYES\nYES\n"}, {"input": "4 4\n1 2 1\n2 3 1\n3 1 2\n1 4 3\n3\n1 1 3\n1 2 4\n4 0 1\n", "output": "\nYES\nNO\nYES\n"}, {"input": "4 4\n1 2 1\n2 3 1\n3 1 2\n1 4 3\n3\n1 1 2\n1 2 1\n4 0 1\n", "output": "NO\nYES\nYES\n"}, {"input": "4 4\n... | code_stdio |
[
{
"content": "Let be `n` an integer prime with `10` e.g. `7`. \n\n`1/7 = 0.142857 142857 142857 ...`.\n\nWe see that the decimal part has a cycle: `142857`. The length of this cycle is `6`. In the same way:\n\n`1/11 = 0.09 09 09 ...`. Cycle length is `2`.\n\n# Task\n\nGiven an integer n (n > 1), the function cy... | [{"input": "1234567", "output": "[34020]", "fn_name": "cycle"}, {"input": "218713", "output": "[9744]", "fn_name": "cycle"}, {"input": "221193", "output": "[3510]", "fn_name": "cycle"}, {"input": "38127", "output": "[6230]", "fn_name": "cycle"}, {"input": "431541", "output": "[726]", "fn_name": "cycle"}, {"input": "181... | code_functional |
[
{
"content": "There is a circular pond with a perimeter of K meters, and N houses around them.\nThe i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.\nWhen traveling between these houses, you can only go around the pond.\nFind the minimum d... | [{"input": "20 3\n5 10 15\n", "output": "10\n"}, {"input": "37 3\n-1 0 91", "output": "-54\n"}, {"input": "10 3\n-2 9 50", "output": "-31\n"}, {"input": "10 3\n-2 5 50", "output": "-35\n"}, {"input": "10 3\n0 1 110", "output": "-99\n"}, {"input": "10 3\n0 1 100", "output": "-89\n"}, {"input": "7 3\n-1 14 54", "output":... | code_stdio |
[
{
"content": "Your math teacher gave you the following problem:\n\nThere are $n$ segments on the $x$-axis, $[l_1; r_1], [l_2; r_2], \\ldots, [l_n; r_n]$. The segment $[l; r]$ includes the bounds, i.e. it is a set of such $x$ that $l \\le x \\le r$. The length of the segment $[l; r]$ is equal to $r - l$.\n\nTwo ... | [{"input": "1\n10\n132182352 630066892\n906984407 923129673\n100213482 882571434\n191064823 398771294\n243750814 1483105037\n322757488 608184251\n241900265 682732740\n197067927 815099563\n17475338 866870249\n271628366 729808874\n", "output": "508213113\n"}, {"input": "1\n10\n132182352 57732154\n323711215 923129673\n100... | code_stdio |
[
{
"content": "Let's denote a $k$-step ladder as the following structure: exactly $k + 2$ wooden planks, of which\n\n two planks of length at least $k+1$ — the base of the ladder; $k$ planks of length at least $1$ — the steps of the ladder; \n\nNote that neither the base planks, nor the steps planks are requir... | [{"input": "4\n4\n1 12 1 3\n3\n1 3 1\n5\n2 1 3 1 2\n3\n1 1 2\n", "output": "2\n0\n1\n0\n"}, {"input": "4\n4\n1 12 1 3\n3\n1 3 1\n5\n2 1 3 4 2\n3\n1 1 2\n", "output": "2\n0\n2\n0\n"}, {"input": "4\n4\n1 3 1 3\n3\n3 3 2\n5\n2 3 3 4 2\n3\n1 1 2\n", "output": "2\n1\n2\n0\n"}, {"input": "4\n4\n1 4 1 3\n3\n3 3 2\n5\n2 3 3 4 ... | code_stdio |
[
{
"content": "# Task\nJohn is an orchard worker. \n\nThere are `n` piles of fruits waiting to be transported. Each pile of fruit has a corresponding weight. John's job is to combine the fruits into a pile and wait for the truck to take them away.\n\nEvery time, John can combine any two piles(`may be adjacent pi... | [{"input": "[11, 9, 20, 10, 21, 35, 15, 34, 48, 76, 94, 28, 79, 16, 4, 41, 98, 30, 35, 92, 93, 33, 100, 93, 64, 23, 37, 6, 86, 27, 48, 16, 66, 99, 61, 83, 3, 5, 95]", "output": "[9056]", "fn_name": "comb"}, {"input": "[87, 84, 42, 34, 24, 81, 60, 48, 75]", "output": "[1663]", "fn_name": "comb"}, {"input": "[4, 3, 5, 6,... | code_functional |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nChef wants to hire a new assistant. He published an advertisement regarding that in a newspaper. After seeing the advertisement, many candidates have applied for the job. Now chef wants to shortlist people for the interviews, so he gav... | [{"input": "2\n109\n1", "output": "110\n1\n"}, {"input": "2\n185\n1", "output": "228\n1\n"}, {"input": "2\n15\n12", "output": "24\n28\n"}, {"input": "2\n208\n1", "output": "434\n1\n"}, {"input": "2\n78\n3", "output": "168\n4\n"}, {"input": "2\n84\n3", "output": "224\n4\n"}, {"input": "2\n84\n2", "output": "224\n3\n"}, ... | code_stdio |
[
{
"content": "You have a fraction $\\frac{a}{b}$. You need to find the first occurrence of digit c into decimal notation of the fraction after decimal point.\n\n\n-----Input-----\n\nThe first contains three single positive integers a, b, c (1 ≤ a < b ≤ 10^5, 0 ≤ c ≤ 9).\n\n\n-----Output-----\n\nPrint position o... | [{"input": "99999 100000 13\n", "output": "-1\n"}, {"input": "69168 84860 4\n", "output": "107\n"}, {"input": "25102 31579 2\n", "output": "174\n"}, {"input": "13805 15538 3\n", "output": "164\n"}, {"input": "38790 39359 0\n", "output": "212\n"}, {"input": "47117 78718 0\n", "output": "213\n"}, {"input": "99999 100000 ... | code_stdio |
[
{
"content": "Ohana Matsumae is trying to clean a room, which is divided up into an n by n grid of squares. Each square is initially either clean or dirty. Ohana can sweep her broom over columns of the grid. Her broom is very strange: if she sweeps over a clean square, it will become dirty, and if she sweeps ov... | [{"input": "20\n10101011101000011010\n11111010001100110101\n01011100010000001111\n10110100000101010011\n11010001110111101101\n00100110011011101010\n01000110101011001100\n01101100111101101101\n10111010010100111100\n00010010110001101110\n10111110010000101010\n10010111110100100100\n11010111001111110100\n111101111011000000... | code_stdio |
[
{
"content": "Lucy likes letters. She studied the definition of the lexicographical order at school and plays with it.\n\nAt first, she tried to construct the lexicographically smallest word out of given letters. It was so easy! Then she tried to build multiple words and minimize one of them. This was much hard... | [{"input": "100 1 92\nxwcbimztwcyuckyappbkrddnxgnxqvmobveinzvvnseqxooecwrrdeuwzfzxvfkvguqrsofbbnhfcscxggpxzmruycgqfmnnoovd\n", "output": "a\nb\nb\nb\nb\nb\nc\nc\nc\nc\nc\nc\nc\nd\nd\nd\nd\ne\ne\ne\ne\nf\nf\nf\nf\nf\ng\ng\ng\ng\ng\nh\ni\ni\nk\nk\nk\nm\nm\nm\nm\nn\nn\nn\nn\nn\nn\nn\no\no\no\no\no\no\np\np\np\nq\nq\nq\nq\... | code_stdio |
[
{
"content": "Ralph has a magic field which is divided into n × m blocks. That is to say, there are n rows and m columns on the field. Ralph can put an integer in each block. However, the magic field doesn't always work properly. It works only if the product of integers in each row and each column equals to k, ... | [{"input": "1319740251273561528 1167937824526374114 1\n", "output": "855801178\n"}, {"input": "999999999999999999 1000000000000000000 1\n", "output": "102810659\n"}, {"input": "999999999999999999 1000000000000000000 1\n", "output": "102810659\n"}, {"input": "987654321987654321 1167937824526374114 1\n", "output": "18645... | code_stdio |
[
{
"content": "You are given a string s and should process m queries. Each query is described by two 1-based indices l_{i}, r_{i} and integer k_{i}. It means that you should cyclically shift the substring s[l_{i}... r_{i}] k_{i} times. The queries should be processed one after another in the order they are given... | [{"input": "tcpyttzcpo\n10\n2 3 6\n2 4 1\n2 6 9\n7 10 5\n2 3 5\n4 10 6\n3 4 5\n7 9 4\n9 10 7\n2 10 8\n", "output": "ttcyopztcp\n"}, {"input": "tcpyzttcpo\n10\n2 3 6\n4 4 1\n2 6 9\n2 10 5\n2 3 5\n4 5 11\n3 4 5\n7 9 4\n9 10 7\n1 10 8\n", "output": "pccozptytt\n"}, {"input": "tcpyzttcpo\n10\n2 3 6\n2 4 1\n2 6 9\n7 10 5\n2... | code_stdio |
[
{
"content": "Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!\n\nThe computers bought for the room were different. So... | [{"input": "37 80 100\n31\n901706521 USB\n555265160 PS/2\n547038505 PS/2\n644436873 PS/2\n105558073 USB\n915082057 PS/2\n913113815 USB\n953413471 PS/2\n252912707 PS/2\n830344497 USB\n781593007 USB\n610659875 PS/2\n177755858 PS/2\n496444729 PS/2\n617569418 USB\n304908147 PS/2\n188649950 PS/2\n705737216 USB\n473915286 US... | code_stdio |
[
{
"content": "The Red Kingdom is attacked by the White King and the Black King!\n\nThe Kingdom is guarded by $n$ castles, the $i$-th castle is defended by $a_i$ soldiers. To conquer the Red Kingdom, the Kings have to eliminate all the defenders. \n\nEach day the White King launches an attack on one of the castl... | [{"input": "10\n6 3 4 5\n2 3 2 3 1 3\n1 5 4 3\n10\n4 4 2 3\n0 10 14 5\n2 2 1 4\n8 5\n3 5 3 5\n9 2 10\n4 5 5 5\n2 10 2 2\n2 3 1 4\n1 10\n3 1 5 3\n11 8 7\n2 5 4 5\n8 8\n3 5 1 4\n5 2 10\n", "output": "0\n2\n3\n2\n5\n12\n5\n0\n0\n2\n"}, {"input": "10\n6 3 4 5\n2 3 2 3 1 3\n1 5 4 3\n10\n4 4 2 3\n0 10 14 5\n2 2 1 4\n8 3\n3 5... | code_stdio |
[
{
"content": "Chef likes rectangles. Among all possible rectangles, he loves rectangles that can be drawn like a grid, such that they have N rows and M columns. Grids are common in Byteland. Hence, Chef has drawn such a rectangle and plans on moving around in it.\n\nThe rows of the rectangle are labeled from 1 ... | [{"input": "3\n1 10 2\n4 2 2\n1 9 -2", "output": "2\n1\n-2\n"}, {"input": "3\n2 14 2\n4 2 2\n1 9 -2", "output": "1\n1\n-2\n"}, {"input": "3\n2 18 2\n4 2 3\n1 4 -1", "output": "1\n2\n-1\n"}, {"input": "3\n2 2 1\n3 1 2\n1 5 12", "output": "1\n2\n12\n"}, {"input": "3\n2 2 2\n3 2 2\n1 5 12", "output": "1\n1\n12\n"}, {"inpu... | code_stdio |
[
{
"content": "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\" se... | [{"input": "\"I don't know if this will work without watering it first.\"", "output": "[\"sludge\"]", "fn_name": "bucket_of"}, {"input": "\"you know what, i don't know what was in that Barth burger\"", "output": "[\"slime\"]", "fn_name": "bucket_of"}, {"input": "\"i'm just going to wash my hands of this\"", "output": "... | code_functional |
[
{
"content": "There is an infinite sequence consisting of all positive integers in the increasing order: p = {1, 2, 3, ...}. We performed n swap operations with this sequence. A swap(a, b) is an operation of swapping the elements of the sequence on positions a and b. Your task is to find the number of inversion... | [{"input": "30\n1 200000\n2 199999\n3 199998\n4 199997\n5 199996\n200001 399996\n200002 399997\n200003 399998\n200004 399999\n200005 400000\n400001 599998\n400002 599999\n400003 600000\n400004 599996\n400005 599995\n600001 800000\n600002 799999\n600003 799998\n600004 799997\n600005 799996\n600001 799998\n600002 799999\... | code_stdio |
[
{
"content": "You have a garden consisting entirely of grass and weeds. Your garden is described by an n × m grid, with rows numbered 1 to n from top to bottom, and columns 1 to m from left to right. Each cell is identified by a pair (r, c) which means that the cell is located at row r and column c. Each cell m... | [{"input": "3 150\nGGGWGGGGWWGGGGGGGGGGGGGWGGWGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGWGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGWGGGGGGGWGGGGGGGGGGGGGGGGGWGGGGGGGGGGGGGGGGGGW\nGGGGGGGGGGGGWGGGGGGGGGWGGGGGGGGGGGGWGGGGGWGGGGGGGWGGGGGGGWGGGGGWGGGGGGGGGGGGGGGGGGGGGGGGWGGGGWGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGWGGWGG... | code_stdio |
[
{
"content": "<image>\n\nInput\n\nThe input contains two integers row, col (0 ≤ row, col ≤ 63), separated by a single space.\n\nOutput\n\nOutput \"IN\" or \"OUT\".\n\nExamples\n\nInput\n\n\n0 0\n\n\nOutput\n\n\nOUT\n\n\nInput\n\n\n27 0\n\n\nOutput\n\n\nIN\n\n\nInput\n\n\n0 27\n\n\nOutput\n\n\nOUT\n\n\nInput\n\n... | [{"input": "27 36\n", "output": "OUT\n"}, {"input": "0 45\n", "output": "OUT\n"}, {"input": "53 27\n", "output": "IN\n"}, {"input": "0 18\n", "output": "OUT\n"}, {"input": "51 1\n", "output": "OUT\n"}, {"input": "0 13\n", "output": "OUT\n"}, {"input": "51 0\n", "output": "OUT\n"}, {"input": "1 13\n", "output": "OUT\n"}... | code_stdio |
[
{
"content": "Gildong has a square board consisting of n rows and n columns of square cells, each consisting of a single digit (from 0 to 9). The cell at the j-th column of the i-th row can be represented as (i, j), and the length of the side of each cell is 1. Gildong likes big things, so for each digit d, he ... | [{"input": "5\n3\n000\n122\n101\n2\n57\n75\n4\n0123\n5469\n3401\n2340\n1\n9\n8\n42987101\n91120855\n77861569\n87599023\n92834718\n83917348\n19823743\n38947912\n", "output": "4 4 1 0 0 0 0 0 0 0\n0 0 0 0 0 1 0 1 0 0\n9 6 9 9 4 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n18 49 49 49 49 30 15 35 42 42\n"}, {"input": "5\n3\n000\n122\n... | code_stdio |
[
{
"content": "You are given an integer $n$ and an array $a_1, a_2, \\ldots, a_n$. You should reorder the elements of the array $a$ in such way that the sum of $\\textbf{MEX}$ on prefixes ($i$-th prefix is $a_1, a_2, \\ldots, a_i$) is maximized.\n\nFormally, you should find an array $b_1, b_2, \\ldots, b_n$, suc... | [{"input": "1\n100\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1... | code_stdio |
[
{
"content": "Write a program which reads an integer n and identifies the number of combinations of a, b, c and d (0 ≤ a, b, c, d ≤ 9) which meet the following equality:\n\na + b + c + d = n\n\nFor example, for n = 35, we have 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), a... | [{"input": "35\n011", "output": "4\n348\n"}, {"input": "35\n010", "output": "4\n282\n"}, {"input": "35\n15", "output": "4\n592\n"}, {"input": "35\n26", "output": "4\n282\n"}, {"input": "35\n13", "output": "4\n480\n"}, {"input": "35\n29", "output": "4\n120\n"}, {"input": "35\n22", "output": "4\n540\n"}, {"input": "35\n1... | code_stdio |
[
{
"content": "Aoki loves numerical sequences and trees.\n\nOne day, Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree.\n\nAoki wants to construct a tree with N vertices numbered 1 through N, such that for each i = 1,2,...,N, the distance between vert... | [{"input": "10\n-1 0 -2 6 1 -4 0 0 0 -1", "output": "Impossible\n"}, {"input": "10\n-1 0 -2 6 1 -4 0 0 1 -1", "output": "Impossible\n"}, {"input": "10\n-1 1 -2 6 2 -1 2 0 0 2", "output": "Impossible\n"}, {"input": "10\n-1 2 -2 6 2 -1 2 0 0 2", "output": "Impossible\n"}, {"input": "10\n-1 2 -2 6 2 -1 2 0 0 0", "output":... | code_stdio |
[
{
"content": "Jamie is preparing a Codeforces round. He has got an idea for a problem, but does not know how to solve it. Help him write a solution to the following problem:\n\nFind k integers such that the sum of two to the power of each number equals to the number n and the largest integer in the answer is as... | [{"input": "10 19228\n", "output": "Yes\n-10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10... | code_stdio |
[
{
"content": "A penguin Rocher has $n$ sticks. He has exactly one stick with length $i$ for all $1 \\le i \\le n$.\n\nHe can connect some sticks. If he connects two sticks that have lengths $a$ and $b$, he gets one stick with length $a + b$. Two sticks, that were used in the operation disappear from his set and... | [{"input": "4\n1\n2\n3\n20\n", "output": "1\n1\n2\n10\n"}, {"input": "4\n1\n3\n3\n20\n", "output": "1\n2\n2\n10\n"}, {"input": "4\n3\n2\n12\n15\n", "output": "2\n1\n6\n8\n"}, {"input": "4\n1\n3\n1\n20\n", "output": "1\n2\n1\n10\n"}, {"input": "4\n3\n2\n15\n15\n", "output": "2\n1\n8\n8\n"}, {"input": "4\n1\n3\n1\n36\n",... | code_stdio |
[
{
"content": "Find the longest substring in alphabetical order.\n\nExample: the longest alphabetical substring in `\"asdfaaaabbbbcttavvfffffdf\"` is `\"aaaabbbbctt\"`.\n\nThere are tests with strings up to `10 000` characters long so your code will need to be efficient.\n\nThe input will only consist of lowerca... | [{"input": "\"asdfaaaabbbbcttavvfffffdf\"", "output": "[\"aaaabbbbctt\"]", "fn_name": "longest"}, {"input": "\"asdfbyfgiklag\"", "output": "[\"fgikl\"]", "fn_name": "longest"}, {"input": "\"abcdeapbcdef\"", "output": "[\"abcde\"]", "fn_name": "longest"}, {"input": "\"asd\"", "output": "[\"as\"]", "fn_name": "longest"},... | code_functional |
[
{
"content": "Pak Chanek has a grid that has $N$ rows and $M$ columns. Each row is numbered from $1$ to $N$ from top to bottom. Each column is numbered from $1$ to $M$ from left to right.\n\nEach tile in the grid contains a number. The numbers are arranged as follows:\n\nRow $1$ contains integers from $1$ to $M... | [{"input": "1000000000 1000000000\n", "output": "999999999000000000\n"}, {"input": "767928735 1000000000\n", "output": "767928734232071265\n"}, {"input": "1000000000 906523442\n", "output": "906523441000000000\n"}, {"input": "647242241 921242095\n", "output": "596266797424092654\n"}, {"input": "2 1000000000\n", "output... | code_stdio |
[
{
"content": "A brave princess in a poor country's tomboy is married to another country for a political marriage. However, a villain who is trying to kill the princess is releasing a thug on the way to his wife.\n\nYou have already decided on a safe route to safely deliver the princess to the other country, but... | [{"input": "3 2 10\n1 2 13 6\n2 3 10 3\n3 2 10\n1 2 3 16\n2 3 9 7\n3 3 10\n1 3 17 6\n1 2 2 4\n2 3 9 19\n4 4 5\n1 3 13 5\n1 4 7 25\n2 3 8 2\n2 4 9 3\n0 0 0", "output": "6\n7\n4\n10\n"}, {"input": "3 2 10\n1 2 8 5\n2 3 10 0\n3 2 10\n1 2 3 8\n2 3 7 7\n3 3 10\n1 3 17 6\n1 2 2 4\n2 3 15 13\n4 4 5\n2 3 9 3\n1 4 7 25\n2 3 8 4... | code_stdio |
[
{
"content": "Ivan unexpectedly saw a present from one of his previous birthdays. It is array of n numbers from 1 to 200. Array is old and some numbers are hard to read. Ivan remembers that for all elements at least one of its neighbours ls not less than it, more formally:\n\na_{1} ≤ a_{2},\n\na_{n} ≤ a_{n-1} a... | [{"input": "37\n52 52 66 149 149 130 47 47 26 110 185 -1 73 73 65 -1 -1 130 -1 -1 -1 94 97 190 -1 -1 49 49 54 -1 92 92 5 25 48 79 79\n", "output": "903952722\n"}, {"input": "37\n52 52 66 149 149 130 47 47 17 110 185 -1 73 73 65 -1 -1 130 -1 -1 -1 94 97 190 -1 -1 49 49 54 -1 92 92 5 25 48 79 79\n", "output": "903952722\... | code_stdio |
[
{
"content": "Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS: \n\nYou are given two integers $d, m$, find the number of arrays $a$, satisfying the following constraints: The length of $a$ is $n$, $n \\ge 1$ $1 \\le a_1 < a_2 < \\dots < a_n \\le d$ D... | [{"input": "10\n1 1000000000\n2 999999999\n3 39238314\n2 14233839\n3 1308869\n6 99995\n13 14099\n8 474\n9 146\n10 2\n", "output": "1\n3\n5\n3\n5\n23\n209\n59\n89\n1\n"}, {"input": "10\n1 1000000000\n2 999999999\n3 99999998\n4 9999997\n5 999996\n6 99995\n7 9994\n12 993\n15 92\n10 1\n", "output": "1\n3\n5\n11\n17\n23\n29... | code_stdio |
[
{
"content": "Little girl Margarita is a big fan of competitive programming. She especially loves problems about arrays and queries on them.\n\nRecently, she was presented with an array $a$ of the size of $10^9$ elements that is filled as follows: $a_1 = -1$ $a_2 = 2$ $a_3 = -3$ $a_4 = 4$ $a_5 = -5$ And ... | [{"input": "10\n449347852 741090797\n541919355 938202256\n442458747 465872502\n463474612 789217678\n146477812 390217056\n302933612 477640295\n48191125 1417399529\n173202385 374432789\n78807265 428215825\n194590462 1318087870\n", "output": "-145871473\n198141451\n11706878\n626346145\n268347434\n-87353342\n-732795327\n-2... | code_stdio |
[
{
"content": "We have A apples and P pieces of apple.\nWe can cut an apple into three pieces of apple, and make one apple pie by simmering two pieces of apple in a pan.\nFind the maximum number of apple pies we can make with what we have now.\n\n-----Constraints-----\n - All values in input are integers.\n - 0 ... | [{"input": "100 100\n", "output": "200\n"}, {"input": "1052 1", "output": "1578\n"}, {"input": "1829 1", "output": "2744\n"}, {"input": "3156 1", "output": "4734\n"}, {"input": "1450 1", "output": "2175\n"}, {"input": "74 28\n", "output": "125\n"}, {"input": "39 85\n", "output": "101\n"}, {"input": "93 70\n", "output":... | code_stdio |
[
{
"content": "We want to encode a given string $S$ to a binary string. Each alphabet character in $S$ should be mapped to a different variable-length code and the code must not be a prefix of others.\n\nHuffman coding is known as one of ways to obtain a code table for such encoding.\n\nFor example, we consider ... | [{"input": "aaabbcccdeeegfg", "output": "41\n"}, {"input": "aaadbcccbeedgfg", "output": "42\n"}, {"input": "gegdeebcccbeaaa", "output": "38\n"}, {"input": "aeaaacccbeedgeg", "output": "36\n"}, {"input": "gegdeebccdaaaea", "output": "37\n"}, {"input": "gegdfebccdaaaea", "output": "40\n"}, {"input": "abadbcccbeedhfg", "o... | code_stdio |
[
{
"content": "Most football fans love it for the goals and excitement. Well, this Kata doesn't.\nYou are to handle the referee's little notebook and count the players who were sent off for fouls and misbehavior.\n\nThe rules:\nTwo teams, named \"A\" and \"B\" have 11 players each; players on each team are numbe... | [{"input": "[\"A4R\", \"A2R\", \"A3R\", \"A6R\", \"A8R\", \"A10R\", \"A11R\"]", "output": "[[6, 11]]", "fn_name": "men_still_standing"}, {"input": "[\"A4Y\", \"A5R\", \"B5R\", \"A4Y\", \"B6Y\"]", "output": "[[9, 10]]", "fn_name": "men_still_standing"}, {"input": "[\"A4R\", \"A4R\", \"A4R\"]", "output": "[[10, 11]]", "f... | code_functional |
[
{
"content": "There are three horses living in a horse land: one gray, one white and one gray-and-white. The horses are really amusing animals, which is why they adore special cards. Each of those cards must contain two integers, the first one on top, the second one in the bottom of the card. Let's denote a car... | [{"input": "10 10\n4 8 4 10 2 10 8 10 4 6\n", "output": " 25\n"}, {"input": "10 10\n9 3 6 6 3 3 6 3 6 9\n", "output": " 25\n"}, {"input": "5 20\n11 11 11 11 11\n", "output": " ... | code_stdio |
[
{
"content": "Petya organized a strange birthday party. He invited $n$ friends and assigned an integer $k_i$ to the $i$-th of them. Now Petya would like to give a present to each of them. In the nearby shop there are $m$ unique presents available, the $j$-th present costs $c_j$ dollars ($1 \\le c_1 \\le c_2 \\l... | [{"input": "6\n6 6\n2 3 1 5 6 6\n629717071 992393438 995305242 999968259 999970082 999971487\n6 6\n2 5 2 2 4 3\n756869732 979591024 993778447 1268827656 999873038 999943064\n6 6\n5 1 4 5 6 4\n733550952 979779220 979918868 983712198 991976436 995169050\n6 6\n4 2 2 3 2 4\n257971677 920812339 981000482 998142568 999902643... | code_stdio |
[
{
"content": "Please note the non-standard memory limit.\n\nThere are n problems numbered with integers from 1 to n. i-th problem has the complexity c_i = 2^i, tag tag_i and score s_i.\n\nAfter solving the problem i it's allowed to solve problem j if and only if IQ < |c_i - c_j| and tag_i ≠ tag_j. After solving... | [{"input": "5\n4\n3 0 1 14\n10 10 87 16\n4\n1 1 0 1\n5 3 56 24\n4\n4 0 6 1\n0 2 19 2\n2\n-1 1\n1 18\n1\n1\n666\n", "output": "160\n104\n40\n17\n0\n"}, {"input": "5\n4\n3 0 1 14\n10 10 87 16\n4\n1 1 0 1\n5 3 56 24\n4\n4 0 6 1\n0 2 22 2\n2\n-1 1\n1 18\n1\n1\n666\n", "output": "160\n104\n46\n17\n0\n"}, {"input": "5\n4\n3 ... | code_stdio |
[
{
"content": "E: Jam\n\nproblem\n\nThere are N cities in a country, numbered 1, \\ 2, \\ ..., \\ N. These cities are connected in both directions by M roads, and the i-th road allows you to travel between the cities u_i and v_i in time t_i. Also, any two cities can be reached by using several roads.\n\nBread is... | [{"input": "4 4 3\n3 12 1 6\n1 1 2 3\n10 1 9 5\n1 2 1\n2 3 1\n1 3 1\n1 4 1", "output": "20\n18\n13\n"}, {"input": "4 4 3\n3 12 1 6\n1 1 2 3\n10 1 9 5\n1 2 0\n2 3 1\n1 3 1\n1 4 1", "output": "22\n19\n15\n"}, {"input": "4 4 3\n3 12 1 6\n1 1 2 3\n10 1 9 2\n1 2 0\n2 3 1\n1 3 1\n1 4 1", "output": "22\n19\n12\n"}, {"input": ... | code_stdio |
[
{
"content": "Remainder of Big Integers\n\nGiven two integers $A$ and $B$, compute the remainder of $\\frac{A}{B}$.\n\nInput\n\nTwo integers $A$ and $B$ separated by a space character are given in a line.\n\nOutput\n\nPrint the remainder in a line.\n\nConstraints\n\n* $0 \\leq A, B \\leq 10^{1000}$\n* $B \\ne 0... | [{"input": "10 16", "output": "10\n"}, {"input": "11 12", "output": "11\n"}, {"input": "12 47", "output": "12\n"}, {"input": "14 28", "output": "14\n"}, {"input": "18 11", "output": "7\n"}, {"input": "0 100", "output": "0\n"}, {"input": "0 110", "output": "0\n"}, {"input": "1 110", "output": "1\n"}, {"input": "1 111", ... | code_stdio |
[
{
"content": "A triangle is called an equable triangle if its area equals its perimeter. Return `true`, if it is an equable triangle, else return `false`. You will be provided with the length of sides of the triangle. Happy Coding!\n\nWrite Python code to solve this problem. Define a top-level function named `e... | [{"input": "120\n109\n13", "output": "[false]", "fn_name": "equable_triangle"}, {"input": "17\n17\n30", "output": "[false]", "fn_name": "equable_triangle"}, {"input": "25\n25\n45", "output": "[false]", "fn_name": "equable_triangle"}, {"input": "13\n37\n30", "output": "[false]", "fn_name": "equable_triangle"}, {"input":... | code_functional |
[
{
"content": "Polycarp has an array $a$ consisting of $n$ integers.\n\nHe wants to play a game with this array. The game consists of several moves. On the first move he chooses any element and deletes it (after the first move the array contains $n-1$ elements). For each of the next moves he chooses any element ... | [{"input": "2\n1000000 1000000\n", "output": "1000000\n"}, {"input": "2\n1000010 1001000\n", "output": "1000010\n"}, {"input": "2\n1000110 1001000\n", "output": "1000110\n"}, {"input": "2\n1000110 1000000\n", "output": "1000000\n"}, {"input": "2\n1100010 1111100\n", "output": "1100010\n"}, {"input": "2\n1110100 1011000... | code_stdio |
[
{
"content": "A string is binary, if it consists only of characters \"0\" and \"1\".\n\nString v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string \"010\" has six substrings: \"0\", \"1\", \"0\", \"01\", \"10\", \"010\". Two subst... | [{"input": "94\n111111111111010111100111111111111011011111111011111111111011111111111111101111101111110111011111111110011111111001111101111\n", "output": "17\n"}, {"input": "94\n111111111111010111100111111111111011011111111011111111111011111111111111101111101111110111010111111110011111111001111101111\n", "output": "15\... | code_stdio |
[
{
"content": "N persons are standing in a row. The height of the i-th person from the front is A_i.\nWe want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:\nCondition: Nobody in front of the person is taller than the person. ... | [{"input": "5\n49 10 1 -4 -1", "output": "190\n"}, {"input": "5\n49 10 2 -4 -1", "output": "189\n"}, {"input": "5\n49 10 0 -4 -1", "output": "191\n"}, {"input": "5\n4 -1 107 3 0", "output": "216\n"}, {"input": "5\n4 -1 107 2 0", "output": "217\n"}, {"input": "5\n8 -1 107 2 0", "output": "221\n"}, {"input": "5\n8 -1 107... | code_stdio |
[
{
"content": "Today s kilometer long auto race takes place in Berland. The track is represented by a straight line as long as s kilometers. There are n cars taking part in the race, all of them start simultaneously at the very beginning of the track. For every car is known its behavior — the system of segments ... | [{"input": "9 81812\n8 31 410 547 18 22 77 449 5 491 8 10 382 746 21 61 523\n1 452 181\n1 724 113\n1 113 724\n1 226 362\n46 5 257 2 126 373 6 6 491 9 7 137 23 93 73 163 13 17 106 3 100 5 415 270 2 7 723 597 4 176 3 274 18 1 852 334 14 7 25 163 1 3 199 29 140 32 32 191 2 583 3 23 11 22 23 250 1 79 3 33 83 8 433 59 11 2 ... | code_stdio |
[
{
"content": "You all know the Dirichlet principle, the point of which is that if n boxes have no less than n + 1 items, that leads to the existence of a box in which there are at least two items.\n\nHaving heard of that principle, but having not mastered the technique of logical thinking, 8 year olds Stas and ... | [{"input": "10000 1 1000000000\n", "output": "Masha\n\n"}, {"input": "1010 1 1000000000\n", "output": "Masha\n\n"}, {"input": "2635 2 1000000000\n", "output": "Masha\n\n"}, {"input": "1 30 1000000000\n", "output": "Missing\n\n"}, {"input": "10000 2 1000000000\n", "output": "Stas\n\n"}, {"input": "1000 2 1000000000\n", ... | code_stdio |
[
{
"content": "Vasily the bear has a favorite rectangle, it has one vertex at point (0, 0), and the opposite vertex at point (x, y). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes. \n\nVasya also loves triangles, if the triangles have one vertex at point B = (0, 0). That's... | [{"input": "-1000000000 -1000000000\n", "output": "-2000000000 0 0 -2000000000\n"}, {"input": "-1000000000 -1000000000\n", "output": "-2000000000 0 0 -2000000000 "}, {"input": "-1000000000 -999999999\n", "output": "-1999999999 0 0 -1999999999\n"}, {"input": "-999999999 -1000000000\n", "output": "-1999999999 0 0 -199999... | code_stdio |
[
{
"content": "You have written on a piece of paper an array of n positive integers a[1], a[2], ..., a[n] and m good pairs of integers (i_1, j_1), (i_2, j_2), ..., (i_{m}, j_{m}). Each good pair (i_{k}, j_{k}) meets the following conditions: i_{k} + j_{k} is an odd number and 1 ≤ i_{k} < j_{k} ≤ n.\n\nIn one ope... | [{"input": "20 19\n512 524288 268435456 2048 16384 8192 524288 16777216 128 536870912 256 1 32768 2097152 131072 268435456 262144 134217728 8388608 16\n3 20\n5 12\n19 20\n10 15\n3 18\n3 4\n6 19\n3 14\n3 16\n5 10\n3 12\n5 20\n12 17\n8 9\n13 18\n2 11\n7 12\n6 11\n2 15\n", "output": "106\n"}, {"input": "20 19\n512 524288 ... | code_stdio |
[
{
"content": "# Task\n You are given n rectangular boxes, the ith box has the length lengthi, the width widthi and the height heighti. \n \n Your task is to check if it is possible to pack all boxes into one so that inside each box there is no more than one another box (which, in turn, can contain at most one a... | [{"input": "[5, 7, 4, 1, 2]\n[4, 10, 3, 1, 4]\n[6, 5, 5, 1, 2]", "output": "[true]", "fn_name": "boxes_packing"}, {"input": "[4, 10, 3, 1, 4]\n[5, 7, 4, 1, 2]\n[6, 5, 5, 1, 2]", "output": "[true]", "fn_name": "boxes_packing"}, {"input": "[10, 8, 6, 4, 1]\n[7, 7, 6, 3, 2]\n[9, 6, 3, 2, 1]", "output": "[true]", "fn_name"... | code_functional |
[
{
"content": "Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements:\n\n each cut should be straight (horizontal or vertical); each cut should go along edges of unit squares (it is prohibited to di... | [{"input": "1000000000 1000000000 999999999\n", "output": "1000000000\n"}, {"input": "1000000000 1000000000 1\n", "output": "500000000000000000\n"}, {"input": "1000000000 1000000000 123456\n", "output": "8099000000000\n"}, {"input": "1000000000 1000000000 220000000\n", "output": "4000000000\n"}, {"input": "1000000000 1... | code_stdio |
[
{
"content": "Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.\n\nReliable sources have informed the financier Anton of some information ab... | [{"input": "4314752277691991627730686134692292422155753465948025897701703862445837045929984759093775762579123919\n", "output": "9314752277691991627730686134692292422155753465948025897701703862445837045929984759093775762579123914\n"}, {"input": "431475227769199162773068613469229242215575346594802589770170386244583704592... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.