messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
1 value
[ { "content": "There is a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. Also, each of these vertices and edges has a specified weight. Vertex i has a weight of X_i; Edge i has a weight of Y_i and connects Vertex A_i and B_i.\n\nWe wou...
[{"input": "10 9\n81 20 73 7 2 61 86 38 90 28\n6 8 725\n3 10 12\n1 4 558\n4 9 615\n5 6 942\n8 9 918\n2 7 720\n4 7 292\n7 10 414", "output": "8\n"}, {"input": "10 9\n81 20 73 7 2 61 86 44 90 28\n6 8 725\n3 10 12\n1 4 558\n4 9 615\n5 6 942\n8 9 918\n2 7 720\n4 7 292\n7 10 414", "output": "8\n"}, {"input": "10 9\n81 20 73...
code_stdio
[ { "content": "There is a tree with N vertices, numbered 1 through N. The i-th of the N-1 edges connects vertices a_i and b_i.\n\nCurrently, there are A_i stones placed on vertex i. Determine whether it is possible to remove all the stones from the vertices by repeatedly performing the following operation:\n\n* ...
[{"input": "6\n3 2 2 2 2 2\n1 2\n2 3\n1 6\n1 5\n4 6", "output": "YES\n"}, {"input": "6\n5 2 2 2 2 2\n1 2\n2 3\n1 6\n1 5\n4 6", "output": "NO\n"}, {"input": "6\n5 2 4 2 2 2\n1 2\n2 3\n1 6\n1 5\n4 6", "output": "NO\n"}, {"input": "6\n5 2 4 2 2 2\n1 2\n2 3\n1 6\n1 5\n6 6", "output": "NO\n"}, {"input": "6\n5 2 4 2 2 2\n1 0...
code_stdio
[ { "content": "In Berland a money reform is being prepared. New coins are being introduced. After long economic calculations was decided that the most expensive coin should possess the denomination of exactly n Berland dollars. Also the following restriction has been introduced for comfort: the denomination of e...
[{"input": "1000000\n", "output": "1000000 500000 250000 125000 62500 31250 15625 3125 625 125 25 5 1\n"}, {"input": "685248\n", "output": "685248 342624 171312 85656 42828 21414 10707 3569 83 1 "}, {"input": "100000\n", "output": "100000 50000 25000 12500 6250 3125 625 125 25 5 1\n"}, {"input": "537000\n", "output": "...
code_stdio
[ { "content": "We have N strings of lowercase English letters: S_1, S_2, \\cdots, S_N.\nTakahashi wants to make a string that is a palindrome by choosing one or more of these strings - the same string can be chosen more than once - and concatenating them in some order of his choice.\nThe cost of using the string...
[{"input": "50\nxkxkbxdadmrlymnhzpdb 964776970\nfxocahjfrcucddkozsuy 964776970\nxdqaekpuagisbklbybec 964776970\nvyowutrbwyqqqyvlchvr 964776970\nwjtibdpzhnmylrmdadxb 964776970\nyfvmjwesjqnahyzn 964776970\nuvbgtgszdkzicesngmpn 964776970\nmltwiydbpshxhgtgewfu 964776970\nsqhxdcadyvkjsyfwnphs 964776970\nxwbkeyhvgqcfznwybsct...
code_stdio
[ { "content": "Alice and Bob are playing a game on a matrix, consisting of $2$ rows and $m$ columns. The cell in the $i$-th row in the $j$-th column contains $a_{i, j}$ coins in it.\n\nInitially, both Alice and Bob are standing in a cell $(1, 1)$. They are going to perform a sequence of moves to reach a cell $(2...
[{"input": "3\n3\n2 3 12\n2 10 0\n3\n-1 4 17\n3 9 0\n1\n4\n3\n", "output": "12\n12\n0\n"}, {"input": "3\n3\n2 3 12\n2 10 1\n3\n-1 4 17\n2 9 0\n1\n4\n3\n", "output": "12\n11\n0\n"}, {"input": "3\n3\n2 3 12\n2 10 2\n3\n-1 4 17\n3 5 0\n1\n4\n3\n", "output": "12\n8\n0\n"}, {"input": "3\n3\n2 3 12\n2 10 0\n3\n-1 4 17\n3 5 0...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \nNim is a well-known combinatorial game, based on removing stones from piles. In this problem, we'll deal with a similar game, which we'll call Dual Nim. The rules of this game are as follows:\n\nInitially, there are N ...
[{"input": "3\n4\n1 2 4 12\n3\n2 3 3\n5\n1 3 3 3 3", "output": "First\nSecond\nSecond\n"}, {"input": "3\n4\n1 2 4 12\n3\n1 3 3\n5\n1 3 3 3 3", "output": "First\nSecond\nSecond\n"}, {"input": "3\n4\n1 2 8 13\n3\n3 1 3\n5\n1 3 1 3 3", "output": "First\nSecond\nSecond\n"}, {"input": "3\n4\n1 2 4 16\n3\n3 3 3\n5\n1 3 3 3 3...
code_stdio
[ { "content": "You are given a matrix consisting of digits zero and one, its size is n Γ— m. You are allowed to rearrange its rows. What is the maximum area of the submatrix that only consists of ones and can be obtained in the given problem by the described operations?\n\nLet's assume that the rows of matrix a a...
[{"input": "15 18\n111111111111111111\n111111111111111111\n111111111111111111\n111111111111111111\n111111111111111111\n111111111111111111\n111111111111111111\n111111111111111111\n111111111111111111\n111111111111111111\n111111111111111111\n111111111111111111\n111111111111111111\n111111111111111111\n111111111111111111\n"...
code_stdio
[ { "content": "You are given several queries. In the i-th query you are given a single positive integer n_{i}. You are to represent n_{i} as a sum of maximum possible number of composite summands and print this maximum number, or print -1, if there are no such splittings.\n\nAn integer greater than 1 is composit...
[{"input": "100\n611\n513\n544\n463\n38\n778\n347\n317\n848\n1308\n382\n108\n718\n33\n544\n876\n234\n22\n944\n305\n159\n245\n513\n691\n639\n135\n435\n324\n813\n459\n304\n116\n331\n993\n184\n224\n853\n769\n121\n687\n93\n930\n751\n308\n485\n914\n400\n695\n95\n981\n175\n972\n121\n1007\n242\n610\n617\n999\n237\n548\n742\n7...
code_stdio
[ { "content": "Cosmic market, commonly known as Kozumike, is the largest coterie spot sale in the universe. Doujin lovers of all genres gather at Kozumike. In recent years, the number of visitors to Kozumike has been increasing. If everyone can enter from the beginning, it will be very crowded and dangerous, so ...
[{"input": "5 5 4\n0 0 1\n0 0 0\n0 2 0\n1 1 1\n1 0 0\n5 5 5\n1 4 0\n0 1 1\n0 4 1\n1 3 0\n0 3 1\n5 5 5\n1 0 0\n0 3 1\n1 2 1\n0 4 0\n1 1 1\n0 0 0", "output": "5\n0\n13\n12\n"}, {"input": "5 14 5\n2 0 2\n0 0 0\n0 0 1\n1 2 1\n1 0 0\n5 5 5\n1 4 1\n0 1 1\n1 1 1\n1 3 0\n1 3 0\n5 10 5\n1 0 0\n0 3 0\n1 2 1\n0 4 0\n0 1 0\n0 0 0"...
code_stdio
[ { "content": "You are given two arrays of integers $a_1, a_2, \\ldots, a_n$ and $b_1, b_2, \\ldots, b_n$.\n\nLet's define a transformation of the array $a$:\n\nChoose any non-negative integer $k$ such that $0 \\le k \\le n$.\n\nChoose $k$ distinct array indices $1 \\le i_1 < i_2 < \\ldots < i_k \\le n$.\n\nAdd ...
[{"input": "2\n10\n3 3 2 2 3 2 1 1 2 3\n3 3 2 1 2 3 2 3 1 1\n10\n1 1 3 1 2 2 1 3 3 3\n3 1 3 1 1 2 3 2 2 1\n", "output": "NO\nNO\n"}, {"input": "1\n10\n14 -91 -52 -82 -4 69 33 3 -46 81\n-45 15 -4 82 33 3 -90 -81 -51 69\n", "output": "YES\n"}, {"input": "4\n2\n1 1\n0 0\n3\n1 2 3\n1 3 5\n4\n1 3 5 7\n0 2 4 8\n3\n0 0 0\n-1 ...
code_stdio
[ { "content": "Ujan has a lot of useless stuff in his drawers, a considerable part of which are his math notebooks: it is time to sort them out. This time he found an old dusty graph theory notebook with a description of a graph.\n\nIt is an undirected weighted graph on $n$ vertices. It is a complete graph: each...
[{"input": "15 10\n2 3\n5 4\n5 6\n5 7\n3 8\n3 10\n11 12\n12 13\n13 14\n14 15\n", "output": "0\n"}, {"input": "15 10\n2 3\n5 4\n5 6\n5 7\n3 8\n3 10\n11 12\n12 13\n13 14\n14 15\n", "output": "0\n"}, {"input": "15 10\n2 3\n5 4\n5 4\n5 7\n3 8\n3 10\n11 12\n12 13\n13 14\n14 15\n", "output": "0\n"}, {"input": "15 10\n2 3\n5 ...
code_stdio
[ { "content": "Let T be arbitrary binary tree β€” tree, every vertex of which has no more than two children. Given tree is rooted, so there exists only one vertex which doesn't have a parent β€” it's the root of a tree. Every vertex has an integer number written on it. Following algorithm is run on every value from ...
[{"input": "10\n911605217 -1 -1\n801852416 -1 -1\n140035920 -1 9\n981454947 10 2\n404988051 6 3\n307545107 8 7\n278188888 4 1\n523010786 -1 -1\n441817740 -1 -1\n789680429 -1 -1\n", "output": "7\n"}, {"input": "10\n911605217 -1 -1\n801852416 -1 -1\n140035920 -1 9\n981454947 10 2\n404988051 6 3\n307545107 8 7\n278188888 ...
code_stdio
[ { "content": "Gennady is one of the best child dentists in Berland. Today n children got an appointment with him, they lined up in front of his office.\n\nAll children love to cry loudly at the reception at the dentist. We enumerate the children with integers from 1 to n in the order they go in the line. Every ...
[{"input": "10\n9 8 8\n2 9 33\n10 7 42\n7 2 18\n3 5 82\n9 9 25\n3 2 86\n3 5 49\n5 3 72\n4 4 71\n", "output": "10\n1 2 3 4 5 6 7 8 9 10 "}, {"input": "10\n9 8 8\n2 9 33\n10 7 42\n7 2 18\n3 5 82\n9 9 25\n3 2 86\n3 5 49\n5 3 72\n4 4 71\n", "output": "10\n1 2 3 4 5 6 7 8 9 10 "}, {"input": "10\n9 8 8\n2 9 33\n10 7 42\n7 2 ...
code_stdio
[ { "content": "Imp likes his plush toy a lot.\n\n [Image] \n\nRecently, he found a machine that can clone plush toys. Imp knows that if he applies the machine to an original toy, he additionally gets one more original toy and one copy, and if he applies the machine to a copied toy, he gets two additional copies....
[{"input": "1000000000 999999999\n", "output": "Yes\n"}, {"input": "1000000000 1000000000\n", "output": "No\n"}, {"input": "1000000000 999999999\n", "output": "Yes\n"}, {"input": "1000000000 1000000000\n", "output": "No\n"}, {"input": "1079372212 582938127\n", "output": "Yes\n"}, {"input": "1000001000 1000000000\n", "o...
code_stdio
[ { "content": "ZS the Coder is coding on a crazy computer. If you don't type in a word for a c consecutive seconds, everything you typed disappear! \n\nMore formally, if you typed a word at second a and then the next word at second b, then if b - a ≀ c, just the new word is appended to other words on the screen....
[{"input": "2 1000000000\n1 1000000000\n", "output": "2\n"}, {"input": "2 1000000000\n1 1000000000\n", "output": "2"}, {"input": "6 5\n1 5 8 14 19 20\n", "output": "3\n"}, {"input": "5 10\n-1 1 22 32 34\n", "output": "3\n"}, {"input": "5 12\n-1 1 22 32 34\n", "output": "3\n"}, {"input": "6 5\n1 3 8 14 19 20\n", "output...
code_stdio
[ { "content": "There is a long-established secondhand bookstore called JOI secondhand bookstore in your town, and you often use the JOI secondhand bookstore. Each book has a standard price, and you can buy it at that price if you go to the JOI secondhand bookstore.\n\nAt the JOI secondhand bookstore, books are c...
[{"input": "7 7\n4 1\n13 2\n18 3\n64 3\n13 2\n16 10\n11 2", "output": "147\n"}, {"input": "7 7\n4 1\n13 2\n12 3\n48 3\n8 2\n16 10\n11 2", "output": "120\n"}, {"input": "7 5\n4 1\n13 3\n12 3\n48 3\n8 3\n16 10\n11 2", "output": "109\n"}, {"input": "7 7\n4 1\n13 2\n18 3\n48 3\n8 2\n16 10\n11 2", "output": "126\n"}, {"inpu...
code_stdio
[ { "content": "After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size $n \\times m$ (where $n$ is the number of rows, $m$ is the number of columns) and starts to draw snakes in cells.\n\nPolycarp draws s...
[{"input": "2\n1 1\nb\n1 1\nz\n", "output": "YES\n2\n1 1 1 1\n1 1 1 1\nYES\n26\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n1 1 1 1\n"}, {"...
code_stdio
[ { "content": "A monster is attacking the Cyberland!\n\nMaster Yang, a braver, is going to beat the monster. Yang and the monster each have 3 attributes: hitpoints (HP), offensive power (ATK) and defensive power (DEF).\n\nDuring the battle, every second the monster's HP decrease by max(0, ATKY - DEFM), while Yan...
[{"input": "100 100 100\n100 100 100\n100 100 100\n", "output": "100"}, {"input": "50 100 51\n100 100 100\n1 100 100\n", "output": "1384"}, {"input": "100 100 1\n100 100 100\n1 100 100\n", "output": "1891"}, {"input": "1 1 1\n100 100 100\n100 100 101\n", "output": "19999\n"}, {"input": "50 100 80\n100 100 100\n1 100 10...
code_stdio
[ { "content": "Vladik is a competitive programmer. This year he is going to win the International Olympiad in Informatics. But it is not as easy as it sounds: the question Vladik face now is to find the cheapest way to get to the olympiad.\n\nVladik knows n airports. All the airports are located on a straight li...
[{"input": "16 4 12\n0000000011111111\n", "output": "1\n"}, {"input": "16 1 12\n0000000011111111\n", "output": "1\n"}, {"input": "16 1 12\n0100000011111111\n", "output": "1\n"}, {"input": "16 2 12\n0100000011111111\n", "output": "0\n"}, {"input": "16 3 12\n0100000011111111\n", "output": "1\n"}, {"input": "16 2 12\n0100...
code_stdio
[ { "content": "An old document says that a Ninja House in Kanazawa City was in fact a defensive fortress, which was designed like a maze. Its rooms were connected by hidden doors in a complicated manner, so that any invader would become lost. Each room has at least two doors.\n\nThe Ninja House can be modeled by...
[{"input": "2\n3 3 3 3 -3 3 2 -5 3 2 -5 -3 0\n3 5 3 -2 4 -3 -2 -2 -1 0", "output": "1 2 4 6\n2 1 3 8\n3 2 4 7\n4 1 3 5\n5 4 6 7\n6 1 5\n7 3 5 8\n8 2 7\n1 2 2 3 4\n2 1 1 3 4 4\n3 1 2 4\n4 1 2 2 3\n"}, {"input": "2\n3 3 3 3 -3 3 2 -5 3 2 -5 -3 0\n3 5 4 -2 4 -1 -2 -2 -1 0", "output": "1 2 4 6\n2 1 3 8\n3 2 4 7\n4 1 3 5\n5...
code_stdio
[ { "content": "Watto, the owner of a spare parts store, has recently got an order for the mechanism that can process strings in a certain way. Initially the memory of the mechanism is filled with n strings. Then the mechanism should be able to process queries of the following type: \"Given string s, determine if...
[{"input": "1 17\ncacdbcacabccba\naccbcbcabaabbcbcaa\nbabccaaacccacbb\nbbbabbabbbcaacbaaac\nabbaccacabacaaaa\nbccbccabaacaacb\nbbbabbbbabcaacbcaac\nbcacababbbdaaca\nccbbbbababbccaab\nbbcbcc`babcaacb\naacccbabbacbabacaca\nbcaacbabcccbcbb\nacbacacbcacc\ncaaabcaaabacabbabbb\nabcbabaaaba\naacccbcaabacbcbcba\nabbaccacabbcaa...
code_stdio
[ { "content": "Anton and Dasha like to play different games during breaks on checkered paper. By the 11th grade they managed to play all the games of this type and asked Vova the programmer to come up with a new game. Vova suggested to them to play a game under the code name \"dot\" with the following rules: \n\...
[{"input": "12 -11 20 200\n11 189\n12 108\n19 190\n21 27\n24 193\n26 86\n26 123\n31 180\n39 196\n107 193\n122 46\n129 103\n131 129\n132 135\n142 51\n157 22\n161 27\n195 163\n198 55\n199 64\n", "output": "Anton\n"}, {"input": "12 -11 20 200\n11 189\n12 108\n19 190\n42 27\n24 193\n26 86\n26 123\n31 180\n39 196\n107 193\n...
code_stdio
[ { "content": "Π—Π°Π²Ρ‚Ρ€Π° Ρƒ Ρ…ΠΎΠΊΠΊΠ΅ΠΉΠ½ΠΎΠΉ ΠΊΠΎΠΌΠ°Π½Π΄Ρ‹, ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΉ Ρ€ΡƒΠΊΠΎΠ²ΠΎΠ΄ΠΈΡ‚ Π•Π²Π³Π΅Π½ΠΈΠΉ, Π²Π°ΠΆΠ½Ρ‹ΠΉ ΠΌΠ°Ρ‚Ρ‡. Π•Π²Π³Π΅Π½ΠΈΡŽ Π½ΡƒΠΆΠ½ΠΎ Π²Ρ‹Π±Ρ€Π°Ρ‚ΡŒ ΡˆΠ΅ΡΡ‚ΡŒ ΠΈΠ³Ρ€ΠΎΠΊΠΎΠ², ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ Π²Ρ‹ΠΉΠ΄ΡƒΡ‚ Π½Π° Π»Π΅Π΄ Π² стартовом составС: ΠΎΠ΄ΠΈΠ½ Π²Ρ€Π°Ρ‚Π°Ρ€ΡŒ, Π΄Π²Π° Π·Π°Ρ‰ΠΈΡ‚Π½ΠΈΠΊΠ° ΠΈ Ρ‚Ρ€ΠΈ Π½Π°ΠΏΠ°Π΄Π°ΡŽΡ‰ΠΈΡ….\n\nΠ’Π°ΠΊ ΠΊΠ°ΠΊ это стартовый состав, ЕвгСния большС Π²ΠΎΠ»Π½ΡƒΠ΅Ρ‚, насколько красива Π±ΡƒΠ΄Π΅Ρ‚ ΠΊΠΎΠΌΠ°Π½Π΄Π° Π½Π° Π»ΡŒΠ΄Ρƒ, Ρ‡Π΅ΠΌ сп...
[{"input": "29 42 50\n605 254 369 842 889 103 937 235 135 698 482 883 738 467 848 70 1000 129 970 58 94 873 140 363 133 913 834 727 185\n17 676 703 245 149 296 800 106 153 111 285 382 12 704 830 664 30 533 604 380 469 155 216 466 36 347 270 170 10 349 86 5 164 599 517 593 373 461 908 34 569 573\n614 439 78 172 109 217 ...
code_stdio
[ { "content": "Any resemblance to any real championship and sport is accidental.\n\nThe Berland National team takes part in the local Football championship which now has a group stage. Let's describe the formal rules of the local championship: \n\n * the team that kicked most balls in the enemy's goal area wins...
[{"input": "MYCXFLPTHVGWDSRXCOI BERLAND 5:9\nSPSHVVQLXQNRUB BERLAND 0:5\nSPSHVVQLXQNRUB MYCXFLPTHVGWDSRXCOI 4:6\nZPIIZCGCLCHNLIXCPBRM MYCXFLPTHVGWDSRXCOI 7:5\nZPIIZCGCLCHNLIXCPBRM SPSHVVQLXQNRUB 3:9\n", "output": "1:0"}, {"input": "VJWNNQCMHKJVXAPRVAD BERLAND 9:3\nVJWNNQCMHKJVXAPRVAD BUDKMHAAE 7:8\nYUMJUSFUDMHTXZAQN BE...
code_stdio
[ { "content": "Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.\n\nA bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to...
[{"input": "20 10\n10 11 U\n12 9 U\n6 15 L\n17 4 U\n11 10 L\n7 14 L\n4 17 U\n2 19 L\n8 13 L\n14 7 U\n", "output": "11\n9\n6\n4\n1\n7\n2\n2\n8\n7\n"}, {"input": "10 10\n5 6 U\n4 7 U\n8 3 L\n8 3 L\n1 10 U\n9 2 U\n10 1 L\n10 1 L\n8 3 U\n8 3 U\n", "output": "6\n7\n3\n0\n10\n2\n1\n0\n0\n0\n"}, {"input": "15 7\n8 8 U\n6 10 L...
code_stdio
[ { "content": "A sweet little monster Om Nom loves candies very much. One day he found himself in a rather tricky situation that required him to think a bit in order to enjoy candies the most. Would you succeed with the same task if you were on his place? [Image] \n\nOne day, when he came to his friend Evan, Om ...
[{"input": "925819493 47350513 28377591 119226256 49881078\n", "output": "510796638\n"}, {"input": "930064129 32726326 25428197 158103592 64501049\n", "output": "355994758\n"}, {"input": "930064129 32726326 25428197 83013449 64501049\n", "output": "363523396\n"}, {"input": "951102310 39876134 24967176 70096104 43888451...
code_stdio
[ { "content": "The three friends, Kuro, Shiro, and Katie, met up again! It's time for a party...\n\nWhat the cats do when they unite? Right, they have a party. Since they wanted to have as much fun as possible, they invited all their friends. Now $n$ cats are at the party, sitting in a circle and eating soup. Th...
[{"input": "1000 843\n", "output": "157\n"}, {"input": "1000 488\n", "output": "488\n"}, {"input": "1000 843\n", "output": "157\n"}, {"input": "1000 488\n", "output": "488\n"}, {"input": "1000 733\n", "output": "267\n"}, {"input": "543 110\n", "output": "110\n"}, {"input": "924 576\n", "output": "348\n"}, {"input": "10...
code_stdio
[ { "content": "You are given a mysterious language (codenamed \"Secret\") available in \"Custom Invocation\" tab. Figure out what this language is and write a program which prints its name. Note that the program must be written in this language.\n\nInput\n\nThis program has only one test (your program doesn't ha...
[{"input": "-111\n", "output": "INTERCAL\n"}, {"input": "-165\n", "output": "INTERCAL\n"}, {"input": "-137\n", "output": "INTERCAL\n"}, {"input": "-116\n", "output": "INTERCAL\n"}, {"input": "-14\n", "output": "INTERCAL\n"}, {"input": "-17\n", "output": "INTERCAL\n"}, {"input": "-30\n", "output": "INTERCAL\n"}, {"input...
code_stdio
[ { "content": "Once at a team training Vasya, Petya and Sasha got a problem on implementing linear search in an array.\n\nAccording to the boys, linear search works as follows. The array elements in a pre-selected order are in turn compared with the number that you need to find. Once you find the array element t...
[{"input": "10\n5 2 10 8 3 1 9 7 6 4\n9\n2 1 9 2 9 2 10 9 8\n", "output": "40 59\n"}, {"input": "10\n5 2 10 8 3 1 9 7 6 4\n9\n3 1 9 2 9 2 10 9 8\n", "output": "43 56\n"}, {"input": "10\n5 2 10 8 3 1 9 7 6 4\n9\n2 1 6 2 9 2 10 9 8\n", "output": "42 57\n"}, {"input": "10\n5 2 10 8 3 1 9 7 6 4\n9\n2 1 6 2 9 2 10 8 8\n", "...
code_stdio
[ { "content": "Recently, Masha was presented with a chessboard with a height of $n$ and a width of $m$.\n\nThe rows on the chessboard are numbered from $1$ to $n$ from bottom to top. The columns are numbered from $1$ to $m$ from left to right. Therefore, each cell can be specified with the coordinates $(x,y)$, w...
[{"input": "5\n2 2\n1 1 2 2\n1 1 2 2\n3 4\n2 2 3 3\n3 1 4 3\n1 5\n1 1 3 1\n3 1 5 1\n6 4\n1 1 4 2\n1 3 4 4\n3 4\n1 2 4 2\n2 1 3 3\n", "output": "0 4\n4 8\n2 3\n12 12\n4 8\n"}, {"input": "5\n2 2\n1 1 2 2\n1 1 2 2\n3 5\n2 2 3 2\n3 1 4 3\n1 5\n1 1 5 1\n3 1 5 1\n4 4\n1 1 4 2\n1 3 4 4\n3 4\n1 2 4 2\n2 1 3 3\n", "output": "0 ...
code_stdio
[ { "content": "Goa'uld Apophis captured Jack O'Neill's team again! Jack himself was able to escape, but by that time Apophis's ship had already jumped to hyperspace. But Jack knows on what planet will Apophis land. In order to save his friends, Jack must repeatedly go through stargates to get to this planet.\n\n...
[{"input": "8 10\n1 2 3\n2 8 3\n1 4 1\n4 3 6\n3 7 7\n4 5 5\n7 7 2\n7 8 1\n1 6 8\n6 8 7\n0\n4 1 2 3 4\n0\n0\n0\n0\n0\n0\n", "output": "8\n"}, {"input": "8 10\n1 2 3\n2 8 3\n1 4 1\n4 3 6\n3 7 7\n4 5 5\n5 7 2\n7 8 1\n1 6 8\n6 8 7\n0\n4 1 2 3 4\n0\n0\n0\n0\n0\n0\n", "output": "8"}, {"input": "7 6\n1 2 1\n1 3 3\n2 4 3\n2 5 ...
code_stdio
[ { "content": "This year, as in previous years, MemSQL is inviting the top 25 competitors from the Start[c]up qualification round to compete onsite for the final round. Not everyone who is eligible to compete onsite can afford to travel to the office, though. Initially the top 25 contestants are invited to come ...
[{"input": "25\n1000000 999999 999998 999997 999996 999995 999994 999993 999992 999991 999990 999989 999988 999987 999986 999985 999984 999983 999982 999981 999980 999979 999978 999977 999976\n", "output": "999975\n"}, {"input": "25\n58115 794098 753382 484882 238434 674285 690118 858677 196185 173301 349729 918792 600...
code_stdio
[ { "content": "Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled \"a\" to \"z\", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet can be described as a string of lowercase lett...
[{"input": "xulsyfkuizjauadjjopu\n", "output": "526\n"}, {"input": "cskgsxywlvfeicoueglr\n", "output": "526\n"}, {"input": "gggggggggggggggggggg\n", "output": "526\n"}, {"input": "qdqdddqddqqddqddqdqd\n", "output": "526\n"}, {"input": "takttttaakaaktakttkt\n", "output": "526\n"}, {"input": "coccoooogogcgocccmcg\n", "ou...
code_stdio
[ { "content": "Karafs is some kind of vegetable in shape of an 1 Γ— h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs.\n\n<image>\n\nEach Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The hei...
[{"input": "469 128038 4\n143 914502 747\n74 1244223 74477\n835 246699 1021\n7 477777 444444\n", "output": "-1\n-1\n-1\n-1\n"}, {"input": "469 128038 4\n82 914502 747\n80 1244223 74477\n1360 246699 1021\n7 477777 444444\n", "output": "-1\n-1\n-1\n-1\n"}, {"input": "469 128038 4\n82 914502 747\n74 1244223 74477\n432 383...
code_stdio
[ { "content": "Hexadecimal likes drawing. She has drawn many graphs already, both directed and not. Recently she has started to work on a still-life Β«interesting graph and applesΒ». An undirected graph is called interesting, if each of its vertices belongs to one cycle only β€” a funny ring β€” and does not belong to...
[{"input": "50 21\n27 16\n42 35\n15 28\n46 17\n30 39\n47 18\n35 25\n26 24\n24 30\n28 41\n40 38\n11 21\n33 20\n43 10\n37 14\n1 43\n32 49\n49 6\n10 45\n21 50\n39 3\n", "output": "YES\n29\n1 2\n2 3\n4 5\n4 6\n5 7\n7 8\n8 9\n9 11\n12 13\n12 14\n13 15\n16 17\n18 19\n19 20\n22 23\n22 25\n23 26\n27 29\n29 31\n31 32\n33 34\n34...
code_stdio
[ { "content": "A priority queue is a data structure which maintains a set $S$ of elements, each of with an associated value (key), and supports the following operations:\n\n* $insert(S, k)$: insert an element $k$ into the set $S$\n* $extractMax(S)$: remove and return the element of $S$ with the largest key\n\n\n...
[{"input": "insert 8\ninsert -1\nextract\ninsert 12\nextract\ninsert 11\nextract\nextract\nend", "output": "8\n12\n11\n-1\n"}, {"input": "insert 9\ninsert -1\nextract\ninsert 12\nextract\ninsert 11\nextract\nextract\nend", "output": "9\n12\n11\n-1\n"}, {"input": "insert 16\ninsert 1\nextract\ninsert 15\nextract\ninsert...
code_stdio
[ { "content": "A ticket is a string consisting of six digits. A ticket is considered lucky if the sum of the first three digits is equal to the sum of the last three digits. Given a ticket, output if it is lucky or not. Note that a ticket can have leading zeroes.\n\n\n-----Input-----\n\nThe first line of the inp...
[{"input": "5\n213132\n973894\n045207\n000000\n055776\n", "output": "YES\nNO\nYES\nYES\nNO\n"}, {"input": "2\n193758\n123456\n", "output": "NO\nNO\n"}, {"input": "2\n192758\n123456\n", "output": "NO\nNO\n"}, {"input": "1\n114514\n", "output": "NO\n"}, {"input": "1\n975310\n", "output": "NO\n"}, {"input": "1\n666999\n",...
code_stdio
[ { "content": "You are given an integer $n$ ($n \\ge 0$) represented with $k$ digits in base (radix) $b$. So,\n\n$$n = a_1 \\cdot b^{k-1} + a_2 \\cdot b^{k-2} + \\ldots a_{k-1} \\cdot b + a_k.$$\n\nFor example, if $b=17, k=3$ and $a=[11, 15, 7]$ then $n=11\\cdot17^2+15\\cdot17+7=3179+255+7=3441$.\n\nDetermine wh...
[{"input": "97 100\n93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93\...
code_stdio
[ { "content": "Given are integers L and R. Find the number, modulo 10^9 + 7, of pairs of integers (x, y) (L \\leq x \\leq y \\leq R) such that the remainder when y is divided by x is equal to y \\mbox{ XOR } x.What is \\mbox{ XOR }?\n\nThe XOR of integers A and B, A \\mbox{ XOR } B, is defined as follows:\n\n - ...
[{"input": "576460752303423487 1000000000000000000\n", "output": "576747015\n"}, {"input": "576460752303423488 1000000000000000000\n", "output": "576747014\n"}, {"input": "272710541579005162 367157307262253986\n", "output": "252027897\n"}, {"input": "1000000000000000000 1000000000000000000\n", "output": "1\n"}, {"input...
code_stdio
[ { "content": "You are given n strings s_1, s_2, ..., s_{n} consisting of characters 0 and 1. m operations are performed, on each of them you concatenate two existing strings into a new one. On the i-th operation the concatenation s_{a}_{i}s_{b}_{i} is saved into a new string s_{n} + i (the operations are number...
[{"input": "2\n011\n100\n63\n1 1\n3 3\n4 4\n5 5\n6 6\n7 7\n8 8\n9 9\n10 10\n11 11\n12 12\n13 13\n14 14\n15 15\n16 16\n17 17\n18 18\n19 19\n20 20\n21 21\n22 22\n23 23\n24 24\n25 25\n26 26\n27 27\n28 28\n29 29\n30 30\n31 31\n32 32\n2 2\n34 34\n35 35\n36 36\n37 37\n38 38\n39 39\n40 40\n41 41\n42 42\n43 43\n44 44\n45 45\n4...
code_stdio
[ { "content": "Mojtaba and Arpa are playing a game. They have a list of n numbers in the game.\n\nIn a player's turn, he chooses a number pk (where p is a prime number and k is a positive integer) such that pk divides at least one number in the list. For each number in the list divisible by pk, call it x, the pl...
[{"input": "63\n16807 1 1419857 59049 1 2187 6859 1 33554432 129140163 11 1 16777216 3 9765625 1331 2197 268435456 2 169 390625 343 1048576 536870912 19683 125 16384 27 40353607 815730721 32 130321 43046721 524288 17 8388608 7 4782969 15625 282475249 134217728 1 25 4913 9 19 131072 244140625 625 2476099 1 2048 21435888...
code_stdio
[ { "content": "Sergei B., the young coach of Pokemons, has found the big house which consists of n flats ordered in a row from left to right. It is possible to enter each flat from the street. It is possible to go out from each flat. Also, each flat is connected with the flat to the left and the flat to the righ...
[{"input": "100\nfAfhfNNNhfffAfNffNANhffNffffffNfffffhNfffNfefNfffNfNNNffNfffNfhNNNffffNfNfffAffNffNffNNfhfffNhNffNNN\n", "output": "26\n"}, {"input": "100\nfAfhfNNNhfffAfNffNANhffNffffffNfffffhNfffNfffNfffNfNNNffNfffNfhNNNffffNfNfffAffNffNffNNfhfffNhNffNNN\n", "output": "4\n"}, {"input": "100\nfAfhfNNNhfffAfNffNANhffN...
code_stdio
[ { "content": "AtCoDeer the deer found N rectangle lying on the table, each with height 1.\nIf we consider the surface of the desk as a two-dimensional plane, the i-th rectangle i(1≀i≀N) covers the vertical range of [i-1,i] and the horizontal range of [l_i,r_i], as shown in the following figure:\n\nAtCoDeer will...
[{"input": "5\n999999999 1000000000\n1 2\n314 315\n500000 500001\n999999999 1000000000\n", "output": "1999999680\n"}, {"input": "5\n999999999 1000001000\n1 -1\n269 106\n500000 500001\n999999999 1000000000", "output": "1999999892\n"}, {"input": "5\n999999999 1000001000\n1 -1\n269 101\n500000 500001\n999999999 1000000000...
code_stdio
[ { "content": "Currently, people's entertainment is limited to programming contests. The activity of the entertainment club of a junior high school to which she belongs is to plan and run a programming contest. Her job is not to create problems. It's a behind-the-scenes job of soliciting issues from many, organi...
[{"input": "1 2 1 1 1 0\n1 2 1 0 0 -1\n1 0 0 0 1 1\n3 -1 0 0 2 0\n3 1 0 1 3 1\n0 2 0 2 -1 0\n0 0 1 1 0 7\n2 0 0 1 0 0\n0 0 0 0 0 0", "output": "1\n0\n1\n1\n3\n0\n2\n1\n"}, {"input": "1 2 1 1 1 0\n1 2 1 0 0 -1\n1 0 0 0 1 1\n3 -1 0 0 2 0\n3 0 0 1 3 1\n0 2 0 2 -1 0\n0 0 1 1 0 7\n2 0 0 1 0 0\n0 0 0 0 0 0", "output": "1\n0\...
code_stdio
[ { "content": "M-kun is a student in Aoki High School, where a year is divided into N terms.\nThere is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows:\n\n* For the first through (K-1)-th terms: not given.\n* For each of the K-th throu...
[{"input": "15 1\n4 1 4 0 6 9 2 6 5 3 5 7 9 1 9", "output": "No\nYes\nNo\nYes\nYes\nNo\nYes\nNo\nNo\nYes\nYes\nYes\nNo\nYes\n"}, {"input": "15 1\n3 0 8 1 6 9 1 6 5 5 9 7 2 7 16", "output": "No\nYes\nNo\nYes\nYes\nNo\nYes\nNo\nNo\nYes\nNo\nNo\nYes\nYes\n"}, {"input": "15 2\n6 1 8 2 12 9 1 8 1 6 9 15 9 3 28", "output": "...
code_stdio
[ { "content": "Allen is hosting a formal dinner party. 2n people come to the event in n pairs (couples). After a night of fun, Allen wants to line everyone up for a final picture. The 2n people line up, but Allen doesn't like the ordering. Allen prefers if each pair occupies adjacent positions in the line, as th...
[{"input": "86\n33 6 22 8 54 43 57 85 70 41 20 17 35 12 66 25 45 78 67 55 50 19 31 75 77 29 58 78 34 15 40 48 14 82 6 37 44 53 62 23 56 22 34 18 71 83 21 80 47 38 3 42 60 9 73 49 84 7 76 30 5 4 11 28 69 16 26 10 59 48 64 46 32 68 24 63 79 36 13 1 27 61 39 74 2 51 51 2 74 39 61 27 1 13 36 79 86 24 68 32 46 64 63 59 10 2...
code_stdio
[ { "content": "A plurality of trampolines are arranged in a line at 10 m intervals. Each trampoline has its own maximum horizontal distance within which the jumper can jump safely. Starting from the left-most trampoline, the jumper jumps to another trampoline within the allowed jumping range. The jumper wants to...
[{"input": "4\n163\n51\n2\n32", "output": "yes\n"}, {"input": "4\n001\n103\n-1\n0", "output": "no\n"}, {"input": "4\n001\n136\n-1\n0", "output": "no\n"}, {"input": "4\n001\n155\n-1\n0", "output": "no\n"}, {"input": "4\n20\n51\n1\n20", "output": "yes\n"}, {"input": "4\n37\n51\n1\n20", "output": "yes\n"}, {"input": "4\n5...
code_stdio
[ { "content": "Ann has recently started commuting by subway. We know that a one ride subway ticket costs a rubles. Besides, Ann found out that she can buy a special ticket for m rides (she can buy it several times). It costs b rubles. Ann did the math; she will need to use subway n times. Help Ann, tell her what...
[{"input": "1000 1 1000 1000\n", "output": "1000000\n"}, {"input": "1000 1 1000 1000\n", "output": "1000000\n"}, {"input": "1000 3 1000 1000\n", "output": "334000\n"}, {"input": "1000 3 1000 1000\n", "output": "334000\n"}, {"input": "1000 3 1001 1000\n", "output": "334000\n"}, {"input": "1000 5 1000 1000\n", "output": ...
code_stdio
[ { "content": "Given is a lowercase English letter C that is not z. Print the letter that follows C in alphabetical order.\n\n-----Constraints-----\n - C is a lowercase English letter that is not z.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nC\n\n-----Output-----\nPrint the ...
[{"input": "a\n", "output": "b\n"}, {"input": "y\n", "output": "z\n"}, {"input": "c\n", "output": "d\n"}, {"input": "p\n", "output": "q\n"}, {"input": "d\n", "output": "e\n"}, {"input": "t\n", "output": "u\n"}, {"input": "z", "output": "{\n"}, {"input": "b", "output": "c\n"}, {"input": "x", "output": "y\n"}, {"input": ...
code_stdio
[ { "content": "Given are an integer N and four characters c_{\\mathrm{AA}}, c_{\\mathrm{AB}}, c_{\\mathrm{BA}}, and c_{\\mathrm{BB}}.\nHere, it is guaranteed that each of those four characters is A or B.\nSnuke has a string s, which is initially AB.\nLet |s| denote the length of s.\nSnuke can do the four kinds o...
[{"input": "1000\nB\nA\nA\nA\n", "output": "589888339\n"}, {"input": "1000\nA\nB\nA\nA\n", "output": "336052903\n"}, {"input": "1000\nB\nB\nA\nA\n", "output": "336052903\n"}, {"input": "1000\nB\nA\nB\nA\n", "output": "336052903\n"}, {"input": "1000\nA\nB\nB\nA\n", "output": "589888339\n"}, {"input": "1000\nB\nB\nB\nA\n...
code_stdio
[ { "content": "An autumn sports festival is held. There are four events: foot race, ball-carrying, obstacle race, and relay. There are n teams participating, and we would like to commend the team with the shortest total time in this 4th event as the \"winner\", the next smallest team as the \"runner-up\", and th...
[{"input": "8\n65541 3 20 3 8 6 27 2 25\n20941 3 5 2 41 7 19 2 42\n90585 4 8 3 12 11 46 2 34\n92201 3 28 2 47 6 37 2 58\n10001 3 50 2 42 7 12 4 54\n63812 4 11 3 11 6 98 2 22\n54092 3 33 2 54 6 18 2 19\n25012 3 44 2 58 6 45 2 46\n4\n1 3 23 1 23 1 34 4 69\n2 5 12 2 12 3 41 2 29\n3 5 24 1 24 2 0 3 35\n4 4 49 2 22 4 41 4 2...
code_stdio
[ { "content": "You are given an alphabet consisting of n letters, your task is to make a string of the maximum possible length so that the following conditions are satisfied: the i-th letter occurs in the string no more than a_{i} times; the number of occurrences of each letter in the string must be distinct ...
[{"input": "26\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "259...
code_stdio
[ { "content": "You are given nonnegative integers a and b (a ≀ b), and a positive integer x.\nAmong the integers between a and b, inclusive, how many are divisible by x?\n\n-----Constraints-----\n - 0 ≀ a ≀ b ≀ 10^{18}\n - 1 ≀ x ≀ 10^{18}\n\n-----Input-----\nThe input is given from Standard Input in the followin...
[{"input": "1 1000000000000000000 3\n", "output": "333333333333333333\n"}, {"input": "-1 1010010100000100000 4", "output": "252502525000025001\n"}, {"input": "-1 1010010110000100000 3", "output": "336670036666700001\n"}, {"input": "-1 1010010111000100000 3", "output": "336670037000033334\n"}, {"input": "1 1000010000000...
code_stdio
[ { "content": "You were dreaming that you are traveling to a planet named Planetforces on your personal spaceship. Unfortunately, its piloting system was corrupted and now you need to fix it in order to reach Planetforces.\n\nSpace can be represented as the $XY$ plane. You are starting at point $(0, 0)$, and Pla...
[{"input": "6\n10 5\nRRRRRRRRRRUUUUU\n1 -1\nUDDDRLLL\n-3 -5\nLDLDLDDDR\n-1 2\nUULLLL\n6 -2\nRDULRLLDR\n-1 6\nRUDURUUUUR\n", "output": "YES\nYES\nYES\nYES\nNO\nNO\n"}, {"input": "6\n10 5\nRRRRRRRRRRUUUUU\n1 -1\nUDDDRLLL\n-3 -5\nLDLDLDDDR\n0 2\nUULLLL\n6 -2\nRDULRLLDR\n-1 6\nRUDURUUUUR\n", "output": "YES\nYES\nYES\nYES\n...
code_stdio
[ { "content": "After his wife's tragic death, Eurydice, Orpheus descended to the realm of death to see her. Reaching its gates was uneasy, but passing through them proved to be even more challenging. Mostly because of Cerberus, the three-headed hound of Hades.\n\nOrpheus, a famous poet, and musician plans to cal...
[{"input": "7\nbabba\nabaac\ncodeforces\nzeroorez\nabcdcba\nbbbbbbb\na\n", "output": "\n1\n1\n0\n1\n1\n4\n0\n"}, {"input": "7\nbabba\nabaac\ncodeforces\nzeroorez\nabcdcba\nbbbbbbb\na\n", "output": "1\n1\n0\n1\n1\n4\n0\n"}, {"input": "7\nabbab\nabaac\ncodeforces\nzeroorez\nabcdcba\nbbbbbbb\na\n", "output": "1\n1\n0\n1\n...
code_stdio
[ { "content": "Yet another round on DecoForces is coming! Grandpa Maks wanted to participate in it but someone has stolen his precious sofa! And how can one perform well with such a major loss?\n\nFortunately, the thief had left a note for Grandpa Maks. This note got Maks to the sofa storehouse. Still he had no ...
[{"input": "6\n10 10\n3 6 3 7\n4 9 5 9\n5 4 5 3\n7 1 8 1\n9 10 8 10\n7 7 7 8\n0 5 2 3\n", "output": "1\n"}, {"input": "6\n10 10\n3 6 3 7\n4 9 5 9\n5 4 5 3\n7 1 8 1\n9 10 8 10\n7 7 7 8\n0 5 2 3\n", "output": "1\n"}, {"input": "5\n4 6\n4 3 3 3\n4 2 4 1\n3 6 2 6\n2 4 2 3\n1 1 1 2\n1 2 2 1\n", "output": "-1\n"}, {"input": ...
code_stdio
[ { "content": "Chef changed the password of his laptop a few days ago, but he can't remember it today. Luckily, he wrote the encrypted password on a piece of paper, along with the rules for decryption.\nThe encrypted password is a string S consists of ASCII printable characters except space (ASCII 33 - 126, in d...
[{"input": "4\n2\n2 3\n1 1\n8\n0\n1800.7150295041072\n0\n0.42064717124502127\n3\nx 1\nc 2\n# .\n0xd21#dc/98x", "output": "8\n1800.7150295041072\n.42064717124502127\n1d21.d2/981\n"}, {"input": "4\n2\n7 3\n3 1\n10\n0\n1800.0493927440593\n0\n0.9085107376538183\n3\ny 0\nd 3\n# .\n0xd21#xd098d", "output": "10\n1800.04939274...
code_stdio
[ { "content": "n evenly spaced points have been marked around the edge of a circle. There is a number written at each point. You choose a positive real number k. Then you may repeatedly select a set of 2 or more points which are evenly spaced, and either increase all numbers at points in the set by k or decrease...
[{"input": "488\n453349582488862562152454328120974624021885842759505659322561694358728150516204337664755243733316681382547751353198982127441183878962690095592236469807087207161691714104527568781618875688104415243715506909284770554256616642020503116458540489226220383015748323400356936736149732496461685474945266209347338...
code_stdio
[ { "content": "Write a program which solve a simultaneous equation:\n\nax + by = c\ndx + ey = f\n\nThe program should print x and y for given a, b, c, d, e and f (-1,000 ≀ a, b, c, d, e, f ≀ 1,000). You can suppose that given equation has a unique solution.\n\n\n\nInput\n\nThe input consists of several data sets...
[{"input": "3 -1 -3 1 0 -3\n2 -1 -3 -9 18 27", "output": "-3.000 -6.000\n-1.000 1.000\n"}, {"input": "3 -2 -3 1 0 -3\n2 -1 -3 -9 18 27", "output": "-3.000 -3.000\n-1.000 1.000\n"}, {"input": "3 -1 -3 1 0 -3\n2 -1 -3 -9 13 27", "output": "-3.000 -6.000\n-0.706 1.588\n"}, {"input": "3 -2 -6 1 0 -3\n2 -1 -3 -9 18 27", "ou...
code_stdio
[ { "content": "N people are standing in a queue, numbered 1, 2, 3, ..., N from front to back. Each person wears a hat, which is red, blue, or green.\n\nThe person numbered i says:\n\n* \"In front of me, exactly A_i people are wearing hats with the same color as mine.\"\n\n\n\nAssuming that all these statements a...
[{"input": "54\n0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17", "output": "115295190"}, {"input": "54\n0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 20 13 14 14 15 15 15 16 16 16 17 17 17...
code_stdio
[ { "content": "You are given a string $a$, consisting of $n$ characters, $n$ is even. For each $i$ from $1$ to $n$ $a_i$ is one of 'A', 'B' or 'C'.\n\nA bracket sequence is a string containing only characters \"(\" and \")\". A regular bracket sequence is a bracket sequence that can be transformed into a correct...
[{"input": "28\nAABBAC\nCACA\nBBBBAC\nABCA\nAABBAC\nCACA\nBBBBAC\nABCA\nAABBAC\nCACA\nBBBBAC\nABCA\nAABBAC\nCACA\nBBBBAC\nABCA\nAABBAC\nCACA\nBBBBAC\nABCA\nAABBAC\nCACA\nBBBBAC\nABCA\nAABBAC\nCACA\nAABBAC\nCACA\n", "output": "YES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\nYES\...
code_stdio
[ { "content": "Lee just became Master in Codeforces, and so, he went out to buy some gifts for his friends. He bought $n$ integers, now it's time to distribute them between his friends rationally...\n\nLee has $n$ integers $a_1, a_2, \\ldots, a_n$ in his backpack and he has $k$ friends. Lee would like to distrib...
[{"input": "3\n4 2\n1 13 7 17\n1 3\n6 2\n10 10 10 10 11 11\n3 3\n4 4\n1000000000 1000000000 1000000000 1000000000\n1 1 1 1\n", "output": "48\n42\n8000000000\n"}, {"input": "3\n4 2\n1 13 12 1\n1 3\n6 2\n10 10 10 10 11 11\n3 3\n4 4\n1000000000 1000000000 1000000000 1000000000\n1 1 1 1\n", "output": "39\n42\n8000000000\n"...
code_stdio
[ { "content": "M-kun is a competitor in AtCoder, whose highest rating is X.\nIn this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:\n\n* From 400 through 599: 8-kyu\n* From 600 through 799: 7-kyu\n* From 800 through ...
[{"input": "1359", "output": "4\n"}, {"input": "1855", "output": "1\n"}, {"input": "1485", "output": "3\n"}, {"input": "1125", "output": "5\n"}, {"input": "1764", "output": "2\n"}, {"input": "1596", "output": "3\n"}, {"input": "1543", "output": "3\n"}, {"input": "1815", "output": "1\n"}, {"input": "1307", "output": "4\...
code_stdio
[ { "content": "You are given an array $a$ consisting of $n$ integers. Each $a_i$ is one of the six following numbers: $4, 8, 15, 16, 23, 42$.\n\nYour task is to remove the minimum number of elements to make this array good.\n\nAn array of length $k$ is called good if $k$ is divisible by $6$ and it is possible to...
[{"input": "100\n4 42 23 23 16 42 16 23 42 16 42 8 4 23 4 4 23 42 16 42 23 23 23 42 4 42 8 8 16 23 15 23 16 4 42 15 15 23 16 15 16 4 4 15 23 42 42 15 8 23 8 23 4 15 16 15 42 8 23 16 15 42 23 8 4 16 15 16 23 16 16 4 23 16 8 23 16 15 23 4 4 8 15 4 4 15 8 23 23 4 4 8 8 4 42 15 4 4 42 16\n", "output": "64\n"}, {"input": "1...
code_stdio
[ { "content": "Autocomplete is a program function that enables inputting the text (in editors, command line shells, browsers etc.) completing the text by its inputted part. Vasya is busy working on a new browser called 'BERowser'. He happens to be working on the autocomplete function in the address line at this ...
[{"input": "hzkqvwliymwjbejfpnydrbwskhyrtrlsdinfrgwmnbdpwytcnjeoowxrfgfuaffzayjylvzu\n1\nhzkqvwliymwjbejfpnydrbwskhyrtrlsdinfrgwmnbdpwytcnjeoowxrfgfuaffzayjylvzubwjlvhhsfurqb\n", "output": "hzkqvwliymwjbejfpnydrbwskhyrtrlsdinfrgwmnbdpwytcnjeoowxrfgfuaffzayjylvzubwjlvhhsfurqb\n"}, {"input": "uzvlyjyazffaufgfrxwooejnctyw...
code_stdio
[ { "content": "Manao is trying to open a rather challenging lock. The lock has n buttons on it and to open it, you should press the buttons in a certain order to open the lock. When you push some button, it either stays pressed into the lock (that means that you've guessed correctly and pushed the button that go...
[{"input": "2000\n", "output": "1333335000\n"}, {"input": "1999\n", "output": "1331335999\n"}, {"input": "1837\n", "output": "1033182073\n"}, {"input": "2000\n", "output": "1333335000\n"}, {"input": "1837\n", "output": "1033182073\n"}, {"input": "1999\n", "output": "1331335999\n"}, {"input": "1747\n", "output": "888644...
code_stdio
[ { "content": "Over time, Alexey's mail box got littered with too many letters. Some of them are read, while others are unread.\n\nAlexey's mail program can either show a list of all letters or show the content of a single letter. As soon as the program shows the content of an unread letter, it becomes read lett...
[{"input": "213\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
code_stdio
[ { "content": "The next lecture in a high school requires two topics to be discussed. The $i$-th topic is interesting by $a_i$ units for the teacher and by $b_i$ units for the students.\n\nThe pair of topics $i$ and $j$ ($i < j$) is called good if $a_i + a_j > b_i + b_j$ (i.e. it is more interesting for the teac...
[{"input": "14\n137698508 528184026 54130884 239033739 1038011779 720680829 605286542 89272810 284191042 179359950 186766648 570400677 107541072 25121211\n195343970 709242622 422954170 980941827 265963618 812646456 943660193 344102432 295006337 221455256 203711937 632473368 334173424 49206958\n", "output": "13\n"}, {"i...
code_stdio
[ { "content": "It has been noted that if some ants are put in the junctions of the graphene integer lattice then they will act in the following fashion: every minute at each junction (x, y) containing at least four ants a group of four ants will be formed, and these four ants will scatter to the neighbouring jun...
[{"input": "30000 39\n2650 -1515\n-3169 4818\n-1896 2727\n1323 -2335\n-387 901\n-4299 1481\n-2114 4435\n3654 -2730\n4569 3801\n-3815 -3355\n4777 1749\n4486 -780\n-3936 -158\n717 -3518\n4765 -909\n-3032 3726\n-2970 3346\n2067 -1560\n-521 -1331\n-4953 -2098\n-849 580\n-4941 4018\n1338 -2629\n-1444 -3550\n1502 4995\n1156 ...
code_stdio
[ { "content": "You have a list of numbers from $1$ to $n$ written from left to right on the blackboard.\n\nYou perform an algorithm consisting of several steps (steps are $1$-indexed). On the $i$-th step you wipe the $i$-th number (considering only remaining numbers). You wipe the whole number (not one digit). $...
[{"input": "2\n1000000000 1\n1000000000 500000000\n", "output": "2\n1000000000\n"}, {"input": "2\n1000000000 1\n1000000000 500000000\n", "output": "2\n1000000000\n"}, {"input": "3\n3 1\n4 2\n69 6\n", "output": "2\n4\n12\n"}, {"input": "3\n3 1\n5 2\n69 6\n", "output": "2\n4\n12\n"}, {"input": "3\n3 1\n5 2\n34 6\n", "out...
code_stdio
[ { "content": "ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '$\\sqrt{}$' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1.\n\nWhen ZS the Coder is at...
[{"input": "6723\n", "output": "2\n17\n46\n97\n176\n289\n442\n641\n892\n1201\n1574\n2017\n2536\n3137\n3826\n4609\n5492\n6481\n7582\n8801\n10144\n11617\n13226\n14977\n16876\n18929\n21142\n23521\n26072\n28801\n31714\n34817\n38116\n41617\n45326\n49249\n53392\n57761\n62362\n67201\n72284\n77617\n83206\n89057\n95176\n101569\...
code_stdio
[ { "content": "In the State of Takahashi in AtCoderian Federation, there are N cities, numbered 1, 2, ..., N.\nM bidirectional roads connect these cities.\nThe i-th road connects City A_i and City B_i.\nEvery road connects two distinct cities.\nAlso, for any two cities, there is at most one road that directly co...
[{"input": "10 39\n7 2\n7 1\n5 6\n5 8\n9 10\n2 8\n8 7\n3 10\n10 1\n8 10\n2 3\n7 4\n3 9\n4 10\n3 4\n6 1\n6 7\n9 5\n9 7\n6 9\n9 4\n4 6\n7 5\n8 3\n2 5\n9 2\n10 7\n8 6\n8 9\n7 3\n5 3\n4 5\n6 3\n2 10\n5 10\n4 2\n6 2\n8 4\n10 6\n", "output": "21\n"}, {"input": "10 39\n7 2\n7 1\n5 6\n5 8\n9 10\n2 8\n8 7\n3 10\n10 1\n8 10\n2 3...
code_stdio
[ { "content": "We will call a non-negative integer increasing if, for any two adjacent digits in its decimal representation, the digit to the right is greater than or equal to the digit to the left. For example, 1558, 11, 3 and 0 are all increasing; 10 and 20170312 are not.\n\nSnuke has an integer N. Find the mi...
[{"input": "3704579452095997258280591217784156184311155893966777597430447796450532", "output": "32\n"}, {"input": "4271374355872521214646189206931447259915557225329718337053006899386612", "output": "33\n"}, {"input": "4636365955583185577236629139430025754175155260406833067161877454344706", "output": "37\n"}, {"input": ...
code_stdio
[ { "content": "A: Many Kinds of Apples\n\nProblem Statement\n\nApple Farmer Mon has two kinds of tasks: \"harvest apples\" and \"ship apples\".\n\nThere are N different species of apples, and N distinguishable boxes. Apples are labeled by the species, and boxes are also labeled, from 1 to N. The i-th species of ...
[{"input": "2\n1 0\n0\n-1 -1 1\n-1 1 0\n3 1 3\n-1 1 2", "output": "0\n"}, {"input": "2\n1 0\n0\n-1 -1 1\n-1 1 3\n3 1 3\n0 3 2", "output": "0\n"}, {"input": "2\n1 0\n0\n-1 -1 1\n-1 1 0\n3 1 3\n0 3 2", "output": "0\n"}, {"input": "2\n1 0\n0\n-1 -1 1\n-1 1 0\n2 1 3\n0 3 2", "output": "0\n"}, {"input": "2\n1 -1\n0\n0 -1 1\...
code_stdio
[ { "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": "-100 -100 -100 -99 -99 -99 -99 -100\n-10 -10 -9 -9 -10 -8 -11 -9\n", "output": "NO\n"}, {"input": "-100 -100 -100 100 100 100 100 -100\n-100 0 0 100 100 0 0 -100\n", "output": "YES\n"}, {"input": "-12 -54 -12...
code_stdio
[ { "content": "The following sorting operation is repeated for the stacked blocks as shown in Fig. A.\n\n1. Stack all the bottom blocks (white blocks in Figure a) on the right edge (the remaining blocks will automatically drop one step down, as shown in Figure b).\n2. If there is a gap between the blocks, pack i...
[{"input": "6\n1 4 1 3 2 4\n5\n1 2 5 4 5\n10\n1 1 1 1 1 1 1 1 1 1\n9\n1 1 1 1 1 1 1 1 1\n12\n1 4 1 3 2 4 3 3 2 1 2 2\n1\n5050\n3\n10000 10000 100\n0", "output": "24\n-1\n10\n-1\n48\n5049\n-1\n"}, {"input": "6\n1 4 1 3 2 4\n5\n1 2 5 4 5\n10\n1 1 1 1 1 1 1 1 1 1\n9\n1 1 1 1 1 1 1 1 1\n12\n1 4 1 3 2 4 3 1 2 1 2 2\n1\n5050...
code_stdio
[ { "content": "Translator's note: in Russia's most widespread grading system, there are four grades: 5, 4, 3, 2, the higher the better, roughly corresponding to A, B, C and F respectively in American grading system.\n\nThe term is coming to an end and students start thinking about their grades. Today, a professo...
[{"input": "100\n3 2 4 3 3 3 4 2 3 5 5 2 5 2 3 2 4 4 4 5 5 4 2 5 4 3 2 5 3 4 3 4 2 4 5 4 2 4 3 4 5 2 5 3 3 4 2 2 4 4 4 5 4 3 3 3 2 5 2 2 2 3 5 4 3 2 4 5 5 5 2 2 4 2 3 3 3 5 3 2 2 4 5 5 4 5 5 4 2 3 2 2 2 2 5 3 5 2 3 4\n", "output": "40\n"}, {"input": "100\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...
code_stdio
[ { "content": "Compute A \\times B.\n\n-----Constraints-----\n - 1 \\leq A \\leq 100\n - 1 \\leq B \\leq 100\n - All values in input are integers.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nA B\n\n-----Output-----\nPrint the value A \\times B as an integer.\n\n-----Sample In...
[{"input": "100 100\n", "output": "10000\n"}, {"input": "101 110", "output": "11110\n"}, {"input": "101 111", "output": "11211\n"}, {"input": "101 101", "output": "10201\n"}, {"input": "100 110", "output": "11000\n"}, {"input": "100 111", "output": "11100\n"}, {"input": "100 101", "output": "10100\n"}, {"input": "111 1...
code_stdio
[ { "content": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of t...
[{"input": "VVKKVKKVVKKVKKVKVVKKVKKVVKKVKVVKKVKKVKVVKKVVKKVKVVKKVKVVKKVVKVVKKVKKVKKVKKVKKVKVVKKVKKVKKVKKVKKVVKVK\n", "output": "32\n"}, {"input": "VVVVVKKVKVKVKVVKVVKKVVKVKKKKKKKVKKKVVVVVVKKVVVKVKVVKVKKVVKVVVKKKKKVVVVVKVVVVKVVVKKVKKVKKKVKKVKKVVKKV\n", "output": "25\n"}, {"input": "KKVVKKVVVKKVKKVKKVVVKVVVKKVKKVVVKKVVVK...
code_stdio
[ { "content": "Vasya has an array a consisting of positive integer numbers. Vasya wants to divide this array into two non-empty consecutive parts (the prefix and the suffix) so that the sum of all elements in the first part equals to the sum of elements in the second part. It is not always possible, so Vasya wil...
[{"input": "100\n27 95 57 29 91 85 83 36 72 86 39 5 79 61 78 93 100 97 73 23 82 66 41 92 38 92 100 96 48 23 66 47 5 32 69 13 95 23 46 62 99 83 57 66 98 82 81 57 37 37 81 64 45 76 72 43 99 76 86 22 37 39 93 80 99 36 53 83 3 32 52 9 78 34 47 100 33 72 19 40 29 56 77 32 79 72 15 88 100 98 56 50 22 81 88 92 58 70 21 19\n",...
code_stdio
[ { "content": "Vasya thinks that lucky tickets are the tickets whose numbers are divisible by 3. He gathered quite a large collection of such tickets but one day his younger brother Leonid was having a sulk and decided to destroy the collection. First he tore every ticket exactly in two, but he didn’t think it w...
[{"input": "10\n146767769 71795210 50866429 35232438 22664883 56785812 91050433 75677099 84393937 43832346\n", "output": "5\n"}, {"input": "10\n146767769 71795210 50866429 35232438 22664883 56785812 91050433 75677099 18053121 43832346\n", "output": "4\n"}, {"input": "10\n146767769 71795210 50866429 35232438 22664883 56...
code_stdio
[ { "content": "An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10.\nGiven an integer N, determine whether it is a Harshad number.\n\n-----Constraints-----\n - 1?N?10^8\n - N is an integer.\n\n-----Input-----\nInput is given from Sta...
[{"input": "12\n", "output": "Yes\n"}, {"input": "148\n", "output": "No\n"}, {"input": "112", "output": "Yes\n"}, {"input": "224", "output": "Yes\n"}, {"input": "133", "output": "Yes\n"}, {"input": "162", "output": "Yes\n"}, {"input": "190", "output": "Yes\n"}, {"input": "171", "output": "Yes\n"}, {"input": "375", "out...
code_stdio
[ { "content": "Kevin and Nicky Sun have invented a new game called Lieges of Legendre. In this game, two players take turns modifying the game state with Kevin moving first. Initially, the game is set up so that there are n piles of cows, with the i-th pile containing ai cows. During each player's turn, that pla...
[{"input": "10 2\n3 10 10 8 6 10 9 9 5 7\n", "output": "Kevin\n"}, {"input": "10 2\n3 10 10 7 6 10 9 9 5 7\n", "output": "Nicky\n"}, {"input": "10 2\n3 10 10 7 6 10 9 9 1 7\n", "output": "Kevin\n"}, {"input": "10 1\n5 6 3 10 6 6 1 1 5 3\n", "output": "Kevin\n"}, {"input": "2 3\n1000000000 1000000000\n", "output": "Nick...
code_stdio
[ { "content": "Quickly after finishing the tutorial of the online game ATChat, you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the friendliness of Player i is A_i.\nThe N players will arrive at the place one by on...
[{"input": "7\n-1 100 -2 1 -1 -1 18", "output": "137\n"}, {"input": "7\n-1 111 -2 2 -1 -16 3", "output": "120\n"}, {"input": "7\n-1 111 -2 2 -1 -24 4", "output": "122\n"}, {"input": "7\n-1 111 -2 2 -2 -16 6", "output": "126\n"}, {"input": "7\n0 101 -2 4 -1 -16 10", "output": "129\n"}, {"input": "7\n0 100 -2 4 -1 -27 10...
code_stdio
[ { "content": "For his computer science class, Jacob builds a model tree with sticks and balls containing n nodes in the shape of a tree. Jacob has spent a_{i} minutes building the i-th ball in the tree.\n\nJacob's teacher will evaluate his model and grade Jacob based on the effort he has put in. However, she do...
[{"input": "10 10\n794273 814140 758469 932911 607860 683826 1479233 652494 952171 698608\n1 3\n3 8\n2 7\n2 1\n2 9\n3 10\n6 4\n9 6\n3 5\n", "output": "607860\n"}, {"input": "10 10\n794273 594029 758469 932911 607860 683826 1479233 652494 952171 698608\n1 3\n3 8\n2 7\n2 1\n2 9\n3 10\n6 4\n9 6\n3 5\n", "output": "594029\...
code_stdio
[ { "content": "An army of n droids is lined up in one row. Each droid is described by m integers a_1, a_2, ..., a_{m}, where a_{i} is the number of details of the i-th type in this droid's mechanism. R2-D2 wants to destroy the sequence of consecutive droids of maximum length. He has m weapons, the i-th weapon ca...
[{"input": "49 2 1971\n794 866\n401 575\n341 83\n103 208\n352 134\n260 878\n497 931\n630 570\n885 464\n23 663\n60 1461\n416 870\n955 405\n392 961\n530 258\n73 404\n736 923\n44 436\n594 314\n904 138\n980 163\n76 720\n879 809\n81 838\n263 599\n218 139\n659 493\n1044 754\n679 302\n490 7\n204 530\n184 758\n114 849\n113 649...
code_stdio
[ { "content": "Luba has a ticket consisting of 6 digits. In one move she can choose digit in any position and replace it with arbitrary digit. She wants to know the minimum number of digits she needs to replace in order to make the ticket lucky.\n\nThe ticket is considered lucky if the sum of first three digits ...
[{"input": "000000\n", "output": "0\n"}, {"input": "123456\n", "output": "2\n"}, {"input": "111000\n", "output": "1\n"}, {"input": "120111\n", "output": "0\n"}, {"input": "999999\n", "output": "0\n"}, {"input": "199880\n", "output": "1\n"}, {"input": "899889\n", "output": "1\n"}, {"input": "899888\n", "output": "1\n"},...
code_stdio
[ { "content": "There is a game called Packet Monster. A game that catches, raises, fights and exchanges monsters, and is very popular all over Japan. Of course, in my class. That's why I also raise monsters so that I can play with everyone in this game, but sadly there is no opponent to play against. I'm not the...
[{"input": "10\n4 17 1 9 5 18 2 3 2 1\n8 12 6 5 10 5 4 4 7 6\n5\n4 3 2 1 1\n2 4 4 4 4\n4\n1 1 3 2\n5 3 2 1\n0", "output": "1\nNA\nNA\n"}, {"input": "10\n4 17 1 9 5 18 2 3 2 1\n8 12 6 5 10 5 4 4 7 6\n5\n4 3 2 1 1\n2 4 4 4 4\n4\n2 1 3 2\n5 3 2 1\n0", "output": "1\nNA\nNA\n"}, {"input": "10\n4 17 1 9 5 18 2 3 2 1\n8 12 6 ...
code_stdio
[ { "content": "The Zoo in the Grid Kingdom is represented by an infinite grid. The Zoo has n observation binoculars located at the OX axis. For each i between 1 and n, inclusive, there exists a single binocular located at the point with coordinates (i, 0). There are m flamingos in the Zoo, located at points with...
[{"input": "3 10\n1000000000 1000000000\n1000000000 999999999\n1000000000 999999998\n1000010000 1199925182\n1000000000 999999996\n1000000000 999999995\n1000000000 999999994\n1000000000 999999993\n1000000000 999999992\n1000000000 999999991\n", "output": "3\n"}, {"input": "3 10\n1000000000 1000000000\n1000000000 99999999...
code_stdio
[ { "content": "New Year is coming! Vasya has prepared a New Year's verse and wants to recite it in front of Santa Claus.\n\nVasya's verse contains $n$ parts. It takes $a_i$ seconds to recite the $i$-th part. Vasya can't change the order of parts in the verse: firstly he recites the part which takes $a_1$ seconds...
[{"input": "1\n50 1\n2 1 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 10000...
code_stdio
[ { "content": "After Vitaly was expelled from the university, he became interested in the graph theory.\n\nVitaly especially liked the cycles of an odd length in which each vertex occurs at most once.\n\nVitaly was wondering how to solve the following problem. You are given an undirected graph consisting of n ve...
[{"input": "5 5\n1 2\n2 3\n3 4\n4 5\n5 1\n", "output": "0 1\n"}, {"input": "6 5\n1 2\n2 3\n3 4\n4 5\n5 1\n", "output": "0 1\n"}, {"input": "9 5\n1 2\n2 3\n3 4\n4 5\n5 1\n", "output": "0 1\n"}, {"input": "100000 0\n", "output": "3 166661666700000\n"}, {"input": "59139 1\n10301 5892\n", "output": "2 59137\n"}, {"input": ...
code_stdio
[ { "content": "You are given a simple connected undirected graph consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M.\n\nEdge i connects Vertex a_i and b_i bidirectionally.\n\nDetermine if three circuits (see Notes) can be formed using each of the edges exact...
[{"input": "18 27\n17 9\n12 15\n18 17\n13 18\n13 1\n5 7\n12 1\n14 5\n15 11\n14 6\n1 9\n5 1\n18 16\n4 6\n7 2\n7 11\n6 3\n12 14\n5 3\n10 5\n5 8\n10 15\n3 15\n9 8\n7 15\n2 16\n18 15", "output": "No\n"}, {"input": "18 15\n17 9\n12 15\n18 17\n13 18\n13 1\n5 7\n12 1\n14 5\n15 11\n14 6\n1 9\n5 1\n18 16\n4 6\n7 2\n7 11\n6 3\n1...
code_stdio
[ { "content": "A long time ago in some far country lived king Copa. After the recent king's reform, he got so large powers that started to keep the books by himself.\n\nThe total income A of his kingdom during 0-th year is known, as well as the total income B during n-th year (these numbers can be negative β€” it ...
[{"input": "-1 -512 10\n", "output": "No solution\n"}, {"input": "-3 -768 13\n", "output": "No solution\n"}, {"input": "-173 373 3\n", "output": "No solution\n"}, {"input": "-521 526 1\n", "output": "No solution\n"}, {"input": "-1 -512 19\n", "output": "No solution\n"}, {"input": "-2 -768 13\n", "output": "No solution\...
code_stdio
[ { "content": "You're given a row with $n$ chairs. We call a seating of people \"maximal\" if the two following conditions hold: There are no neighbors adjacent to anyone seated. It's impossible to seat one more person without violating the first rule. \n\nThe seating is given as a string consisting of zeros a...
[{"input": "459\n000111000101010000100001001010111110011011010001100101111010111011101110111101111101100101100011011001100110001001111001101000111001011100110100011111011111000010000110010011100110011011111110011100001101001111000100111011001000001011111100110100001001001100101011100001110110100101011011110100100111101...
code_stdio
[ { "content": "Xenia the vigorous detective faced n (n β‰₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right. \n\nSpy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the impo...
[{"input": "100000 1 11500 86289\n1 86 75626\n", "output": "XRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...
code_stdio
[ { "content": "Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks: Each time Toastman gets a group of numbers, he sums up all the numbers and adds this sum to the score. Then he gives the group to the Appleman. Eac...
[{"input": "10\n1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000\n", "output": "64000000\n"}, {"input": "10\n1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000\n", "output": "64000000\n"}, {"input": "10\n1000000 1000000 1000000 1000000 1000000 1000000 1000000 ...
code_stdio
[ { "content": "In Aizu prefecture, we decided to create a new town to increase the population. To that end, we decided to cultivate a new rectangular land and divide this land into squares of the same size. The cost of developing this land is proportional to the number of plots, but the prefecture wants to minim...
[{"input": "10 29 10", "output": "2900\n"}, {"input": "10 29 13", "output": "3770\n"}, {"input": "4 -1 104", "output": "-416\n"}, {"input": "20 -1 18", "output": "-360\n"}, {"input": "12 -1 14", "output": "-168\n"}, {"input": "3 -1 43", "output": "-129\n"}, {"input": "10 29 5", "output": "1450\n"}, {"input": "10 7 16",...
code_stdio
[ { "content": "Anfisa the monkey learns to type. She is yet unfamiliar with the \"space\" key and can only type in lower-case Latin letters. Having typed for a fairly long line, Anfisa understood that it would be great to divide what she has written into k lines not shorter than a and not longer than b, for the ...
[{"input": "200 1 200\nlycjpjrpkgxrkfvutlcwglghxadttpihmlpphwfttegfpimjxintjdxgqfhzrmxfcfojnxruhyfynlzgpxjeobjyxarsfxaqeogxfzvdlwsimupkwujudtfenryulzvsiazneyibqtweeuxpzrbumqqswjasliyjnnzfzuvthhzcsgfljikkajqkpjftztrzpjneaxqg\n", "output": "l\ny\nc\nj\np\nj\nr\np\nk\ng\nx\nr\nk\nf\nv\nu\nt\nl\nc\nw\ng\nl\ng\nh\nx\na\nd\n...
code_stdio
[ { "content": "The famous global economic crisis is approaching rapidly, so the states of Berman, Berance and Bertaly formed an alliance and allowed the residents of all member states to freely pass through the territory of any of them. In addition, it was decided that a road between the states should be built t...
[{"input": "10 10\n##.#..#.#2\n...###....\n#..#....##\n.....#....\n.#........\n.....#####\n...#..#...\n....###...\n###.##...#\n.#...1#.3.\n", "output": "-1\n"}, {"input": "10 10\n#...33.#.#\n#.#.33.#1.\n2.....#.11\n222#.#.#..\n####...#.#\n#.........\n.#....#...\n..#..#.##.\n##.....#.#\n#..#....#.\n", "output": "12\n"},...
code_stdio
[ { "content": "Problem statement\n\nA $ 2 $ human-player match-up game tournament is about to take place in front of Kyoto University Camphor Tree.\n\nThere are $ 2 ^ N $ participants in this tournament, numbered from $ 1 $ to $ 2 ^ N $.\n\nWinning or losing when $ 2 $ of participants fight is represented by the...
[{"input": "2\n010\n-2 1 1 -1", "output": "-2\n-2\n-2\n-2\n"}, {"input": "2\n001\n-2 1 0 -1", "output": "-1\n-2\n-1\n-2\n"}, {"input": "2\n100\n-2 1 0 -1", "output": "-2\n-1\n-2\n-1\n"}, {"input": "2\n001\n-1 1 0 0", "output": "-1\n-1\n-1\n-1\n"}, {"input": "2\n010\n-2 1 0 -1", "output": "-2\n0\n-2\n0\n"}, {"input": "2...
code_stdio