messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 1
value |
|---|---|---|
[
{
"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": "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 |
[
{
"content": "Malek lives in an apartment block with 100 floors numbered from 0 to 99. The apartment has an elevator with a digital counter showing the floor that the elevator is currently on. The elevator shows each digit of a number with 7 light sticks by turning them on or off. The picture below shows how th... | [{"input": "73\n", "output": "15\n"}, {"input": "11\n", "output": "49\n"}, {"input": "55\n", "output": "16\n"}, {"input": "77\n", "output": "25\n"}, {"input": "67\n", "output": "10\n"}, {"input": "35\n", "output": "12\n"}, {"input": "57\n", "output": "20\n"}, {"input": "77\n", "output": "25\n"}, {"input": "35\n", "outp... | code_stdio |
[
{
"content": "A popular game in a certain country, Pachimon Creature, has been remade and released in Japan. If you love games, after playing this game many times, you've come to think about how you can clear it the fastest. However, no matter how much you think about it, you didn't know the fastest way to capt... | [{"input": "6 6\nS.1..4\n5..3..\n..4.1.\n4....5\n.2.32.\n5.1..G\n3 2\n...\nS.G\n0 0", "output": "3 12\nNA\n"}, {"input": "6 6\nS.1..4\n3..5..\n..4.1.\n4...5.\n.2.32.\n5.1..G\n3 2\n...\nS.G\n0 0", "output": "2 10\nNA\n"}, {"input": "6 6\nS.1..4\n4..5..\n..4.1.\n4....5\n.2.32.\n5.1..G\n3 2\n...\nS.G\n0 0", "output": "3 1... | code_stdio |
[
{
"content": "Igor is a post-graduate student of chemistry faculty in Berland State University (BerSU). He needs to conduct a complicated experiment to write his thesis, but laboratory of BerSU doesn't contain all the materials required for this experiment.\n\nFortunately, chemical laws allow material transform... | [{"input": "11\n1 1 1 1 1 1 1 1 1 1 1\n1 1000000001 1000000001 1000000001 1000000001 1000000001 1000000001 1000000001 1000000001 1000000001 1000000001\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n", "output": "NO\n"}, {"inpu... | code_stdio |
[
{
"content": "There are N cities in Republic of AtCoder. The size of the i-th city is A_{i}. Takahashi would like to build N-1 bidirectional roads connecting two cities so that any city can be reached from any other city by using these roads.\n\nAssume that the cost of building a road connecting the i-th city a... | [{"input": "12 5\n95 94 27 3 104 328 93 25 27 19 46 13", "output": "1076\n"}, {"input": "12 5\n95 112 27 3 104 328 93 25 27 19 46 5", "output": "1070\n"}, {"input": "12 5\n95 94 27 3 104 328 56 25 27 19 46 7", "output": "1023\n"}, {"input": "12 5\n95 94 27 3 104 328 93 25 27 19 46 7", "output": "1060\n"}, {"input": "12... | code_stdio |
[
{
"content": "Hongcow is ruler of the world. As ruler of the world, he wants to make it easier for people to travel by road within their own countries.\n\nThe world can be modeled as an undirected graph with n nodes and m edges. k of the nodes are home to the governments of the k countries that make up the worl... | [{"input": "24 38 2\n4 13\n7 1\n24 1\n2 8\n17 2\n2 18\n22 2\n23 3\n5 9\n21 5\n6 7\n6 19\n6 20\n11 7\n7 20\n13 8\n16 8\n9 10\n14 9\n21 9\n12 10\n10 22\n23 10\n17 11\n11 24\n20 12\n13 16\n13 23\n15 14\n17 14\n14 20\n19 16\n17 20\n17 23\n18 22\n18 23\n22 19\n21 20\n23 24\n", "output": "215\n"}, {"input": "24 38 2\n4 13\n7... | 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": "Takahashi is taking exams on N subjects. The score on each subject will be an integer between 0 and K (inclusive).\nHe has already taken exams on N-1 subjects and scored A_i points on the i-th subject.\nHis goal is to achieve the average score of M points or above on the N subjects.\nPrint the min... | [{"input": "100 100 100\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": "There are n people and k keys on a straight line. Every person wants to get to the office which is located on the line as well. To do that, he needs to reach some point with a key, take the key and then go to the office. Once a key is taken by somebody, it couldn't be taken by anybody else.\n\nYou... | [{"input": "50 55 2000\n9518 9743 9338 9956 9827 9772 9094 9644 9242 9292 11221 9205 9907 9860 9530 9814 9662 9482 9725 9227 9105 9424 9268 9427 9470 9578 9808 9976 9143 9070 9079 9896 9367 9235 9925 9009 9619 9012 9669 9077 9870 9766 9479 9598 9055 9988 9792 9197 9377 9610\n828 656 345 412 69 506 274 994 384 766 587 1... | code_stdio |
[
{
"content": "There are N boxes arranged in a row.\nInitially, the i-th box from the left contains a_i candies.\nSnuke can perform the following operation any number of times:\n - Choose a box containing at least one candy, and eat one of the candies in the chosen box.\nHis objective is as follows:\n - Any two ... | [{"input": "6 1\n1 6 1 2 0 4\n", "output": "11\n"}, {"input": "-2 124\n10 2 2 6 3", "output": "0\n"}, {"input": "-2 124\n10 1 2 6 3", "output": "0\n"}, {"input": "-2 189\n10 1 2 6 3", "output": "0\n"}, {"input": "-1 124\n10 2 2 6 3", "output": "0\n"}, {"input": "-2 124\n10 1 4 6 3", "output": "0\n"}, {"input": "6 1\n2 ... | code_stdio |
[
{
"content": "Problem\n\nIf you bring an empty bottle of $ a $ milk, you can exchange it for a new bottle of $ b $ milk.\nHow many bottles of milk can Mr. Kawabayashi, who initially has a bottle of $ x $ milk, drink? Output the remainder after dividing by $ 1000000007 $.\n\nConstraints\n\nThe input satisfies th... | [{"input": "560118409912468 316250877917599 1316995007040099", "output": "500636509\n"}, {"input": "316250877917604 316250877917599 672514164456590", "output": "265329493\n"}, {"input": "560118409912468 316250877917599 681260158257385", "output": "29192407\n"}, {"input": "560118409912468 316250877917599 21421406777778"... | code_stdio |
[
{
"content": "The Little Elephant loves playing with arrays. He has array a, consisting of n positive integers, indexed from 1 to n. Let's denote the number with index i as ai. \n\nAdditionally the Little Elephant has m queries to the array, each query is characterised by a pair of integers lj and rj (1 ≤ lj ≤ ... | [{"input": "6 6\n2 1 2 3 3 10\n1 2\n2 2\n1 3\n2 4\n3 6\n2 2\n", "output": "1\n1\n2\n1\n0\n1\n"}, {"input": "6 6\n1 2 2 3 3 3\n1 2\n2 2\n1 3\n2 4\n4 6\n1 6\n", "output": "1\n0\n2\n1\n1\n3\n"}, {"input": "6 6\n1 2 2 3 3 3\n1 2\n2 2\n1 3\n4 4\n4 6\n1 6\n", "output": "1\n0\n2\n0\n1\n3\n"}, {"input": "6 6\n1 2 2 3 3 3\n1 4\... | code_stdio |
[
{
"content": "Joisino is planning to record N TV programs with recorders.\nThe TV can receive C channels numbered 1 through C.\nThe i-th program that she wants to record will be broadcast from time s_i to time t_i (including time s_i but not t_i) on Channel c_i.\nHere, there will never be more than one program ... | [{"input": "2 4\n51 60 4\n28 48 4\n89 108 5\n52 127 2\n108 134 0\n71 68 3\n31 86 3\n70 96 1\n22 12 3", "output": "1\n"}, {"input": "2 4\n56 60 4\n28 48 4\n89 90 5\n52 127 2\n108 112 0\n71 68 3\n31 86 3\n70 96 1\n11 12 3", "output": "1\n"}, {"input": "2 4\n56 60 4\n28 48 4\n89 90 5\n52 127 2\n108 112 0\n71 68 3\n31 86 3... | code_stdio |
[
{
"content": "Artist Shinagawa was asked to exhibit n works. Therefore, I decided to exhibit the six sides of the cube colored with paint as a work. The work uses all six colors, Red, Yellow, Blue, Magenta, Green, and Cyan, and each side is filled with one color. Shinagawa changed the arrangement of colors even... | [{"input": "3\nCyan Yellow Red Magenta Green Blue\nCyan Yellow Red Magenta Green Blue\nRed Yellow Magenta Blue Green Cyan\n4\nRed Mahenta Blue Green Yellow Cyan\nRed Yellow Magenta Blue Green Cyan\nMagenta Green Red Cyan Yellow Blue\nCyan Green Yellow Blue Magenta Red\n0", "output": "1\n1\n"}, {"input": "3\nCyan Yellow... | code_stdio |
[
{
"content": "Kalila and Dimna are two jackals living in a huge jungle. One day they decided to join a logging factory in order to make money. \n\nThe manager of logging factory wants them to go to the jungle and cut n trees with heights a_1, a_2, ..., a_{n}. They bought a chain saw from a shop. Each time they ... | [{"input": "6\n1 2 3 10 20 30\n6 5 4 3 2 0\n", "output": "138\n"}, {"input": "6\n2 2 3 10 20 30\n6 5 4 3 2 0\n", "output": "138\n"}, {"input": "6\n1 2 3 10 20 25\n6 5 4 3 2 0\n", "output": "118\n"}, {"input": "6\n1 1 2 10 20 25\n6 5 4 3 2 0\n", "output": "112\n"}, {"input": "6\n1 2 3 10 20 39\n6 5 4 3 2 0\n", "output":... | code_stdio |
[
{
"content": "People in Silverland use square coins. Not only they have square shapes but also their values are square numbers. Coins with values of all square numbers up to 289 (= 172), i.e., 1-credit coins, 4-credit coins, 9-credit coins, ..., and 289-credit coins, are available in Silverland.\n\nThere are fo... | [{"input": "2\n19\n51\n0", "output": "1\n10\n107\n"}, {"input": "2\n19\n92\n0", "output": "1\n10\n804\n"}, {"input": "2\n173\n0\n-6", "output": "1\n13027\n"}, {"input": "2\n10\n51\n0", "output": "1\n4\n107\n"}, {"input": "2\n27\n37\n0", "output": "1\n21\n46\n"}, {"input": "2\n25\n39\n0", "output": "1\n19\n50\n"}, {"inp... | code_stdio |
[
{
"content": "Game \"Minesweeper 1D\" is played on a line of squares, the line's height is 1 square, the line's width is n squares. Some of the squares contain bombs. If a square doesn't contain a bomb, then it contains a number from 0 to 2 — the total number of bombs in adjacent squares.\n\nFor example, the co... | [{"input": "?2*?2*??1*2**?2*1???*2???100?????*???*?*????0????2?*?*?1??1??*?01**2**1001??**??**??1*?*???00??**??*\n", "output": "147483634\n"}, {"input": "?2*?2*??1*2**?2*1???*2???100?????*???*?*????0????2?*?*?1??1??*?01**2**1001??**??**??1*?*???00??**??*\n", "output": "147483634\n"}, {"input": "*??**??00???*?*1??**??**... | code_stdio |
[
{
"content": "Trouble came from the overseas lands: a three-headed dragon Gorynych arrived. The dragon settled at point C and began to terrorize the residents of the surrounding villages.\n\nA brave hero decided to put an end to the dragon. He moved from point A to fight with Gorynych. The hero rode from point ... | [{"input": "-1000000000 1000000000\n-1000000000 -1000000000\n1000000000 -1000000000\n", "output": "LEFT\n"}, {"input": "-1000000000 1000001000\n-1000000000 -1000000000\n1000000000 -1000000000\n", "output": "LEFT\n"}, {"input": "-1000000000 1000000010\n-1000000000 -1000000000\n1000000000 -1000000000\n", "output": "LEFT\... | code_stdio |
[
{
"content": "Polycarp is working on a new project called \"Polychat\". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of comman... | [{"input": "+qlHEc2AuYy\nqlHE02AuYy:YYRwDc edNZgpE nGfOguRWnMYpTpGUVM aXDKGWo1GL1tHv9\n0Upwze6PcQNBcUovrqmIcPsG3hvy:yYuA2cEHlq oaNiKV49p[KatlVAx\nqlHEc2AuYy:zuCO6Opey L eu7lTwysaSk00zjpv zrDfbt8l ufHph\n+pErDMxgVgh\nsiLF1I:yYu@1cEHlq mmQbZtd8Ui7y 2vcax6yZBMhVdRD6Ahlq7MNCw\nqlHEc2AuYy:lz MFUNJZhlqBYckHUDlNhLiDkmecSh1... | code_stdio |
[
{
"content": "A permutation p of size n is the sequence p_1, p_2, ..., p_{n}, consisting of n distinct integers, each of them is from 1 to n (1 ≤ p_{i} ≤ n).\n\nA lucky permutation is such permutation p, that any integer i (1 ≤ i ≤ n) meets this condition p_{p}_{i} = n - i + 1.\n\nYou have integer n. Find some ... | [{"input": "16440\n", "output": "2 16440 4 16438 6 16436 8 16434 10 16432 12 16430 14 16428 16 16426 18 16424 20 16422 22 16420 24 16418 26 16416 28 16414 30 16412 32 16410 34 16408 36 16406 38 16404 40 16402 42 16400 44 16398 46 16396 48 16394 50 16392 52 16390 54 16388 56 16386 58 16384 60 16382 62 16380 64 16378 66 ... | code_stdio |
[
{
"content": "The term of this problem is the same as the previous one, the only exception — increased restrictions.\n\n\n-----Input-----\n\nThe first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ 10^9) — the number of ingredients and the number of grams of the magic powder.\n\nThe secon... | [{"input": "80 979\n2 1 1 1 2 1 1 1 3 1 4 4 2 1 1 3 1 1 2 1 4 1 1 2 5 4 8 1 3 6 5 7 2 3 4 1 2 2 6 1 2 2 4 1 1 2 3 2 8 1 1 3 3 4 1 1 2 1 4 4 1 4 3 2 6 5 2 1 4 1 2 3 2 1 3 3 2 2 1 3\n498 976 513 869 917 914 664 656 957 893 981 947 985 693 576 958 987 822 981 718 884 729 295 683 485 998 730 894 731 975 739 854 906 740 987... | code_stdio |
[
{
"content": "Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock.\n\n [Image] \n\nThe combination lock is represented by n rotating disks with digits from 0 to 9 written o... | [{"input": "125\n23269567683904664184142384849516523616863461607751021071772615078579713054027902974007001544768640273491193035874486891541257\n47635110303703399505805044019026243695451609639556649012447370081552870340011971572363458960190590266459684717415349529509024\n", "output": "305\n"}, {"input": "125\n2326956768... | code_stdio |
[
{
"content": "You are given an integer N. Determine if there exists a tree with 2N vertices numbered 1 to 2N satisfying the following condition, and show one such tree if the answer is yes.\n\n* Assume that, for each integer i between 1 and N (inclusive), Vertex i and N+i have the weight i. Then, for each integ... | [{"input": "3", "output": "Yes\n1 2\n2 3\n3 4\n4 5\n5 6"}, {"input": "001", "output": "No\n"}, {"input": "128", "output": "No\n"}, {"input": "256", "output": "No\n"}, {"input": "001", "output": "No\n"}, {"input": "256", "output": "No\n"}, {"input": "128", "output": "No\n"}, {"input": "16", "output": "No\n"}, {"input": ... | code_stdio |
[
{
"content": "Polycarpus analyzes a string called abracadabra. This string is constructed using the following algorithm: \n\n * On the first step the string consists of a single character \"a\". \n * On the k-th step Polycarpus concatenates two copies of the string obtained on the (k - 1)-th step, while inser... | [{"input": "156642200 503020953 296806626 871864091\n", "output": "234585497\n"}, {"input": "462616550 929253987 199885647 365920450\n", "output": "166034804\n"}, {"input": "166724572 472113234 358126054 528083792\n", "output": "125430608\n"}, {"input": "443495607 813473994 192923319 637537620\n", "output": "268435455\... | code_stdio |
[
{
"content": "For the multiset of positive integers $s=\\{s_1,s_2,\\dots,s_k\\}$, define the Greatest Common Divisor (GCD) and Least Common Multiple (LCM) of $s$ as follow: $\\gcd(s)$ is the maximum positive integer $x$, such that all integers in $s$ are divisible on $x$. $\\textrm{lcm}(s)$ is the minimum posit... | [{"input": "10\n972 972 324 972 324 648 1944 243 324 474\n", "output": "162\n"}, {"input": "10\n972 972 324 972 324 648 1944 243 324 474\n", "output": "162\n"}, {"input": "10\n540 648 1116 648 720 540 594 864 972 648\n", "output": "36\n"}, {"input": "10\n972 1224 324 972 324 507 1868 392 324 474\n", "output": "2\n"}, {... | code_stdio |
[
{
"content": "A sequence of positive integers is called great for a positive integer $x$, if we can split it into pairs in such a way that in each pair the first number multiplied by $x$ is equal to the second number. More formally, a sequence $a$ of size $n$ is great for a positive integer $x$, if $n$ is even ... | [{"input": "1\n11 100000\n310065408 310065408 310065408 310065408 89000 89000 89000 89000 10000000 5 69\n", "output": "11\n"}, {"input": "4\n4 4\n1 16 4 4\n6 2\n1 2 2 2 4 7\n5 3\n5 2 3 5 15\n9 10\n10 10 10 20 1 100 200 2000 3\n", "output": "0\n2\n3\n3\n"}, {"input": "1\n8 1000000\n100000000 100000000 276447232 1000 100... | code_stdio |
[
{
"content": "You are given two integers $n$ and $k$.\n\nYou should create an array of $n$ positive integers $a_1, a_2, \\dots, a_n$ such that the sum $(a_1 + a_2 + \\dots + a_n)$ is divisible by $k$ and maximum element in $a$ is minimum possible.\n\nWhat is the minimum possible maximum element in $a$?\n\n\n---... | [{"input": "25\n3 1000000000\n3 1000000000\n3 1000000000\n3 1000000000\n3 1000000000\n3 1000000000\n3 1000000000\n3 1000000000\n3 1000000000\n3 1000000000\n3 1000000000\n3 1000000000\n3 1000000000\n3 1000000000\n3 1000000000\n3 1000000000\n3 1000000000\n3 1000000000\n3 1000000000\n3 1000000000\n1000000000 3\n1000000000... | code_stdio |
[
{
"content": "A substring of some string is called the most frequent, if the number of its occurrences is not less than number of occurrences of any other substring.\n\nYou are given a set of strings. A string (not necessarily from this set) is called good if all elements of the set are the most frequent substr... | [{"input": "76\namnctposz\nmnctpos\nos\nu\ne\nam\namnc\neamnctpo\nl\nx\nq\nposzq\neamnc\nctposzq\nctpos\nmnc\ntpos\namnctposzql\ntposzq\nmnctposz\nnctpos\nctposzql\namnctpos\nmnct\np\nux\nposzql\ntpo\nmnctposzql\nmnctp\neamnctpos\namnct\ntposzql\nposz\nz\nct\namnctpo\noszq\neamnct\ntposz\ns\nmn\nn\nc\noszql\npo\no\nmnc... | code_stdio |
[
{
"content": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time... | [{"input": "65 654 560 571\n83 511 615 263 171 146 241 511 582 216 352 632 506 538 536 217 627 213 324 579 172 241 363 584 450 144 447 536 241 523 162 21 437 291 191 111 567 502 170 570 231 493 169 360 107 114 322 160 574 611 460 558 616 361 284 58 41 345 450 560 543 520 105 416 38\n", "output": "2\n"}, {"input": "65 6... | code_stdio |
[
{
"content": "Let's dive into one of the most interesting areas of magic — writing spells. Learning this exciting but challenging science is very troublesome, so now you will not learn the magic words, but only get to know the basic rules of writing spells.\n\nEach spell consists of several lines. The line, who... | [{"input": "# a \n # a \n\n # a \n\n\n # a \n \n # a \n \n\n # a \n\n \n # a\n \n \n # a \n\n\n \n\n \n ... | code_stdio |
[
{
"content": "Vasya should paint a fence in front of his own cottage. The fence is a sequence of n wooden boards arranged in a single row. Each board is a 1 centimeter wide rectangle. Let's number the board fence using numbers 1, 2, ..., n from left to right. The height of the i-th board is h_{i} centimeters.\n... | [{"input": "118\n8850 1770\n97 19 137 20 92 16 145 35 2 86 4 83 147 135 125 7 145 84 142 124 14 91 169 132 149 117 67 41 137 132 91 34 162 70 92 75 73 24 6 143 24 12 149 48 107 82 146 119 107 174 166 103 42 31 70 142 156 25 153 159 116 108 151 21 156 43 38 85 68 2 107 16 163 179 92 150 48 52 85 115 37 186 82 94 67 170 ... | code_stdio |
[
{
"content": "Curry making\n\nAs the ACM-ICPC domestic qualifying is approaching, you who wanted to put more effort into practice decided to participate in a competitive programming camp held at a friend's house. Participants decided to prepare their own meals.\n\nOn the first night of the training camp, the pa... | [{"input": "10 5 3 4\n1 6 2 3\n150 13 7 62\n10 1 3 5\n20 100 3 20\n2 14 13 1\n0 0 0 0", "output": "2\n4\n0\n0\n14\n180\n"}, {"input": "10 5 3 4\n1 5 2 3\n150 13 12 62\n10 1 11 5\n20 100 3 20\n3 14 3 1\n0 0 0 0", "output": "2\n3\n1\n1\n14\n39\n"}, {"input": "10 5 6 4\n1 5 2 3\n150 13 12 62\n10 1 11 5\n20 100 3 20\n3 14 ... | code_stdio |
[
{
"content": "A remote island chain contains n islands, labeled 1 through n. Bidirectional bridges connect the islands to form a simple cycle — a bridge connects islands 1 and 2, islands 2 and 3, and so on, and additionally a bridge connects islands n and 1. The center of each island contains an identical pedes... | [{"input": "10\n2 4 8 3 6 1 15 0 5 14\n3 6 1 10 0 5 7 2 14 4\n", "output": "NO\n"}, {"input": "10\n2 4 8 3 6 1 15 0 5 7\n3 6 1 10 0 5 7 2 14 4\n", "output": "NO\n"}, {"input": "10\n2 4 8 3 6 1 15 0 5 7\n3 6 1 10 0 5 7 2 22 4\n", "output": "NO\n"}, {"input": "10\n2 0 1 6 4 12 8 5 3 7\n12 4 11 0 5 3 7 2 1 8\n", "output":... | code_stdio |
[
{
"content": "You are given set of n points in 5-dimensional space. The points are labeled from 1 to n. No two points coincide.\n\nWe will call point a bad if there are different points b and c, not equal to a, from the given set such that angle between vectors $\\vec{ab}$ and $\\vec{ac}$ is acute (i.e. strictl... | [{"input": "11\n358 -724 -232 53 -520\n486 -554 -328 53 -220\n358 -554 -232 -372 -520\n358 -554 -232 308 -520\n868 -554 448 53 -520\n478 -554 -322 53 -600\n358 296 -232 53 -520\n256 -554 -368 53 -520\n230 -554 -136 53 -820\n-182 -554 173 53 -160\n358 -554 -232 53 -520\n", "output": "1\n11\n"}, {"input": "11\n358 -724 -... | code_stdio |
[
{
"content": "There are N flowers arranged in a row. For each i (1 \\leq i \\leq N), the height and the beauty of the i-th flower from the left is h_i and a_i, respectively. Here, h_1, h_2, \\ldots, h_N are all distinct.\n\nTaro is pulling out some flowers so that the following condition is met:\n\n* The height... | [{"input": "5\n1 2 3 4 5\n1000000000 1000000010 1000000000 1000000000 1000000000", "output": "5000000010\n"}, {"input": "5\n1 2 3 4 5\n1000000000 1000000010 1000000000 1010000000 1000000000", "output": "5010000010\n"}, {"input": "5\n1 2 3 4 5\n1000000000 1000000010 1000100000 1010000000 1000000000", "output": "50101000... | code_stdio |
[
{
"content": "Nick is interested in prime numbers. Once he read about Goldbach problem. It states that every even integer greater than 2 can be expressed as the sum of two primes. That got Nick's attention and he decided to invent a problem of his own and call it Noldbach problem. Since Nick is interested only ... | [{"input": "1000 1000\n", "output": "NO\n"}, {"input": "1000 1100\n", "output": "NO\n"}, {"input": "1000 44\n", "output": "YES\n"}, {"input": "428 23\n", "output": "YES\n"}, {"input": "332 20\n", "output": "YES\n"}, {"input": "802 35\n", "output": "YES\n"}, {"input": "640 32\n", "output": "YES\n"}, {"input": "995 44\n"... | code_stdio |
[
{
"content": "Let's define the sum of two permutations p and q of numbers 0, 1, ..., (n - 1) as permutation <image>, where Perm(x) is the x-th lexicographically permutation of numbers 0, 1, ..., (n - 1) (counting from zero), and Ord(p) is the number of permutation p in the lexicographical order.\n\nFor example,... | [{"input": "84\n83 4 68 34 24 2 48 38 22 51 5 62 31 67 66 53 49 70 9 71 46 41 30 8 50 17 28 79 15 80 32 43 14 74 29 42 81 60 56 65 23 0 77 76 58 78 1 11 37 27 75 35 18 73 54 20 57 33 36 6 61 69 64 55 39 10 3 45 13 26 59 82 21 25 63 52 16 44 47 72 19 12 7 40\n63 41 80 52 36 45 17 69 22 66 37 21 46 44 64 9 48 74 58 81 10... | code_stdio |
[
{
"content": "Vasya came up with his own weather forecasting method. He knows the information about the average air temperature for each of the last n days. Assume that the average air temperature for each day is integral.\n\nVasya believes that if the average temperatures over the last n days form an arithmeti... | [{"input": "100\n-85 -80 -76 -72 -68 -64 -60 -56 -52 -48 -44 -40 -36 -32 -28 -24 -20 -16 -12 -8 -4 0 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120 124 128 132 136 140 144 148 152 156 160 164 168 172 176 180 184 188 192 196 200 204 208 212 216 220 224 228 232 236 240 244 2... | code_stdio |
[
{
"content": "Little X and Little Z are good friends. They always chat online. But both of them have schedules.\n\nLittle Z has fixed schedule. He always online at any moment of time between a_1 and b_1, between a_2 and b_2, ..., between a_{p} and b_{p} (all borders inclusive). But the schedule of Little X is q... | [{"input": "13 42 292 733\n304 308\n362 365\n396 397\n686 688\n719 722\n815 816\n901 902\n904 905\n921 924\n929 933\n953 954\n977 980\n982 985\n28 30\n36 37\n108 112\n123 127\n134 135\n151 153\n160 162\n203 205\n208 212\n240 243\n261 264\n271 274\n294 297\n356 358\n383 385\n408 412\n415 418\n435 439\n444 447\n500 502\n... | code_stdio |
[
{
"content": "Alice got a new doll these days. It can even walk!\n\nAlice has built a maze for the doll and wants to test it. The maze is a grid with n rows and m columns. There are k obstacles, the i-th of them is on the cell (x_i, y_i), which means the cell in the intersection of the x_i-th row and the y_i-th... | [{"input": "10 10 70\n10 4\n5 5\n6 10\n8 9\n3 8\n10 9\n10 10\n8 2\n2 10\n7 2\n7 3\n10 2\n8 3\n9 8\n2 9\n3 1\n6 5\n6 9\n2 8\n10 7\n8 4\n8 6\n7 6\n5 6\n9 10\n3 9\n5 8\n4 8\n3 10\n10 5\n5 2\n5 4\n8 8\n3 2\n3 6\n2 3\n1 9\n6 6\n2 4\n6 2\n5 3\n6 4\n7 9\n2 2\n5 9\n7 10\n7 8\n3 3\n2 6\n7 5\n8 10\n3 4\n6 8\n8 5\n1 8\n10 6\n10 8... | code_stdio |
[
{
"content": "Vova plans to go to the conference by train. Initially, the train is at the point $1$ and the destination point of the path is the point $L$. The speed of the train is $1$ length unit per minute (i.e. at the first minute the train is at the point $1$, at the second minute — at the point $2$ and so... | [{"input": "10\n10 1 1 1\n10 1 1 2\n10 1 1 3\n10 1 1 4\n10 1 1 5\n10 1 1 6\n10 1 1 7\n10 1 1 8\n10 1 1 9\n10 1 1 10\n", "output": "9\n8\n7\n6\n5\n4\n3\n2\n1\n0\n"}, {"input": "10\n10 2 1 1\n10 2 1 2\n10 2 1 3\n10 2 1 4\n10 2 1 5\n10 2 1 6\n10 2 1 7\n10 2 1 8\n10 2 1 9\n10 2 1 10\n", "output": "5\n4\n4\n3\n3\n2\n2\n1\n1... | code_stdio |
[
{
"content": "Iahub got lost in a very big desert. The desert can be represented as a n × n square matrix, where each cell is a zone of the desert. The cell (i, j) represents the cell at row i and column j (1 ≤ i, j ≤ n). Iahub can go from one cell (i, j) only down or right, that is to cells (i + 1, j) or (i, j... | [{"input": "999999989 38\n999999980 999999981\n10 8\n2 5\n999999978 999999981\n999999978 999999985\n7 9\n8 10\n9 10\n999999984 999999980\n6 6\n999999985 999999986\n999999982 999999978\n999999981 999999987\n8 5\n999999982 999999980\n999999989 999999980\n999999988 999999983\n999999982 999999984\n10 9\n6 2\n999999980 9999... | code_stdio |
[
{
"content": "You are given $n$ packages of $w_i$ kg from a belt conveyor in order ($i = 0, 1, ... n-1$). You should load all packages onto $k$ trucks which have the common maximum load $P$. Each truck can load consecutive packages (more than or equals to zero) from the belt conveyor unless the total weights of... | [{"input": "4 2\n11\n17\n10\n0\n6", "output": "27\n"}, {"input": "4 4\n-1\n4\n18\n5\n4", "output": "18\n"}, {"input": "4 4\n-1\n2\n17\n1\n4", "output": "17\n"}, {"input": "4 6\n-2\n3\n5\n13\n8", "output": "13\n"}, {"input": "2 1\n11\n12\n5\n2\n6", "output": "23\n"}, {"input": "4 4\n-2\n3\n11\n4\n4", "output": "11\n"}, ... | code_stdio |
[
{
"content": "Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right.\nWe will call the arrangement of the poles beautiful if the tops of the poles lie on the same line, that is, b-a = c-b.\nDetermine whether the arrangement of the poles is beautiful.\n\n-----Const... | [{"input": "-1 -1 -1", "output": "YES\n"}, {"input": "-2 -3 -4", "output": "YES\n"}, {"input": "-1 -2 -1", "output": "NO\n"}, {"input": "-1 -3 -1", "output": "NO\n"}, {"input": "-2 -4 -1", "output": "NO\n"}, {"input": "-2 -2 -1", "output": "NO\n"}, {"input": "-2 -1 -1", "output": "NO\n"}, {"input": "-2 -3 -1", "output"... | code_stdio |
[
{
"content": "You are given two integers $x$ and $y$. You can perform two types of operations: Pay $a$ dollars and increase or decrease any of these integers by $1$. For example, if $x = 0$ and $y = 7$ there are four possible outcomes after this operation: $x = 0$, $y = 6$; $x = 0$, $y = 8$; $x = -1$, $y ... | [{"input": "3\n1 3\n391 555\n129 8437\n9 4\n321 654\n3 4\n", "output": "1337\n75288\n2283\n"}, {"input": "3\n1 3\n391 555\n129 8437\n9 4\n321 654\n3 4\n", "output": "1337\n75288\n2283\n"}, {"input": "3\n1 6\n391 555\n129 8437\n9 4\n321 654\n3 4\n", "output": "2510\n75288\n2283\n"}, {"input": "3\n1 6\n391 555\n129 9245\... | code_stdio |
[
{
"content": "Vasya has got two number: a and b. However, Vasya finds number a too short. So he decided to repeat the operation of lengthening number a n times.\n\nOne operation of lengthening a number means adding exactly one digit to the number (in the decimal notation) to the right provided that the resultin... | [{"input": "99999 334 94854\n", "output": "9999960000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000... | code_stdio |
[
{
"content": "Vasya came up with a password to register for EatForces — a string s. The password in EatForces should be a string, consisting of lowercase and uppercase Latin letters and digits.\n\nBut since EatForces takes care of the security of its users, user passwords must contain at least one digit, at lea... | [{"input": "6\n11b\n4bh\nBeh\nTuY\n1YJ\nP28\n", "output": "A1b\n4Ah\nB1h\n1uY\n1aJ\nPa8\n"}, {"input": "6\n11b\n4bh\nBeh\nTvY\n1YJ\nP28\n", "output": "A1b\n4Ah\nB1h\n1vY\n1aJ\nPa8\n"}, {"input": "6\n11b\n4bh\nBeh\nvTY\n1YJ\nP28\n", "output": "A1b\n4Ah\nB1h\nv1Y\n1aJ\nPa8\n"}, {"input": "6\n11b\n4bh\nBeh\nvYT\n1YJ\nP28\... | code_stdio |
[
{
"content": "We start with a string $s$ consisting only of the digits $1$, $2$, or $3$. The length of $s$ is denoted by $|s|$. For each $i$ from $1$ to $|s|$, the $i$-th character of $s$ is denoted by $s_i$. \n\nThere is one cursor. The cursor's location $\\ell$ is denoted by an integer in $\\{0, \\ldots, |s|\... | [{"input": "9\n1500\n1212\n1500\n1221\n1500\n122\n1500\n12121\n1500\n22\n1500\n1111112111111112\n1500\n1111111111221111111\n1500\n111111122\n1500\n11111121111121111111\n", "output": "1504\n1599\n1502\n1598\n1502\n1510\n1657\n1502\n1763\n"}, {"input": "9\n1500\n1212\n1500\n1221\n1500\n122\n1500\n12121\n1500\n22\n1500\n1... | code_stdio |
[
{
"content": "Given an undirected tree, let the distance between vertices u and v be the number of edges on the simple path from u to v. The diameter of a tree is the maximum among the distances between any two vertices. We will call a tree good if and only if its diameter is at most K.\n\nYou are given an undi... | [{"input": "6 10\n1 3\n3 2\n4 1\n1 6\n5 6", "output": "0\n"}, {"input": "6 10\n1 3\n3 2\n4 2\n1 6\n5 6", "output": "0\n"}, {"input": "6 10\n1 3\n6 2\n4 2\n1 6\n5 6", "output": "0\n"}, {"input": "6 1\n1 2\n3 2\n4 2\n1 6\n5 6", "output": "4\n"}, {"input": "6 7\n1 2\n3 2\n4 2\n1 6\n5 6", "output": "0\n"}, {"input": "6 2\n... | code_stdio |
[
{
"content": "Let's write all the positive integer numbers one after another from $1$ without any delimiters (i.e. as a single string). It will be the infinite sequence starting with 123456789101112131415161718192021222324252627282930313233343536...\n\nYour task is to print the $k$-th digit of this sequence.\n\... | [{"input": "1000000000000\n", "output": "1\n"}, {"input": "1000000000000\n", "output": "1\n"}, {"input": "1000000000000\n", "output": "1\n"}, {"input": "100000000000\n", "output": "0\n"}, {"input": "100000000000\n", "output": "0\n"}, {"input": "999999999999\n", "output": "9\n"}, {"input": "100000000004\n", "output": "0... | code_stdio |
[
{
"content": "Harry Potter is on a mission to destroy You-Know-Who's Horcruxes. The first Horcrux that he encountered in the Chamber of Secrets is Tom Riddle's diary. The diary was with Ginny and it forced her to open the Chamber of Secrets. Harry wants to know the different people who had ever possessed the di... | [{"input": "9\nliyzmbjwnzryjokufuxcqtzwworjeoxkbaqrujrhdidqdvwdfzilwszgnzglnnbogaclckfnbqovtziuhwvyrqwmskx\nliyzmbjwnzryjokufuxcqtzwworjeoxkbaqrujrhdidqdvwdfzilwszgnzglnnbogaclckfnbqovtziuhwvyrqwmskx\nliyzmbjwnzryjokufuxcqtzwworjeoxkbaqrujrhdidqdvwdfzilwszgnzglnnbogaclckfnbqovtziuhwvyrqwmskx\nhrtm\nssjqvixduertmotgagiz... | code_stdio |
[
{
"content": "Step up and down\n\nKazuki, commonly known as Kerr, who attends JAG University, was invited by your friend this summer to participate in the ICPC (International Collegiate Potchari Contest). ICPC is a sports contest and requires a high degree of athletic ability. However, Mr. Kerr was always in fr... | [{"input": "4\nlu ru ld rd\n4\nlu ld lu ru\n1\nlu\n10\nru lu ld rd ru rd ru lu rd ld\n0", "output": "2\n1\n0\n4"}, {"input": "4\nlu ru ld rd\n4\nlu ld lu ru\n0\nlu\n10\nur lu ld rd ru rd ru lu rd ld\n-1", "output": "2\n1\n"}, {"input": "4\nlu ru ld rd\n4\nlu ld lu ru\n0\nlu\n10\nur lu ld rd ru rd ru lu sd ld\n-1", "out... | code_stdio |
[
{
"content": "Professor Tsukuba invented a mysterious jewelry box that can be opened with a special gold key whose shape is very strange. It is composed of gold bars joined at their ends. Each gold bar has the same length and is placed parallel to one of the three orthogonal axes in a three dimensional space, i... | [{"input": "19\n 1 +x 1 +y +z 3 +z\n 3 +y -z +x +y -z -x +z 2 +z\n 2 +y\n19\n 1 +x 1 +x +z 3 +y -z +x +y -z -x +z 2 +y\n 3 +z\n 2 +z\n19\n 1 +x 1 +y +z 3 +z\n 3 +y -z +x +y -z -x +z 2 +y\n 2 +z\n18\n 1 -y\n 1 +y -z +x\n 1 +z +y +x +z +y -x -y 1 -y\n 2 +z\n3 +x +y +z\n3 +y +z -x\n0", "output": "DIFFERENT\nD... | code_stdio |
[
{
"content": "A star is a figure of the following type: an asterisk character '*' in the center of the figure and four rays (to the left, right, top, bottom) of the same positive length. The size of a star is the length of its rays. The size of a star must be a positive number (i.e. rays of length $0$ are not a... | [{"input": "100 3\n.*.\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\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": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \nToday a plane was hijacked by a maniac. All the passengers of the flight are taken as hostage. Chef is also one of them.\nHe invited one of the passengers to play a game with him. If he loses the game, he will release ... | [{"input": "2\n-1 -1 2\n0\n-1 0 3\n-3", "output": "-2\n-11\n"}, {"input": "2\n-1 0 2\n-1\n-1 0 3\n-3", "output": "-5\n-11\n"}, {"input": "2\n-1 0 4\n-2\n-1 1 5\n-3", "output": "-8\n-11\n"}, {"input": "2\n1 1 10\n-2\n-1 1 -2\n-1", "output": "-8\n-5\n"}, {"input": "2\n1 1 10\n-2\n-1 1 -1\n-2", "output": "-8\n-8\n"}, {"in... | code_stdio |
[
{
"content": "Takahashi is a member of a programming competition site, ButCoder.\nEach member of ButCoder is assigned two values: Inner Rating and Displayed Rating.\nThe Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Ra... | [{"input": "100 4111\n", "output": "4111\n"}, {"input": "22 3051\n", "output": "3051\n"}, {"input": "10 3141\n", "output": "3141\n"}, {"input": "11 3141\n", "output": "3141\n"}, {"input": "2 2919\n", "output": "3719\n"}, {"input": "1 4111\n", "output": "5011\n"}, {"input": "9 3141\n", "output": "3241\n"}, {"input": "3 ... | code_stdio |
[
{
"content": "Problem\n\nGPA is an abbreviation for \"Galaxy Point of Aizu\" and takes real numbers from 0 to 4.\nGPA rock-paper-scissors is a game played by two people. After each player gives a signal of \"rock-paper-scissors, pon (hoi)\" to each other's favorite move, goo, choki, or par, the person with the ... | [{"input": "3\n1.2162360718264462\n2.9346880694304285\n3.9759367558439593", "output": "0\n3\n6\n"}, {"input": "3\n1.3676423535538285\n2.5451927881659007\n3.4551403734048662", "output": "0\n3\n6\n"}, {"input": "3\n2.2132650658019095\n2.5451927881659007\n3.4551403734048662", "output": "0\n3\n6\n"}, {"input": "3\n2.234124... | code_stdio |
[
{
"content": "Little Artem is fond of dancing. Most of all dances Artem likes rueda — Cuban dance that is danced by pairs of boys and girls forming a circle and dancing together.\n\nMore detailed, there are n pairs of boys and girls standing in a circle. Initially, boy number 1 dances with a girl number 1, boy ... | [{"input": "364 57\n1 -101\n1 110\n1 -76\n1 329\n2\n2\n2\n1 -191\n1 97\n1 189\n1 305\n1 -313\n1 312\n1 -148\n2\n1 -104\n1 85\n1 -55\n1 -79\n1 230\n1 -94\n1 58\n1 -72\n2\n2\n2\n1 -104\n1 -351\n1 23\n2\n1 215\n2\n2\n2\n1 58\n1 -237\n2\n2\n2\n1 198\n2\n1 83\n2\n1 -205\n2\n2\n2\n2\n1 -110\n2\n2\n2\n2\n1 153\n1 -344\n1 -281... | code_stdio |
[
{
"content": "We have an integer sequence A of length N, where A_1 = X, A_{i+1} = A_i + D (1 \\leq i < N ) holds.\nTakahashi will take some (possibly all or none) of the elements in this sequence, and Aoki will take all of the others.\nLet S and T be the sum of the numbers taken by Takahashi and Aoki, respecti... | [{"input": "199903 -42042635 15996643\n", "output": "1331394274247808\n"}, {"input": "199937 46898475 97994148\n", "output": "1332073730358274\n"}, {"input": "199903 2748118 -84690464\n", "output": "1331394274247808\n"}, {"input": "199961 71272203 60243765\n", "output": "1322010346302492\n"}, {"input": "199966 -4418116... | code_stdio |
[
{
"content": "The only difference between the easy and hard versions is that the given string $s$ in the easy version is initially a palindrome, this condition is not always true for the hard version.\n\nA palindrome is a string that reads the same left to right and right to left. For example, \"101101\" is a p... | [{"input": "3\n3\n110\n2\n00\n4\n1010\n", "output": "\nALICE\nBOB\nALICE\n"}, {"input": "3\n3\n110\n2\n00\n4\n1010\n", "output": "ALICE\nBOB\nALICE\n"}, {"input": "3\n3\n110\n2\n00\n4\n1011\n", "output": "ALICE\nBOB\nALICE\n"}, {"input": "3\n3\n110\n2\n00\n4\n0011\n", "output": "ALICE\nBOB\nALICE\n"}, {"input": "3\n3\n... | code_stdio |
[
{
"content": "Chief Judge's log, stardate 48642.5. We have decided to make a problem from elementary number theory. The problem looks like finding all prime factors of a positive integer, but it is not.\n\nA positive integer whose remainder divided by 7 is either 1 or 6 is called a 7N+{1,6} number. But as it is... | [{"input": "205920\n34152\n262200\n279936\n152244\n1", "output": "205920: 6 8 13 15 20 22 55 99\n34152: 6 8 4269 5692\n262200: 6 8 15 20 50 57 69 76 92 190 230 475 575 874 2185\n279936: 6 8 27\n152244: 6 4229\n"}, {"input": "205920\n262144\n262200\n9766\n81220\n1", "output": "205920: 6 8 13 15 20 22 55 99\n262144: 8\n2... | code_stdio |
[
{
"content": "You are given three positive integers $n$, $a$ and $b$. You have to construct a string $s$ of length $n$ consisting of lowercase Latin letters such that each substring of length $a$ has exactly $b$ distinct letters. It is guaranteed that the answer exists.\n\nYou have to answer $t$ independent tes... | [{"input": "1\n3495 231 24\n", "output": "abcdefghijklmnopqrstuvwxabcdefghijklmnopqrstuvwxabcdefghijklmnopqrstuvwxabcdefghijklmnopqrstuvwxabcdefghijklmnopqrstuvwxabcdefghijklmnopqrstuvwxabcdefghijklmnopqrstuvwxabcdefghijklmnopqrstuvwxabcdefghijklmnopqrstuvwxabcdefghijklmnopqrstuvwxabcdefghijklmnopqrstuvwxabcdefghijklmn... | code_stdio |
[
{
"content": "You are given a string $s=s_1s_2\\dots s_n$ of length $n$, which only contains digits $1$, $2$, ..., $9$.\n\nA substring $s[l \\dots r]$ of $s$ is a string $s_l s_{l + 1} s_{l + 2} \\ldots s_r$. A substring $s[l \\dots r]$ of $s$ is called even if the number represented by it is even. \n\nFind the... | [{"input": "39\n263254663359864483324578786753512345165\n", "output": "327\n"}, {"input": "39\n263254663359864483324578786753512345165\n", "output": "327"}, {"input": "10\n9572683145\n", "output": "24\n"}, {"input": "10\n9572683145\n", "output": "24"}, {"input": "4\n2864\n", "output": "10\n"}, {"input": "4\n2244\n", "o... | code_stdio |
[
{
"content": "Chef Jessie has a lot of recipes with her (N). She often remembered the starting few characters of the recipe and forgot the rest. As all the great chefs do, Jessie also numbered the recipes depending on the priority. So, given the list of recipes along with their priorities answer Jessie’s querie... | [{"input": "4\nflour-with-eggs 100\nchicken-ham -10\nflour-without-eggs 200\nfish-with-pepper 1100\n6\nf\nflour-with\nflour-with-\nc\nfl\nciik", "output": "fish-with-pepper\nflour-without-eggs\nflour-with-eggs\nchicken-ham\nflour-without-eggs\nNO\n"}, {"input": "4\nflour-with-eggs 100\nchicken-ham -10\nflour-without-eg... | code_stdio |
[
{
"content": "Allen has a LOT of money. He has $n$ dollars in the bank. For security reasons, he wants to withdraw it in cash (we will not disclose the reasons here). The denominations for dollar bills are $1$, $5$, $10$, $20$, $100$. What is the minimum number of bills Allen could receive after withdrawing his... | [{"input": "1000000000\n", "output": "10000000\n"}, {"input": "1230910855\n", "output": "12309112\n"}, {"input": "1199225057\n", "output": "11992256\n"}, {"input": "1100000000\n", "output": "11000000\n"}, {"input": "1173603402\n", "output": "11736036\n"}, {"input": "1100010000\n", "output": "11000100\n"}, {"input": "10... | code_stdio |
[
{
"content": "Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last class the teacher wrote three positive integers a, b, c on the blackboard. The task was to insert signs of operations '+' and '*', and probably brackets between the numbers so that the va... | [{"input": "10\n10\n10\n", "output": "1000\n"}, {"input": "10\n10\n10\n", "output": "1000\n"}, {"input": "10\n5\n6\n", "output": "300\n"}, {"input": "10\n5\n6\n", "output": "300\n"}, {"input": "9\n14\n2\n", "output": "252\n"}, {"input": "4\n3\n10\n", "output": "120\n"}, {"input": "10\n9\n6\n", "output": "540\n"}, {"inp... | code_stdio |
[
{
"content": "You finally got a magic pot, an alchemy pot. You can create a new item by putting multiple items in the alchemy pot. Newly created items can also be placed in alchemy pots to make other items. A list of items needed to make an item will be called an alchemy recipe. The following three are examples... | [{"input": "8\nwood 5003\nstring 1120\nrice 32\nwater -1\nracket 5000\nmicrophone 4961\nonigiri 140\nguitar 98000\n3\nracket 2 wood string\nonigiri 2 rice water\nguitar 3 tekcar microphone onigiri\nguitar\n1\ncomputer 112750\n-1\ncomputer\n0", "output": "4992\n112750\n"}, {"input": "8\nwood 5003\nstring 1120\nrice 32\n... | code_stdio |
[
{
"content": "Manao works on a sports TV. He's spent much time watching the football games of some country. After a while he began to notice different patterns. For example, each team has two sets of uniforms: home uniform and guest uniform. When a team plays a game at home, the players put on the home uniform.... | [{"input": "30\n44 17\n44 17\n44 17\n17 44\n44 17\n44 17\n17 44\n17 44\n17 44\n44 17\n44 17\n44 17\n44 17\n44 17\n17 44\n17 44\n17 44\n44 17\n44 17\n17 44\n44 17\n44 17\n44 17\n17 44\n17 44\n44 17\n17 44\n44 17\n44 17\n44 17\n", "output": "418\n"}, {"input": "30\n67 21\n85 39\n85 87\n21 39\n66 85\n10 95\n10 21\n87 85\n... | code_stdio |
[
{
"content": "AquaMoon has n friends. They stand in a row from left to right, and the i-th friend from the left wears a T-shirt with a number a_i written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.\n\nAquaMoon can make some operations on friends. ... | [{"input": "10\n10\n6 2 1 1 1 10 10 2 10 5\n8\n1 3 1 1 4 5 4 4\n9\n9 6 9 9 2 8 7 2 2\n10\n9 4 3 3 5 4 3 10 4 5\n9\n7 5 1 7 5 5 5 5 6\n8\n8 8 4 4 7 6 2 8\n10\n6 8 1 6 8 8 5 6 8 4\n10\n5 5 5 8 3 4 3 3 10 10\n8\n1 1 3 6 6 7 1 2\n8\n4 1 3 5 3 1 3 3\n", "output": "NO\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nNO\n"}, {"input"... | code_stdio |
[
{
"content": "You are given a string $s$ consisting only of characters + and -. You perform some process with this string. This process can be described by the following pseudocode: res = 0\n\nfor init = 0 to inf\n\n cur = init\n\n ok = true\n\n for i = 1 to |s|\n\n res = res + 1\n\n if s... | [{"input": "15\n-\n--\n+\n+-\n-\n+\n-\n+\n-\n-+\n-+\n-+\n-+\n-+\n-+\n", "output": "2\n5\n1\n2\n2\n1\n2\n1\n2\n3\n3\n3\n3\n3\n3\n"}, {"input": "15\n-\n--\n+\n+-\n-\n+\n-\n+\n-\n-+\n-+\n-+\n-+\n-+\n-+\n", "output": "2\n5\n1\n2\n2\n1\n2\n1\n2\n3\n3\n3\n3\n3\n3\n"}, {"input": "15\n-\n--\n+\n+-\n-\n+\n-\n+\n-\n-+\n-+\n-+\n-... | code_stdio |
[
{
"content": "Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the lette... | [{"input": "100 50\nYYIYYAAAIEAAYAYAEAIIIAAEAAYEAEYYYIAEYAYAYYAAAIAYAEAAYAYYIYAAYYAAAAAAIYYYAAYAAEAAYAIEIYIYAYAYAYIIAAEY\n", "output": "1972\n"}, {"input": "100 90\nFAFAOOAOOAFAOTFAFAFFATAAAOFAAOAFBAAAFBOAOFFFOAOAFAPFOFAOFAAFOAAAAFAAFOFAAOFPPAAOOAAOOFFOFFFOFAOTOFAF\n", "output": "2828\n"}, {"input": "100 99\nBFFBBFBFBQ... | code_stdio |
[
{
"content": "problem\n\nYou are in charge of quality control at a machine manufacturing plant. This machine requires a power supply, a motor, and a cable as parts. The manufacturing plant has a power supply, b motors, and c cables, numbered from 1 to a, a + 1 to a + b, and a + b + 1 to a + b + c, respectively.... | [{"input": "2 2 8\n4\n1 1 1 0\n5 3 4 0\n1 4 0 0\n1 3 0 0\n0 0 0", "output": "2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n"}, {"input": "1 2 8\n4\n4 1 1 0\n5 0 5 0\n-1 4 0 0\n1 3 2 0\n0 0 0", "output": "2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n"}, {"input": "4 2 4\n4\n3 1 -1 0\n5 3 4 1\n1 4 1 0\n1 3 0 0\n0 0 0", "output": "2\n2\n1\n1\n... | code_stdio |
[
{
"content": "Read problems statements in Mandarin and Russian. Translations in Vietnamese to be uploaded soon. \n\nYou have a matrix of size N * N with rows numbered through 1 to N from top to bottom and columns through 1 to N from left to right. It contains all values from 1 to N^{2}, i.e. each value from 1 t... | [{"input": "2\n2\n1 3\n2 4\n3\n2 7 9\n1 4 8\n3 6 5", "output": "4\n13\n"}, {"input": "2\n2\n1 3\n2 4\n3\n1 7 9\n3 4 8\n2 6 5", "output": "4\n12\n"}, {"input": "2\n2\n1 3\n2 4\n3\n1 7 9\n2 4 8\n6 3 5", "output": "4\n14\n"}, {"input": "2\n2\n1 3\n2 4\n3\n1 7 5\n2 4 8\n6 3 9", "output": "4\n16\n"}, {"input": "2\n2\n2 3\n1... | code_stdio |
[
{
"content": "This is the easy version of the problem. The difference is the constraints on $n$, $m$ and $t$. You can make hacks only if all versions of the problem are solved.\n\nAlice and Bob are given the numbers $n$, $m$ and $k$, and play a game as follows:\n\nThe game has a score that Alice tries to maximi... | [{"input": "10\n74 66 762901908\n543 237 181918820\n455 298 213830486\n54 35 373479158\n85 72 98863599\n85 72 351650459\n106 18 450755091\n344 26 748825922\n65 48 594595004\n189 52 282125334\n", "output": "271485562\n845881147\n625043331\n624104397\n478865056\n346406768\n733766402\n149326158\n296003967\n345448913\n"}, ... | code_stdio |
[
{
"content": "Given is a string S consisting of digits from 1 through 9.\nFind the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition:\nCondition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.\n\n-----Constraints-----\n - 1 ≤... | [{"input": "17363411548681837295128261415319567339781353176864449667411811151437528238242154453591258857339631698313648443916861223514163135267434612598561425414167173299132999132912477426521378378857571251998814421613836117444161875651252375139311654156139512913688822685276844411124583145973751484529881214395471691922... | code_stdio |
[
{
"content": "problem\n\nSoccer is popular in JOI, and a league match called the JOI League is held every week.\n\nThere are N teams in the JOI league, numbered from 1 to N. All combinations of matches are played exactly once. In other words, N × (N -1) / 2 games are played. The outcome of each match is determi... | [{"input": "4\n1 1 0 21\n1 4 2 0\n1 -1 12 2\n4 3 1 3\n4 16 6 1\n-1 1 1 12", "output": "1\n4\n2\n2\n"}, {"input": "4\n1 2 0 19\n2 3 2 2\n1 0 22 1\n3 3 3 -1\n3 16 6 0\n0 1 -1 8", "output": "2\n3\n1\n4\n"}, {"input": "4\n1 2 0 19\n2 3 8 1\n2 0 22 1\n3 0 3 0\n3 16 5 0\n0 1 0 16", "output": "3\n1\n2\n4\n"}, {"input": "4\n1 ... | code_stdio |
[
{
"content": "Sergey Semyonovich is a mayor of a county city N and he used to spend his days and nights in thoughts of further improvements of Nkers' lives. Unfortunately for him, anything and everything has been done already, and there are no more possible improvements he can think of during the day (he now pr... | [{"input": "10\n2 3\n3 9\n6 3\n9 8\n9 10\n4 10\n3 1\n2 5\n7 2\n", "output": "70\n"}, {"input": "10\n2 3\n2 9\n6 3\n9 8\n9 10\n4 10\n3 1\n2 5\n7 2\n", "output": "70\n"}, {"input": "10\n2 3\n3 9\n6 4\n10 8\n9 10\n4 2\n3 1\n3 5\n7 1\n", "output": "75\n"}, {"input": "10\n2 3\n2 9\n6 3\n9 8\n5 10\n4 10\n3 1\n2 5\n7 2\n", "o... | code_stdio |
[
{
"content": "The Cereal Guy's friend Serial Guy likes to watch soap operas. An episode is about to start, and he hasn't washed his plate yet. But he decided to at least put in under the tap to be filled with water. The plate can be represented by a parallelepiped k × n × m, that is, it has k layers (the first ... | [{"input": "4 10 10\n\n..........\n..........\n..........\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": "Given an array $a$, consisting of $n$ integers, find:\n\n$$\\max\\limits_{1 \\le i < j \\le n} LCM(a_i,a_j),$$\n\nwhere $LCM(x, y)$ is the smallest positive integer that is divisible by both $x$ and $y$. For example, $LCM(6, 8) = 24$, $LCM(4, 12) = 12$, $LCM(2, 3) = 6$.\n\n\n-----Input-----\n\nThe... | [{"input": "174\n28 44 12 32 9 27 23 5 23 47 14 49 39 5 10 5 20 9 4 34 18 40 16 4 45 30 32 44 44 30 29 23 21 27 35 13 23 46 5 32 47 45 44 23 12 2 9 28 47 23 22 27 45 27 40 41 22 39 50 14 40 44 20 40 49 23 14 29 27 23 16 40 45 44 15 18 28 9 23 15 21 10 46 29 18 6 15 3 11 34 1 15 35 27 46 36 4 20 30 20 5 35 24 37 42 42 4... | code_stdio |
[
{
"content": "You are given a multiset $S$ initially consisting of $n$ distinct non-negative integers. A multiset is a set, that can contain some elements multiple times.\n\nYou will perform the following operation $k$ times:\n\nAdd the element $\\lceil\\frac{a+b}{2}\\rceil$ (rounded up) into $S$, where $a = \\... | [{"input": "7\n5 1000000000\n4 2 3 0 1\n4 0\n5 2 0 1\n3 0\n100 0 1\n6 1234567\n1 2 3 4 5 0\n3 114514\n8 0 4\n1 1000000\n0\n1 10000000\n1\n", "output": "1000000005\n4\n3\n1234573\n4\n1000001\n1\n"}, {"input": "7\n5 1000000000\n4 2 3 0 1\n4 0\n5 2 0 1\n3 0\n100 0 1\n6 1234567\n1 2 3 4 5 0\n3 114514\n8 0 4\n1 1000000\n0\n... | code_stdio |
[
{
"content": "Chef recently saw the movie Matrix. He loved the movie overall but he didn't agree with some things in it. Particularly he didn't agree with the bald boy when he declared - There is no spoon. Being a chef, he understands the importance of the spoon and realizes that the universe can't survive with... | [{"input": "3\n3 6\nabDefb\nbSooon\nNIKHil\n6 6\naaaaaa\nssssst\nxuisdP\noooooo\nioowoo\nbdylan\n6 5\njhfdb\ncacac\nopqrs\nddddd\nindia\nyucky", "output": "There is indeed no spoon!\nThere is indeed no spoon!\nThere is indeed no spoon!\n"}, {"input": "3\n3 6\nbfeDba\nbnpooS\nNIKHil\n6 6\naaaaaa\nssssss\nOdsiux\noooooo\... | code_stdio |
[
{
"content": "Thumbelina has had an accident. She has found herself on a little island in the middle of a swamp and wants to get to the shore very much.\n\nOne can get to the shore only by hills that are situated along a straight line that connects the little island with the shore. Let us assume that the hills ... | [{"input": "200 72 29\n201 145 169 163 32 126 131 71 26 130 2 61 110 17 179 114 79 30 192 91 141 70 101 119 185 66 72 76 164 144 106 162 122 146 119 181 184 61 131 131 140 152 60 65 183 154 32 33 108 77 29 102 67 5 125 26 126 104 20 89 183 21 126 195 198 24 123 173 135 164 141 32\n160 65 136 22 194 110 155 138 92 118 8... | code_stdio |
[
{
"content": "The athletics competition 200M semi-final three races were held. Eight players (24 players in total) will participate in each group. A total of eight players, including the top two players in each group and the top two players from all the players in each group who are third or lower, will advance... | [{"input": "18 25.46\n16 26.23\n3 23.00\n10 25.483235609039603\n5 22.88\n11 24.901687688146353\n34 23.981112112664086\n1 25.301186029802214\n23 24.244672722558832\n2 23.844314504002764\n7 24.77498515307103\n17 24.26966625451088\n13 21.99\n26 22.86\n9 23.12\n6 24.09\n17 22.51\n22 23.49\n4 23.9495728367704\n14 22.23\n5 2... | code_stdio |
[
{
"content": "There are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i).\nWe will repeat the following operation as long as possible:\n - Choose four integers a, b, c, d (a \\neq c, b \\neq d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b) and... | [{"input": "1000\n75100 60743\n9726 45312\n39324 37026\n6218 24919\n37911 86455\n24562 12622\n88324 30198\n33847 67328\n2909 91511\n42029 31498\n41511 74704\n96712 15653\n86190 59227\n59789 67915\n15677 3177\n66597 62255\n27003 69079\n83921 51556\n49566 24925\n44399 87252\n70161 73909\n7368 27271\n54727 29016\n40590 56... | code_stdio |
[
{
"content": "Mike is given a matrix A, N and M are numbers of rows and columns respectively. A1, 1 is the number in the top left corner. All the numbers in A are non-negative integers. He also has L pairs of integers (ik, jk). His task is to calculate Ai1, j1 + Ai2, j2 + ... + AiL, jL.\n\nUnfortunately, Mike f... | [{"input": "3 2\n2 2\n4 1\n7 -1\n2\n1 2\n2 2", "output": "5\n"}, {"input": "3 2\n2 2\n7 0\n7 -1\n2\n1 2\n2 2", "output": "7\n"}, {"input": "3 2\n1 2\n3 5\n7 0\n2\n2 2\n2 2", "output": "10\n"}, {"input": "3 2\n1 2\n3 6\n7 0\n2\n2 2\n2 2", "output": "12\n"}, {"input": "3 2\n2 2\n4 0\n7 -1\n2\n1 2\n2 2", "output": "4\n"},... | code_stdio |
[
{
"content": "The year of 2012 is coming...\n\nAccording to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the human world. But seven brave heroes have already gathered on the top of a mount... | [{"input": "22\nCleo likes Snowy\nCleo likes Troll\nChapay likes Dracul\nSnowy likes Troll\nDracul likes Chapay\nDracul likes Snowy\nChapay likes Cleo\nSnowy likes Chapay\nDracul likes Troll\nAnka likes Hexadecimal\nSnowy likes Anka\nHexadecimal likes Cleo\nHexadecimal likes Troll\nDracul likes Anka\nCleo likes Hexadec... | code_stdio |
[
{
"content": "Andrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of contemporary art.\n\nThe main exhibit is a construction of n matryoshka dolls that can be nested one into another. The matryoshka dolls are numbered from 1 to n. A matryoshka with ... | [{"input": "100 19\n6 62 72 83 91 94 97\n3 61 84 99\n1 63\n5 46 53 56 69 78\n5 41 43 49 74 89\n5 55 57 79 85 87\n3 47 59 98\n3 64 76 82\n3 48 66 75\n2 60 88\n2 67 77\n4 40 51 73 95\n41 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 44 71 81\n4 58 65 90 93\n1 100... | code_stdio |
[
{
"content": "Sunake is in the form of a polygonal line consisting of n vertices (without self-intersection). First, Sunake-kun's i-th vertex is at (xi, yi). You can move continuously by translating or rotating, but you cannot deform (change the length of the polygonal line or the angle between the two line seg... | [{"input": "11\n63 106\n87 143\n102 132\n115 169\n74 145\n41 177\n56 130\n28 102\n19 124\n0 156\n22 183", "output": "Impossible\n"}, {"input": "11\n63 106\n87 143\n102 132\n115 169\n74 145\n41 177\n56 130\n28 102\n19 124\n0 294\n22 183", "output": "Impossible\n"}, {"input": "11\n63 106\n87 143\n102 132\n115 169\n74 145... | code_stdio |
[
{
"content": "It's been a while since I played with A, B, and C. Mr. A and Mr. B became players, and Mr. C became a referee and played a badminton singles game. The rules decided by the three people are as follows.\n\n* 3 Play the game.\n* The person who gets 11 points first wins the game.\n* The first serve of... | [{"input": "AABBAAABABAABBBAABA\nAABBBABBABBAAABABABAAB\nBABAABAABABABBAAAB\nAABABAAABBAABBBABAA\nAAAAAAAAAAA\nABBBBBBBBBB\n0", "output": "11 8\n10 12\n11 7\n11 8\n11 0\n0 11\n"}, {"input": "ABAABBBAABABAAABBAA\nAABBBABBABBAAABABABAAB\nBABAABAABABABBAAAB\nAABABAAABBAABBBABAA\nAAAAAAAAAAA\nABBBBBABBBB\n0", "output": "11... | code_stdio |
[
{
"content": "Mike and Ann are sitting in the classroom. The lesson is boring, so they decided to play an interesting game. Fortunately, all they need to play this game is a string $s$ and a number $k$ ($0 \\le k < |s|$).\n\nAt the beginning of the game, players are given a substring of $s$ with left border $l$... | [{"input": "wfyjbwcuxjrvmunfbrhethdmepeampvjcypavwoolteucetnqntytdfstvunnfyvngydjcohnwgtfddcnvuewxcafwureiupfeljqydwtickfbokoytlxtuwmvmvflemfvcksszlwgcwtamzovectkzxuzdtvbujyfpvcruvzvgglozwktwawcbkkwkookmuhjlcyjvfrnzmgpglvnbrujtbvtwrsqbulusfwzulxnadaqbijfrsvteqqoirfaolhfbgorxdwigwxcydbfxhvhqzjqirtznnwcjlcbakbitsjwocfgwc... | code_stdio |
[
{
"content": "Chef has a nice complete binary tree in his garden. Complete means that each node has exactly two sons, so the tree is infinite. Yesterday he had enumerated the nodes of the tree in such a way: \n- Let's call the nodes' level a number of nodes that occur on the way to this node from the root, incl... | [{"input": "4\nrll\nrll\nr\nlllr", "output": "14\n14\n4\n13\n"}, {"input": "4\nlrl\nrll\nr\nrlll", "output": "10\n14\n4\n27\n"}, {"input": "4\nlrl\nrll\nr\nllrl", "output": "10\n14\n4\n15\n"}, {"input": "4\nrll\nrll\nr\nllrl", "output": "14\n14\n4\n15\n"}, {"input": "4\nrll\nrll\nr\nrlll", "output": "14\n14\n4\n27\n"},... | code_stdio |
[
{
"content": "You are given an undirected graph with n vertices. There are no edge-simple cycles with the even length in it. In other words, there are no cycles of even length that pass each edge at most once. Let's enumerate vertices from 1 to n. \n\nYou have to answer q queries. Each query is described by a s... | [{"input": "12 12\n5 1\n5 11\n1 11\n8 11\n8 9\n5 12\n6 9\n7 11\n9 3\n9 10\n4 12\n10 2\n78\n1 1\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n2 10\n1 11\n1 12\n2 2\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n3 9\n2 10\n2 11\n2 12\n3 3\n3 4\n3 5\n3 6\n4 7\n3 8\n3 9\n3 10\n3 11\n3 12\n4 4\n4 5\n4 6\n4 7\n4 8\n4 10\n4 10\n4 11\n4 12\n5 5\n5... | code_stdio |
[
{
"content": "Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?\n\nJeff must make the number without leading zero. At that... | [{"input": "214\n5 0 5 0 5 0 0 0 5 5 0 5 0 5 5 0 5 0 0 0 0 5 5 0 0 5 5 0 0 0 0 5 5 5 5 0 5 0 0 0 0 0 0 5 0 0 0 5 0 0 5 0 0 5 5 0 0 5 5 0 0 0 0 0 5 0 5 0 5 5 0 5 0 0 5 5 5 0 5 0 5 0 5 5 0 5 0 0 0 5 5 0 5 0 5 5 5 5 5 0 0 0 0 0 0 5 0 5 5 0 5 0 5 0 5 5 0 0 0 0 5 0 5 0 5 0 0 5 0 0 5 5 5 5 5 0 0 5 0 0 5 0 0 5 0 0 5 0 0 5 0 5... | code_stdio |
[
{
"content": "There are H rows and W columns of white square cells.\nYou will choose h of the rows and w of the columns, and paint all of the cells contained in those rows or columns.\nHow many white cells will remain?\nIt can be proved that this count does not depend on what rows and columns are chosen.\n\n---... | [{"input": "21 -1\n-5 -5", "output": "104\n"}, {"input": "39 -1\n-5 -5", "output": "176\n"}, {"input": "13 13\n8 10\n", "output": "15\n"}, {"input": "20 20\n19 19\n", "output": "1\n"}, {"input": "19 19\n5 3\n", "output": "224\n"}, {"input": "20 20\n1 1\n", "output": "361\n"}, {"input": "20 20\n20 20\n", "output": "0\n"... | code_stdio |
[
{
"content": "The main street of Berland is a straight line with n houses built along it (n is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side of the street and are numbered from 1 to n - 1 in the order from the beginning of the street to the end ... | [{"input": "100000 99999\n", "output": "50000\n"}, {"input": "100000 23458\n", "output": "38272\n"}, {"input": "100000 23457\n", "output": "11729\n"}, {"input": "92480 43074\n", "output": "24704\n"}, {"input": "85766 64050\n", "output": "10859\n"}, {"input": "67808 61809\n", "output": "30905\n"}, {"input": "80124 68695... | code_stdio |
[
{
"content": "A permutation of length n is an array containing each integer from 1 to n exactly once. For example, q = [4, 5, 1, 2, 3] is a permutation. For the permutation q the square of permutation is the permutation p that p[i] = q[q[i]] for each i = 1... n. For example, the square of q = [4, 5, 1, 2, 3] is... | [{"input": "100\n94 22 24 99 58 97 20 29 67 30 38 64 77 50 15 44 92 88 39 42 25 70 2 76 84 6 37 49 17 71 31 19 26 79 10 35 65 63 32 95 5 8 52 27 83 18 53 93 13 81 48 68 54 82 34 60 87 23 16 86 55 40 61 45 28 7 74 41 14 91 3 72 33 11 98 89 90 69 78 36 80 59 56 21 43 1 75 46 47 12 96 73 57 51 4 85 9 100 66 62\n", "output... | code_stdio |
[
{
"content": "Anya has bought a new smartphone that uses Berdroid operating system. The smartphone menu has exactly n applications, each application has its own icon. The icons are located on different screens, one screen contains k icons. The icons from the first to the k-th one are located on the first screen... | [{"input": "71 96 75634\n1 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\n27 26 27 26 27 26 27 26 27 26 27 26 27 26 27 26 27 26 27 26 27 26 27 26 27 26 27 26 27 26 ... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.