messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 1
value |
|---|---|---|
[
{
"content": "There are N towns in the State of Atcoder, connected by M bidirectional roads.\nThe i-th road connects Town A_i and B_i and has a length of C_i.\nJoisino is visiting R towns in the state, r_1,r_2,..,r_R (not necessarily in this order).\nShe will fly to the first town she visits, and fly back from ... | [{"input": "4 6 3\n2 3 4\n1 2 4\n2 3 3\n4 3 1\n1 4 1\n4 2 2\n3 1 6\n", "output": "3\n"}, {"input": "4 6 3\n2 3 4\n1 2 4\n2 3 6\n4 3 1\n1 4 1\n4 2 2\n3 1 6", "output": "3\n"}, {"input": "4 6 3\n2 3 4\n1 2 4\n2 3 6\n4 3 1\n1 4 1\n4 1 2\n3 1 6", "output": "7\n"}, {"input": "4 6 3\n2 3 4\n1 2 4\n2 3 6\n4 4 1\n1 4 1\n4 2 2\... | code_stdio |
[
{
"content": "There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.\n\nInput\n\nThe first line contains an integer n (1 ≤ n ≤ 106). The second ... | [{"input": "30\n2 1 3 2 3 2 2 2 2 3 2 2 3 2 1 1 3 1 3 2 1 2 3 1 1 3 3 1 3 1\n", "output": "19\n"}, {"input": "30\n2 1 3 2 3 2 2 2 2 3 2 2 1 2 1 1 3 1 3 2 1 2 3 1 1 3 3 1 3 1\n", "output": "19\n"}, {"input": "30\n2 1 3 2 3 2 2 2 2 3 2 2 1 2 1 1 3 1 3 2 1 2 3 1 1 3 2 1 3 1\n", "output": "18\n"}, {"input": "30\n2 1 3 2 3 ... | code_stdio |
[
{
"content": "Nowadays it is becoming increasingly difficult to park a car in cities successfully. Let's imagine a segment of a street as long as L meters along which a parking lot is located. Drivers should park their cars strictly parallel to the pavement on the right side of the street (remember that in the ... | [{"input": "50 3 1\n30\n1 9\n2 1\n1 6\n1 5\n1 8\n1 1\n2 6\n1 7\n2 3\n2 8\n1 7\n2 4\n2 5\n2 11\n1 2\n2 15\n1 6\n1 3\n2 17\n1 9\n1 3\n2 18\n1 3\n2 23\n2 21\n1 8\n1 2\n2 27\n1 8\n2 29\n", "output": "0\n0\n9\n17\n28\n28\n0\n0\n0\n9\n15\n0\n6\n0\n11\n27\n"}, {"input": "50 3 2\n30\n1 9\n2 1\n1 6\n1 5\n1 8\n1 1\n2 6\n1 7\n2 3... | code_stdio |
[
{
"content": "You are given two integers a and b. Moreover, you are given a sequence s_0, s_1, ..., s_{n}. All values in s are integers 1 or -1. It's known that sequence is k-periodic and k divides n+1. In other words, for each k ≤ i ≤ n it's satisfied that s_{i} = s_{i - k}.\n\nFind out the non-negative remain... | [{"input": "904132655 827386249 118827660 334\n+++-+++++--+++----+-+-+-+-+--+-+---++--++--++--+-+-+++-+++--+-+-+----+-+-++++-----+--++++------+++-+-+-++-++++++++-+-++-+++--+--++------+--+-+++--++--+---++-++-+-+-++---++-++--+-+-++-+------+-+----+++-+++--+-+-+--+--+--+------+--+---+--+-++--+++---+-+-++--------+-++--++-+-... | code_stdio |
[
{
"content": "Karl is developing a key storage service. Each user has a positive integer key.\n\nKarl knows that storing keys in plain text is bad practice. So, instead of storing a key, he decided to store a fingerprint of a key. However, using some existing fingerprint algorithm looked too boring to him, so h... | [{"input": "100\n1\n3\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n14\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n19\n42\n43\n44\n45\n46\n47\n20\n49\n50\n65\n52\n53\n54\n55\n56\n57\n58\n59\n60\n61\n62\n63\n64\n65\n66\n67\n68\n69\n70\n71\n72\n73\n123\n75\n76\n77\n78\... | code_stdio |
[
{
"content": "Once again Tavas started eating coffee mix without water! Keione told him that it smells awful, but he didn't stop doing that. That's why Keione told his smart friend, SaDDas to punish him! SaDDas took Tavas' headphones and told him: \"If you solve the following problem, I'll return it to you.\" [... | [{"input": "777777777\n", "output": "1022\n"}, {"input": "444444444\n", "output": "511\n"}, {"input": "477477447\n", "output": "728\n"}, {"input": "777744747\n", "output": "996\n"}, {"input": "777777777\n", "output": "1022"}, {"input": "477477447\n", "output": "728"}, {"input": "777744747\n", "output": "996"}, {"input"... | code_stdio |
[
{
"content": "You are given a string $s$, consisting of $n$ letters, each letter is either 'a' or 'b'. The letters in the string are numbered from $1$ to $n$.\n\n$s[l; r]$ is a continuous substring of letters from index $l$ to $r$ of the string inclusive.\n\nA string is called balanced if the number of letters ... | [{"input": "4\n1\na\n6\nabbaba\n6\nabbaba\n9\nbabbabbaa\n", "output": "-1 -1\n1 2\n1 2\n1 2\n"}, {"input": "4\n1\na\n6\nabbaba\n6\nabbaba\n9\nbabbabbaa\n", "output": "-1 -1\n1 2\n1 2\n1 2\n"}, {"input": "4\n1\na\n6\nabbaba\n6\nabbaba\n7\nbabbabbaa\n", "output": "-1 -1\n1 2\n1 2\n1 2\n"}, {"input": "4\n1\na\n6\nababba\n... | code_stdio |
[
{
"content": "There are $n$ players sitting at the card table. Each player has a favorite number. The favorite number of the $j$-th player is $f_j$.\n\nThere are $k \\cdot n$ cards on the table. Each card contains a single integer: the $i$-th card contains number $c_i$. Also, you are given a sequence $h_1, h_2,... | [{"input": "50 1\n995 1815 941 1716 725 1098 747 627 1728 1007 34 1001 679 1742 22 1495 1299 1696 507 631 1971 775 1052 1665 1035 203 1564 1329 1592 1295 983 177 734 1442 172 943 33 486 1078 946 947 592 1524 563 396 1541 1670 326 543 79\n176 214 1601 1758 1468 972 628 1524 1506 425 746 309 387 1761 1002 625 496 1638 18... | code_stdio |
[
{
"content": "Valera runs a 24/7 fast food cafe. He magically learned that next day n people will visit his cafe. For each person we know the arrival time: the i-th person comes exactly at h_{i} hours m_{i} minutes. The cafe spends less than a minute to serve each client, but if a client comes in and sees that ... | [{"input": "50\n0 23\n1 21\n2 8\n2 45\n3 1\n4 19\n4 37\n7 7\n7 40\n8 43\n9 51\n10 13\n11 2\n11 19\n11 30\n12 37\n12 37\n12 37\n12 37\n12 37\n12 37\n12 37\n12 37\n12 54\n13 32\n13 42\n14 29\n14 34\n14 48\n15 0\n15 27\n16 22\n16 31\n17 25\n17 26\n17 33\n18 14\n18 16\n18 20\n19 0\n19 5\n19 56\n20 22\n21 26\n22 0\n22 10\n2... | code_stdio |
[
{
"content": "You have a nuts and lots of boxes. The boxes have a wonderful feature: if you put x (x ≥ 0) divisors (the spacial bars that can divide a box) to it, you get a box, divided into x + 1 sections.\n\nYou are minimalist. Therefore, on the one hand, you are against dividing some box into more than k sec... | [{"input": "1201 495 438 1293\n", "output": "1\n"}, {"input": "241 1202 830 417\n", "output": "1\n"}, {"input": "1201 492 438 690\n", "output": "1\n"}, {"input": "241 1247 830 417\n", "output": "1\n"}, {"input": "1201 495 438 690\n", "output": "1\n"}, {"input": "477 492 438 690\n", "output": "1\n"}, {"input": "461 790 ... | code_stdio |
[
{
"content": "Wabbit is trying to move a box containing food for the rest of the zoo in the coordinate plane from the point $(x_1,y_1)$ to the point $(x_2,y_2)$.\n\nHe has a rope, which he can use to pull the box. He can only pull the box if he stands exactly $1$ unit away from the box in the direction of one o... | [{"input": "5\n1 0 1000000000 1000000000\n1 1 1000000000 1000001100\n1 0 1001000000 1000000000\n1 1 1100010011 1001000000\n2 1 108856 18413\n", "output": "2000000001\n2000001100\n2001000001\n2101010011\n127268\n"}, {"input": "5\n1 0 1000000000 1000000000\n1 1 1001000000 1000001100\n1 0 1001000000 1000000000\n1 1 110001... | code_stdio |
[
{
"content": "You have a permutation: an array $a = [a_1, a_2, \\ldots, a_n]$ of distinct integers from $1$ to $n$. The length of the permutation $n$ is odd.\n\nConsider the following algorithm of sorting the permutation in increasing order.\n\nA helper procedure of the algorithm, $f(i)$, takes a single argumen... | [{"input": "3\n3\n3 2 1\n7\n4 5 7 1 3 2 6\n5\n1 2 3 4 5\n", "output": "3\n5\n0\n"}, {"input": "3\n3\n3 2 1\n7\n4 5 7 1 3 2 6\n5\n1 3 2 4 5\n", "output": "3\n5\n2\n"}, {"input": "3\n3\n2 3 1\n7\n4 5 7 1 3 2 6\n5\n1 2 3 4 5\n", "output": "3\n5\n0\n"}, {"input": "3\n3\n3 2 1\n7\n4 5 6 1 3 2 7\n5\n1 2 3 4 5\n", "output": "... | code_stdio |
[
{
"content": "JAG-channel\n\nNathan O. Davis operates an electronic bulletin board called JAG-channel. He is currently working on adding a new feature called Thread View.\n\nLike many other electronic bulletin boards, JAG-channel is thread-based. Here, a thread refers to a group of conversations consisting of a... | [{"input": "6\nhoge\n.fuga\n..foobar\n..jagjag\n...zigzag\n.piyo\n8\njagjag\n.hogehoge\n..fugafuga\n...ponyoponyo\n....evaeva\n....pokemon\n...nowawa\n.buhihi\n8\nhello\n.goodmorning\n..howareyou\n.goodafternoon\n..letshavealunch\n.goodevening\n.goodnight\n..gotobed\n3\ncaution\n.themessagelengthislessthanorequaltofift... | code_stdio |
[
{
"content": "Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:\n\nGiven two binary numbers $a$ and $b$ of length $n$. How many different ways of swapping two digits in $a$ (only in $a$, not $b$) so that bitwise OR of these two numbers will be changed? ... | [{"input": "30\n011110110100010000011001000100\n110111101001011001100001101101\n", "output": "146\n"}, {"input": "30\n011110110100010000011001000100\n110111101001011001100001101101\n", "output": "146\n"}, {"input": "30\n011110110100010000011001000100\n110111101000011001100001101101\n", "output": "153\n"}, {"input": "30... | code_stdio |
[
{
"content": "One day Dima and Alex had an argument about the price and quality of laptops. Dima thinks that the more expensive a laptop is, the better it is. Alex disagrees. Alex thinks that there are two laptops, such that the price of the first laptop is less (strictly smaller) than the price of the second l... | [{"input": "4\n4 2\n6 1\n2 6\n-2 11\n", "output": "Happy Alex\n"}, {"input": "4\n4 1\n6 2\n2 5\n-1 4\n", "output": "Happy Alex\n"}, {"input": "4\n4 1\n6 2\n2 5\n-2 4\n", "output": "Happy Alex\n"}, {"input": "4\n4 1\n6 2\n2 9\n-2 4\n", "output": "Happy Alex\n"}, {"input": "4\n4 1\n6 1\n2 9\n-2 4\n", "output": "Happy Ale... | code_stdio |
[
{
"content": "You've got string s, consisting of small English letters. Some of the English letters are good, the rest are bad.\n\nA substring s[l...r] (1 ≤ l ≤ r ≤ |s|) of string s = s_1s_2...s_{|}s| (where |s| is the length of string s) is string s_{l}s_{l} + 1...s_{r}.\n\nThe substring s[l...r] is good, i... | [{"input": "dcijflpluxgeqlroaktzcujfaaidnrdzgogzhobhsmbwmjpschtvjmivfapddsmxfvlhhgguymgtdjxpiezbnlmnlvdnuaohqskdbcjlyfdrzicflveffvpeyzhwqqdaenbsghuvetpxvqcutjxbelbfzuqpwlfvveebnmkoryxgodpccanzwhziiiumgtwskxhrhwdkwmyreefwmoedcvaokvetcgundyiidsqkolpqkarpszrrmagrfvpnwharotashtwcnrcnhapdwrbltgkpkkmlrpapfizonyttrikh\n110110... | code_stdio |
[
{
"content": "The new PIN is hard to remember. I was told that I shouldn't take notes, but I don't think I can remember them. Therefore, I decided to embed a numerical value in the text and make a note of the PIN. Here, the sum of all the numbers is the PIN.\n\nCreate a program that reads the memorandum and out... | [{"input": "Thereare100yenonthetable.Iam17yearsold.\n.mp6taemohogdluohsI", "output": "123\n"}, {"input": "Thergarn100yeeontgesable-Iam17ye`rsolc.\nIshptkogdhomemt5q`.", "output": "122\n"}, {"input": "Thereare100yenonthetable.Iam17ye`rsold.\n.mp6taemohogdluohsI", "output": "123\n"}, {"input": "Thereare100yenonthesable.I... | code_stdio |
[
{
"content": "An array is called beautiful if all the elements in the array are equal.\n\nYou can transform an array using the following steps any number of times: \n\n 1. Choose two indices i and j (1 ≤ i,j ≤ n), and an integer x (1 ≤ x ≤ a_i). Let i be the source index and j be the sink index. \n 2. Decreas... | [{"input": "5\n0 11 12 13 14\n", "output": "\n120"}, {"input": "5\n0 12 1 13 14\n", "output": "24\n"}, {"input": "5\n1 3 0 13 48\n", "output": "120\n"}, {"input": "5\n1 18 2 13 26\n", "output": "24\n"}, {"input": "5\n0 11 14 13 14\n", "output": "0\n"}, {"input": "5\n-1 20 2 13 14\n", "output": "0\n"}, {"input": "5\n0 1... | code_stdio |
[
{
"content": "You are given a sequence of numbers a_1, a_2, ..., a_{n}, and a number m.\n\nCheck if it is possible to choose a non-empty subsequence a_{i}_{j} such that the sum of numbers in this subsequence is divisible by m.\n\n\n-----Input-----\n\nThe first line contains two numbers, n and m (1 ≤ n ≤ 10^6, 2... | [{"input": "100 968\n966 966 967 966 967 967 967 967 966 1446 966 967 966 966 966 967 967 966 966 967 967 967 967 966 967 967 967 967 563 967 967 967 600 967 967 966 967 1750 967 966 967 966 967 966 966 966 967 966 967 966 966 967 967 193 966 966 967 966 1294 967 967 966 967 966 966 580 966 967 966 966 967 966 966 966 ... | code_stdio |
[
{
"content": "There is a grass field that stretches infinitely.\nIn this field, there is a negligibly small cow. Let (x, y) denote the point that is x\\ \\mathrm{cm} south and y\\ \\mathrm{cm} east of the point where the cow stands now. The cow itself is standing at (0, 0).\nThere are also N north-south lines a... | [{"input": "1000 1000\n-994461514 -985306778 -517708279\n-994461514 -985306778 -232175991\n-991585642 -983349857 -817377920\n-991585642 -983349857 -769081289\n-983107981 -980980057 -973401374\n-997908939 -980980057 -857139401\n-978282897 -966923595 -81201061\n-997908939 -966923595 45414533\n-962515169 -962345576 -98681... | code_stdio |
[
{
"content": "According to rules of the Berland fashion, a jacket should be fastened by all the buttons except only one, but not necessarily it should be the last one. Also if the jacket has only one button, it should be fastened, so the jacket will not swinging open.\n\nYou are given a jacket with n buttons. D... | [{"input": "231\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 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... | code_stdio |
[
{
"content": "We have a grid with H rows and W columns. At first, all cells were painted white.\nSnuke painted N of these cells. The i-th ( 1 \\leq i \\leq N ) cell he painted is the cell at the a_i-th row and b_i-th column.\nCompute the following:\n - For each integer j ( 0 \\leq j \\leq 9 ), how many subrecta... | [{"input": "10 28 20\n0 1\n2 4\n1 9\n2 5\n0 6\n4 1\n1 7\n5 9\n6 4\n6 6\n6 5\n2 2\n10 3\n7 8\n16 1\n3 5\n11 10\n10 5\n17 4\n4 7", "output": "152\n28\n18\n10\n0\n0\n0\n0\n0\n0\n"}, {"input": "10 28 20\n0 1\n2 4\n1 9\n2 5\n0 6\n4 1\n1 7\n5 9\n6 4\n6 6\n6 5\n2 2\n10 1\n7 8\n16 1\n3 5\n11 10\n10 5\n17 4\n4 7", "output": "15... | code_stdio |
[
{
"content": "Snuke is interested in strings that satisfy the following conditions:\n\n* The length of the string is at least N.\n* The first N characters equal to the string s.\n* The last N characters equal to the string t.\n\n\n\nFind the length of the shortest string that satisfies the conditions.\n\nConstr... | [{"input": "4\nexpr\nexpq", "output": "8\n"}, {"input": "4\nexpr\nrxep", "output": "7\n"}, {"input": "4\nexpr\nepxq", "output": "8\n"}, {"input": "4\nexpr\npexq", "output": "8\n"}, {"input": "4\nexpr\nqxep", "output": "8\n"}, {"input": "4\nexqr\nrxep", "output": "7\n"}, {"input": "4\nexqr\nrxeo", "output": "7\n"}, {"in... | code_stdio |
[
{
"content": "Furik loves writing all sorts of problems, especially such that he can't solve himself. You've got one of his problems, the one Furik gave to Rubik. And Rubik asks you to solve it.\n\nThere is integer n and array a, consisting of ten integers, indexed by numbers from 0 to 9. Your task is to count ... | [{"input": "100\n100 100 100 100 100 100 100 100 100 100\n", "output": "0\n"}, {"input": "100\n100 100 100 100 100 100 100 100 101 100\n", "output": "0\n"}, {"input": "82\n100 100 100 100 100 100 100 100 100 100\n", "output": "0\n"}, {"input": "55\n100 100 100 100 100 100 100 100 100 100\n", "output": "0\n"}, {"input":... | code_stdio |
[
{
"content": "There are two sisters Alice and Betty. You have $n$ candies. You want to distribute these $n$ candies between two sisters in such a way that: Alice will get $a$ ($a > 0$) candies; Betty will get $b$ ($b > 0$) candies; each sister will get some integer number of candies; Alice will get a greate... | [{"input": "98\n710\n896\n635\n909\n528\n799\n184\n970\n731\n285\n481\n62\n829\n815\n204\n927\n48\n958\n858\n549\n722\n900\n290\n96\n414\n323\n488\n140\n494\n286\n783\n551\n896\n580\n722\n766\n841\n914\n200\n170\n384\n664\n14\n203\n582\n203\n678\n502\n677\n318\n189\n144\n97\n330\n169\n20\n492\n233\n198\n876\n697\n691\n... | code_stdio |
[
{
"content": "Andrey's favourite number is n. Andrey's friends gave him two identical numbers n as a New Year present. He hung them on a wall and watched them adoringly.\n\nThen Andrey got bored from looking at the same number and he started to swap digits first in one, then in the other number, then again in t... | [{"input": "10802611971893001160947949048137125257663360973350362557151889546818281691354280360512029669737944667993533147136817951837479019430773307929092792540144287240690218353482990299029694493198951486742073494255017372881972567810450854959208991586907060759736152497682999322253656832611644507455595270340103399952... | code_stdio |
[
{
"content": "Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit... | [{"input": "100\n1 1 0 0 1 1 1 1 0 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 0 1 0 0 0 0 1 1 1 1 0 0 1 0 0 1 1 0 1 1 1 1 1 1 0 0 0 0 1 1 0 0 0 0 0 1 1 0 1 0 0 1 0 0 1 0 1 0 0 0 0 1 0 1 1 0 1 1 1 1 0 0 1 1 0 0 0 0 1 1 1 0 0 1 0 0\n", "output": "1446"}, {"input": "50\n1 1 0 1 1 1 1 1 1 0 0 1 1 0 1 1 0 0 1 0 1 1 0 1 1 1 1 0 1 0 1 1 1... | code_stdio |
[
{
"content": "Mayor of city S just hates trees and lawns. They take so much space and there could be a road on the place they occupy!\n\nThe Mayor thinks that one of the main city streets could be considerably widened on account of lawn nobody needs anyway. Moreover, that might help reduce the car jams which ha... | [{"input": "10\n21005 10850\n27020 13372\n28183 3724\n22874 13564\n27446 11493\n22522 10012\n24819 11529\n24166 11084\n24539 9211\n24152 9235\n", "output": "71869\n31855 31856 31857 31858 31859 31860 31861 31862 31863 31864 \n"}, {"input": "10\n21005 10850\n27020 13372\n28183 3724\n22874 13564\n27446 11493\n22522 10012... | code_stdio |
[
{
"content": "Jeff got 2n real numbers a1, a2, ..., a2n as a birthday present. The boy hates non-integer numbers, so he decided to slightly \"adjust\" the numbers he's got. Namely, Jeff consecutively executes n operations, each of them goes as follows:\n\n * choose indexes i and j (i ≠ j) that haven't been cho... | [{"input": "10\n8003.867 4368.000 2243.298 3340.000 5384.489 1036.000 3506.115 4463.317 1477.000 2420.314 9391.186 1696.000 5857.833 244.314 8220.000 5879.647 5424.482 2631.000 7111.130 9157.536\n", "output": "0.472\n"}, {"input": "10\n8003.000 4368.194 2243.000 3340.287 5384.000 1036.456 3506.000 4463.000 1477.787 242... | code_stdio |
[
{
"content": "There are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies.\nYou will take out the candies from some consecutive boxes and distribute them evenly to M children.\nSuch being the case, find the number of the pairs (l, r) that satisfy the following:\n - l ... | [{"input": "43535 7\n5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1 5 1 1... | code_stdio |
[
{
"content": "Joisino has a formula consisting of N terms: A_1 op_1 A_2 ... op_{N-1} A_N. Here, A_i is an integer, and op_i is an binary operator either `+` or `-`. Because Joisino loves large numbers, she wants to maximize the evaluated value of the formula by inserting an arbitrary number of pairs of parenthe... | [{"input": "5\n2 - 159 - 13 + 21 - 5", "output": "-118\n"}, {"input": "5\n1 - 157 - 13 + 14 - 5", "output": "-124\n"}, {"input": "5\n2 - 119 - 13 + 14 - 5", "output": "-85\n"}, {"input": "5\n2 - 119 - 13 + 19 - 5", "output": "-80\n"}, {"input": "5\n1 - 119 - 13 + 19 - 5", "output": "-81\n"}, {"input": "5\n1 - 119 - 13 ... | code_stdio |
[
{
"content": "Some time ago Lesha found an entertaining string $s$ consisting of lowercase English letters. Lesha immediately developed an unique algorithm for this string and shared it with you. The algorithm is as follows.\n\nLesha chooses an arbitrary (possibly zero) number of pairs on positions $(i, i + 1)$... | [{"input": "ggaaaawwwxxxxxxrrrrrrrrwwwwwwwwggggggggjjusszzzzqqqqqsssssssbbwwwwwwmmmmtttttttvvvvvvvvssssppppppggggsrrrrrrzzzzzzzyyyyyccccccchhhhhhhhjjrrrrhhhhhhhheeeeeeeaaaaaaaiiiiiuuuuuuuvvvvvjjjjjjjjffbbbbbbbbrrrrrllllllllggggggggooooollssvvvvvvvvvvnnnnnnnnuuuuuuuucccccyyyyyyyyyyzzzzzzzkkkkuuuuuunnnnnnnqnnnnnnggggdddd... | code_stdio |
[
{
"content": "Unlucky year in Berland is such a year that its number n can be represented as n = x^{a} + y^{b}, where a and b are non-negative integer numbers. \n\nFor example, if x = 2 and y = 3 then the years 4 and 17 are unlucky (4 = 2^0 + 3^1, 17 = 2^3 + 3^2 = 2^4 + 3^0) and year 18 isn't unlucky as there i... | [{"input": "433333986179614514 1000000000000000000 433333986179614515 726628630292055493\n", "output": "293294644112440978\n"}, {"input": "433333986179614514 1000001000000000000 433333986179614515 726628630292055493\n", "output": "293294644112440978\n"}, {"input": "239838434825939759 805278168279318096 2023378499191046... | code_stdio |
[
{
"content": "A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the start time l_{i} and the finish time r_{i} (l_{i} ≤ r_{i}).\n\nRestaurant management can accept and reject orders. What ... | [{"input": "20\n22 77\n13 50\n55 64\n16 52\n67 96\n49 51\n59 95\n2 25\n69 91\n2 24\n4 46\n50 74\n45 106\n39 55\n31 33\n9 33\n6 72\n14 67\n56 98\n69 152\n", "output": "5\n"}, {"input": "20\n22 77\n13 50\n55 64\n16 52\n62 96\n49 51\n59 95\n2 25\n69 91\n2 24\n4 46\n50 74\n45 106\n39 55\n31 33\n9 33\n6 72\n14 67\n56 98\n69... | code_stdio |
[
{
"content": "The new ITone 6 has been released recently and George got really keen to buy it. Unfortunately, he didn't have enough money, so George was going to work as a programmer. Now he faced the following problem at the work.\n\nGiven a sequence of n integers p_1, p_2, ..., p_{n}. You are to choose k pair... | [{"input": "141 12 6\n66 53 86 91 12 27 5 74 79 50 33 2 100 26 2 73 16 14 50 86 75 9 66 48 19 34 25 1 22 50 63 39 38 42 98 71 76 27 80 16 74 21 36 1 32 20 65 28 68 40 41 6 0 77 65 84 0 34 60 0 42 65 2 16 25 85 35 57 74 66 26 33 39 14 0 6 2 15 87 99 47 67 75 63 72 32 93 7 5 63 35 99 89 61 18 25 76 5 39 80 37 17 78 23 61... | code_stdio |
[
{
"content": "You are given n integers a_1, a_2, …, a_n and an integer k. Find the maximum value of i ⋅ j - k ⋅ (a_i | a_j) over all pairs (i, j) of integers with 1 ≤ i < j ≤ n. Here, | is the [bitwise OR operator](https://en.wikipedia.org/wiki/Bitwise_operation#OR).\n\nInput\n\nThe first line contains a single... | [{"input": "4\n3 3\n1 1 3\n2 2\n2 2\n4 3\n0 1 2 3\n6 6\n3 2 0 0 5 6\n", "output": "-1\n-2\n3\n12\n"}, {"input": "4\n3 3\n1 1 3\n2 2\n0 2\n4 3\n0 1 2 3\n6 6\n3 2 0 0 5 6\n", "output": "-1\n-2\n3\n12\n"}, {"input": "4\n3 3\n1 1 3\n2 2\n0 2\n4 3\n0 1 2 3\n6 9\n3 2 0 0 5 6\n", "output": "-1\n-2\n3\n12\n"}, {"input": "4\n3 ... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian as well. \n\nMike likes strings. He is also interested in algorithms. A few days ago he discovered for himself a very nice problem:\n\nYou are given an AB-string S. You need to count the number of substrings of S, which have an equal number ... | [{"input": "ABACABA\n", "output": "2\n"}, {"input": "ABBCABA", "output": "2\n"}, {"input": "ABABBBA", "output": "0\n"}, {"input": "@BABBBA", "output": "1\n"}, {"input": "@BABCBA", "output": "3\n"}, {"input": "AB@BCAB", "output": "4\n"}, {"input": "BCABACB", "output": "6\n"}, {"input": "ABCBACB", "output": "5\n"}, {"inp... | code_stdio |
[
{
"content": "Two players decided to play one interesting card game.\n\nThere is a deck of $n$ cards, with values from $1$ to $n$. The values of cards are pairwise different (this means that no two different cards have equal values). At the beginning of the game, the deck is completely distributed between playe... | [{"input": "2\n2 1 1\n2\n-1\n5 2 3\n1 3\n2 11 5\n", "output": "YES\nNO\n"}, {"input": "2\n2 1 1\n2\n-1\n5 2 3\n2 3\n2 2 5\n", "output": "YES\nNO\n"}, {"input": "2\n2 1 1\n2\n1\n5 2 3\n2 3\n-1 6 5\n", "output": "YES\nNO\n"}, {"input": "2\n2 1 1\n2\n-1\n5 2 3\n2 3\n3 2 5\n", "output": "YES\nNO\n"}, {"input": "2\n2 1 1\n2... | code_stdio |
[
{
"content": "Today, Snuke will eat B pieces of black chocolate and W pieces of white chocolate for an afternoon snack.\n\nHe will repeat the following procedure until there is no piece left:\n\n* Choose black or white with equal probability, and eat a piece of that color if it exists.\n\n\n\nFor each integer i... | [{"input": "69 1", "output": "500000004\n750000006\n875000007\n437500004\n718750006\n859375007\n429687504\n714843756\n857421882\n928710945\n464355473\n232177737\n116088869\n58044435\n29022218\n514511113\n257255557\n128627779\n64313890\n532156949\n266078475\n133039238\n566519623\n283259812\n641629910\n820814959\n4104074... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nRecently Chef has decided to make some changes in our beloved Codechef. As you know, each problem at Codechef has its memory and time limits. To make problems even more challenging, he decided to measure allocated memory in a different... | [{"input": "3\n2\n0 4\n5\n0 2 10 2 3\n3\n1 1 1", "output": "4\n11\n1\n"}, {"input": "3\n2\n2 2\n5\n0 0 11 4 3\n3\n0 3 0", "output": "2\n11\n3\n"}, {"input": "3\n2\n0 2\n5\n1 2 12 2 3\n3\n1 0 1", "output": "2\n13\n2\n"}, {"input": "3\n2\n2 2\n5\n0 2 12 4 3\n3\n1 0 1", "output": "2\n12\n2\n"}, {"input": "3\n2\n3 12\n5\n0... | code_stdio |
[
{
"content": "Example\n\nInput\n\n3\naab\nczc\nbaa\n\n\nOutput\n\naac\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to stdout. Enclose your complete solution in a single ```python code block.",
"role": "user"
}
] | [{"input": "3\naab\nccz\nbaa", "output": "aac\n"}, {"input": "3\nbba\nzcc\nbaa", "output": "aaz\n"}, {"input": "3\nabb\nzbc\nbaa", "output": "aab\n"}, {"input": "3\nbbb\nzcd\nbaa", "output": "abc\n"}, {"input": "3\nabb\ncyc\nbba", "output": "aay\n"}, {"input": "3\nbba\nzbc\nbba", "output": "abb\n"}, {"input": "3\nbbb\n... | code_stdio |
[
{
"content": "Let's call an array consisting of n integer numbers a_1, a_2, ..., a_{n}, beautiful if it has the following property:\n\n consider all pairs of numbers x, y (x ≠ y), such that number x occurs in the array a and number y occurs in the array a; for each pair x, y must exist some position j (1 ≤ j ... | [{"input": "58 38\n6384 48910\n97759 90589\n28947 5031\n45169 32592\n85656 26360\n88538 42484\n44042 88351\n42837 79021\n96022 59200\n485 96735\n98000 3939\n3789 64468\n10894 58484\n26422 26618\n25515 95617\n37452 5250\n39557 66304\n79009 40610\n80703 60486\n90344 37588\n57504 61201\n62619 79797\n51282 68799\n15158 276... | code_stdio |
[
{
"content": "A string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n - S is a palindrome.\n - Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n - The string consisting of the (N+3... | [{"input": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\n", "output": "Yes\n"}, {"input": "kszhkbpphykinkezplvfjaqmpmqajfvlpzeknikyhppbkhzskokszhkbpphykinkezplvfjaqmpmqajfvlpzeknikyhppbkhzsk\n", "output": "Yes\n"}, {"input": "avtvnrdyluacvrayggwnpnzidiznpnwggyarvc... | code_stdio |
[
{
"content": "Everyone loves a freebie. Especially students.\n\nIt is well-known that if in the night before exam a student opens window, opens the student's record-book and shouts loudly three times \"Fly, freebie, fly!\" — then flown freebie helps him to pass the upcoming exam.\n\nIn the night before the exam... | [{"input": "100\n98 63 672 100 254 218 623 415 426 986 920 915 736 795 407 541 382 213 935 743 961 59 660 512 134 935 248 378 739 356 543 714 28 667 602 596 759 791 103 564 225 520 159 542 966 332 983 655 517 273 95 242 593 940 286 236 41 318 941 727 384 225 319 627 982 359 232 769 854 172 643 598 215 231 305 30 347 46... | code_stdio |
[
{
"content": "Write a program which print coordinates $(x_i, y_i)$ of given $n$ points on the plane by the following criteria.\n\n1. first by $x$-coordinate\n2. in case of a tie, by $y$-coordinate\n\nConstraints\n\n* $1 \\leq n \\leq 100,000$\n* $-1,000,000,000 \\leq x_i, y_i \\leq 1,000,000,000$\n\nInput\n\nTh... | [{"input": "5\n-1 3\n1 15\n-1 1\n-1 -1\n-1 -1", "output": "-1 -1\n-1 -1\n-1 1\n-1 3\n1 15\n"}, {"input": "5\n-1 3\n1 15\n-1 0\n-1 -1\n-1 -1", "output": "-1 -1\n-1 -1\n-1 0\n-1 3\n1 15\n"}, {"input": "5\n-1 3\n1 22\n-1 0\n-1 -1\n-1 -1", "output": "-1 -1\n-1 -1\n-1 0\n-1 3\n1 22\n"}, {"input": "5\n-1 5\n1 22\n-1 0\n-1 -1... | code_stdio |
[
{
"content": "Motorist Kojiro spent 10 years saving up for his favorite car brand, Furrari. Finally Kojiro's dream came true! Kojiro now wants to get to his girlfriend Johanna to show off his car to her.\n\nKojiro wants to get to his girlfriend, so he will go to her along a coordinate line. For simplicity, we c... | [{"input": "386 20 29 30\n1 349\n2 482\n1 112\n1 93\n2 189\n1 207\n2 35\n2 -5\n1 422\n1 442\n1 402\n2 238\n3 258\n3 54\n2 369\n2 290\n2 329\n3 74\n3 -62\n2 170\n1 462\n2 15\n2 222\n1 309\n3 150\n1 -25\n3 130\n1 271\n1 -43\n351 250 91 102 0 286 123 93 100 205 328 269 188 83 73 35 188 223 73 215 199 64 47 379 61 298 295 ... | code_stdio |
[
{
"content": "There are N cities. There are also K roads and L railways, extending between the cities. The i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities. No two roads connect the same pair of cities. Similarly, no two ... | [{"input": "25 4 4\n1 2\n3 3\n2 5\n6 7\n3 5\n4 3\n3 4\n6 7", "output": "1 1 1 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n"}, {"input": "27 0 1\n0 0\n2 10\n3 -1\n1 0", "output": "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n"}, {"input": "23 3 0\n-4 2\n2 4\n3 4\n10 5", "output": "1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... | code_stdio |
[
{
"content": "Vasily the bear has got a sequence of positive integers a_1, a_2, ..., a_{n}. Vasily the Bear wants to write out several numbers on a piece of paper so that the beauty of the numbers he wrote out was maximum. \n\nThe beauty of the written out numbers b_1, b_2, ..., b_{k} is such maximum non-negati... | [{"input": "39\n37749932 37750076 37750391 37750488 37750607 37750812 37750978 37751835 37752173 37752254 75497669 75497829 75497852 75498044 75498061 75498155 75498198 75498341 75498382 75498465 150994988 150994989 150995009 150995019 150995024 150995030 150995031 150995069 150995072 805306369 805306373 805306375 8053... | code_stdio |
[
{
"content": "A string t is called an anagram of the string s, if it is possible to rearrange letters in t so that it is identical to the string s. For example, the string \"aab\" is an anagram of the string \"aba\" and the string \"aaa\" is not.\n\nThe string t is called a substring of the string s if it can b... | [{"input": "??fb???a??\ndeeefc\n", "output": "0\n"}, {"input": "??fb???a??\ndedefc\n", "output": "0\n"}, {"input": "??fb???a??\ndedefd\n", "output": "0\n"}, {"input": "??a???bf??\ndedefd\n", "output": "0\n"}, {"input": "??fb?a????\ndeeefc\n", "output": "0\n"}, {"input": "??a???bf??\ndedefc\n", "output": "0\n"}, {"input... | code_stdio |
[
{
"content": "Today is August 24, one of the five Product Days in a year.\n\nA date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day):\n\n* d_... | [{"input": "15 38", "output": "10\n"}, {"input": "16 38", "output": "11\n"}, {"input": "16 57", "output": "16\n"}, {"input": "16 94", "output": "19\n"}, {"input": "12 94", "output": "12\n"}, {"input": "26 38", "output": "15\n"}, {"input": "24 94", "output": "31\n"}, {"input": "14 68", "output": "13\n"}, {"input": "31 4... | code_stdio |
[
{
"content": "Scheme? - Too loudly said. Just a new idea. Now Chef is expanding his business. He wants to make some new restaurants in the big city of Lviv. To make his business competitive he should interest customers. Now he knows how. But don't tell anyone - it is a secret plan. Chef knows four national Ukr... | [{"input": "3\n17\n7\n20", "output": "129140160\n2184\n486784383\n"}, {"input": "3\n19\n7\n21", "output": "162261457\n2184\n460353130\n"}, {"input": "3\n12\n13\n11", "output": "531444\n1594320\n177144\n"}, {"input": "3\n17\n7\n12", "output": "129140160\n2184\n531444\n"}, {"input": "3\n17\n7\n11", "output": "129140160\n... | code_stdio |
[
{
"content": "Permutation p is an ordered set of integers p_1, p_2, ..., p_{n}, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as p_{i}. We'll call number n the size or the length of permutation p_1, p_2, ..., p_{n}.\n\nPetya decid... | [{"input": "011\n", "output": "890786230\n"}, {"input": "13\n", "output": "695720788\n"}, {"input": "15\n", "output": "150347555\n"}, {"input": "11\n", "output": "890786230\n"}, {"input": "11\n", "output": "890786230\n"}, {"input": "15\n", "output": "150347555\n"}, {"input": "13\n", "output": "695720788\n"}, {"input": ... | code_stdio |
[
{
"content": "You are given an array of n positive integers a_1, a_2, …, a_n. Your task is to calculate the number of arrays of n positive integers b_1, b_2, …, b_n such that: \n\n * 1 ≤ b_i ≤ a_i for every i (1 ≤ i ≤ n), and \n * b_i ≠ b_{i+1} for every i (1 ≤ i ≤ n - 1). \n\n\n\nThe number of such arrays ca... | [{"input": "100\n23 39 20 46 127 72 41 70 37 18 8 40 24 61 12 79 51 148 61 66 85 97 78 14 70 47 100 40 15 40 23 52 19 30 6 91 82 56 10 6 68 24 97 61 31 136 18 45 88 6 37 38 51 86 37 42 66 30 79 56 50 14 61 18 24 20 57 3 93 15 24 74 32 21 71 93 4 66 20 82 75 10 86 108 30 31 6 49 15 33 100 35 1 96 161 63 29 21 41 22\n", ... | code_stdio |
[
{
"content": "You are given an array consisting of $n$ integers $a_1$, $a_2$, ..., $a_n$. Initially $a_x = 1$, all other elements are equal to $0$.\n\nYou have to perform $m$ operations. During the $i$-th operation, you choose two indices $c$ and $d$ such that $l_i \\le c, d \\le r_i$, and swap $a_c$ and $a_d$.... | [{"input": "9\n100 50 6\n1 49\n51 100\n40 60\n30 70\n20 30\n70 80\n100 1 11\n1 1\n1 1\n1 1\n2 2\n2 100\n1 4\n2 3\n3 7\n5 6\n6 100\n4 5\n1 1 5\n1 1\n1 1\n1 1\n1 1\n1 1\n11 6 4\n6 6\n1 5\n7 11\n6 6\n3 3 2\n1 2\n2 3\n1000000000 1 1\n1 1000000000\n1000000000 1 1\n1 999999999\n1000000000 1 1\n2 1000000000\n1000000000 2 1\n1... | code_stdio |
[
{
"content": "Write a program which identifies the number of combinations of three integers which satisfy the following conditions:\n\n* You should select three distinct integers from 1 to n.\n* A total sum of the three integers is x.\n\n\n\nFor example, there are two combinations for n = 5 and x = 9.\n\n* 1 + ... | [{"input": "37 49\n0 0", "output": "151\n"}, {"input": "13 14\n0 0", "output": "10\n"}, {"input": "16 22\n0 0", "output": "26\n"}, {"input": "20 20\n0 0", "output": "24\n"}, {"input": "19 22\n0 0", "output": "30\n"}, {"input": "20 32\n0 0", "output": "45\n"}, {"input": "20 48\n0 0", "output": "12\n"}, {"input": "12 22\... | code_stdio |
[
{
"content": "Luba thinks about watering her garden. The garden can be represented as a segment of length k. Luba has got n buckets, the i-th bucket allows her to water some continuous subsegment of garden of length exactly a_{i} each hour. Luba can't water any parts of the garden that were already watered, als... | [{"input": "100 100\n2 46 24 18 86 90 31 38 84 49 58 28 15 80 14 24 87 56 62 87 41 87 55 71 87 32 41 56 91 32 24 75 43 42 35 30 72 53 31 26 54 61 87 85 36 75 44 31 7 38 77 57 61 54 70 77 45 96 39 57 11 8 91 42 52 15 42 30 92 41 27 26 34 27 3 80 32 86 26 97 63 91 30 75 14 7 19 23 45 11 8 43 44 73 11 56 3 55 63 16\n", "o... | code_stdio |
[
{
"content": "Little Artem has invented a time machine! He could go anywhere in time, but all his thoughts of course are with computer science. He wants to apply this time machine to a well-known data structure: multiset.\n\nArtem wants to create a basic multiset of integers. He wants these structure to support... | [{"input": "10\n1 1 1000000000\n1 4 1000000000\n2 2 1000000000\n1 5 1000000000\n1 8 1000000000\n2 15 1000000000\n3 3 1000000000\n3 10 1000000000\n3 6 1000000000\n3 7 1000000000\n", "output": "0\n3\n2\n2\n"}, {"input": "10\n1 1 1000000000\n1 4 1000000000\n2 2 1000000000\n1 5 1000000000\n1 8 1000000000\n2 15 1000000000\n... | code_stdio |
[
{
"content": "Little boy Gerald studies at school which is quite far from his house. That's why he has to go there by bus every day. The way from home to school is represented by a segment of a straight line; the segment contains exactly n + 1 bus stops. All of them are numbered with integers from 0 to n in the... | [{"input": "68 74\n51 54\n3 22\n12 24\n3 27\n32 42\n36 55\n60 64\n1 4\n4 23\n11 64\n54 62\n50 56\n21 34\n27 63\n15 54\n28 61\n13 57\n39 53\n12 32\n32 40\n33 67\n55 61\n33 67\n30 37\n15 49\n27 45\n21 41\n8 42\n24 63\n40 48\n28 41\n30 67\n0 4\n7 15\n27 59\n60 62\n25 65\n30 31\n38 67\n24 43\n14 64\n26 46\n8 12\n34 41\n32 ... | code_stdio |
[
{
"content": "Vasya learns to type. He has an unusual keyboard at his disposal: it is rectangular and it has n rows of keys containing m keys in each row. Besides, the keys are of two types. Some of the keys have lowercase Latin letters on them and some of the keys work like the \"Shift\" key on standard keyboa... | [{"input": "10 10 2\nfriuxvShvg\nerslojqtgu\nzeqsmdewry\nwvhbeeyeSu\ngkofbjaavr\ntwkcdxugps\nnzlylSmafu\nstamkpxnzt\nuwxwximkrm\nmzxyboazbl\n100\nmRIfAtrLKmztpVkAmojDCiIgseBwlUilBIiyDQhqNhNAqVLLIobuCIretLdSvixNNdCiouFMXtwHZFlObCeaygmIiFBfaCirbmCa\n", "output": "19\n"}, {"input": "10 10 1\nmgziiihbkq\niobjknuogh\nvntwah... | code_stdio |
[
{
"content": "The Hedgehog likes to give presents to his friend, but no less he likes to receive them.\n\nHaving received another present today, the Hedgehog suddenly understood that he has no place to put it as there was no room left on the special shelf in the cupboard. He will have to choose another shelf, b... | [{"input": "350 22\n73 1 4 8 10 14 16 19 28 37 41 42 43 55 56 64 66 67 79 80 84 87 96 99 101 103 119 120 121 122 127 128 135 141 142 143 148 156 159 160 161 166 167 169 173 189 201 202 205 219 223 227 233 242 243 244 250 257 260 262 263 264 273 291 301 302 305 306 307 314 326 336 342 345\n", "output": "73\n"}, {"input"... | code_stdio |
[
{
"content": "City X consists of n vertical and n horizontal infinite roads, forming n × n intersections. Roads (both vertical and horizontal) are numbered from 1 to n, and the intersections are indicated by the numbers of the roads that form them.\n\nSand roads have long been recognized out of date, so the dec... | [{"input": "9\n4 5\n2 3\n8 3\n5 6\n9 3\n4 4\n5 4\n4 7\n1 7\n8 4\n1 4\n1 5\n5 7\n7 8\n7 1\n9 9\n8 7\n7 5\n3 7\n6 6\n7 3\n5 2\n3 6\n7 4\n9 6\n5 8\n9 7\n6 3\n7 9\n1 2\n1 1\n6 2\n5 3\n7 2\n1 6\n4 1\n6 1\n8 9\n2 2\n3 9\n2 9\n7 7\n2 8\n9 4\n2 5\n8 6\n3 4\n2 1\n2 7\n6 5\n9 1\n3 3\n3 8\n5 5\n4 3\n3 1\n1 9\n6 4\n3 2\n6 8\n2 6\n... | code_stdio |
[
{
"content": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Ima... | [{"input": "mmmmmmmmmmmmmmmm\n", "output": "NIE\n"}, {"input": "mmmmmmmmmmmmmmmm\n", "output": "NIE\n"}, {"input": "mmmmmmmmmmmmmmmn\n", "output": "NIE\n"}, {"input": "nnnnnnnnnnnnn\n", "output": "NIE\n"}, {"input": "nnnnnnnnnnnnn\n", "output": "NIE\n"}, {"input": "onnnnnnnnnnnn\n", "output": "NIE\n"}, {"input": "AAAAN... | code_stdio |
[
{
"content": "You have a team of N people. For a particular task, you can pick any non-empty subset of people. The cost of having x people for the task is x^{k}. \n\nOutput the sum of costs over all non-empty subsets of people.\n\n\n-----Input-----\n\nOnly line of input contains two integers N (1 ≤ N ≤ 10^9) re... | [{"input": "1000000000 5000\n", "output": "642932262\n"}, {"input": "1000000000 5000\n", "output": "642932262\n"}, {"input": "158260522 4575\n", "output": "875142289\n"}, {"input": "602436426 4445\n", "output": "582490088\n"}, {"input": "262703497 2202\n", "output": "813734619\n"}, {"input": "971407775 4325\n", "output... | code_stdio |
[
{
"content": "You are given a polynomial of degree N with integer coefficients: f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0. Find all prime numbers p that divide f(x) for every integer x.\n\nConstraints\n\n* 0 \\leq N \\leq 10^4\n* |a_i| \\leq 10^9(0\\leq i\\leq N)\n* a_N \\neq 0\n* All values in input are integers.\n\n... | [{"input": "0\n461740266", "output": "2\n3\n13\n1327\n1487\n"}, {"input": "0\n1326078230", "output": "2\n5\n1051\n126173\n"}, {"input": "0\n754892205", "output": "3\n5\n41\n853\n1439\n"}, {"input": "0\n732779016", "output": "2\n3\n17\n263\n6829\n"}, {"input": "0\n663325004", "output": "2\n29\n197\n29027\n"}, {"input": ... | code_stdio |
[
{
"content": "Sitting in a station waiting room, Joisino is gazing at her train ticket.\nThe ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).\nIn the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with + or - so that the formula ho... | [{"input": "1222\n", "output": "1+2+2+2=7\n"}, {"input": "0290\n", "output": "0-2+9+0=7\n"}, {"input": "3242\n", "output": "3+2+4-2=7\n"}, {"input": "2364", "output": "2+3+6-4=7\n"}, {"input": "1114", "output": "1+1+1+4=7\n"}, {"input": "2005", "output": "2+0+0+5=7\n"}, {"input": "1455", "output": "1-4+5+5=7\n"}, {"inp... | code_stdio |
[
{
"content": "You have $r$ red and $b$ blue beans. You'd like to distribute them among several (maybe, one) packets in such a way that each packet:\n\nhas at least one red bean (or the number of red beans $r_i \\ge 1$);\n\nhas at least one blue bean (or the number of blue beans $b_i \\ge 1$);\n\nthe number of r... | [{"input": "10\n1 1000000000 1000000000\n1 1000000000 1000000000\n1 1000000000 1000000000\n1 1000000000 1000000000\n1 1000000000 1000000000\n1 1000000000 1000000000\n1 1000000000 1000000000\n1 1000000000 1000000000\n1 1000000000 1000000000\n1 1000000000 1000000000\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\n... | code_stdio |
[
{
"content": "Amidakuji is a traditional method of lottery in Japan.\nTo make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 [cm], and the endpoints of the horizontal lines must be at 1, 2, 3, ..., or H [cm] from t... | [{"input": "100 8 8\n", "output": "467571711\n"}, {"input": "100 8 3\n", "output": "938282570\n"}, {"input": "100 8 1\n", "output": "755868507\n"}, {"input": "15 8 5\n", "output": "437760187\n"}, {"input": "77 7 7\n", "output": "237739357\n"}, {"input": "98 7 6\n", "output": "736412603\n"}, {"input": "57 5 1\n", "outpu... | code_stdio |
[
{
"content": "You've got an n × m pixel picture. Each pixel can be white or black. Your task is to change the colors of as few pixels as possible to obtain a barcode picture.\n\nA picture is a barcode if the following conditions are fulfilled: \n\n * All pixels in each column are of the same color. \n * The w... | [{"input": "56 2 2 2\n##\n##\n##\n..\n..\n##\n.#\n.#\n..\n##\n##\n..\n..\n#.\n#.\n#.\n#.\n##\n..\n.#\n..\n##\n##\n.#\n#.\n.#\n..\n..\n#.\n..\n##\n..\n#.\n.#\n#.\n#.\n#.\n##\n#.\n##\n##\n.#\n#.\n##\n..\n.#\n#.\n#.\n##\n..\n..\n#.\n##\n..\n..\n##\n", "output": "55\n"}, {"input": "56 2 2 2\n##\n##\n##\n..\n..\n##\n.#\n.#\... | code_stdio |
[
{
"content": "The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills.\n\nThe boy is now looking at the ratings o... | [{"input": "3\n576460752303423484\n576460752303423484\n576460752303423485\n", "output": "1152921504606846911\n1152921504606846911\n1152921504606846912\n"}, {"input": "3\n576460752303423484\n576460752303423484\n576460752303423485\n", "output": "1152921504606846911\n1152921504606846911\n1152921504606846912\n"}, {"input":... | code_stdio |
[
{
"content": "There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`.\n\nYou will appoint one of the N people as the leader, then... | [{"input": "12\nEWWWEEEWEWEW", "output": "5\n"}, {"input": "12\nWWWWEEEWEWEE", "output": "6\n"}, {"input": "12\nEWWEWEEEWWWE", "output": "4\n"}, {"input": "12\nWEWWEEWWEWEE", "output": "6\n"}, {"input": "12\nEEWEWEEEWWWW", "output": "2\n"}, {"input": "12\nEWWWEEEWEWWE", "output": "5\n"}, {"input": "12\nEWWWEEEWWWEE", "... | code_stdio |
[
{
"content": "You are given a matrix f with 4 rows and n columns. Each element of the matrix is either an asterisk (*) or a dot (.).\n\nYou may perform the following operation arbitrary number of times: choose a square submatrix of f with size k × k (where 1 ≤ k ≤ 4) and replace each element of the chosen subma... | [{"input": "33\n548 102 31 979\n.**..**.**...******.*.**....**.**\n**..******...*.*...*.....*....*.*\n.**..*...*.**.*.....*..*..**.*..*\n.....**.....*..*...***.***..**.**\n", "output": "527\n"}, {"input": "33\n548 102 31 730\n.**..**.**...******.*.**....**.**\n**..******...*.*...*.....*....*.*\n.**..*...*.**.*.....*..*... | code_stdio |
[
{
"content": "problem\n\nYou decide to invite your friends of the school and your friends of a friend to the Christmas party. The number of students in your school is n, and each student is assigned a number from 1 to n. Your number is 1. You have a list of who and who are your friends. Based on this list, crea... | [{"input": "6\n5\n1 2\n1 3\n3 4\n2 3\n4 5\n10\n5\n2 3\n3 4\n4 3\n5 6\n1 6\n0\n0", "output": "3\n2\n"}, {"input": "6\n5\n1 2\n1 3\n3 4\n2 3\n4 5\n6\n5\n2 3\n3 4\n4 5\n5 6\n2 6\n0\n0", "output": "3\n0\n"}, {"input": "6\n5\n1 2\n1 3\n3 4\n2 3\n4 5\n6\n5\n2 3\n3 4\n1 5\n5 6\n2 6\n0\n0", "output": "3\n2\n"}, {"input": "6\n5... | code_stdio |
[
{
"content": "Authors have come up with the string $s$ consisting of $n$ lowercase Latin letters.\n\nYou are given two permutations of its indices (not necessary equal) $p$ and $q$ (both of length $n$). Recall that the permutation is the array of length $n$ which contains each integer from $1$ to $n$ exactly on... | [{"input": "6 5\n5 6 1 2 3 4\n6 5 1 2 3 4\n", "output": "YES\nbcdeaa\n"}, {"input": "6 5\n5 6 1 2 3 4\n6 5 1 2 3 4\n", "output": "YES\nbcdeaa\n"}, {"input": "5 2\n5 2 4 3 1\n5 4 3 1 2\n", "output": "YES\nbbbba\n"}, {"input": "5 2\n5 2 4 3 1\n5 4 3 1 2\n", "output": "YES\nbbbba\n"}, {"input": "5 1\n1 3 2 4 5\n2 3 5 1 4\... | code_stdio |
[
{
"content": "You are given a set of $2n+1$ integer points on a Cartesian plane. Points are numbered from $0$ to $2n$ inclusive. Let $P_i$ be the $i$-th point. The $x$-coordinate of the point $P_i$ equals $i$. The $y$-coordinate of the point $P_i$ equals zero (initially). Thus, initially $P_i=(i,0)$.\n\nThe giv... | [{"input": "1000000000000000000 1000000000000000000\n", "output": "1\n"}, {"input": "1 1000000000000000000\n", "output": "1000000000000000000\n"}, {"input": "1000000001 1000000000000000000\n", "output": "1000000000\n"}, {"input": "1000000001 1000000000000000000\n", "output": "1000000000\n"}, {"input": "1000000000000000... | code_stdio |
[
{
"content": "Kostya likes the number 4 much. Of course! This number has such a lot of properties, like:\n\n- Four is the smallest composite number;\n- It is also the smallest Smith number;\n- The smallest non-cyclic group has four elements;\n- Four is the maximal degree of the equation that can be solved in ra... | [{"input": "5\n794947\n1850\n2424\n119\n24", "output": "2\n0\n2\n0\n1\n"}, {"input": "5\n1167956\n340\n2424\n40\n42", "output": "0\n1\n2\n1\n1\n"}, {"input": "5\n163328\n953\n2213\n157\n12", "output": "0\n0\n0\n0\n0\n"}, {"input": "5\n406876\n1014\n1542\n74\n18", "output": "1\n1\n1\n1\n0\n"}, {"input": "5\n428282\n1310... | code_stdio |
[
{
"content": "Polycarp starts his own business. Tomorrow will be the first working day of his car repair shop. For now the car repair shop is very small and only one car can be repaired at a given time.\n\nPolycarp is good at marketing, so he has already collected n requests from clients. The requests are numbe... | [{"input": "30\n522692116 159\n589719489 488\n662495181 961\n915956552 470\n683572975 271\n498400137 480\n327010963 181\n200704287 367\n961198611 54\n978100746 208\n345455616 986\n106372142 876\n446972337 42\n309349333 200\n93462198 543\n167946793 318\n325598940 427\n121873339 459\n174934933 598\n279521023 1152\n739750... | code_stdio |
[
{
"content": "Given is a string S consisting of `0` and `1`. Find the number of strings, modulo 998244353, that can result from applying the following operation on S between 0 and K times (inclusive):\n\n* Choose a pair of integers i, j (1\\leq i < j\\leq |S|) such that the i-th and j-th characters of S are `0`... | [{"input": "1100011010101110110111101111011111011000111101110110010010101000101 108", "output": "298688651\n"}, {"input": "1100011010101110110111101111011111011000111101110110010011101000101 108", "output": "573021841\n"}, {"input": "1100011010101110110111101111010111011000111101110110010011101000101 108", "output": "9... | code_stdio |
[
{
"content": "There are three points marked on the coordinate plane. The goal is to make a simple polyline, without self-intersections and self-touches, such that it passes through all these points. Also, the polyline must consist of only segments parallel to the coordinate axes. You are to find the minimum num... | [{"input": "1000000000 -1000000000\n1000000000 1000000000\n-1000000000 -1000000000\n", "output": "2\n"}, {"input": "1000000000 -1000000000\n1000000000 1000000000\n-1000000000 -1000000000\n", "output": "2\n"}, {"input": "1000000000 -1000000000\n1000000000 1000000010\n-1000000000 -1000000000\n", "output": "2\n"}, {"input... | code_stdio |
[
{
"content": "Wherever the destination is, whoever we meet, let's render this song together.\n\nOn a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no collisions will happen before one enters the s... | [{"input": "20 50000 50000\n2 45955 55488\n1 19804 29337\n2 3767 90811\n2 24025 33558\n1 46985 56518\n2 21094 30627\n2 5787 15320\n1 4262 91306\n2 37231 46764\n1 18125 27658\n1 36532 12317\n1 31330 40863\n1 18992 28525\n1 29387 38920\n1 44654 54187\n2 45485 55018\n2 36850 46383\n1 44649 54182\n1 40922 50455\n2 12781 99... | code_stdio |
[
{
"content": "XXI Berland Annual Fair is coming really soon! Traditionally fair consists of $n$ booths, arranged in a circle. The booths are numbered $1$ through $n$ clockwise with $n$ being adjacent to $1$. The $i$-th booths sells some candies for the price of $a_i$ burles per item. Each booth has an unlimited... | [{"input": "78 74\n20194 1621 21498 13827 31277 19791 6583 13579 11160 20419 26490 160 3450 12925 18134 10381 27009 28815 10209 6478 18504 15371 32608 14197 12075 13723 12612 19020 28762 11057 12891 31164 16684 13717 19933 25453 2742 4955 6814 2863 10397 15461 20616 10905 2600 20137 4681 9199 27033 14388 32585 7241 351... | code_stdio |
[
{
"content": "Frog Gorf is traveling through Swamp kingdom. Unfortunately, after a poor jump, he fell into a well of $n$ meters depth. Now Gorf is on the bottom of the well and has a long way up.\n\nThe surface of the well's walls vary in quality: somewhere they are slippery, but somewhere have convenient ledge... | [{"input": "19\n1 1 3 4 5 3 5 0 0 6 3 1 10 3 13 9 1 4 2\n3 0 6 3 8 6 8 7 8 6 0 0 5 0 0 1 1 1 0\n", "output": "5\n17 15 2 1 0\n"}, {"input": "19\n1 1 3 4 5 3 5 11 0 6 5 3 10 3 13 9 1 4 17\n3 0 6 3 8 6 8 7 8 6 -1 0 5 0 0 1 1 1 0\n", "output": "3\n2 1 0\n"}, {"input": "19\n1 1 3 4 5 3 5 11 0 6 5 3 10 3 13 9 1 4 17\n3 0 6 ... | code_stdio |
[
{
"content": "Ivan had string s consisting of small English letters. However, his friend Julia decided to make fun of him and hid the string s. Ivan preferred making a new string to finding the old one. \n\nIvan knows some information about the string s. Namely, he remembers, that string t_{i} occurs in string ... | [{"input": "20\nadabacabaeabacabada 1 359\nabadabacabafabaca 1 213\nacabagabacaba 1 315\ncabaeabacabadabacab 1 268\nfabacabadabacabaeab 1 352\ncabafabacabada 1 28\nacabadabacabaea 1 67\ncabadabacabaeabacaba 1 484\nabacabadabacaba 1 209\nacabaiabacaba 1 251\nacabafabacabadabac 1 475\nabacabaeabacabadaba 1 105\ncabadabac... | code_stdio |
[
{
"content": "Write a program which reads $n$ dices constructed in the same way as Dice I, and determines whether they are all different. For the determination, use the same way as Dice III.\n\nConstraints\n\n* $2 \\leq n \\leq 100$\n* $0 \\leq $ the integer assigned to a face $ \\leq 100$\n\nInput\n\nIn the fi... | [{"input": "3\n-1 10 1 14 13 17\n6 0 35 1 0 0\n4 4 2 7 -1 -1", "output": "Yes\n"}, {"input": "3\n-1 10 1 14 13 17\n6 0 35 1 0 0\n4 4 2 5 -1 -1", "output": "Yes\n"}, {"input": "3\n0 10 1 14 9 17\n6 0 35 1 0 0\n13 4 2 7 -1 -1", "output": "Yes\n"}, {"input": "3\n0 10 1 14 13 17\n6 0 35 1 0 0\n4 4 2 7 -1 -1", "output": "Ye... | code_stdio |
[
{
"content": "Polycarp was given an array of $a[1 \\dots n]$ of $n$ integers. He can perform the following operation with the array $a$ no more than $n$ times:\n\nPolycarp selects the index $i$ and adds the value $a_i$ to one of his choice of its neighbors. More formally, Polycarp adds the value of $a_i$ to $a_... | [{"input": "50\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n", "... | code_stdio |
[
{
"content": "Berland scientists noticed long ago that the world around them depends on Berland population. Due to persistent research in this area the scientists managed to find out that the Berland chronology starts from the moment when the first two people came to that land (it is considered to have happened... | [{"input": "5833850738115444790123301858525860464609052423198474077217629208584932325696195827387610627649689452307781278299607661979317839675618367523485801890948530770658677574385684508313179053341358796468870615462459993169923271075382282788408147405323998383308800\n", "output": "YES\n1\n465\n232\n468898754020481677... | code_stdio |
[
{
"content": "You are at the top left cell $(1, 1)$ of an $n \\times m$ labyrinth. Your goal is to get to the bottom right cell $(n, m)$. You can only move right or down, one cell per step. Moving right from a cell $(x, y)$ takes you to the cell $(x, y + 1)$, while moving down takes you to the cell $(x + 1, y)$... | [{"input": "10 10\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n", "output": "48620\n"}, {"input": "10 10\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n", "output": "4862... | code_stdio |
[
{
"content": "Connected undirected graph without cycles is called a tree. Trees is a class of graphs which is interesting not only for people, but for ants too.\n\nAn ant stands at the root of some tree. He sees that there are n vertexes in the tree, and they are connected by n - 1 edges so that there is a path... | [{"input": "51\n28 3\n42 40\n40 51\n48 20\n13 28\n18 40\n44 40\n22 5\n22 27\n45 34\n40 9\n34 46\n40 34\n22 1\n22 11\n40 7\n28 40\n40 22\n14 40\n34 30\n40 20\n47 40\n12 34\n28 23\n40 24\n40 43\n41 40\n28 15\n49 32\n40 8\n32 10\n40 50\n40 36\n40 21\n16 33\n40 38\n34 2\n28 16\n34 4\n17 34\n19 40\n32 35\n40 29\n6 40\n40 39... | code_stdio |
[
{
"content": "While Mahmoud and Ehab were practicing for IOI, they found a problem which name was Longest common subsequence. They solved it, and then Ehab challenged Mahmoud with another problem.\n\nGiven two strings a and b, find the length of their longest uncommon subsequence, which is the longest string th... | [{"input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n", "ou... | code_stdio |
[
{
"content": "Taro is addicted to a novel. The novel has n volumes in total, and each volume has a different thickness. Taro likes this novel so much that he wants to buy a bookshelf dedicated to it. However, if you put a large bookshelf in the room, it will be quite small, so you have to devise to make the wid... | [{"input": "3 9\n1051\n300\n800\n200\n100\n600\n900\n1032\n400\n4 3\n1000\n1000\n1000\n0 0", "output": "2151\n1000\n"}, {"input": "3 9\n1051\n300\n800\n200\n100\n600\n900\n1032\n400\n4 3\n1000\n1000\n1001\n0 0", "output": "2151\n1001\n"}, {"input": "3 9\n500\n300\n800\n200\n100\n600\n900\n1032\n400\n4 3\n1000\n1000\n10... | code_stdio |
[
{
"content": "You are a judge of a programming contest. You are preparing a dataset for a graph problem to seek for the cost of the minimum cost path. You've generated some random cases, but they are not interesting. You want to produce a dataset whose answer is a desired value such as the number representing t... | [{"input": "3 3 3\n1 2 3\n2 3 4\n1 3 8\n12 12 2010\n1 2 0\n2 3 3000\n3 4 0\n4 5 1940\n5 6 3000\n6 12 2010\n2 7 100\n7 8 200\n8 9 506\n12 10 400\n10 11 500\n11 6 512\n10 18 1\n1 2 7\n1 3 2\n1 4 16\n2 5 0\n3 6 10\n2 7 2\n3 5 10\n3 6 3\n3 7 10\n4 7 6\n5 8 10\n6 8 2\n6 9 11\n7 9 3\n1 9 16\n8 10 8\n9 10 1\n8 2 0\n0 0 0", "o... | code_stdio |
[
{
"content": "A binary heap which satisfies max-heap property is called max-heap. In a max-heap, for every node $i$ other than the root, $A[i] \\leq A[parent(i)]$, that is, the value of a node is at most the value of its parent. The largest element in a max-heap is stored at the root, and the subtree rooted at ... | [{"input": "10\n-1 2 2 0 140 11 1 1 12 5", "output": " 140 12 11 1 5 2 1 -1 0 2\n"}, {"input": "10\n0 2 2 0 140 11 1 -1 12 5", "output": " 140 12 11 0 5 2 1 -1 0 2\n"}, {"input": "10\n1 -1 0 0 15 18 1 -1 -1 2", "output": " 18 15 1 0 2 0 1 -1 -1 -1\n"}, {"input": "10\n1 -1 1 -2 16 18 1 0 -1 1", "output": " 18 16 1 0 1 1... | code_stdio |
[
{
"content": "The store sells $n$ beads. The color of each bead is described by a lowercase letter of the English alphabet (\"a\"–\"z\"). You want to buy some beads to assemble a necklace from them.\n\nA necklace is a set of beads connected in a circle.\n\nFor example, if the store sells beads \"a\", \"b\", \"c... | [{"input": "1\n364 1485\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeefffffffffffffffffffffffffffgggggggggggggggggggggggggggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh... | code_stdio |
[
{
"content": "Codeforces user' handle color depends on his rating — it is red if his rating is greater or equal to 2400; it is orange if his rating is less than 2400 but greater or equal to 2200, etc. Each time participant takes part in a rated contest, his rating is changed depending on his performance.\n\nAnt... | [{"input": "9\nmwAz9lQ 1786 -1631\nnYgYFXZQfY -1849 -1775\nKU4jF -1773 -3376\nopR 3752 2931\nGl -1481 -1002\nR -1111 3778\n0i9B21DC 3650 279\nQ8L2dS0 358 -3305\ng -2662 3968\n", "output": "NO\n"}, {"input": "9\nmwAz9lQ 1786 -1631\nnYgYFXZQfY -1849 -1775\nKU4jF -1773 -3376\nopR 3752 2854\nGl -1481 -1002\nR -1111 3778\n0... | code_stdio |
[
{
"content": "Polycarp thinks about the meaning of life very often. He does this constantly, even when typing in the editor. Every time he starts brooding he can no longer fully concentrate and repeatedly presses the keys that need to be pressed only once. For example, instead of the phrase \"how are you\" he c... | [{"input": "babbbbabbabbbababbabbbbbbabaabaababaaabbbbbabbbbaaaaabbaaabbaabaabbbbabbbababbabaaabbababaaababbbaaa\n", "output": "babababababababababababa\n"}, {"input": "aaabbbabaaabababbaaababbababbbabbbbaabaabbaaabbaaaaabbbbabbbbbaaababaabaababbbbbbabbababbbabbabbbbab\n", "output": "abababababababababababab\n"}, {"inp... | code_stdio |
[
{
"content": "Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price — their owners are ready to pay Bob if he buys their useless apparatus. Bob can «buy» any TV sets he wants. Though he's very strong, Bob can carry at m... | [{"input": "99 17\n-993 -1745 -959 -989 -991 -995 -976 -997 -990 -1000 -996 -994 -999 -354 -1000 -983 -979 -1000 -989 -968 -994 -992 -962 -1593 -999 -983 -991 -979 -995 -993 -973 -999 -995 -995 -999 -993 -995 -992 -947 -1000 -999 -998 -982 -988 -757 -993 -426 -988 -980 -990 -979 -976 -995 -999 -981 -988 -998 -999 -970 ... | code_stdio |
[
{
"content": "You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should write any integer number that is a non-trivial divisor of the last written number. Then he should ru... | [{"input": "7938986881993\n", "output": "1\n378028993\n"}, {"input": "472670214391\n", "output": "1\n23020027\n"}, {"input": "1468526771489\n", "output": "1\n613783\n"}, {"input": "1245373417369\n", "output": "1\n908209\n"}, {"input": "1307514188557\n", "output": "1\n39283\n"}, {"input": "1408514752349\n", "output": "1... | code_stdio |
[
{
"content": "Consider creating the following number pattern.\n\n\n4 8 2 3 1 0 8 3 7 6\n2 0 5 4 1 8 1 0 3\n2 5 9 5 9 9 1 3\n7 4 4 4 8 0 4\n1 8 8 2 8 4\n9 6 0 0 2\n5 6 0 2\n1 6 2\n7 8\nFive\n\n\nThis pattern follows the rules below.\n\n\nA B\nC\n\n\nIn the sequence of numbers, C is the ones digit of A + B. For e... | [{"input": "4823108376\n2273064329\n0123456789", "output": "5\n1\n4\n"}, {"input": "4823108376\n2314825047\n0123456789", "output": "5\n4\n4\n"}, {"input": "4823108376\n1842094049\n0123456789", "output": "5\n0\n4\n"}, {"input": "4823108376\n2704372300\n0123456789", "output": "5\n7\n4\n"}, {"input": "4823108376\n28114748... | code_stdio |
[
{
"content": "There is a directed graph with N vertices numbered 1 to N and M edges.\nThe i-th edge is directed from Vertex A_i to Vertex B_i, and there are C_i coins placed along that edge.\nAdditionally, there is a button on Vertex N.\nWe will play a game on this graph.\nYou start the game on Vertex 1 with ze... | [{"input": "2500 5000 0\n1206 2272 100000\n315 2399 100000\n1186 1435 100000\n303 1569 100000\n2364 581 100000\n1683 1969 100000\n700 1088 100000\n717 410 100000\n1412 1595 100000\n2066 813 100000\n1190 949 100000\n258 2307 100000\n423 2263 100000\n671 425 100000\n1712 1110 100000\n787 1469 100000\n1954 1281 100000\n23... | code_stdio |
[
{
"content": "Taro is playing with a puzzle that places numbers 1-9 in 9x9 squares. In this puzzle, you have to arrange the numbers according to the following rules.\n\n* One number appears exactly once in the same column\n* A number appears exactly once on the same line\n* In each of the 3x3 ranges separated b... | [{"input": "2\n-1 2 3 3 4 10 8 13 9\n6 5 1 7 39 9 1 2 3\n7 11 11 2 -1 3 2 5 8\n2 4 0 1 6 9 12 9 0\n0 8 7 8 9 1 2 1 4\n8 9 1 0 3 4 2 8 7\n1 4 5 8 7 8 9 1 3\n8 12 8 9 1 4 3 4 5\n12 0 2 3 4 0 13 7 0\n2 1 3 2 5 4 7 8 14\n4 5 6 7 8 9 0 1 3\n7 8 13 1 4 4 8 5 8\n2 6 4 8 6 7 8 9 1\n5 6 12 8 9 1 2 6 3\n2 14 1 2 3 4 5 6 2\n3 7 5... | code_stdio |
[
{
"content": "Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one s... | [{"input": "138 245 30\n3 5 6 8 9 13 15 16 19 20 24 25 27 29 30 32 33 34 35 36 37 38 40 42 47 51 52 53 55 56 58 59 63 66 67 68 69 72 73 74 75 77 78 80 81 82 85 86 87 89 91 93 95 96 99 100 102 104 105 108 110 111 112 117 122 124 125 128 129 131 133 136 139 144 145 146 147 148 149 151 153 155 156 159 162 163 164 165 168 ... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.