messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 1
value |
|---|---|---|
[
{
"content": "You are given an array a of length n. We define f_{a} the following way:\n\n Initially f_{a} = 0, M = 1; for every 2 ≤ i ≤ n if a_{M} < a_{i} then we set f_{a} = f_{a} + a_{M} and then set M = i. \n\nCalculate the sum of f_{a} over all n! permutations of the array a modulo 10^9 + 7.\n\nNote: two... | [{"input": "9\n347223417 807654168 573530036 826123287 366028010 257025851 15406743 784063803 132844347\n", "output": "932879531\n"}, {"input": "9\n347223417 807654168 573530036 826123287 366028010 257025851 15406743 784063803 138878790\n", "output": "655212093\n"}, {"input": "9\n347223417 807654168 573530036 826123287... | code_stdio |
[
{
"content": "A line on the plane is described by an equation Ax + By + C = 0. You are to find any point on this line, whose coordinates are integer numbers from - 5·1018 to 5·1018 inclusive, or to find out that such points do not exist.\n\nInput\n\nThe first line contains three integers A, B and C ( - 2·109 ≤... | [{"input": "-1548994394 -1586527767 -1203252104\n", "output": "-878123061596147680 857348814150663048\n"}, {"input": "1999999993 1999999991 -1999999997\n", "output": "-1999999987000000015 1999999989000000012\n"}, {"input": "-1516373701 -584304312 -746376800\n", "output": "202167007852295200 -524659372900676000\n"}, {"i... | code_stdio |
[
{
"content": "You are given three integers k, p_{a} and p_{b}.\n\nYou will construct a sequence with the following algorithm: Initially, start with the empty sequence. Each second, you do the following. With probability p_{a} / (p_{a} + p_{b}), add 'a' to the end of the sequence. Otherwise (with probability p_{... | [{"input": "1000 123456 654321\n", "output": "977760856\n"}, {"input": "1000 123456 654321\n", "output": "977760856\n"}, {"input": "305 337309 378395\n", "output": "174667130\n"}, {"input": "108 531040 908573\n", "output": "145579983\n"}, {"input": "781 817338 452871\n", "output": "711597307\n"}, {"input": "270 967166 ... | code_stdio |
[
{
"content": "In an embassy of a well-known kingdom an electronic queue is organised. Every person who comes to the embassy, needs to make the following three actions: show the ID, pay money to the cashier and be fingerprinted. Besides, the actions should be performed in the given order.\n\nFor each action seve... | [{"input": "2 7 1\n10 3 10\n100\n3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100... | code_stdio |
[
{
"content": "A holiday weekend is coming up,\nand Hotel Bytelandia needs to find out if it has enough rooms to accommodate all potential guests.\nA number of guests have made reservations.\nEach reservation consists of an arrival time, and a departure time.\nThe hotel management has hired you to calculate the ... | [{"input": "3\n3\n1 2 3\n4 5 7\n5\n1 2 3 4 1\n2 4 4 5 6\n7\n13 6 5 8 2 10 12\n19 18 6 16 9 11 15", "output": "3\n3\n4\n"}, {"input": "3\n3\n1 2 3\n4 5 7\n5\n1 2 3 4 1\n2 4 4 5 6\n7\n13 6 5 8 1 10 12\n19 18 6 16 9 11 15", "output": "3\n3\n4\n"}, {"input": "3\n3\n1 2 3\n4 5 7\n5\n1 2 3 4 1\n3 4 4 5 6\n7\n13 6 5 8 1 10 12... | code_stdio |
[
{
"content": "The Holmes children are fighting over who amongst them is the cleverest.\n\nMycroft asked Sherlock and Eurus to find value of f(n), where f(1) = 1 and for n ≥ 2, f(n) is the number of distinct ordered positive integer pairs (x, y) that satisfy x + y = n and gcd(x, y) = 1. The integer gcd(a, b) is ... | [{"input": "1000000000000 1000000000000\n", "output": "1"}, {"input": "1000000000000 1000000000000\n", "output": "1"}, {"input": "331725641503 465583326659\n", "output": "1\n"}, {"input": "594243639083 188040404706\n", "output": "1\n"}, {"input": "892726102335 265691489675\n", "output": "1\n"}, {"input": "483154390901 ... | code_stdio |
[
{
"content": "Recently Lynyrd and Skynyrd went to a shop where Lynyrd bought a permutation $p$ of length $n$, and Skynyrd bought an array $a$ of length $m$, consisting of integers from $1$ to $n$. \n\nLynyrd and Skynyrd became bored, so they asked you $q$ queries, each of which has the following form: \"does th... | [{"input": "3 6 3\n2 1 3\n1 2 3 1 2 3\n1 5\n2 6\n3 5\n", "output": "110\n"}, {"input": "3 6 3\n2 1 3\n1 1 3 1 2 3\n1 5\n2 6\n3 5\n", "output": "110\n"}, {"input": "3 6 3\n2 1 3\n1 2 3 1 2 3\n1 5\n3 6\n3 5\n", "output": "100\n"}, {"input": "3 6 3\n2 1 3\n1 1 3 1 3 3\n1 5\n2 6\n3 5\n", "output": "000\n"}, {"input": "3 6 ... | code_stdio |
[
{
"content": "Heidi and Doctor Who hopped out of the TARDIS and found themselves at EPFL in 2018. They were surrounded by stormtroopers and Darth Vader was approaching. Miraculously, they managed to escape to a nearby rebel base but the Doctor was very confused. Heidi reminded him that last year's HC2 theme was... | [{"input": "1 2\n1156621358\n561572949 6885\n312543334 3629\n", "output": "10514\n"}, {"input": "1 2\n458828651\n209599643 7592\n208642144 8751\n", "output": "16343\n"}, {"input": "1 2\n754725914\n561572949 6885\n312543334 3629\n", "output": "10514\n"}, {"input": "1 2\n458828651\n209599643 7611\n208642144 8751\n", "out... | code_stdio |
[
{
"content": "Write a program which judges wheather given length of three side form a right triangle. Print \"YES\" if the given sides (integers) form a right triangle, \"NO\" if not so.\n\nConstraints\n\n* 1 ≤ length of the side ≤ 1,000\n* N ≤ 1,000\n\nInput\n\nInput consists of several data sets. In the first... | [{"input": "3\n-1 -2 0\n0 1 -1\n-2 0 2", "output": "NO\nYES\nYES\n"}, {"input": "3\n-1 -2 -1\n0 1 0\n-2 0 2", "output": "NO\nNO\nYES\n"}, {"input": "3\n1 1 0\n29 1 -1\n0 1 -1", "output": "YES\nNO\nYES\n"}, {"input": "3\n2 2 -2\n-1 5 -1\n3 15 -1", "output": "NO\nNO\nNO\n"}, {"input": "3\n2 2 -2\n-1 5 -1\n3 11 -1", "outp... | code_stdio |
[
{
"content": "Let's call a positive integer extremely round if it has only one non-zero digit. For example, $5000$, $4$, $1$, $10$, $200$ are extremely round integers; $42$, $13$, $666$, $77$, $101$ are not.\n\nYou are given an integer $n$. You have to calculate the number of extremely round integers $x$ such t... | [{"input": "5\n9\n42\n13\n100\n111\n", "output": "9\n13\n10\n19\n19\n"}, {"input": "1\n707951\n", "output": "52\n"}, {"input": "1\n99889\n", "output": "45\n"}, {"input": "1\n9123\n", "output": "36\n"}, {"input": "1\n9999\n", "output": "36\n"}, {"input": "1\n9998\n", "output": "36\n"}, {"input": "1\n9997\n", "output": "... | code_stdio |
[
{
"content": "Seen from above, there is a grid-like square shaped like Figure 1. The presence or absence of \"walls\" on each side of this grid is represented by a sequence of 0s and 1s. Create a program that stands at point A, puts your right hand on the wall, keeps walking in the direction of the arrow, and o... | [{"input": "1111\n00001\n0110\n11111\n1010\n00011\n1010\n01011\n1111", "output": "RRRRDDDDLLLLRULRDRRULRULULDLUDRURRDDDRUUUULLLL\n"}, {"input": "1111\n01001\n0010\n11101\n1110\n00111\n1110\n10001\n1110", "output": "RRRRDDDDUUUULLLDDRURLDRDLLLDRRRLLLURRULLUDRUUL\n"}, {"input": "1111\n00010\n1001\n10110\n1111\n00100\n011... | code_stdio |
[
{
"content": "Two children are playing tag on a number line. (In the game of tag, the child called \"it\" tries to catch the other child.) The child who is \"it\" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W ... | [{"input": "11 -1\n-1 -1\n9", "output": "NO\n"}, {"input": "14 -1\n-1 -1\n9", "output": "NO\n"}, {"input": "2 -1\n-1 -2\n5", "output": "YES\n"}, {"input": "3 -1\n-1 -2\n5", "output": "YES\n"}, {"input": "3 -1\n-2 -2\n5", "output": "YES\n"}, {"input": "1 1\n-1 12\n19", "output": "NO\n"}, {"input": "1 0\n-1 12\n19", "out... | code_stdio |
[
{
"content": "After a long party Petya decided to return home, but he turned out to be at the opposite end of the town from his home. There are $n$ crossroads in the line in the town, and there is either the bus or the tram station at each crossroad.\n\nThe crossroads are represented as a string $s$ of length $... | [{"input": "5\n3 1 1\nBC\n1 0 0\nAB\n4 1 11\nAABBBBAABB\n1 3 1\nBBBBB\n6 1 1\nABABAB\n", "output": "1\n2\n1\n5\n6\n"}, {"input": "5\n2 1 1\nBB\n1 1 1\nAB\n3 2 0\nAABBBBAABB\n5 3 4\nBBBBB\n2 1 1\nABABAB\n", "output": "1\n1\n10\n1\n6\n"}, {"input": "5\n3 1 1\nBC\n1 0 1\nAB\n4 1 11\nAABBBBAABB\n1 3 1\nBBBBB\n6 1 1\nABABAB... | code_stdio |
[
{
"content": "Highway 201 is the most busy street in Rockport. Traffic cars cause a lot of hindrances to races, especially when there are a lot of them. The track which passes through this highway can be divided into $n$ sub-tracks. You are given an array $a$ where $a_i$ represents the number of traffic cars in... | [{"input": "3\n3\n1 2 3\n4\n0 1 1 0\n10\n10 3 1 11 5 2 1 7 19 4\n", "output": "0\n4\n21\n"}, {"input": "3\n3\n1 2 3\n4\n0 1 1 0\n10\n10 3 1 11 5 2 1 7 10 4\n", "output": "0\n4\n24\n"}, {"input": "3\n3\n1 1 3\n4\n1 1 1 0\n10\n16 3 6 11 0 2 1 3 10 4\n", "output": "2\n3\n24\n"}, {"input": "3\n3\n1 1 3\n4\n1 1 1 0\n10\n16 ... | code_stdio |
[
{
"content": "Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nPetya has two strings a and b of the same length n. The strings consist on... | [{"input": "44447774444474477747774774477777474774744744477444447777477477744747477774744444744777777777747777477447744774744444747477744744\n77777474477477747774777777474474477444474777477747747777477747747744474474747774747747444777474444744744444477477777747744747477\n", "output": "37\n"}, {"input": "774774747744474... | code_stdio |
[
{
"content": "Create a program that inputs the test result data of the visual acuity test and outputs the number of people who apply to each judgment based on the following visual acuity judgment table for each of the left and right eyesight.\n\nJudgment | Sight\n--- | ---\nA | 1.1 or above\nB | 0.6 or more and... | [{"input": "1.4450818768746183 1.8412288178078728\n2.6983178051647414 1.5471720124202895\n2.573217216239934 0.8500864926517523\n4.9346769267643475 2.1903643288076555", "output": "4 3\n0 1\n0 0\n0 0\n"}, {"input": "1.4450818768746183 2.8044369815893004\n2.6983178051647414 1.5471720124202895\n2.573217216239934 0.85008649... | code_stdio |
[
{
"content": "The Little Elephant loves numbers. \n\nHe has a positive integer x. The Little Elephant wants to find the number of positive integers d, such that d is the divisor of x, and x and d have at least one common (the same) digit in their decimal representations. \n\nHelp the Little Elephant to find the... | [{"input": "1010000000\n", "output": "117\n"}, {"input": "1011000000\n", "output": "171\n"}, {"input": "654885000\n", "output": "698\n"}, {"input": "1000000000\n", "output": "91\n"}, {"input": "101871000\n", "output": "460\n"}, {"input": "211768200\n", "output": "244\n"}, {"input": "901800900\n", "output": "639\n"}, {"... | code_stdio |
[
{
"content": "Recently, you found a bot to play \"Rock paper scissors\" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \\dots s_{n}$ of length $n$ where each letter is either R, S or P.\n\nWhile initializing, the bot is choosing a starting index $pos$ ($1 \\le p... | [{"input": "3\nRRRR\nRSP\nS\n", "output": "PPPP\nPPP\nR\n"}, {"input": "3\nRRRR\nRSP\nS\n", "output": "PPPP\nPPP\nR\n"}, {"input": "3\nRRRR\nSSP\nS\n", "output": "PPPP\nRRR\nR\n"}, {"input": "3\nQRRR\nRSP\nS\n", "output": "PPPP\nPPP\nR\n"}, {"input": "3\nRRRR\nSSP\nR\n", "output": "PPPP\nRRR\nP\n"}, {"input": "3\nQRRR\... | code_stdio |
[
{
"content": "You are given an array consisting of $n$ integers $a_1, a_2, \\dots, a_n$, and a positive integer $m$. It is guaranteed that $m$ is a divisor of $n$.\n\nIn a single move, you can choose any position $i$ between $1$ and $n$ and increase $a_i$ by $1$.\n\nLet's calculate $c_r$ ($0 \\le r \\le m-1)$ —... | [{"input": "100 25\n6745 2075 7499 7517 1776 5164 2335 2745 4465 1457 7565 2232 2486 9025 8059 9646 8017 7662 9690 3352 2306 366 7422 1073 7169 8966 4506 8225 5614 8628 2908 7452 9625 9332 7097 353 1043 8118 5794 4486 626 971 6731 6618 887 6354 4814 7307 7681 6160 9351 2579 411 3436 5570 2812 2726 4433 3220 577 5891 38... | code_stdio |
[
{
"content": "Recently in Divanovo, a huge river locks system was built. There are now $n$ locks, the $i$-th of them has the volume of $v_i$ liters, so that it can contain any amount of water between $0$ and $v_i$ liters. Each lock has a pipe attached to it. When the pipe is open, $1$ liter of water enters the ... | [{"input": "50\n3 60 52 60 60 84 63 40 50 21 39 59 40 15 59 54 5 84 63 23 11 69 27 65 64 8 39 4 89 19 10 45 51 66 69 60 82 25 82 66 86 35 24 64 43 67 35 25 39 82\n50\n57\n46\n44\n70\n74\n98\n36\n48\n76\n52\n86\n40\n28\n56\n73\n64\n78\n21\n37\n54\n33\n93\n16\n18\n66\n75\n62\n77\n81\n96\n31\n41\n68\n24\n80\n67\n50\n72\n9... | code_stdio |
[
{
"content": "There are N monsters, numbered 1, 2, ..., N.\nInitially, the health of Monster i is A_i.\nBelow, a monster with at least 1 health is called alive.\nUntil there is only one alive monster, the following is repeated:\n - A random alive monster attacks another random alive monster.\n - As a result, th... | [{"input": "3\n1000000000 1000000000 1000000000\n", "output": "1000000000\n"}, {"input": "3\n1000000000 1000000000 1000000000", "output": "1000000000"}, {"input": "3\n1000000100 1000000000 1000000000", "output": "100\n"}, {"input": "3\n1000000100 1000100000 1000000000", "output": "100\n"}, {"input": "3\n1100000100 0100... | code_stdio |
[
{
"content": "Pak Chanek plans to build a garage. He wants the garage to consist of a square and a right triangle that are arranged like the following illustration.\n\nDefine $a$ and $b$ as the lengths of two of the sides in the right triangle as shown in the illustration. An integer $x$ is suitable if and only... | [{"input": "1000000000\n", "output": "1333333336\n"}, {"input": "999999999\n", "output": "1333333335\n"}, {"input": "999999998\n", "output": "1333333333\n"}, {"input": "999999997\n", "output": "1333333332\n"}, {"input": "767928734\n", "output": "1023904981\n"}, {"input": "999993999\n", "output": "1333325335\n"}, {"inpu... | code_stdio |
[
{
"content": "problem\n\nThere are $ N $ islands numbered from $ 1 $ to $ N $.\nEach island has $ N-1 $ bridges, allowing any $ 2 $ island to move to each other across several bridges.\nEach bridge has durability, and the durability of the $ i $ th bridge given the input is $ w_i $.\nThere are $ 1 $ treasures o... | [{"input": "4 10 1 4\n1 2 45\n2 3 68\n3 4 121", "output": "Yes\n"}, {"input": "4 10 1 4\n1 2 52\n1 3 134\n3 4 17", "output": "Yes\n"}, {"input": "4 10 1 4\n1 2 45\n2 3 68\n3 4 113", "output": "Yes\n"}, {"input": "4 16 1 4\n1 2 45\n2 3 68\n3 4 121", "output": "Yes\n"}, {"input": "4 10 1 4\n1 2 20\n2 3 68\n3 4 113", "out... | code_stdio |
[
{
"content": "Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit n should be located in the centre. The digits should decrease as they approach the edges. For exampl... | [{"input": "9\n", "output": " 0\n 0 1 0\n 0 1 2 1 0\n 0 1 2 3 2 1 0\n 0 1 2 3 4 3 2 1 0\n 0 1 2 3 4 5 4 3 2 1 0\n 0 1 2 3 4 5 6 5 4 3 2 1 0\n 0 1 2 3 4 5 6 7 6 5 4 3 2 1 0\n 0 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 0\n0 1 2 3 4 5 6 7 8 9 8 7 6 5 4 ... | code_stdio |
[
{
"content": "The Super Duper Secret Meeting of the Super Duper Secret Military Squad takes place in a Super Duper Secret Place. The place is an infinite plane with introduced Cartesian coordinate system. The meeting table is represented as a rectangle whose sides are parallel to the coordinate axes and whose v... | [{"input": "-565 -444 -419 -421\n30\n363 -249 790\n704 57 999\n-316 -305 119\n-778 -543 373\n-589 466 190\n516 -174 893\n-742 -662 390\n-382 825 1000\n520 -732 909\n-220 -985 555\n-49 -697 396\n-701 -882 520\n-105 227 691\n-113 -470 231\n-503 98 1088\n236 69 759\n150 393 951\n414 381 1000\n1096 3 999\n-357 485 905\n432... | code_stdio |
[
{
"content": "You have m = n·k wooden staves. The i-th stave has length a_{i}. You have to assemble n barrels consisting of k staves each, you can use any k staves to construct a barrel. Each stave must belong to exactly one barrel.\n\nLet volume v_{j} of barrel j be equal to the length of the minimal stave in ... | [{"input": "10 3 726\n277 706 1241 812 692 1291 196 507 911 111 498 704 573 381 463 1095 704 36 443 640 326 405 47 834 962 521 1296 740 520 622\n", "output": "5072\n"}, {"input": "10 3 726\n277 706 1241 812 692 1291 196 507 911 111 498 704 573 381 463 1095 704 36 693 640 326 405 47 834 962 521 1296 740 520 622\n", "out... | code_stdio |
[
{
"content": "People in the Tomskaya region like magic formulas very much. You can see some of them below.\n\nImagine you are given a sequence of positive integer numbers p_1, p_2, ..., p_{n}. Lets write down some magic formulas:$q_{i} = p_{i} \\oplus(i \\operatorname{mod} 1) \\oplus(i \\operatorname{mod} 2) \\... | [{"input": "25\n39226529 640445129 936289624 364461191 1096077769 573427707 1919403410 950067229 1217479531 455229458 1574949468 397268319 1267289585 995220637 1920919164 501015483 1815262670 1197059269 86947741 1137410885 667368575 733666398 1536581408 611239452 947487746\n", "output": "259654661\n"}, {"input": "25\n3... | code_stdio |
[
{
"content": "You are given two very long integers a, b (leading zeroes are allowed). You should check what number a or b is greater or determine that they are equal.\n\nThe input size is very large so don't use the reading of symbols one by one. Instead of that use the reading of a whole line or token.\n\nAs i... | [{"input": "00011111111111111111111111111111111111000000000000000000000000000000000000000000000000000210000000000000000000000000000000000000000011000\n11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112091\n", "output": "<\n"}, {"input": "0... | code_stdio |
[
{
"content": "Today, Wet Shark is given n bishops on a 1000 by 1000 grid. Both rows and columns of the grid are numbered from 1 to 1000. Rows are numbered from top to bottom, while columns are numbered from left to right.\n\nWet Shark thinks that two bishops attack each other if they share the same diagonal. No... | [{"input": "10\n646 171\n816 449\n375 934\n950 299\n702 232\n657 81\n885 306\n660 304\n369 371\n798 657\n", "output": "0\n"}, {"input": "10\n646 171\n816 449\n375 934\n950 299\n702 232\n657 81\n885 306\n660 304\n369 371\n798 657\n", "output": "0\n"}, {"input": "10\n646 171\n816 449\n375 934\n950 299\n702 232\n657 81\n8... | code_stdio |
[
{
"content": "Vasya has recently found out what a digital root of a number is and he decided to share his knowledge with you.\n\nLet's assume that S(n) is the sum of digits of number n, for example, S(4098) = 4 + 0 + 9 + 8 = 21. Then the digital root of number n equals to: \n\n 1. dr(n) = S(n), if S(n) < 10; \... | [{"input": "4898 3\n", "output": "3000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000... | code_stdio |
[
{
"content": "You are given an array $a$ of $n$ integers. You are asked to find out if the inequality $$\\max(a_i, a_{i + 1}, \\ldots, a_{j - 1}, a_{j}) \\geq a_i + a_{i + 1} + \\dots + a_{j - 1} + a_{j}$$ holds for all pairs of indices $(i, j)$, where $1 \\leq i \\leq j \\leq n$.\n\n\n-----Input-----\n\nEach t... | [{"input": "5\n19\n1 1 -1 -1 -1 0 -1 -1 1 -1 -1 1 0 1 0 -1 0 -1 -1\n11\n1 0 1 0 -1 1 -1 -1 -1 1 0\n58\n1 0 0 -1 -1 0 1 0 1 0 1 -1 1 1 0 0 1 -1 -1 1 -1 1 -1 -1 1 -1 0 1 0 0 0 0 -1 -1 0 0 0 1 0 0 1 -1 0 0 0 -1 0 0 1 -1 0 -1 1 1 -1 0 0 1\n2\n0 0\n10\n0 -1 1 -1 1 -1 0 0 1 0\n", "output": "NO\nNO\nNO\nYES\nYES\n"}, {"input"... | code_stdio |
[
{
"content": "Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem.\n\nA field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy... | [{"input": "-1000000000 -1000000000 1000000000 1000000000\n", "output": "2000000002000000001"}, {"input": "-1000000000 -1000000000 1000000000 1000000000\n", "output": "2000000002000000001"}, {"input": "-1000000000 -999999999 1000000000 999999999\n", "output": "2000000000000000000"}, {"input": "-999999999 -1000000000 99... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \n\nThe Head Chef is receiving a lot of orders for cooking the best of the problems lately. For this, he organized an hiring event to hire some talented Chefs. He gave the following problem to test the skills of the part... | [{"input": "2\n1\n210", "output": "0\n2628\n"}, {"input": "2\n1\n198", "output": "0\n2484\n"}, {"input": "2\n1\n175", "output": "0\n2288\n"}, {"input": "2\n2\n175", "output": "2\n2288\n"}, {"input": "2\n2\n278", "output": "2\n4204\n"}, {"input": "2\n2\n114", "output": "2\n846\n"}, {"input": "2\n3\n112", "output": "4\n8... | code_stdio |
[
{
"content": "IT City company developing computer games decided to upgrade its way to reward its employees. Now it looks the following way. After a new game release users start buying it actively, and the company tracks the number of sales with precision to each transaction. Every time when the next number of s... | [{"input": "1000000000000000000\n", "output": "228571428571428571\n"}, {"input": "1000000010000000000\n", "output": "228571430857142858\n"}, {"input": "1334196189585702396\n", "output": "304959129048160547\n"}, {"input": "1369783456377690936\n", "output": "313093361457757928\n"}, {"input": "1000000010000000100\n", "out... | code_stdio |
[
{
"content": "The ancient Berlanders believed that the longer the name, the more important its bearer is. Thus, Berland kings were famous for their long names. But long names are somewhat inconvenient, so the Berlanders started to abbreviate the names of their kings. They called every king by the first letters ... | [{"input": "50\nagecd\ncghafi\nfiide\niecc\njbdcfjhgd\ndiee\nhfeg\nehc\ngfijgjh\ngacaifebg\ndicbbddc\nhjgciaei\njjcdh\ng\ngc\ncf\nhfdjhd\nc\nicidbec\nji\neeh\ncgeejggc\nacfd\njjg\najefdj\neghhebiic\nbih\ngbb\njjaa\nidc\ngafi\necg\ndbigbjiehj\ncedif\nahidfaaajg\nhfhhiccbgb\ndgegjgieif\nhgjebhfdc\nj\nahehd\nahdah\nbijbhh... | code_stdio |
[
{
"content": "Vasiliy has an exam period which will continue for n days. He has to pass exams on m subjects. Subjects are numbered from 1 to m.\n\nAbout every day we know exam for which one of m subjects can be passed on that day. Perhaps, some day you can't pass any exam. It is not allowed to pass more than on... | [{"input": "100 10\n1 1 6 6 6 2 5 7 6 5 3 7 10 10 8 9 7 6 9 2 6 7 8 6 7 5 2 5 10 1 10 1 8 10 2 9 7 1 6 8 3 10 9 4 4 8 8 6 6 1 5 5 6 5 6 6 6 9 4 7 5 4 6 6 1 1 2 1 8 10 6 2 1 7 2 1 8 10 9 2 7 3 1 5 10 2 8 10 10 10 8 9 5 4 6 10 8 9 6 6\n2 4 10 11 5 2 6 7 2 15\n", "output": "74\n"}, {"input": "100 10\n1 1 6 6 6 2 5 7 6 5 3... | code_stdio |
[
{
"content": "Old timers of Summer Informatics School can remember previous camps in which each student was given a drink of his choice on the vechorka (late-evening meal). Or may be the story was more complicated?\n\nThere are $n$ students living in a building, and for each of them the favorite drink $a_i$ is ... | [{"input": "20 4\n1\n1\n1\n1\n1\n2\n2\n2\n2\n2\n3\n3\n3\n3\n3\n4\n4\n4\n4\n4\n", "output": "18\n"}, {"input": "20 4\n1\n1\n1\n1\n1\n2\n2\n2\n2\n2\n3\n3\n3\n3\n3\n4\n4\n4\n4\n4\n", "output": "18\n"}, {"input": "16 12\n1\n1\n1\n2\n2\n4\n3\n3\n3\n4\n4\n4\n5\n5\n6\n6\n", "output": "15\n"}, {"input": "16 12\n1\n1\n1\n2\n2\n... | code_stdio |
[
{
"content": "You are given a directed graph with $n$ vertices and $m$ directed edges without self-loops or multiple edges.\n\nLet's denote the $k$-coloring of a digraph as following: you color each edge in one of $k$ colors. The $k$-coloring is good if and only if there no cycle formed by edges of same color.\... | [{"input": "18 74\n12 17\n6 3\n7 5\n11 13\n13 12\n16 2\n15 3\n10 6\n18 1\n6 1\n10 18\n3 16\n16 5\n14 12\n12 1\n9 6\n13 11\n11 17\n13 1\n1 7\n18 12\n6 8\n11 15\n2 9\n9 12\n7 4\n8 15\n6 9\n11 9\n11 18\n3 6\n5 7\n1 16\n2 6\n17 11\n4 8\n14 1\n7 13\n18 14\n7 16\n15 5\n11 2\n18 17\n9 16\n4 13\n17 5\n8 6\n18 6\n6 4\n17 10\n10... | code_stdio |
[
{
"content": "You've got two numbers. As long as they are both larger than zero, they go through the same operation: subtract the lesser number from the larger one. If they equal substract one number from the another. For example, one operation transforms pair (4,17) to pair (4,13), it transforms (5,5) to (0,5)... | [{"input": "20\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 9999999... | code_stdio |
[
{
"content": "A string $s$ of length $n$, consisting of lowercase letters of the English alphabet, is given.\n\nYou must choose some number $k$ between $0$ and $n$. Then, you select $k$ characters of $s$ and permute them however you want. In this process, the positions of the other $n-k$ characters remain uncha... | [{"input": "4\n3\nlol\n10\nfecrosedoc\n5\naaaab\n4\nddca\n", "output": "2\n10\n0\n4\n"}, {"input": "4\n3\nnlm\n10\nfecrosedoc\n5\naaaab\n4\nddca\n", "output": "3\n10\n0\n4\n"}, {"input": "4\n3\nlol\n10\ncodeforces\n5\naaaaa\n4\ndcba\n", "output": "2\n6\n0\n4\n"}, {"input": "4\n3\nlol\n10\ncodeforces\n5\nbaaaa\n4\ndcba\... | code_stdio |
[
{
"content": "There is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step.\nHe can climb up one or two steps at a time.\nHowever, the treads of the a_1-th, a_2-th, a_3-th, \\ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.\nHow ... | [{"input": "16090 15931\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59\n60\n61\n62\n63\n64\n65\n66\n67\n68\n69\n70\n71\n72\n73\n74\n75\n76\n... | code_stdio |
[
{
"content": "This is a harder version of the problem. In this version, $n \\le 50\\,000$.\n\nThere are $n$ distinct points in three-dimensional space numbered from $1$ to $n$. The $i$-th point has coordinates $(x_i, y_i, z_i)$. The number of points $n$ is even.\n\nYou'd like to remove all $n$ points using a se... | [{"input": "8\n-100000000 -100000000 -100000000\n100000000 100000000 100000000\n-100000000 100000000 100000000\n-100000000 -100000000 100000000\n100000000 100000000 -100000000\n100000000 -100000000 -100000000\n-100000000 100000000 -100000000\n100000000 -100000000 100000000\n", "output": "1 4\n7 3\n6 8\n5 2\n"}, {"input... | code_stdio |
[
{
"content": "Ivan has $n$ songs on his phone. The size of the $i$-th song is $a_i$ bytes. Ivan also has a flash drive which can hold at most $m$ bytes in total. Initially, his flash drive is empty.\n\nIvan wants to copy all $n$ songs to the flash drive. He can compress the songs. If he compresses the $i$-th so... | [{"input": "1 1364355877\n1000000000 1343571090\n", "output": "0\n"}, {"input": "1 1000000000\n1000000000 999999999\n", "output": "0\n"}, {"input": "1 1000000000\n1000000000 999999999\n", "output": "0\n"}, {"input": "1 1992779579\n1000000000 999999999\n", "output": "0\n"}, {"input": "1 1992779579\n1000000010 999999999\... | code_stdio |
[
{
"content": "Reading books is one of Sasha's passions. Once while he was reading one book, he became acquainted with an unusual character. The character told about himself like that: \"Many are my names in many countries. Mithrandir among the Elves, Tharkûn to the Dwarves, Olórin I was in my youth in the West ... | [{"input": "tttdddssstttssstttdddddddddttttttdddsssdddtttsssdddsssssstttddddddtttdddssstttsssttttttdddtttsssssstttssssssssstttsssssstttssstttdddddddddsssdddssssssdddssstttsssdddssstttdddttttttdddddddddsssssstttdddtttssssssdddddddddttttttdddtttsssdddssstttsssdddssssssdddsssdddddddddtttssstttsssssstttssssssssstttsssssstt... | code_stdio |
[
{
"content": "Taro is not good at hide-and-seek. As soon as you hide, you will find it, and it will be difficult to find the hidden child. My father, who couldn't see it, made an ultra-high performance location search system. You can use it to know exactly where your friends are, including your own. Once you be... | [{"input": "3\n6 6 3\n19 19 6\n42 10 1\n6\n5 2 2 11\n12 7 2 11\n11 9 1 11\n14 2 22 5\n17 9 20 5\n20 10 20 5\n0", "output": "Safe\nDanger\nDanger\nDanger\nDanger\nDanger\n"}, {"input": "3\n6 2 16\n40 7 8\n42 8 1\n6\n5 3 4 11\n12 4 2 15\n16 2 0 11\n28 2 31 5\n17 9 41 5\n24 10 30 10\n0", "output": "Danger\nDanger\nDanger\... | code_stdio |
[
{
"content": "Anton has the integer x. He is interested what positive integer, which doesn't exceed x, has the maximum sum of digits.\n\nYour task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them. \n\n\n-----Input-----\n\nThe first li... | [{"input": "1000000000000000000\n", "output": "999999999999999999\n"}, {"input": "1000000000000000000\n", "output": "999999999999999999\n"}, {"input": "978916546899999999\n", "output": "899999999999999999\n"}, {"input": "999999999999999999\n", "output": "999999999999999999\n"}, {"input": "999999999999990999\n", "output... | code_stdio |
[
{
"content": "There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.\n\nEach second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go... | [{"input": "MFFFMMFMFMFMFFFMMMFFMMMMMMFMMFFMMMFMMFMFFFMMFMMMFFMMFFFFFMFMFFFMMMFFFMFMFMFMFFFMMMMFMMFMMFFMMMMMMFFM\n", "output": "54\n"}, {"input": "MMMMMFFMFMFMFMMFMMFFMMFMFFFFFFFMFFFMMMMMMFFMMMFMFMMFMFFMMFMMMFFFFFMMMMMFMMMMFMMMFFMFFMFFFMFFMFFMMFFM\n", "output": "58\n"}, {"input": "MMMMFMMMMMFFMMFMFMMMFMMFMFMMFFFMMFMMMF... | code_stdio |
[
{
"content": "Let N be a positive even number.\nWe have a permutation of (1, 2, ..., N), p = (p_1, p_2, ..., p_N).\nSnuke is constructing another permutation of (1, 2, ..., N), q, following the procedure below.\nFirst, let q be an empty sequence.\nThen, perform the following operation until p becomes empty:\n -... | [{"input": "8\n2 6 5 2 1 4 -1 1", "output": "-1 1 1 4 2 2 6 5 "}, {"input": "8\n4 6 3 2 8 5 7 1\n", "output": "3 1 2 7 4 6 8 5\n"}, {"input": "8\n4 6 5 2 8 5 7 1", "output": "4 1 2 7 6 5 8 5 "}, {"input": "8\n4 6 5 2 8 5 0 1", "output": "0 1 4 2 6 5 8 5 "}, {"input": "8\n2 6 5 2 8 5 0 1", "output": "0 1 2 2 6 5 8 5 "},... | code_stdio |
[
{
"content": "A sequence $(b_1, b_2, \\ldots, b_k)$ is called strange, if the absolute difference between any pair of its elements is greater than or equal to the maximum element in the sequence. Formally speaking, it's strange if for every pair $(i, j)$ with $1 \\le i<j \\le k$, we have $|a_i-a_j|\\geq MAX$, w... | [{"input": "6\n4\n-1 -2 -1 1\n7\n-3 2 -2 0 -4 7 1\n5\n0 5 -3 2 -5\n3\n2 0 1\n4\n-3 -1 2 0\n6\n-3 -2 -1 1 1 1\n", "output": "3\n5\n4\n2\n3\n4\n"}, {"input": "6\n4\n-1 -2 -1 1\n7\n-3 2 -2 0 -4 7 1\n5\n0 5 -3 1 -5\n3\n2 0 1\n4\n-3 -1 2 0\n6\n-3 -2 -2 1 1 1\n", "output": "3\n5\n4\n2\n3\n3\n"}, {"input": "6\n4\n-1 -2 0 1\n7... | code_stdio |
[
{
"content": "You are given three integers A, B and C.\n\nDetermine if there exists an equilateral triangle whose sides have lengths A, B and C.\n\nConstraints\n\n* All values in input are integers.\n* 1 \\leq A,B,C \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\n\nA B C\n\n... | [{"input": "-1 -1 -1", "output": "Yes\n"}, {"input": "-2 -1 -1", "output": "No\n"}, {"input": "-2 -1 -2", "output": "No\n"}, {"input": "-3 10 -1", "output": "No\n"}, {"input": "-3 1 -11", "output": "No\n"}, {"input": "-3 1 -21", "output": "No\n"}, {"input": "-5 1 -21", "output": "No\n"}, {"input": "-9 1 -21", "output":... | code_stdio |
[
{
"content": "Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. \n\nDima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and sta... | [{"input": "8\n7 3 3 10 9 9 8 1\n8 2 6 6 0 3 8 0\n1 2 5 1 9 4 7 8\n", "output": "52\n"}, {"input": "8\n7 3 3 10 9 9 8 1\n8 2 4 6 0 3 8 0\n1 2 5 1 9 4 7 8\n", "output": "52\n"}, {"input": "8\n7 3 3 10 9 9 6 1\n8 2 4 6 0 3 8 0\n1 2 5 1 9 4 7 8\n", "output": "52\n"}, {"input": "8\n7 3 3 10 9 9 6 1\n8 2 4 8 0 3 8 0\n1 2 5 ... | code_stdio |
[
{
"content": "Little Dima has two sequences of points with integer coordinates: sequence (a1, 1), (a2, 2), ..., (an, n) and sequence (b1, 1), (b2, 2), ..., (bn, n).\n\nNow Dima wants to count the number of distinct sequences of points of length 2·n that can be assembled from these sequences, such that the x-coo... | [{"input": "100\n2 2 10 3 5 6 4 7 9 8 2 7 5 5 1 7 5 9 2 2 10 3 6 10 9 9 10 7 3 9 7 8 8 3 9 3 9 3 3 6 3 7 9 9 7 10 9 1 1 3 6 2 9 5 9 9 6 2 6 5 6 8 2 10 1 1 6 8 8 4 5 2 6 8 8 5 9 2 3 3 7 7 10 5 4 2 10 6 7 6 5 4 10 6 10 3 9 9 1 5\n3 5 6 4 2 3 2 9 3 8 3 1 10 7 4 3 6 9 3 5 9 5 3 10 4 7 9 7 4 3 3 6 9 8 1 1 10 9 1 6 8 8 8 2 1... | code_stdio |
[
{
"content": "Inna loves digit 9 very much. That's why she asked Dima to write a small number consisting of nines. But Dima must have misunderstood her and he wrote a very large number a, consisting of digits from 1 to 9.\n\nInna wants to slightly alter the number Dima wrote so that in the end the number contai... | [{"input": "44444444444444544444444445444444444444444444444444554444444444444444444444444444444444444444455444444444444444444444444444444444444444545444444444444444444444444444444444444445444444444444444444444444444444444444544444444444444444444444444444444444444444444544444444444444444444444444444444445666666666666666... | code_stdio |
[
{
"content": "I bought food at the store to make a lunch box to eat at lunch. At the store, I only got an elongated bag to put food in, so I had to stack all the food vertically and put it in the bag. I want to pack the bag with the heavy ones down so that it won't fall over, but some foods are soft and will co... | [{"input": "4\nsandwich 30 120\nelppa 50 200\ncheese 20 40\ncake 100 100\n9\nonigiri 80 300\nonigiri 80 300\nanpan 70 280\nmikan 50 80\nkanzume 101 500\nchocolate 50 350\niookce 30 132\npurin 40 400\ncracker 40 154\n0", "output": "cake\nelppa\nsandwich\ncheese\nkanzume\npurin\nchocolate\nonigiri\nonigiri\nanpan\nmikan\... | code_stdio |
[
{
"content": "problem\n\nFor the integer n (1 ≤ n), let Pn be a string of n + 1 I's and n O's starting with I and alternating, where I and O are the uppercase Ai and O, respectively. is there.\n\n\nP1 | IOI\n--- | ---\nP2 | IOIOI\nP3 | IOIOIOI\n|. |\n|. |\n|. |\nPn | IOIOIO ... OI (n O)\n\n\n\nFigure 1-1 Charac... | [{"input": "1\n119\nOOJOIOIOIIOII\n1\n14\nKIOIIOIOIOJOO\n0", "output": "3\n3\n"}, {"input": "1\n13\nOIIOIOIOIIOIO\n2\n13\nOOIOIOIOIIOII\n0", "output": "4\n2\n"}, {"input": "1\n13\nOOIOIOIOIIOII\n3\n13\nOOIOIOIOIIOII\n0", "output": "4\n1\n"}, {"input": "1\n25\nOOIOIOIOIIOII\n3\n13\nOOJOIOIOIIOIJ\n0", "output": "4\n0\n"}... | code_stdio |
[
{
"content": "Gottfried learned about binary number representation. He then came up with this task and presented it to you.\n\nYou are given a collection of $n$ non-negative integers $a_1, \\ldots, a_n$. You are allowed to perform the following operation: choose two distinct indices $1 \\leq i, j \\leq n$. If b... | [{"input": "37\n1048575 327657 1046479 686078 513773 589787 387035 736754 1038077 1048056 59263 753353 784318 647131 519679 294910 185560 604141 456668 849789 521404 782287 6137 1047551 849874 523933 521721 278491 1042415 581468 1013705 439526 1011709 917469 655311 327646 917499\n", "output": "24197296011217\n"}, {"inp... | code_stdio |
[
{
"content": "The goal of the matrix-chain multiplication problem is to find the most efficient way to multiply given $n$ matrices $M_1, M_2, M_3,...,M_n$.\n\nWrite a program which reads dimensions of $M_i$, and finds the minimum number of scalar multiplications to compute the maxrix-chain multiplication $M_1M_... | [{"input": "6\n30 35\n35 15\n15 5\n5 10\n10 20\n20 29", "output": "16125\n"}, {"input": "6\n30 35\n35 15\n15 5\n5 10\n10 20\n20 27", "output": "15625\n"}, {"input": "6\n30 35\n35 15\n15 5\n5 10\n10 20\n20 47", "output": "20625\n"}, {"input": "6\n30 35\n35 15\n15 5\n5 10\n10 20\n20 14", "output": "12375\n"}, {"input": "... | code_stdio |
[
{
"content": "There are $n$ athletes in front of you. Athletes are numbered from $1$ to $n$ from left to right. You know the strength of each athlete — the athlete number $i$ has the strength $s_i$.\n\nYou want to split all athletes into two teams. Each team must have at least one athlete, and each athlete must... | [{"input": "5\n5\n3 1 2 10 4\n6\n2 1 3 4 4 3\n4\n14 9 3 1\n2\n0 1000\n3\n110 150 200\n", "output": "1\n0\n2\n1000\n40\n"}, {"input": "5\n5\n3 1 2 10 4\n6\n2 1 3 4 4 3\n4\n14 9 3 1\n2\n0 1000\n3\n100 150 200\n", "output": "1\n0\n2\n1000\n50\n"}, {"input": "5\n5\n3 1 2 10 4\n6\n2 1 3 4 4 3\n4\n7 9 3 1\n2\n0 1000\n3\n100 ... | code_stdio |
[
{
"content": "Your security guard friend recently got a new job at a new security company. The company requires him to patrol an area of the city encompassing exactly N city blocks, but they let him choose which blocks. That is, your friend must walk the perimeter of a region whose area is exactly N blocks. You... | [{"input": "1000000\n", "output": "4000\n"}, {"input": "1000000\n", "output": "4000\n"}, {"input": "999000\n", "output": "3998\n"}, {"input": "999001\n", "output": "4000\n"}, {"input": "999999\n", "output": "4000\n"}, {"input": "933206\n", "output": "3866\n"}, {"input": "718351\n", "output": "3392\n"}, {"input": "60744... | code_stdio |
[
{
"content": "Logical quantifiers are very useful tools for expressing claims about a set. For this problem, let's focus on the set of real numbers specifically. The set of real numbers includes zero and negatives. There are two kinds of quantifiers: universal ($\\forall$) and existential ($\\exists$). You can ... | [{"input": "100 50\n55 13\n84 2\n22 63\n100 91\n2 18\n98 64\n1 86\n93 11\n17 6\n24 97\n14 35\n24 74\n22 3\n42 5\n63 79\n31 89\n81 22\n86 88\n77 51\n81 34\n19 55\n41 54\n34 57\n45 9\n55 72\n67 61\n41 84\n39 32\n51 89\n58 74\n32 79\n65 6\n86 64\n63 42\n100 57\n46 39\n100 9\n23 58\n26 81\n61 49\n71 83\n66 2\n79 74\n30 27\... | code_stdio |
[
{
"content": "Kawashiro Nitori is a girl who loves competitive programming.\n\nOne day she found a string and an integer. As an advanced problem setter, she quickly thought of a problem.\n\nGiven a string $s$ and a parameter $k$, you need to check if there exist $k+1$ non-empty strings $a_1,a_2...,a_{k+1}$, suc... | [{"input": "7\n5 2\nrwrwq\n2 0\nac\n3 1\nioi\n4 0\nibdp\n22 0\ndokidoktliteraiureclub\n19 0\necilbiahgaahsmnetmi\n6 2\naaaaaa\n", "output": "NO\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"input": "7\n5 1\nqwqwq\n2 0\nab\n3 1\nioi\n4 2\nipcc\n22 0\ncokidokiliteratureclub\n19 11\nimtdamshanghaialice\n6 2\naaaaaa\n", "output": "... | code_stdio |
[
{
"content": "Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks.\n\nThe students don’t want to use too many blocks, but t... | [{"input": "1000000 1000000\n", "output": "3000000\n"}, {"input": "1000000 1000000\n", "output": "3000000\n"}, {"input": "1000000 999999\n", "output": "2999998\n"}, {"input": "999999 1000000\n", "output": "3000000\n"}, {"input": "1000000 666667\n", "output": "2500000\n"}, {"input": "1000000 999999\n", "output": "299999... | code_stdio |
[
{
"content": "You are given a string S as input. This represents a valid date in the year 2019 in the yyyy/mm/dd format. (For example, April 30, 2019 is represented as 2019/04/30.)\nWrite a program that prints Heisei if the date represented by S is not later than April 30, 2019, and prints TBD otherwise.\n\n---... | [{"input": "2019/04/30\n", "output": "Heisei\n"}, {"input": "2019/01/01\n", "output": "Heisei\n"}, {"input": "2019/02/28\n", "output": "Heisei\n"}, {"input": "2019/04/29\n", "output": "Heisei\n"}, {"input": "2019/03/30", "output": "Heisei\n"}, {"input": "2019/04/20", "output": "Heisei\n"}, {"input": "1019/04/30", "outp... | code_stdio |
[
{
"content": "This contest, AtCoder Beginner Contest, is abbreviated as ABC.\nWhen we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC.\nWhat is the abbreviation for the N-th round of ABC? Write a program to output the answer.\n\n-----Co... | [{"input": "1530", "output": "ABC1530\n"}, {"input": "2825", "output": "ABC2825\n"}, {"input": "5621", "output": "ABC5621\n"}, {"input": "-105", "output": "ABC-105\n"}, {"input": "-136", "output": "ABC-136\n"}, {"input": "-215", "output": "ABC-215\n"}, {"input": "-111", "output": "ABC-111\n"}, {"input": "-104", "output... | code_stdio |
[
{
"content": "Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.\n\nIn one second, Genos is able to choose exactly one continuous substring of co... | [{"input": "50\n22 19 14 22 20 11 16 28 23 15 3 23 6 16 30 15 15 10 43 28 19 19 22 30 28 1 27 12 12 14 17 30 17 26 21 26 27 1 11 23 9 30 18 19 17 29 11 20 29 24\n", "output": "25\n"}, {"input": "50\n22 19 14 22 20 11 16 28 38 15 3 23 6 16 30 15 15 10 43 28 19 19 22 30 28 1 27 12 12 14 17 30 17 26 21 26 27 1 11 23 9 30 ... | code_stdio |
[
{
"content": "Little Chris is bored during his physics lessons (too easy), so he has built a toy box to keep himself occupied. The box is special, since it has the ability to change gravity.\n\nThere are n columns of toy cubes in the box arranged in a line. The i-th column contains a_{i} cubes. At first, the gr... | [{"input": "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 100 100... | code_stdio |
[
{
"content": "Koa the Koala and her best friend want to play a game.\n\nThe game starts with an array a of length n consisting of non-negative integers. Koa and her best friend move in turns and each have initially a score equal to 0. Koa starts.\n\nLet's describe a move in the game:\n\n * During his move, a p... | [{"input": "4\n5\n4 1 5 1 4\n4\n1 0 0 12\n1\n0\n2\n5 4\n", "output": "LOSE\nWIN\nDRAW\nWIN\n"}, {"input": "4\n5\n2 1 3 1 0\n4\n1 0 1 6\n1\n0\n2\n5 4\n", "output": "LOSE\nWIN\nDRAW\nWIN\n"}, {"input": "4\n5\n4 1 5 1 4\n4\n1 0 1 12\n1\n1\n2\n5 4\n", "output": "LOSE\nWIN\nWIN\nWIN\n"}, {"input": "4\n5\n4 1 5 1 3\n4\n1 0 0... | code_stdio |
[
{
"content": "The King of a little Kingdom on a little island in the Pacific Ocean frequently has childish ideas. One day he said, “You shall make use of a message relaying game when you inform me of something.” In response to the King’s statement, six servants were selected as messengers whose names were Mr. J... | [{"input": "5\nAJMP\naB33d\nE\n86AE\nAM\n-1\nMPJE\nWaEaETC302Q\nCP\nrTurnAGumdam1isdefferentf", "output": "33Bad\nAE86\n2-\nEC302QTWaEa\nTurnAGumdam0isdefferentfr\n"}, {"input": "5\nAJMP\naB33d\nE\n86AE\nMA\n-1\nMPJE\nWaEaETC302Q\nCP\nftnereffedsi1madmuGAnruTr", "output": "33Bad\nAE86\n2-\nEC302QTWaEa\ntnereffedsi0madm... | code_stdio |
[
{
"content": "One day, little Vasya found himself in a maze consisting of (n + 1) rooms, numbered from 1 to (n + 1). Initially, Vasya is at the first room and to get out of the maze, he needs to get to the (n + 1)-th one.\n\nThe maze is organized as follows. Each room of the maze has two one-way portals. Let's ... | [{"input": "129\n1 1 3 3 1 4 7 4 3 5 8 11 3 9 15 4 11 17 1 6 18 9 11 13 17 22 8 18 26 13 16 20 3 16 35 26 23 28 27 30 39 29 43 8 14 6 17 32 26 31 2 18 3 47 52 21 57 1 35 35 53 47 16 26 30 65 48 2 32 11 10 5 4 1 4 53 71 21 53 8 58 49 17 6 19 80 1 49 43 60 12 60 35 25 86 45 47 97 52 74 10 91 93 31 69 41 80 90 67 4 94 92 ... | code_stdio |
[
{
"content": "$2^n$ teams participate in a playoff tournament. The tournament consists of $2^n - 1$ games. They are held as follows: in the first phase of the tournament, the teams are split into pairs: team $1$ plays against team $2$, team $3$ plays against team $4$, and so on (so, $2^{n-1}$ games are played i... | [{"input": "7\n1011011\n", "output": "32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 11... | code_stdio |
[
{
"content": "You are given a table consisting of n rows and m columns. Each cell of the table contains a number, 0 or 1. In one move we can choose some row of the table and cyclically shift its values either one cell to the left, or one cell to the right.\n\nTo cyclically shift a table row one cell to the righ... | [{"input": "10 10\n0000000000\n0000001000\n0000000100\n0101000100\n0000000000\n0000000000\n1000110000\n1011010010\n0000100000\n0000001001\n", "output": "-1\n"}, {"input": "10 10\n0000000000\n0000000010\n0010000000\n0111000010\n1000000000\n0000000100\n0000000100\n0000100100\n0010000000\n0000100000\n", "output": "-1\n"},... | code_stdio |
[
{
"content": "You are given integers A and B, each between 1 and 3 (inclusive).\nDetermine if there is an integer C between 1 and 3 (inclusive) such that A \\times B \\times C is an odd number.\n\n-----Constraints-----\n - All values in input are integers.\n - 1 \\leq A, B \\leq 3\n\n-----Input-----\nInput is g... | [{"input": "-1 -1", "output": "Yes\n"}, {"input": "-3 -1", "output": "Yes\n"}, {"input": "-1 -3", "output": "Yes\n"}, {"input": "-5 -1", "output": "Yes\n"}, {"input": "-1 -5", "output": "Yes\n"}, {"input": "-3 -3", "output": "Yes\n"}, {"input": "-12 -2", "output": "No\n"}, {"input": "3 1\n", "output": "Yes\n"}, {"input... | code_stdio |
[
{
"content": "Greatest common divisor GCD(a, b) of two positive integers a and b is equal to the biggest integer d such that both integers a and b are divisible by d. There are many efficient algorithms to find greatest common divisor GCD(a, b), for example, Euclid algorithm. \n\nFormally, find the biggest inte... | [{"input": "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "output": "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000... | code_stdio |
[
{
"content": "One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters \"a\", \"b\" and \"c\" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: \n\n * G has exactly ... | [{"input": "15 84\n11 9\n3 11\n13 10\n2 12\n5 9\n1 7\n14 4\n14 2\n14 1\n11 8\n1 8\n14 10\n4 15\n10 5\n5 12\n13 11\n6 14\n5 7\n12 11\n9 1\n10 15\n2 6\n7 15\n14 9\n9 7\n11 14\n8 15\n12 7\n13 6\n2 9\n9 6\n15 3\n12 15\n6 15\n4 6\n4 1\n9 12\n10 7\n6 1\n11 10\n2 3\n5 2\n13 2\n13 3\n12 6\n4 3\n5 8\n12 1\n9 15\n14 5\n12 14\n10... | code_stdio |
[
{
"content": "Awruk is taking part in elections in his school. It is the final round. He has only one opponent — Elodreip. The are $n$ students in the school. Each student has exactly $k$ votes and is obligated to use all of them. So Awruk knows that if a person gives $a_i$ votes for Elodreip, than he will get ... | [{"input": "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 100 100... | code_stdio |
[
{
"content": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES\n\nWrite Python code to solve this ... | [{"input": "46\n", "output": "YES\n"}, {"input": "12\n", "output": "YES\n"}, {"input": "30\n", "output": "YES\n"}, {"input": "35\n", "output": "YES\n"}, {"input": "43\n", "output": "YES\n"}, {"input": "52\n", "output": "YES\n"}, {"input": "64\n", "output": "YES\n"}, {"input": "86\n", "output": "YES\n"}, {"input": "011\... | code_stdio |
[
{
"content": "Given a string of length n s = s1, s2,…, sn and m queries. Each query qk (1 ≤ k ≤ m) is one of four types, \"L ++\", \"L-\", \"R ++\", \"R-\", and l [for the kth query qk. k] and r [k] are defined below.\n\n* L ++: l [k] = l [k-1] + 1, r [k] = r [k-1]\n\n* L-: l [k] = l [k-1] -1, r [k] = r [k-1]\n... | [{"input": "10 13\naacacbabac\nR++\nR++\nL++\nR++\nR++\nL++\nL++\nR++\nR++\nL--\nL--\nR--\nR--", "output": "11"}, {"input": "4 6\nbaba\nR++\nL++\nR++\nL++\nR++\nL++", "output": "4\n"}, {"input": "4 6\nbaab\nR++\nL++\nR++\nL++\nR++\nL++", "output": "5\n"}, {"input": "8 6\nbacb\nR++\nL++\nR++\nL++\nR++\nL++", "output": "... | code_stdio |
[
{
"content": "Nantendo Co., Ltd. has released a game software called Packet Monster. This game was intended to catch, raise, and fight monsters, and was a very popular game all over the world.\n\nThis game had features not found in traditional games. There are two versions of this game, Red and Green, and the m... | [{"input": "CBA\ncba\ncCa\nX\nYZ\nZ\n-", "output": "BbA\nYX\n"}, {"input": "CBA\ncba\ncCa\nY\nYZ\nZ\n-", "output": "BbA\nYY\n"}, {"input": "CBA\ncca\ncCa\nX\nZY\nZ\n-", "output": "BcA\nXY\n"}, {"input": "CAB\ncba\ncCa\nX\nYZ\nZ\n-", "output": "AbB\nYX\n"}, {"input": "CAB\ncca\ncCa\nX\nYZ\nZ\n-", "output": "AcB\nYX\n"},... | code_stdio |
[
{
"content": "There are several days left before the fiftieth birthday of a famous Berland's writer Berlbury. In this connection the local library decided to make an exposition of the works of this famous science-fiction writer. It was decided as well that it is necessary to include into the exposition only tho... | [{"input": "55 1000\n2612 1306 4300 1790 3173 9493 7209 7763 8563 4534 7466 1281 4483 6863 3787 7292 3957 8775 7221 4016 5743 6556 2070 2119 4795 9094 1913 2077 8786 4520 1865 2357 7871 3288 8231 5808 9383 9820 9974 3056 5343 2169 5177 6299 5805 8132 9315 6747 5226 3531 1206 4073 8290 1423 6720\n", "output": "3 1\n37 3... | code_stdio |
[
{
"content": "To stay woke and attentive during classes, Karen needs some coffee! [Image] \n\nKaren, a coffee aficionado, wants to know the optimal temperature for brewing the perfect cup of coffee. Indeed, she has spent some time reading several recipe books, including the universally acclaimed \"The Art of th... | [{"input": "3 2 4\n91 288\n92 97\n116 271\n92 192\n93 97\n95 138\n90 100\n", "output": "83\n5\n26\n6\n"}, {"input": "3 2 4\n91 510\n92 97\n66 271\n51 94\n93 97\n95 316\n100 111\n", "output": "4\n5\n177\n12\n"}, {"input": "3 2 4\n91 288\n92 97\n116 271\n86 192\n93 97\n95 138\n90 100\n", "output": "83\n5\n26\n6\n"}, {"in... | code_stdio |
[
{
"content": "There are some beautiful girls in Arpa’s land as mentioned before.\n\nOnce Arpa came up with an obvious problem:\n\nGiven an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \\oplus a_{j} = x$, where $\\oplus$ is bitwise xor operation (see notes for ... | [{"input": "64 118\n361 547 410 294 448 377 482 490 13 116 346 50 251 330 443 128 543 580 370 489 337 509 414 291 228 71 245 308 319 314 154 39 317 288 145 248 547 152 262 278 89 108 522 238 128 575 112 469 86 230 310 492 127 270 475 25 179 72 345 444 17 332 544 338\n", "output": "3\n"}, {"input": "64 118\n361 547 410 ... | code_stdio |
[
{
"content": "Valentin participates in a show called \"Shockers\". The rules are quite easy: jury selects one letter which Valentin doesn't know. He should make a small speech, but every time he pronounces a word that contains the selected letter, he receives an electric shock. He can make guesses which letter ... | [{"input": "15\n. r\n? e\n. s\n. rw\n? y\n. fj\n. zftyd\n? r\n! wq\n? w\n? p\n. ours\n. dto\n. lbyfru\n? q\n", "output": "2\n"}, {"input": "8\n! hello\n! codeforces\n? c\n. o\n? d\n? h\n. l\n? e\n", "output": "2\n"}, {"input": "7\n! ababahalamaha\n? a\n? b\n? a\n? b\n? a\n? h\n", "output": "0\n"}, {"input": "3\n. abcde... | code_stdio |
[
{
"content": "Problem statement\n\nA programming contest will be held in the Russian Federation. The contest has N questions and has M participants. Question i has a score a_i, and it is known that participant j's ability is b_j. For problem i and participant j, participant j can always solve problem i if a_i ≤... | [{"input": "6\n1 2 0 15 0 2\n7\n2 5 4 2 6 1 0\n1 28 1 3 5 1 0", "output": "Yes\nNo\nYes\nYes\nYes\nYes\nYes\n"}, {"input": "6\n1 1 0 15 0 3\n7\n2 5 4 2 10 1 0\n1 28 1 3 0 1 0", "output": "Yes\nNo\nYes\nNo\nYes\nYes\nYes\n"}, {"input": "6\n1 2 0 15 1 4\n7\n0 5 8 2 11 1 0\n1 11 1 5 0 0 -1", "output": "No\nNo\nYes\nNo\nYe... | code_stdio |
[
{
"content": "You are given a string s.\nAmong the different substrings of s, print the K-th lexicographically smallest one.\nA substring of s is a string obtained by taking out a non-empty contiguous part in s.\nFor example, if s = ababc, a, bab and ababc are substrings of s, while ac, z and an empty string ar... | [{"input": "atcoderandatcodeer\n5\n", "output": "andat\n"}, {"input": "atcoderamdatcodeer\n5", "output": "amdat\n"}, {"input": "roddadtadmaoefectr\n5", "output": "admao\n"}, {"input": "atcoderamdascodeer\n5", "output": "amdas\n"}, {"input": "atcoderandatcodeer\n4", "output": "anda\n"}, {"input": "roddadtadmboefectr\n4"... | code_stdio |
[
{
"content": "Fox Ciel has a robot on a 2D plane. Initially it is located in (0, 0). Fox Ciel code a command to it. The command was represented by string s. Each character of s is one move operation. There are four move operations at all: 'U': go up, (x, y) → (x, y+1); 'D': go down, (x, y) → (x, y-1); 'L... | [{"input": "-1000000000 -1000000000\nDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDL\n", "output": "Yes\n"}, {"input": "-1000000000 -1000000000\nDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDL\n", "output": "Yes\n"... | code_stdio |
[
{
"content": "You are given an infinite checkered field. You should get from a square (x1; y1) to a square (x2; y2). Using the shortest path is not necessary. You can move on the field squares in four directions. That is, when you are positioned in any square, you can move to any other side-neighboring one. \n\... | [{"input": "999999999 1000000000 1000000000 -999999999 -1000000000 999999999\n", "output": "1"}, {"input": "101304499 148554333 -590787464 -890180401 -117457421 997140710\n", "output": "12"}, {"input": "1000000000 1000000000 871940474 991768763 -914352281 -886310260\n", "output": "1"}, {"input": "781751245 1100000000 -... | code_stdio |
[
{
"content": "The only difference between easy and hard versions is constraints.\n\nYou are given a sequence $a$ consisting of $n$ positive integers.\n\nLet's define a three blocks palindrome as the sequence, consisting of at most two distinct elements (let these elements are $a$ and $b$, $a$ can be equal $b$) ... | [{"input": "6\n8\n1 1 4 2 1 2 1 1\n3\n1 3 12\n4\n1 10 10 1\n1\n26\n2\n2 4\n3\n2 1 1\n", "output": "6\n1\n4\n1\n1\n2\n"}, {"input": "6\n8\n1 1 2 2 3 2 1 1\n3\n1 3 3\n4\n1 10 10 1\n1\n26\n2\n2 1\n3\n1 1 1\n", "output": "7\n2\n4\n1\n1\n3\n"}, {"input": "6\n8\n1 1 2 2 3 2 1 1\n3\n1 3 3\n4\n1 10 10 1\n1\n26\n2\n2 2\n3\n1 1 ... | code_stdio |
[
{
"content": "Ramesses knows a lot about problems involving trees (undirected connected graphs without cycles)!\n\nHe created a new useful tree decomposition, but he does not know how to construct it, so he asked you for help!\n\nThe decomposition is the splitting the edges of the tree in some simple paths in s... | [{"input": "9\n1 2\n1 3\n1 4\n1 5\n1 6\n6 7\n7 8\n8 9\n", "output": "Yes\n5\n1 2\n1 3\n1 4\n1 5\n1 9\n"}, {"input": "9\n1 2\n2 3\n1 4\n1 5\n1 6\n6 7\n5 8\n7 9\n", "output": "Yes\n4\n1 3\n1 4\n1 8\n1 9\n"}, {"input": "9\n1 2\n2 3\n1 4\n1 8\n1 6\n6 7\n5 8\n7 9\n", "output": "Yes\n4\n1 3\n1 4\n1 5\n1 9\n"}, {"input": "5\n... | code_stdio |
[
{
"content": "A permutation is a sequence of integers from $1$ to $n$ of length $n$ containing each number exactly once. For example, $[1]$, $[4, 3, 5, 1, 2]$, $[3, 2, 1]$ — are permutations, and $[1, 1]$, $[4, 3, 1]$, $[2, 3, 4]$ — no.\n\nPermutation $a$ is lexicographically smaller than permutation $b$ (they ... | [{"input": "5 4\n1 2 5\n2 3\n1 1 3\n1 3 4\n", "output": "14\n7\n9\n"}, {"input": "4 4\n1 2 4\n2 3\n1 1 2\n1 1 4\n", "output": "9\n4\n10\n"}, {"input": "5 4\n1 1 4\n2 5\n1 1 2\n1 3 4\n", "output": "10\n3\n9\n"}, {"input": "5 4\n1 1 4\n2 5\n1 1 1\n1 3 4\n", "output": "10\n1\n9\n"}, {"input": "4 4\n1 1 4\n2 3\n1 1 2\n1 3 ... | code_stdio |
[
{
"content": "Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coord... | [{"input": "25\n-611859852 0\n-611859842 0\n-611859837 0\n-611859843 0\n-611859863 0\n-611859851 0\n-611859857 0\n-611859858 0\n-611859845 0\n-611859865 0\n-611859836 0\n-611859839 0\n-611859850 0\n-611859854 0\n-611859838 0\n-611859840 0\n-611859860 0\n-611859853 0\n-611859848 0\n-611859844 0\n-611859861 0\n-611859856... | code_stdio |
[
{
"content": "Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside.\n\nThe text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ w... | [{"input": "abcdefghijklyyyyyyymnopqrstuvwxabcdefghijklyyyyyyymnopqrstuvwxabcdefghijklyyyyyyymnopqrstuvwxabcdefghijklyyyyyyymnopqrstuvwxabcdefghijklyyyyyyymnopqrstuvwxabcdefghijklzzzzzzzmnopqrstuvwxabcdefghijklzzzzzzzmnopqrstuvwxabcdefghijklzzzzzzzmnopqrstuvwxabcdefghijklzzzzzzzmnopqrstuvwxabcdefghijklzzzzzzzmnopqrstuv... | code_stdio |
[
{
"content": "Koa the Koala has a binary string $s$ of length $n$. Koa can perform no more than $n-1$ (possibly zero) operations of the following form:\n\nIn one operation Koa selects positions $i$ and $i+1$ for some $i$ with $1 \\le i < |s|$ and sets $s_i$ to $max(s_i, s_{i+1})$. Then Koa deletes position $i+1... | [{"input": "0100111100100101001101111001011101011001111100110111101110001001010111100010011100011011101111010111111010010101000001110110111110010001100010101110111111000011101110000000001101010011000111111100000000000000001010011111010111\n", "output": "975171002\n"}, {"input": "0100111100100101001101111001011101011001... | code_stdio |
[
{
"content": "JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $a_1$, $a_2$, ..., $a_n$ of integers, such that $1 \\le a_1 < a_2 < \\ldots < a_n \\le 10^3$, and then went to the bathroom.\n\nJATC decided to prank his friend by erasing some... | [{"input": "100\n901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976... | code_stdio |
[
{
"content": "You have a string of decimal digits s. Let's define b_{ij} = s_{i}·s_{j}. Find in matrix b the number of such rectangles that the sum b_{ij} for all cells (i, j) that are the elements of the rectangle equals a in each rectangle.\n\nA rectangle in a matrix is a group of four integers (x, y, z, t) (... | [{"input": "700\n100101011011001100111101100101000100000000011001111000111110001011011100010110000000000100100000001100000011110011101110011101101110111011011100001001101011000100000000000110001000101001100011111110011010101011010100010100001011011111001011000101001101000111010100110000100100110011111100010111100010000... | code_stdio |
[
{
"content": "We often have to copy large volumes of information. Such operation can take up many computer resources. Therefore, in this problem you are advised to come up with a way to copy some part of a number array into another one, quickly.\n\nMore formally, you've got two arrays of integers a_1, a_2, ...,... | [{"input": "20 30\n5 6 -6 10 10 -6 10 7 0 -20 3 1 -7 -13 1 -7 5 1 -1 1\n2 10 -10 -1 -9 3 9 -9 6 5 10 -2 -5 -14 1 5 -4 -1 -8 -7\n2 14\n1 8 11 1\n2 7\n1 6 11 1\n1 9 2 7\n1 12 1 7\n2 20\n2 5\n1 14 8 3\n1 8 17 4\n2 4\n1 11 12 9\n2 8\n2 3\n2 2\n1 17 13 2\n1 3 18 1\n2 11\n1 5 12 6\n1 12 13 1\n2 16\n2 11\n2 10\n2 19\n2 20\n2 ... | code_stdio |
[
{
"content": "You are given $n$ segments on a Cartesian plane. Each segment's endpoints have integer coordinates. Segments can intersect with each other. No two segments lie on the same line.\n\nCount the number of distinct points with integer coordinates, which are covered by at least one segment.\n\n\n-----In... | [{"input": "10\n841746 527518 -841746 -527518\n595261 331297 -595261 -331297\n-946901 129987 946901 -129987\n670374 -140388 -670374 140388\n-684770 309555 684770 -309555\n-302589 415564 302589 -415564\n-387435 613331 387435 -613331\n-624940 -95922 624940 95922\n945847 -199224 -945847 199224\n24636 -565799 -24636 565799... | code_stdio |
[
{
"content": "Vasya has a string $s$ of length $n$ consisting only of digits 0 and 1. Also he has an array $a$ of length $n$. \n\nVasya performs the following operation until the string becomes empty: choose some consecutive substring of equal characters, erase it from the string and glue together the remaining... | [{"input": "99\n101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1000000000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... | code_stdio |
[
{
"content": "In Japan, people make offerings called hina arare, colorful crackers, on March 3.\nWe have a bag that contains N hina arare. (From here, we call them arare.)\nIt is known that the bag either contains arare in three colors: pink, white and green, or contains arare in four colors: pink, white, green... | [{"input": "100\nP P P G G P P P G G P P G G P G W G W G G G P G P P G P P P G G G P P G P G P P G P P G G G W G G G P P P W G P G G P G G G G G P P W P G G G G G P P G G P G P G G G G P G G G G W P G P P P G G P G P\n", "output": "Three\n"}, {"input": "100\nG G G G G W W W W W W G W G G G W G P W W W W G G W G W G W W... | code_stdio |
[
{
"content": "Takahashi is going to buy N items one by one.\nThe price of the i-th item he buys is A_i yen (the currency of Japan).\nHe has M discount tickets, and he can use any number of them when buying an item.\nIf Y tickets are used when buying an item priced X yen, he can get the item for \\frac{X}{2^Y} (... | [{"input": "7955 99805\n280223699 243184364 149210358 462114945 880243783 898930650 89064311 63969626 29578760 282083932 336425831 645450084 410674240 438196631 429198606 786790252 782175216 882975396 529275843 756821367 312076396 771188495 855523957 734650681 911233499 357477721 909515813 72334495 882955704 862214008 ... | code_stdio |
[
{
"content": "The educational program (AHK Education) of the Aiz Broadcasting Corporation broadcasts a program called \"Play with Tsukuro\" for children. Today is the time to make a box with drawing paper, but I would like to see if the rectangular drawing paper I prepared can make a rectangular parallelepiped.... | [{"input": "2 -1\n2 9\n-1 1\n0 -1\n-1 6\n-1 5", "output": "no\n"}, {"input": "2 -1\n2 6\n-1 1\n0 -1\n-1 6\n-1 5", "output": "no\n"}, {"input": "2 -1\n2 6\n-1 1\n0 -1\n-1 6\n-2 5", "output": "no\n"}, {"input": "2 -1\n2 7\n-1 1\n0 -1\n-1 6\n-2 5", "output": "no\n"}, {"input": "2 -1\n2 7\n-2 1\n0 -1\n-1 6\n-2 5", "output"... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.