name stringlengths 2 112 | description stringlengths 29 13k | private_tests dict | public_tests dict | generated_tests dict |
|---|---|---|---|---|
1468_A. LaIS | Let's call a sequence b_1, b_2, b_3 ..., b_{k - 1}, b_k almost increasing if $$$min(b_1, b_2) ≤ min(b_2, b_3) ≤ ... ≤ min(b_{k - 1}, b_k).$$$ In particular, any sequence with no more than two elements is almost increasing.
You are given a sequence of integers a_1, a_2, ..., a_n. Calculate the length of its longest alm... | {
"input": [],
"output": []
} | {
"input": [
"3\n8\n1 2 7 3 2 1 2 3\n2\n2 1\n7\n4 1 5 2 6 3 7\n"
],
"output": [
"\n6\n2\n7\n"
]
} | {
"input": [
"3\n8\n1 2 7 3 2 1 2 5\n2\n2 1\n7\n4 1 5 2 6 3 7\n",
"3\n8\n1 2 7 6 2 1 1 3\n2\n2 1\n7\n4 1 5 2 6 3 7\n",
"3\n8\n1 2 7 1 2 1 1 3\n2\n2 1\n7\n4 1 5 2 6 3 7\n",
"3\n8\n1 2 7 6 2 1 4 4\n2\n2 1\n7\n7 3 3 2 6 3 7\n",
"3\n8\n1 2 7 1 2 1 1 3\n2\n2 1\n7\n4 1 5 2 6 1 7\n",
"3\n8\n1 2 1 3 1... |
1541_E2. Converging Array (Hard Version) | This is the hard version of the problem. The only difference is that in this version 1 ≤ q ≤ 10^5. You can make hacks only if both versions of the problem are solved.
There is a process that takes place on arrays a and b of length n and length n-1 respectively.
The process is an infinite sequence of operations. Each... | {
"input": [],
"output": []
} | {
"input": [
"3\n2 3 4\n2 1\n5\n-1 0 1 -100000 100000\n"
],
"output": [
"56\n28\n4\n60\n0\n"
]
} | {
"input": [
"3\n0 3 4\n2 1\n5\n-1 0 1 -100000 100000\n",
"3\n0 3 4\n2 1\n5\n-1 0 1 -100000 000000\n",
"3\n0 3 5\n2 1\n5\n-1 0 1 -100000 000000\n",
"3\n0 3 5\n2 0\n5\n-1 0 1 -100000 000000\n",
"3\n0 0 5\n2 0\n5\n-1 0 2 -100000 000000\n",
"3\n0 -1 5\n2 0\n5\n-1 0 2 -100000 000000\n",
"3\n2 ... |
check-it | Russian Translation Available
You have a graph with N vertices and M edges. Someone has chosen N-1 edges of these M and claims that they form a spanning tree. Just check whether it's true or not.
Input
The first line contains one integer T denoting the number of test cases.
Each test case starts with a line containi... | {
"input": [],
"output": []
} | {
"input": [
"2\n4 4\n1 2\n1 3\n2 3\n1 4\n1 2 3\n4 4\n1 2\n1 3\n2 3\n1 4\n2 3 4\n\n\nSAMPLE"
],
"output": [
"NO\nYES\n"
]
} | {
"input": [
"2\n4 4\n1 2\n1 3\n2 4\n1 4\n1 2 3\n4 4\n1 2\n1 3\n2 3\n1 4\n2 3 4\n\n\nSAMPLE",
"2\n4 4\n1 2\n1 3\n3 4\n1 4\n1 2 3\n4 4\n1 2\n1 3\n2 3\n1 4\n2 3 2\n\n\nSAMPLE",
"2\n4 4\n1 2\n2 3\n1 4\n1 4\n1 1 3\n4 4\n1 2\n1 1\n2 3\n1 4\n2 3 2\n\n\nSAMPLE",
"2\n4 4\n1 2\n1 3\n2 3\n2 4\n1 2 3\n4 4\n1 2\n... |
sunny-arpit-and-kunal | Sunny, Arpit and Kunal are playing a game. All three of them are standing on a number line, each occupying a different integer.
The rules are as follows:
Two of them cannot be at the same integer at same time.
In one move, one of them, who is not between the other two, can jump to a integer ( if there is any space )... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 3 4\n0 3 5\n\nSAMPLE"
],
"output": [
"1\n2\n"
]
} | {
"input": [
"2\n1 3 5\n0 3 5\n\nSAMPLE",
"2\n1 3 5\n0 5 5\n\nSAMPLE",
"2\n0 3 5\n0 5 5\n\nSAMPLE",
"2\n0 3 5\n-1 5 5\n\nSAMPLE",
"2\n1 3 5\n-1 5 5\n\nSAMPLE",
"2\n1 2 1\n-1 0 3\n\nNASOLE",
"2\n1 2 1\n-1 0 6\n\nNASOLE",
"2\n1 2 1\n-1 -1 6\n\nNASOLE",
"2\n1 2 1\n-1 -1 4\n\nNASOLE",
... |
what-is-the-maximum-distance-that-you-can-cover-505 | You have to go on a trip in your car which can hold a limited amount of fuel. You know how many liters of fuel your car uses per hour for certain speeds and you have to find out how far a certain amount of fuel will take you when travelling at the optimal speed.
You will be given a set of speeds, a corresponding set ... | {
"input": [],
"output": []
} | {
"input": [
"6\n250 240 230 220 210 211\n5000 4500 4000 3500 3000 3000\n50000\n\nSAMPLE"
],
"output": [
"3516.666\n"
]
} | {
"input": [
"6\n250 437 230 220 210 211\n5000 4500 4000 3500 3000 3000\n50000\n\nSAMPLE",
"6\n250 763 230 220 210 211\n4704 4500 4000 3500 3166 3000\n50000\n\nSAMPLE",
"6\n51 763 220 31 114 555\n6141 4500 2868 1401 2687 5197\n45599\n\nELPMAS",
"6\n51 763 16 50 114 555\n6141 4500 2868 1401 2687 1325\n... |
p02622 AtCoder Beginner Contest 172 - Minor Change | Given are strings S and T. Consider changing S to T by repeating the operation below. Find the minimum number of operations required to do so.
Operation: Choose one character of S and replace it with a different character.
Constraints
* S and T have lengths between 1 and 2\times 10^5 (inclusive).
* S and T consists ... | {
"input": [],
"output": []
} | {
"input": [
"apple\napple",
"abcde\nbcdea",
"cupofcoffee\ncupofhottea"
],
"output": [
"0",
"5",
"4"
]
} | {
"input": [
"apple\nelppa",
"abcdd\nbcdea",
"eeffocfopuc\ncupofhottea",
"elppa\nelppa",
"elppa\nelppb",
"elpap\nelppb",
"ddc`a\nbbcfa",
"ffgdmdfqpuc\noeutaieppud",
"ffgdmdfqpuc\noevt`ieuppd",
"hcfrahdjpmr\nwvfxmhpcema",
"fhlrglsctdc\nffljyboxtdl",
"ddcba\nbcdea",
"... |
p02753 AtCoder Beginner Contest 158 - Station and Bus | In AtCoder City, there are three stations numbered 1, 2, and 3.
Each of these stations is operated by one of the two railway companies, A and B. A string S of length 3 represents which company operates each station. If S_i is `A`, Company A operates Station i; if S_i is `B`, Company B operates Station i.
To improve t... | {
"input": [],
"output": []
} | {
"input": [
"ABA",
"BBA",
"BBB"
],
"output": [
"Yes",
"Yes",
"No"
]
} | {
"input": [
"AAB",
"AAA",
"ABB",
"BAA",
"BAB",
"BAA",
"BAB",
"AAA",
"AAB",
"ABB"
],
"output": [
"Yes\n",
"No\n",
"Yes\n",
"Yes\n",
"Yes\n",
"Yes\n",
"Yes\n",
"No\n",
"Yes\n",
"Yes\n"
]
} |
p02888 AtCoder Beginner Contest 143 - Triangles | Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.
He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:
* a < b + c
* b < c + a
* c < a + b
How... | {
"input": [],
"output": []
} | {
"input": [
"4\n3 4 2 1",
"7\n218 786 704 233 645 728 389",
"3\n1 1000 1"
],
"output": [
"1",
"23",
"0"
]
} | {
"input": [
"4\n5 4 2 1",
"7\n218 1140 704 233 645 728 389",
"3\n1 1000 2",
"7\n218 1140 704 233 645 890 389",
"7\n218 1140 1051 233 449 890 389",
"7\n218 1140 1051 16 636 890 389",
"7\n218 1140 551 40 636 890 487",
"7\n218 1140 551 40 660 890 487",
"7\n116 1499 551 40 806 890 487... |
p03023 M-SOLUTIONS Programming Contest - Sum of Interior Angles | Given an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides.
Print the answer in degrees, but do not print units.
Constraints
* 3 \leq N \leq 100
Input
Input is given from Standard Input in the following format:
N
Output
Print an integer representing the sum of th... | {
"input": [],
"output": []
} | {
"input": [
"3",
"100"
],
"output": [
"180",
"17640"
]
} | {
"input": [
"5",
"000",
"9",
"001",
"7",
"110",
"101",
"2",
"111",
"-1",
"4",
"8",
"11",
"-2",
"-3",
"-6",
"6",
"10",
"-4",
"-8",
"-16",
"-32",
"-57",
"-60",
"-91",
"-48",
"-39",
"-35",
"-67",
"-10... |
p03164 Educational DP Contest - Knapsack 2 | There are N items, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), Item i has a weight of w_i and a value of v_i.
Taro has decided to choose some of the N items and carry them home in a knapsack. The capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W.
Find ... | {
"input": [],
"output": []
} | {
"input": [
"1 1000000000\n1000000000 10",
"6 15\n6 5\n5 6\n6 4\n6 6\n3 5\n7 2",
"3 8\n3 30\n4 50\n5 60"
],
"output": [
"10",
"17",
"90"
]
} | {
"input": [
"1 1000000000\n0000000000 10",
"6 15\n6 5\n5 6\n3 4\n6 6\n3 5\n7 2",
"3 8\n3 30\n4 35\n5 60",
"3 8\n3 30\n4 35\n5 78",
"6 15\n6 5\n0 6\n3 4\n6 6\n3 5\n7 3",
"3 8\n3 30\n0 35\n5 78",
"2 8\n3 30\n4 50\n5 60",
"1 1000000000\n0000000000 7",
"6 15\n6 5\n5 5\n3 4\n6 6\n3 5\n... |
p03306 SoundHound Inc. Programming Contest 2018 -Masters Tournament- - + Graph | Kenkoooo found a simple connected graph. The vertices are numbered 1 through n. The i-th edge connects Vertex u_i and v_i, and has a fixed integer s_i.
Kenkoooo is trying to write a positive integer in each vertex so that the following condition is satisfied:
* For every edge i, the sum of the positive integers writt... | {
"input": [],
"output": []
} | {
"input": [
"4 3\n1 2 6\n2 3 7\n3 4 5",
"3 3\n1 2 3\n2 3 5\n1 3 4",
"8 7\n1 2 1000000000\n2 3 2\n3 4 1000000000\n4 5 2\n5 6 1000000000\n6 7 2\n7 8 1000000000"
],
"output": [
"3",
"1",
"0"
]
} | {
"input": [
"4 3\n1 2 6\n2 3 7\n3 4 7",
"3 3\n1 2 3\n2 3 0\n1 3 4",
"4 3\n1 2 6\n2 3 7\n3 4 3",
"4 3\n1 2 4\n2 3 7\n3 4 7",
"4 3\n1 2 6\n2 3 7\n3 4 6",
"4 3\n1 2 11\n2 3 7\n3 4 3",
"8 7\n1 2 1000000000\n2 3 2\n3 4 1000000000\n4 5 2\n5 6 1000000000\n6 7 2\n2 8 1000000000",
"8 7\n1 2 10... |
p03466 AtCoder Grand Contest 020 - Min Max Repetition | Let f(A, B), where A and B are positive integers, be the string satisfying the following conditions:
* f(A, B) has length A + B;
* f(A, B) contains exactly A letters `A` and exactly B letters `B`;
* The length of the longest substring of f(A, B) consisting of equal letters (ex., `AAAAA` or `BBBB`) is as small as possi... | {
"input": [],
"output": []
} | {
"input": [
"5\n2 3 1 5\n6 4 1 10\n2 3 4 4\n6 4 3 7\n8 10 5 8"
],
"output": [
"BABAB\nAABAABAABB\nA\nBAABA\nABAB"
]
} | {
"input": [
"5\n2 3 1 5\n6 4 1 10\n2 3 4 4\n6 4 3 7\n8 10 5 14",
"5\n2 3 1 5\n6 4 1 10\n2 3 4 4\n6 4 3 7\n8 2 5 8",
"5\n2 3 1 5\n6 4 1 10\n2 3 4 4\n6 7 3 7\n8 10 5 14",
"5\n2 3 1 5\n6 4 1 10\n2 3 6 4\n6 4 3 7\n8 2 5 8",
"5\n2 3 1 5\n9 4 1 10\n2 3 6 4\n6 4 3 7\n8 2 5 8",
"5\n2 3 1 5\n9 4 1 10\... |
p03626 AtCoder Beginner Contest 071 - Coloring Dominoes | We have a board with a 2 \times N grid. Snuke covered the board with N dominoes without overlaps. Here, a domino can cover a 1 \times 2 or 2 \times 1 square.
Then, Snuke decided to paint these dominoes using three colors: red, cyan and green. Two dominoes that are adjacent by side should be painted by different colors... | {
"input": [],
"output": []
} | {
"input": [
"1\nZ\nZ",
"52\nRvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn\nRLLwwdWIxxNNQUUXXVVMMooBBaggDKqcimmeYrhAljOOTTJuuzzn",
"3\naab\nccb"
],
"output": [
"3",
"958681902",
"6"
]
} | {
"input": [
"1\n[\n[",
"52\nRvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn\nRLLwwdWIxxNNQUUXXVVMMooCBaggDKqcimmeYrhAljOOTTJuuzzn",
"3\naab\nacc",
"3\nbab\nbab",
"3\naab\ncbb",
"3\naab\nbbb",
"3\naab\nbcb",
"3\naab\nbdb",
"52\nnHHppJGGCCjlAhrYebbicqKDSSakkEEffssZZFFQPPyyIWdtt... |
p03786 AtCoder Grand Contest 011 - Colorful Creatures | Snuke found N strange creatures. Each creature has a fixed color and size. The color and size of the i-th creature are represented by i and A_i, respectively.
Every creature can absorb another creature whose size is at most twice the size of itself. When a creature of size A and color B absorbs another creature of siz... | {
"input": [],
"output": []
} | {
"input": [
"5\n1 1 1 1 1",
"3\n3 1 4",
"6\n40 1 30 2 7 20"
],
"output": [
"5",
"2",
"4"
]
} | {
"input": [
"5\n1 1 1 1 2",
"3\n3 1 3",
"6\n40 1 26 2 7 20",
"3\n1 1 3",
"6\n7 2 21 2 9 20",
"5\n1 2 1 1 2",
"6\n40 1 26 2 9 20",
"5\n1 2 1 0 2",
"6\n40 1 21 2 9 20",
"5\n1 1 1 0 2",
"6\n40 1 21 1 9 20",
"5\n2 1 1 0 2",
"6\n40 2 21 1 9 20",
"5\n2 1 2 0 2",
... |
p03954 AtCoder Grand Contest 006 - Median Pyramid Hard | We have a pyramid with N steps, built with blocks. The steps are numbered 1 through N from top to bottom. For each 1≤i≤N, step i consists of 2i-1 blocks aligned horizontally. The pyramid is built so that the blocks at the centers of the steps are aligned vertically.
<image>
A pyramid with N=4 steps
Snuke wrote a per... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 2 3",
"4\n1 6 3 7 4 5 2"
],
"output": [
"2",
"4"
]
} | {
"input": [
"2\n0 2 3",
"4\n0 6 3 7 4 5 2",
"2\n-1 1 7",
"4\n0 5 3 1 4 9 2",
"4\n-1 5 5 0 8 2 0",
"4\n-2 3 3 7 7 5 0",
"4\n-2 3 3 7 6 1 0",
"2\n-1 2 3",
"4\n0 6 3 4 4 5 2",
"2\n-1 2 5",
"4\n0 4 3 4 4 5 2",
"2\n-1 2 7",
"4\n0 5 3 4 4 5 2",
"4\n0 5 3 4 4 9 2",
... |
p00044 Prime Number II | A prime number is an integer that is greater than 1 and can only be divided by itself or 1. For example, 2 is a prime number because it is divisible only by 2 and 1, but 12 is not a prime number because it is divisible by 2, 3, 4, 6 in addition to 12 and 1.
When you enter the integer n, write a program that outputs th... | {
"input": [],
"output": []
} | {
"input": [
"19\n3517"
],
"output": [
"17 23\n3511 3527"
]
} | {
"input": [
"19\n5214",
"19\n3257",
"19\n6476",
"19\n10887",
"19\n17073",
"19\n30085",
"19\n357",
"19\n443",
"19\n631",
"19\n862",
"19\n1431",
"19\n2850",
"19\n995",
"19\n1278",
"19\n507",
"19\n774",
"19\n502",
"19\n734",
"19\n755",
"19\... |
p00176 What Color? | Taro, who aims to become a web designer, is currently training. My senior at the office tells me that the background color of this page is # ffe085, which is a color number peculiar to web design, but I can't think of what kind of color it is.
This color number represents the intensity of each of the three primary col... | {
"input": [],
"output": []
} | {
"input": [
"#ffe085\n#787878\n#decade\n#ff55ff\n0",
"ffe085\n787878\ndecade\nff55ff\n0"
],
"output": [
"white\nblack\nwhite\nfuchsia",
"white\nblack\nwhite\nfuchsia"
]
} | {
"input": [
"ffe085\n787878\ndfcade\nff55ff\n0",
"#ffe085\n#787878\n\"decade\n#ff55ff\n0",
"8fe0f5\n976991\ndebade\nff55ff\n0",
"8fe0f5\n1006397\ndebade\nff55ff\n0",
"#ffe075\n#787878\n#decade\n#ff55ff\n0",
"ffe085\n1502551\ndfcaed\nff55ff\n0",
"ff80e5\n787878\ndfcade\nff5f5f\n0",
"8f... |
p00332 Japanese Calendar | The "Western calendar" is a concept imported from the West, but in Japan there is a concept called the Japanese calendar, which identifies the "era name" by adding a year as a method of expressing the year on the calendar. For example, this year is 2016 in the Christian era, but 2016 in the Japanese calendar. Both are ... | {
"input": [],
"output": []
} | {
"input": [
"0 2015",
"0 1912",
"4 28",
"2 1"
],
"output": [
"H27",
"T1",
"2016",
"1912"
]
} | {
"input": [
"4 2",
"3 1",
"1 28",
"2 0",
"3 2",
"4 1",
"1 42",
"1 0",
"3 0",
"4 0",
"1 81",
"2 -1",
"3 -1",
"4 -1",
"1 125",
"1 -1",
"4 -2",
"1 68",
"1 -2",
"4 -4",
"1 36",
"1 -3",
"2 36",
"1 -4",
"2 45",
"2 17",
... |
p00513 Available Areas | IOI Real Estate rents condominiums. The apartment room handled by this company is 1LDK, and the area is 2xy + x + y as shown in the figure below. However, x and y are positive integers.
Figure_Madori
In the IOI real estate catalog, the areas of condominiums are listed in ascending order (in ascending order), but it... | {
"input": [],
"output": []
} | {
"input": [
"None",
"10\n4\n7\n9\n10\n12\n13\n16\n17\n19\n20"
],
"output": [
"None",
"2"
]
} | {
"input": [
"enoN",
"10\n4\n7\n9\n10\n12\n13\n20\n17\n19\n20",
"10\n8\n7\n8\n10\n12\n13\n20\n17\n19\n20",
"10\n8\n0\n8\n10\n12\n13\n20\n17\n19\n20",
"10\n8\n0\n18\n10\n0\n13\n20\n17\n19\n2",
"10\n8\n0\n18\n10\n0\n13\n3\n3\n19\n3",
"10\n2\n0\n18\n13\n0\n5\n5\n5\n4\n3",
"emoN",
"10\... |
p00690 A Long Ride on a Railway | Travelling by train is fun and exciting. But more than that indeed. Young challenging boys often tried to purchase the longest single tickets and to single ride the longest routes of various railway systems. Route planning was like solving puzzles. However, once assisted by computers, and supplied with machine readable... | {
"input": [],
"output": []
} | {
"input": [
"6 5\n 1 3 10\n 2 3 12\n 3 4 2\n 4 5 13\n 4 6 11\n10 10\n 1 2 11\n 2 3 25\n 2 5 81\n 2 6 82\n 4 5 58\n 5 9 68\n 6 7 80\n 6 9 67\n 8 9 44\n 9 10 21\n 0 0",
"6 5\n1 3 10\n2 3 12\n3 4 2\n4 5 13\n4 6 11\n10 10\n1 2 11\n2 3 25\n2 5 81\n2 6 82\n4 5 ... | {
"input": [
"6 5\n1 3 10\n2 3 12\n3 4 2\n4 5 13\n4 6 11\n10 10\n1 2 11\n2 3 25\n2 5 81\n2 6 82\n4 5 58\n4 9 68\n6 7 80\n6 9 67\n8 9 44\n9 10 21\n0 0",
"6 5\n 1 3 10\n 2 3 12\n 3 4 2\n 2 5 13\n 4 6 11\n10 10\n 1 2 11\n 2 3 25\n 2 5 81\n 2 6 82\n 4 5 58\n 5... |
p00831 Confusing Login Names | Meikyokan University is very famous for its research and education in the area of computer science. This university has a computer center that has advanced and secure computing facilities including supercomputers and many personal computers connected to the Internet.
One of the policies of the computer center is to le... | {
"input": [],
"output": []
} | {
"input": [
"8\n2\nomura\ntoshio\nraku\ntanaka\nimura\nyoshoi\nhayashi\nmiura\n3\n1\ntasaka\nnakata\ntanaka\n1\n1\nfoo\n5\n2\npsqt\nabcdef\nabzdefa\npqrst\nabdxcef\n0"
],
"output": [
"imura,miura\nimura,omura\nmiura,omura\ntoshio,yoshoi\n4\ntanaka,tasaka\n1\n0\nabcdef,abdxcef\nabcdef,abzdefa\npqrst,psqt\... | {
"input": [
"8\n2\nomura\ntoshio\nraku\ntanaka\ninura\nyoshoi\nhayashi\nmiura\n3\n1\ntasaka\nnakata\ntanaka\n1\n1\nfoo\n5\n2\npsqt\nabcdef\nabzdefa\npqrst\nabdxcef\n0",
"8\n2\nomura\ntoshio\nraku\nt`naka\nioura\nyoshoi\nhayashi\nmiura\n3\n1\ntasaka\nnakata\ntanaka\n1\n1\nfoo\n5\n2\npsqt\nabcdef\nabzdefa\npqr... |
p00962 Pizza Delivery | Problem F Pizza Delivery
Alyssa is a college student, living in New Tsukuba City. All the streets in the city are one-way. A new social experiment starting tomorrow is on alternative traffic regulation reversing the one-way directions of street sections. Reversals will be on one single street section between two adjac... | {
"input": [],
"output": []
} | {
"input": [
"4 5\n1 3 5\n3 4 6\n4 2 7\n2 1 18\n2 3 12"
],
"output": [
"SAD\nSAD\nSAD\nSOSO\nHAPPY"
]
} | {
"input": [
"4 5\n1 3 5\n3 4 6\n4 2 7\n2 1 18\n2 3 17",
"4 5\n1 3 5\n3 4 6\n4 2 7\n2 1 6\n2 3 17",
"4 5\n1 3 5\n3 2 6\n4 2 7\n2 1 18\n2 3 12",
"4 5\n1 3 5\n3 4 6\n4 2 13\n2 1 6\n2 3 17",
"4 1\n1 3 5\n3 2 6\n4 2 7\n2 1 18\n2 3 12",
"8 5\n1 3 5\n3 4 6\n4 2 7\n2 1 18\n2 3 12",
"4 5\n1 1 5\n3... |
p01095 Bamboo Blossoms | Bamboo Blossoms
The bamboos live for decades, and at the end of their lives, they flower to make their seeds. Dr. ACM, a biologist, was fascinated by the bamboos in blossom in his travel to Tsukuba. He liked the flower so much that he was tempted to make a garden where the bamboos bloom annually. Dr. ACM started resea... | {
"input": [],
"output": []
} | {
"input": [
"3 1\n3 4\n10 20\n100 50\n2 500000\n0 0"
],
"output": [
"4\n11\n47\n150\n7368791"
]
} | {
"input": [
"3 2\n3 4\n10 20\n100 50\n2 500000\n0 0",
"3 2\n3 4\n13 20\n100 50\n2 500000\n0 0",
"3 2\n3 4\n22 20\n100 50\n2 500000\n0 0",
"3 1\n3 4\n10 20\n100 50\n3 500000\n0 0",
"3 2\n3 4\n13 20\n100 50\n4 500000\n0 0",
"3 2\n3 4\n10 20\n100 52\n2 500000\n0 0",
"6 1\n3 4\n10 20\n100 50\... |
p01231 Aaron and Bruce | Aaron is a vicious criminal. He has repeatedly committed crimes (2 shoplifting, 16 peeping, 256 underwear thieves, 65,536 escapes), but has continued to escape from the police with his extraordinary physical abilities. Bruce is a police officer. Although he does not have outstanding athletic ability, he enjoys photogra... | {
"input": [],
"output": []
} | {
"input": [
"6\n8\n0 1 0 0 0 0 0 0\n1 0 1 0 0 0 0 0\n0 1 0 1 1 0 0 0\n0 0 1 0 0 0 0 0\n0 0 1 0 0 1 1 0\n0 0 0 0 1 0 0 0\n0 0 0 0 1 0 0 1\n0 0 0 0 0 0 1 0\n3 0\n4\n0 1 1 0\n1 0 0 1\n1 0 0 1\n0 1 1 0\n1 0\n5\n0 1 0 1 0\n1 0 0 1 0\n0 0 0 0 1\n1 1 0 0 0\n0 0 1 0 0\n2 0\n5\n0 1 0 0 1\n1 0 1 1 1\n0 1 0 1 0\n0 1 1 0 1\... | {
"input": [
"6\n8\n0 1 0 0 0 0 0 0\n1 0 1 0 0 0 0 0\n0 1 0 1 1 0 0 0\n0 0 1 0 0 0 0 0\n0 0 1 0 0 1 1 0\n0 0 0 0 1 0 0 0\n0 0 0 0 1 0 0 1\n0 0 0 0 0 0 1 0\n3 0\n4\n0 1 1 0\n1 0 0 1\n1 0 0 1\n0 1 1 0\n1 0\n5\n0 1 0 1 0\n1 0 0 1 0\n0 0 0 0 1\n1 1 0 0 0\n0 0 1 0 0\n2 0\n5\n0 1 0 0 1\n1 0 1 1 1\n0 1 0 1 0\n0 1 1 0 1\... |
p01365 Camera Control | "ACM48" is one of the most popular dance vocal units in Japan. In this winter, ACM48 is planning a world concert tour. You joined the tour as a camera engineer.
Your role is to develop software which controls the camera on a stage. For simplicity you can regard the stage as 2-dimensional space. You can rotate the came... | {
"input": [],
"output": []
} | {
"input": [
"2\n0 0\n2\n-5 5 0\n5 5 10\n1\n0 6\n2\n5 5 0\n-5 5 10\n1\n6 10\n1\n7 -65\n2\n-65 10 0\n65 1 3\n2\n0 1\n23 24\n2\n0 0\n2\n100 10 0\n-10 10 10\n5\n0 1\n2 3\n4 5\n6 7\n8 9\n2\n10 0 0\n0 10 10\n5\n1 2\n3 4\n5 6\n7 8\n9 10\n0"
],
"output": [
"9.00000000\n2.00000000\n5.98862017"
]
} | {
"input": [],
"output": []
} |
p01547 Final Defense Line | In a country that has been frequently invaded by unidentified creatures, it has decided to protect important facilities with new defense weapons.
This weapon can damage unidentified creatures by filling a polygonal area with a special gas. If the concentration of gas changes during the invasion of an unidentified creat... | {
"input": [],
"output": []
} | {
"input": [
"2\n4\n0 4\n1 1\n3 1\n4 4\n3\n6 0\n10 0\n8 7\n1\n2 3 9 1",
"2\n4\n0 0\n10 0\n10 10\n0 10\n4\n10 0\n20 0\n20 10\n10 10\n1\n5 5 15 5",
"2\n4\n0 0\n10 0\n10 10\n0 10\n4\n0 0\n10 0\n10 10\n0 10\n2\n15 5 5 5\n5 5 15 5",
"1\n4\n0 0\n10 0\n10 10\n0 10\n2\n15 5 5 5\n5 5 15 5",
"2\n3\n0 0\n10 ... | {
"input": [
"2\n4\n0 4\n1 1\n3 1\n4 4\n3\n6 0\n10 0\n8 7\n1\n2 3 9 2",
"2\n4\n0 0\n10 0\n10 10\n0 10\n4\n10 0\n20 0\n20 10\n10 10\n1\n5 6 15 5",
"2\n4\n0 -1\n10 0\n10 10\n0 10\n4\n0 0\n10 0\n10 10\n0 10\n2\n15 5 5 5\n5 5 15 5",
"1\n4\n0 0\n12 0\n10 10\n0 10\n2\n15 5 5 5\n5 5 15 5",
"2\n4\n0 0\n10... |
p01703 Speedrun | Problem Statement
Infinite Chronicle -Princess Castle- is a simple role-playing game. There are $n + 1$ checkpoints, numbered $0$ through $n$, and for each $i = 1, 2, \ldots, n$, there is a unique one-way road running from checkpoint $i - 1$ to $i$. The game starts at checkpoint $0$ and ends at checkpoint $n$. Evil mo... | {
"input": [],
"output": []
} | {
"input": [
"2\n0.50 0.40\n2\n0.70 0.60\n4\n0.99 1.00 1.00 0.01\n0"
],
"output": [
"5.5000000000\n4.0476190476\n104.0101010101"
]
} | {
"input": [
"2\n0.50 0.9352082555775155\n2\n0.70 0.60\n4\n0.99 1.00 1.00 0.01\n0",
"2\n0.50 0.40\n2\n0.70 0.60\n4\n0.99 1.00 1.00 0.30033521998367063\n0",
"2\n0.50 0.40\n2\n0.70 0.60\n4\n0.99 1.00 1.00 0.3927310360771925\n0",
"2\n0.50 0.6066276706005583\n2\n0.70 0.60\n4\n0.99 1.00 1.00 0.01\n0",
... |
p01847 Curtain | curtain
Summer is coming soon. You decide to redecorate your room for the summer. It is expected that the sun will be very strong this summer, and it will be a difficult season for you who are not good at dazzling. So you thought about installing a curtain on the window of the room to adjust the brightness of the room... | {
"input": [],
"output": []
} | {
"input": [
"4\n0 0\n10 0\n10 10\n0 10\n0 0\n5 0\n5 10\n0 10\n6\n0 0\n10 0\n10 5\n5 5\n5 10\n0 10\n2 0\n8 0\n8 10\n2 10\n12\n1 1\n1 3\n-1 3\n-1 1\n-3 1\n-3 -1\n-1 -1\n-1 -3\n1 -3\n1 -1\n3 -1\n3 1\n2 2\n-2 2\n-2 -2\n2 -2\n4\n20000 20000\n-20000 20000\n-20000 -20000\n20000 -20000\n1000 1000\n-1000 1000\n-1000 -100... | {
"input": [
"4\n0 0\n10 0\n10 10\n0 10\n0 0\n5 0\n5 10\n0 10\n6\n0 0\n10 0\n10 5\n5 5\n5 10\n0 10\n2 0\n8 0\n8 10\n2 10\n12\n1 1\n1 3\n-1 3\n-1 1\n-3 1\n-3 -1\n-1 -1\n-1 -3\n1 -3\n1 -1\n3 -1\n3 1\n2 2\n-2 2\n-2 -2\n2 -2\n4\n20000 20000\n-20000 20000\n-20000 -20000\n20000 -20000\n1000 1000\n-1000 1000\n-1000 -100... |
p01983 Proof of Knowledge | Proof of knowledge
The entrance door of the apartment you live in has a password-type lock. This password consists of exactly four digits, ranging from 0 to 9, and you always use the password P given to you by the apartment manager to unlock this door.
One day, you wondered if all the residents of the apartment were ... | {
"input": [],
"output": []
} | {
"input": [
"[+c[+a[^bd]]]\n0404\n[*b[*[*cd]a]]\n7777\n[^[^ab][^cd]]\n1295\na\n9876\n[^dd]\n9090\n."
],
"output": [
"0 10\n7 1\n15 544\n9 1000\n0 10000"
]
} | {
"input": [
"[+c[+a[^bd]]]\n0404\n[*b[*[*cd]a]]\n7777\n[^[^ab][^cd]]\n2570\na\n9876\n[^dd]\n9090\n.",
"[+c[*a[^bd]]]\n0404\n[*b[*[*cd]a]]\n7777\n[^[^ab][^cd]]\n2570\na\n9876\n[^dd]\n9090\n.",
"[+c[^a[+bd]]]\n0404\n[*b[*[*cd]a]]\n7777\n[^[^ab][^cd]]\n1295\na\n9876\n[^dd]\n9090\n.",
"[+c[+a[^bd]]]\n040... |
p02129 Ghost Legs | Problem
There are $ N $ Amidakuji with 3 vertical lines.
No matter which line you start from, the Amidakuji that ends at the starting line is considered a good Amidakuji.
You can select one or more Amidakuji and connect them vertically in any order.
Output "yes" if you can make a good Amidakuji, otherwise output "no".... | {
"input": [],
"output": []
} | {
"input": [
"3\n2 0 0\n1 1\n5 1 0 0 1 0",
"2\n1 1\n1 0"
],
"output": [
"yes",
"no"
]
} | {
"input": [
"3\n2 0 0\n1 1\n10 1 0 0 1 0",
"2\n1 1\n3 0",
"2\n1 1\n2 0",
"3\n2 0 0\n1 1\n10 1 0 0 2 0",
"2\n1 0\n2 0",
"3\n3 0 0\n1 1\n10 1 0 0 2 0",
"2\n1 1\n2 -1",
"3\n3 0 0\n1 1\n10 2 0 0 2 0",
"2\n1 1\n2 -2",
"3\n3 0 0\n0 1\n10 2 0 0 2 0",
"2\n1 1\n0 -2",
"2\n1 1\n... |
p02270 Allocation | You are given $n$ packages of $w_i$ kg from a belt conveyor in order ($i = 0, 1, ... n-1$). You should load all packages onto $k$ trucks which have the common maximum load $P$. Each truck can load consecutive packages (more than or equals to zero) from the belt conveyor unless the total weights of the packages in the s... | {
"input": [],
"output": []
} | {
"input": [
"5 3\n8\n1\n7\n3\n9",
"4 2\n1\n2\n2\n6"
],
"output": [
"10",
"6"
]
} | {
"input": [
"5 3\n4\n1\n7\n3\n9",
"4 2\n1\n1\n2\n6",
"5 3\n4\n1\n7\n3\n5",
"5 6\n4\n1\n7\n3\n5",
"4 2\n1\n1\n3\n1",
"4 2\n1\n1\n3\n0",
"4 2\n1\n4\n3\n0",
"5 3\n6\n2\n8\n5\n4",
"5 3\n6\n2\n8\n7\n4",
"5 3\n8\n2\n9\n7\n5",
"5 2\n6\n1\n8\n3\n5",
"5 1\n6\n2\n8\n5\n4",
"... |
p02417 Counting Characters | Write a program which counts and reports the number of each alphabetical letter. Ignore the case of characters.
Constraints
* The number of characters in the sentence < 1200
Input
A sentence in English is given in several lines.
Output
Prints the number of alphabetical letters in the following format:
a : The n... | {
"input": [],
"output": []
} | {
"input": [
"This is a pen."
],
"output": [
"a : 1\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\ni : 2\nj : 0\nk : 0\nl : 0\nm : 0\nn : 1\no : 0\np : 1\nq : 0\nr : 0\ns : 2\nt : 1\nu : 0\nv : 0\nw : 0\nx : 0\ny : 0\nz : 0"
]
} | {
"input": [
"This is ` pen.",
"This si a pen.",
"hTit si a pen.",
"hTis ir a pen.",
"hTis ri a pdn.",
"hTis ri a odn.",
"hTis ri a odo.",
"hsiT rh a od.o",
"Tsih is a od-o",
"Tsih is ` od-o",
"ihsT it ` od-o",
"ihsU it ` od-o",
"ihrU it ` od-o",
"Uirh it ` p-do... |
amsgame1 | Chef is playing a game on a sequence of N positive integers, say A1, A2, ... AN. The game is played as follows.
If all the numbers are equal, the game ends.
Otherwise
Select two numbers which are unequal
Subtract the smaller number from the larger number
Replace the larger number with the result from above (see the e... | {
"input": [],
"output": []
} | {
"input": [
"3\n2\n10 12\n2\n5 9\n3\n6 10 15"
],
"output": [
"2\n1\n1\n"
]
} | {
"input": [
"3\n2\n10 12\n2\n5 9\n3\n8 10 15",
"3\n2\n10 12\n2\n5 9\n3\n8 10 24",
"3\n2\n10 19\n2\n5 9\n3\n8 10 24",
"3\n2\n10 12\n2\n5 9\n3\n6 9 15",
"3\n2\n10 12\n2\n7 14\n3\n8 10 24",
"3\n2\n19 12\n2\n7 9\n3\n3 10 24",
"3\n2\n10 21\n2\n7 14\n3\n8 10 24",
"3\n2\n10 12\n2\n5 10\n3\n8... |
chn15a | Gru has not been in the limelight for a long time and is, therefore, planning something particularly nefarious. Frustrated by his minions' incapability which has kept him away from the limelight, he has built a transmogrifier — a machine which mutates minions.
Each minion has an intrinsic characteristic value (simila... | {
"input": [],
"output": []
} | {
"input": [
"1\n5 10\n2 4 1 35 1"
],
"output": [
"1\n"
]
} | {
"input": [
"1\n5 10\n2 4 1 62 1",
"1\n5 2\n0 4 1 3 1",
"1\n5 20\n2 4 1 62 1",
"1\n5 0\n0 4 0 7 1",
"1\n5 0\n1 0 0 0 0",
"1\n5 10\n2 4 1 3 1",
"1\n5 3\n2 4 1 3 1",
"1\n5 3\n2 4 0 3 1",
"1\n5 3\n0 4 0 3 1",
"1\n5 3\n0 4 1 3 1",
"1\n5 2\n0 4 1 5 1",
"1\n5 2\n0 4 1 7 1",
... |
entexam | The faculty of application management and consulting services (FAMCS) of the Berland State University (BSU) has always been popular among Berland's enrollees. This year, N students attended the entrance exams, but no more than K will enter the university. In order to decide who are these students, there are series of e... | {
"input": [],
"output": []
} | {
"input": [
"1\n4 2 3 10\n7 7 7\n4 6 10\n7 10 9\n9 9"
],
"output": [
"4\n"
]
} | {
"input": [
"1\n4 2 3 10\n9 7 7\n4 6 10\n7 10 9\n9 9",
"1\n4 3 3 10\n9 7 7\n4 6 10\n7 10 9\n9 9",
"1\n4 3 3 10\n9 7 7\n4 6 9\n2 10 9\n9 9",
"1\n4 2 3 10\n7 7 7\n2 6 10\n7 10 9\n9 9",
"1\n4 2 3 14\n7 7 7\n10 6 10\n7 10 9\n9 9",
"1\n4 1 3 14\n0 5 7\n10 6 10\n7 4 17\n9 9",
"1\n4 2 3 2\n7 7 7... |
kjcc02 | Sum and Color
Chef is a mathematics student. His professor has given him a difficult task. Professor initially provides Chef with a list of numbers. For every number in the list, Chef has to calculate the sum 'S' of digits such that 0<=S<=9. Even if the sum of digits is coming as a 'n' digit number, Chef has to bring i... | {
"input": [],
"output": []
} | {
"input": [
"5\n5\n128 25 87 50 1558\n4\n11 22 33 44\n3\n36 14 1000\n5\n11112 95 96 256 2669\n3\n10 991 83"
],
"output": [
"yellow\ngreen\nbrown\ncyan\npink"
]
} | {
"input": [],
"output": []
} |
orders | In Byteland it is always the military officer's main worry to order his soldiers on parade correctly. Luckily, ordering soldiers is not really such a problem. If a platoon consists of n men, all of them have different rank (from 1 - lowest to n - highest) and on parade they should be lined up from left to right in incr... | {
"input": [],
"output": []
} | {
"input": [
"2\n3\n0 1 0\n5\n0 1 2 0 1"
],
"output": [
"2 1 3\n3 2 1 5 4\n"
]
} | {
"input": [
"2\n3\n0 1 0\n5\n0 1 0 0 1",
"2\n2\n0 1 0\n5\n0 1 0 0 1",
"2\n2\n0 1 0\n4\n0 1 0 0 1",
"2\n3\n0 1 0\n5\n0 1 2 0 2",
"2\n3\n0 1 0\n4\n0 1 0 0 1",
"2\n3\n0 1 1\n5\n0 1 2 0 2",
"2\n3\n0 1 2\n5\n0 1 2 0 2",
"2\n3\n0 1 0\n5\n0 1 0 0 2",
"2\n3\n0 0 0\n4\n0 1 0 0 1",
"2\n... |
spoons | Lo and Behold! For you may be surprised by what our chief chef Noodle has in mind for this season! Today, Noodle announced one of his most extra-ordinary ideas ever - Project Spoon.
Noodle plans to deploy large spoons in the atmosphere so that people all around the world can download food directly from his kitchen th... | {
"input": [],
"output": []
} | {
"input": [
"2\n2\n3"
],
"output": [
"2\n3\n"
]
} | {
"input": [
"2\n2\n5",
"2\n3\n4",
"2\n3\n3",
"2\n4\n3",
"2\n4\n4",
"2\n2\n10",
"2\n4\n2",
"2\n4\n8",
"2\n3\n11",
"2\n4\n11",
"2\n8\n9",
"2\n2\n11",
"2\n2\n2",
"2\n3\n2",
"2\n4\n21",
"2\n16\n9",
"2\n7\n3",
"2\n9\n4",
"2\n7\n11",
"2\n7\n2"... |
1218_H. Function Composition | We are definitely not going to bother you with another generic story when Alice finds about an array or when Alice and Bob play some stupid game. This time you'll get a simple, plain text.
First, let us define several things. We define function F on the array A such that F(i, 1) = A[i] and F(i, m) = A[F(i, m - 1)] for... | {
"input": [],
"output": []
} | {
"input": [
"10\n2 3 1 5 6 4 2 10 7 7\n5\n10 1\n5 7\n10 6\n1 1\n10 8\n"
],
"output": [
"3\n0\n1\n1\n0\n"
]
} | {
"input": [
"10\n2 3 1 5 6 4 2 10 7 7\n4\n10 1\n5 7\n10 6\n1 1\n10 8\n",
"10\n2 3 1 5 6 4 2 10 7 7\n4\n10 2\n5 7\n10 6\n1 1\n10 8\n",
"10\n2 2 1 5 6 4 2 10 7 7\n4\n10 2\n5 7\n10 6\n1 1\n10 8\n",
"10\n2 2 1 5 6 4 2 10 7 7\n4\n0 2\n5 7\n10 6\n1 1\n10 8\n",
"10\n2 2 1 5 6 4 2 10 7 7\n4\n0 2\n5 7\n10... |
1303_C. Perfect Keyboard | Polycarp wants to assemble his own keyboard. Layouts with multiple rows are too complicated for him — his keyboard will consist of only one row, where all 26 lowercase Latin letters will be arranged in some order.
Polycarp uses the same password s on all websites where he is registered (it is bad, but he doesn't care)... | {
"input": [],
"output": []
} | {
"input": [
"5\nababa\ncodedoca\nabcda\nzxzytyz\nabcdefghijklmnopqrstuvwxyza\n"
],
"output": [
"YES\nabcdefghijklmnopqrstuvwxyz\nYES\nacodebfghijklmnpqrstuvwxyz\nNO\nYES\ntyzxabcdefghijklmnopqrsuvw\nNO\n"
]
} | {
"input": [
"5\nababa\ncodedoca\nabcda\nzxzytyz\nabcdefghjjklmnopqrstuvwxyza\n",
"5\nababa\ncodedoca\nabcda\nzxtyzyz\nazyxwvutsrqponmlkjjhgfedcba\n",
"5\nababa\ncodfdoca\nabcda\nzxzytyz\nabcdefghjjklmnopqrstuvwxyza\n",
"5\nababa\ncodedoba\nabcda\nzxzytyz\nazyxwvutsrqponmlkjjhgfedcba\n",
"5\nababa... |
1327_D. Infinite Path | You are given a colored permutation p_1, p_2, ..., p_n. The i-th element of the permutation has color c_i.
Let's define an infinite path as infinite sequence i, p[i], p[p[i]], p[p[p[i]]] ... where all elements have same color (c[i] = c[p[i]] = c[p[p[i]]] = ...).
We can also define a multiplication of permutations a a... | {
"input": [],
"output": []
} | {
"input": [
"3\n4\n1 3 4 2\n1 2 2 3\n5\n2 3 4 5 1\n1 2 3 4 5\n8\n7 4 5 6 1 8 3 2\n5 3 6 4 7 5 8 4\n"
],
"output": [
"1\n5\n2\n"
]
} | {
"input": [
"3\n4\n1 3 4 2\n1 2 2 3\n5\n2 3 4 5 1\n1 2 3 4 5\n8\n7 4 5 6 1 8 3 2\n5 3 6 8 7 5 8 4\n",
"3\n4\n1 3 4 2\n1 2 2 3\n5\n2 3 4 5 1\n1 2 5 4 5\n8\n7 4 5 6 1 8 3 2\n5 3 6 4 7 5 8 4\n",
"3\n4\n1 3 4 2\n1 1 2 3\n5\n2 3 4 5 1\n1 2 5 4 5\n8\n7 4 5 6 1 8 3 2\n5 3 6 4 7 5 8 4\n",
"3\n4\n1 3 4 2\n1 1... |
1346_F. Dune II: Battle For Arrakis | You're at the last mission in one very old and very popular strategy game Dune II: Battle For Arrakis. The map of the mission can be represented as a rectangular matrix of size n × m. Initially, there are a_{i, j} units of your army in the cell (i, j).
You want to prepare for the final battle, so you want to move all ... | {
"input": [],
"output": []
} | {
"input": [
"3 3 1\n1 2 3\n2 1 2\n1 1 2\n2 3 100\n",
"4 4 3\n2 5 6 3\n4 8 10 5\n2 6 7 1\n8 4 2 1\n1 1 8\n2 3 4\n4 4 5\n"
],
"output": [
"\n21 22 \n",
"\n123 135 129 145 \n"
]
} | {
"input": [],
"output": []
} |
1478_A. Nezzar and Colorful Balls | Nezzar has n balls, numbered with integers 1, 2, …, n. Numbers a_1, a_2, …, a_n are written on them, respectively. Numbers on those balls form a non-decreasing sequence, which means that a_i ≤ a_{i+1} for all 1 ≤ i < n.
Nezzar wants to color the balls using the minimum number of colors, such that the following holds.
... | {
"input": [],
"output": []
} | {
"input": [
"5\n6\n1 1 1 2 3 4\n5\n1 1 2 2 3\n4\n2 2 2 2\n3\n1 2 3\n1\n1\n"
],
"output": [
"\n3\n2\n4\n1\n1\n"
]
} | {
"input": [
"5\n6\n1 1 1 2 3 4\n5\n1 1 2 2 3\n4\n2 2 2 2\n3\n2 2 3\n1\n1\n",
"5\n6\n1 1 1 2 3 3\n5\n1 1 2 2 3\n4\n1 2 2 2\n3\n2 2 3\n1\n1\n",
"5\n6\n1 1 2 2 3 3\n5\n1 1 2 2 3\n4\n1 2 2 2\n3\n2 2 3\n1\n1\n",
"5\n6\n1 1 1 2 3 6\n5\n1 1 2 2 3\n4\n2 2 2 2\n3\n1 2 3\n1\n1\n",
"5\n6\n1 1 1 2 3 4\n5\n1 ... |
1505_D. Xenolith? Hippodrome? |
Input
The input contains two integers N, M (1 ≤ N ≤ 1024, 2 ≤ M ≤ 16), separated by a single space.
Output
Output "YES" or "NO".
Examples
Input
2 3
Output
YES
Input
3 2
Output
NO
Input
33 16
Output
YES
Input
26 5
Output
NO | {
"input": [],
"output": []
} | {
"input": [
"2 3\n",
"33 16\n",
"26 5\n",
"3 2\n"
],
"output": [
"\nYES\n",
"\nYES\n",
"\nNO\n",
"\nNO\n"
]
} | {
"input": [
"4 3\n",
"33 6\n",
"10 5\n",
"2 2\n",
"5 3\n",
"33 9\n",
"14 5\n",
"2 4\n",
"12 9\n",
"10 6\n",
"2 5\n",
"16 9\n",
"10 3\n",
"1 9\n",
"11 3\n",
"1 2\n",
"11 5\n",
"11 6\n",
"11 11\n",
"5 11\n",
"9 11\n",
"9 16\n",
... |
958_A3. Death Stars (hard) | The stardate is 2015, and Death Stars are bigger than ever! This time, two rebel spies have yet again given Heidi two maps with the possible locations of the Death Stars.
Heidi has now received two maps with possible locations of N Death Stars. She knows that each of the maps is possibly corrupted, and may contain som... | {
"input": [],
"output": []
} | {
"input": [],
"output": []
} | {
"input": [],
"output": []
} |
983_B. XOR-pyramid | For an array b of length m we define the function f as
f(b) = \begin{cases} b[1] & if m = 1 \\\ f(b[1] ⊕ b[2],b[2] ⊕ b[3],...,b[m-1] ⊕ b[m]) & otherwise, \end{cases}
where ⊕ is [bitwise exclusive OR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).
For example, f(1,2,4,8)=f(1⊕2,2⊕4,4⊕8)=f(3,6,12)=f(3⊕6... | {
"input": [],
"output": []
} | {
"input": [
"6\n1 2 4 8 16 32\n4\n1 6\n2 5\n3 4\n1 2\n",
"3\n8 4 1\n2\n2 3\n1 2\n"
],
"output": [
"60\n30\n12\n3\n",
"5\n12\n"
]
} | {
"input": [
"6\n1 2 4 12 16 32\n4\n1 6\n2 5\n3 4\n1 2\n",
"3\n6 4 1\n2\n2 3\n1 2\n",
"6\n0 2 4 12 16 32\n4\n2 6\n2 5\n3 4\n1 2\n",
"6\n0 2 4 12 16 32\n4\n2 3\n2 5\n3 4\n1 2\n",
"3\n8 4 1\n2\n2 3\n2 2\n",
"6\n1 2 4 12 16 32\n4\n1 6\n2 6\n3 4\n1 2\n",
"6\n0 4 4 12 16 32\n4\n2 6\n2 5\n3 4\n1... |
bitwise-1 | You are a member of a bomb-disposal squad. Each bomb is identified by a unique serial id X, which is a positive integer. To disarm the bomb, a positive integral key Y needs to be entered such that X + Y = X ⊕ Y (here "⊕" denotes the bit-wise XOR operator and "+" denotes the arithmetic sum operator).
However, there ar... | {
"input": [],
"output": []
} | {
"input": [
"2\n16 3\n8 1\n\nSAMPLE"
],
"output": [
"Case #1: 3\nCase #2: 1"
]
} | {
"input": [
"2\n16 6\n8 1\n\nSAMPLE",
"2\n6 6\n8 1\n\nSAMPLE",
"2\n6 9\n8 1\n\nSAMPLE",
"2\n16 3\n8 1\n\nSLMPAE",
"2\n16 3\n5 1\n\nSAMPLE",
"2\n6 9\n15 1\n\nSAMPLE",
"2\n11 3\n8 1\n\nSLMPAE",
"2\n16 6\n5 1\n\nSAMPLE",
"2\n11 3\n8 2\n\nSLMPAE",
"2\n6 9\n13 1\n\nELPMAS",
"2\... |
crazy-numbers-1 | Golu is crazy about numbers. He loves those numbers such that the difference between the adjacent digits of that number is exactly one. He calls these numbers crazy numbers and wants to find out how many such numbers exist for N number of digits. This task is very difficult for him so he wants your help.
Now your task... | {
"input": [],
"output": []
} | {
"input": [
"2\n1\n2\n\nSAMPLE"
],
"output": [
"10\n17"
]
} | {
"input": [],
"output": []
} |
mike-and-his-guitar-collection-3 | Mike has a huge guitar collection which the whole band is jealous of. Brad, the lead guitarist of the band, gave Mike a challenge so that he can't use all his guitars. The band is on a world tour and Brad told Mike to assign numbers to all his guitars. After that, he told Mike that he can use the guitars in such a mann... | {
"input": [],
"output": []
} | {
"input": [
"3\n1\n1\n2\n1 2\n3\n1 2 3\n\nSAMPLE"
],
"output": [
"2\n4\n7\n"
]
} | {
"input": [
"3\n1\n1\n2\n1 2\n3\n1 2 3\n\nSAMPKE",
"3\n1\n1\n2\n1 2\n3\n1 2 4\n\nSAMPKE",
"3\n1\n1\n2\n1 0\n3\n1 2 4\n\nSAMPKE",
"3\n1\n0\n2\n1 0\n3\n1 2 4\n\nSAMPKE",
"3\n1\n0\n2\n1 2\n3\n1 2 3\n\nSAMPLE",
"3\n1\n1\n2\n1 -1\n3\n1 2 4\n\nSAMPKE",
"3\n1\n2\n2\n1 2\n3\n1 3 3\n\nSAMPKE",
... |
p1-6 | Raj's lucky number is 101. His girl friend Rani wants to give him a string S as a birthday present to him. She went to a shop and there are variety of strings which contains only 1 and 0 ( Binary string ) in that shop. Now in order to impress Raj , she wants to buy a string with highest number of subsequence’s of 101'... | {
"input": [],
"output": []
} | {
"input": [
"10101\n\nSAMPLE"
],
"output": [
"4\n"
]
} | {
"input": [
"10101\n\nELPMAS",
"10101\n\nFLPMAS",
"10101\n\nSAMPLF",
"10101\n\nSAFPLM",
"10101\n\nMLPFAS",
"10101\n\nMLPFBS",
"10101\n\nMLPSBF",
"10101\n\nFBSPLM",
"10101\n\nFBSPKM",
"10101\n\nFBSPKN",
"10101\n\nFBKPSN",
"10101\n\nFBKPSM",
"10101\n\nMSPKBF",
"1... |
remove-friends-5 | After getting her PhD, Christie has become a celebrity at her university, and her facebook profile is full of friend requests. Being the nice girl she is, Christie has accepted all the requests.
Now Kuldeep is jealous of all the attention she is getting from other guys, so he asks her to delete some of the guys from h... | {
"input": [],
"output": []
} | {
"input": [
"3\n3 1\n3 100 1\n5 2\n19 12 3 4 17\n5 3\n23 45 11 77 18\n\nSAMPLE"
],
"output": [
"100 1\n19 12 17\n77 18\n"
]
} | {
"input": [
"3\n3 0\n3 100 1\n5 2\n19 12 3 4 17\n5 3\n23 45 11 77 18\n\nSAMPLE",
"3\n3 1\n3 101 1\n5 2\n19 12 3 4 17\n5 3\n23 45 11 77 18\n\nSAMPLE",
"3\n3 0\n3 101 1\n5 2\n19 12 3 4 17\n5 3\n23 45 11 77 18\n\nSAMPLE",
"3\n3 0\n3 101 2\n5 2\n19 12 3 4 17\n5 3\n23 45 11 77 18\n\nSAMPLE",
"3\n3 0\n... |
sonas-number-sequence | Sona is busy in organizing Port '16. Sona has to formulate two number sequence as two list. As she loves numbers she wrote the two number sequence in two different papers. Both the list have N numbers. She also named the number sequence as A and B where A = {a0,a1,...aN-1} and B = {b0,b1,..,bN-1} where as
b0 = a0... | {
"input": [],
"output": []
} | {
"input": [
"5\n10 11 12 13 14\n\nSAMPLE"
],
"output": [
"10 12 14 16 18\n"
]
} | {
"input": [
"5\n10 11 12 13 14\n\nSAMOLE",
"5\n10 11 15 13 14\n\nSAMOLE",
"5\n20 11 15 13 14\n\nELOMAS",
"5\n20 11 15 13 17\n\nSAMOLE",
"5\n30 11 15 13 17\n\nSAMOLE",
"5\n30 11 15 12 17\n\nSAMOLE",
"5\n30 11 4 12 17\n\nSAMOLE",
"5\n30 6 4 12 17\n\nSAMOLE",
"5\n30 12 4 12 17\n\nSAM... |
p02565 AtCoder Library Practice Contest - Two SAT | Consider placing N flags on a line. Flags are numbered through 1 to N.
Flag i can be placed on the coordinate X_i or Y_i. For any two different flags, the distance between them should be at least D.
Decide whether it is possible to place all N flags. If it is possible, print such a configulation.
Constraints
* 1 \l... | {
"input": [],
"output": []
} | {
"input": [
"3 3\n1 4\n2 5\n0 6",
"3 2\n1 4\n2 5\n0 6"
],
"output": [
"No",
"Yes\n4\n2\n0"
]
} | {
"input": [
"3 3\n1 4\n2 5\n0 10",
"3 2\n1 5\n2 5\n0 6",
"3 3\n1 4\n2 2\n0 10",
"3 2\n1 5\n4 5\n0 6",
"3 3\n1 4\n2 4\n0 10",
"3 3\n1 4\n2 5\n0 16",
"3 3\n1 2\n2 4\n-1 9",
"3 3\n2 4\n2 1\n0 10",
"3 3\n0 4\n2 1\n-1 13",
"3 3\n-1 4\n2 1\n-1 5",
"0 3\n1 4\n2 5\n0 16",
"3 3... |
p02696 AtCoder Beginner Contest 165 - Floor Function | Given are integers A, B, and N.
Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.
Here floor(t) denotes the greatest integer not greater than the real number t.
Constraints
* 1 ≤ A ≤ 10^{6}
* 1 ≤ B ≤ 10^{12}
* 1 ≤ N ≤ 10^{12}
* All values in input are i... | {
"input": [],
"output": []
} | {
"input": [
"5 7 4",
"11 10 9"
],
"output": [
"2",
"9"
]
} | {
"input": [
"4 7 4",
"1 7 4",
"5 7 5",
"2 7 4",
"7 7 5",
"20 10 3",
"35 10 3",
"9 6 5",
"56 12 1",
"11 4 4",
"11 11 9",
"-2 2 1",
"14 7 8",
"42 7 3",
"11 10 2",
"2 10 2",
"1 7 1",
"2 10 0",
"1 7 0",
"2 11 0",
"2 11 1",
"3 11 1",
... |
p02825 AtCoder Grand Contest 041 - Domino Quality | Let us consider a grid of squares with N rows and N columns. You want to put some domino pieces on this grid. Each domino piece covers two squares that have a common side. Each square can be covered by at most one piece.
For each row of the grid, let's define its quality as the number of domino pieces that cover at le... | {
"input": [],
"output": []
} | {
"input": [
"2",
"6"
],
"output": [
"-1",
"aabb..\nb..zz.\nba....\n.a..aa\n..a..b\n..a..b"
]
} | {
"input": [
"0",
"3",
"5",
"4",
"10",
"13",
"14",
"11",
"15",
"7",
"9",
"8",
"28",
"36",
"12",
"17",
"20",
"26",
"18",
"30",
"16",
"47",
"83",
"111",
"101",
"100",
"34",
"110",
"24",
"59",
"38"... |
p02962 AtCoder Beginner Contest 135 - Strings of Eternity | Given are two strings s and t consisting of lowercase English letters. Determine if the number of non-negative integers i satisfying the following condition is finite, and find the maximum value of such i if the number is finite.
* There exists a non-negative integer j such that the concatenation of i copies of t is a... | {
"input": [],
"output": []
} | {
"input": [
"aa\naaaaaaa",
"aba\nbaaab",
"abcabab\nab"
],
"output": [
"-1",
"0",
"3"
]
} | {
"input": [
"aa\nabaaaaa",
"abcaabb\nab",
"aba\naaaab",
"aa\naaaaaba",
"aba\naa`ab",
"accaabb\nab",
"ab\naaaaaba",
"`ba\naa`ab",
"acdaabb\nab",
"ab\nabaaaaa",
"`ab\naa`ab",
"acda`bb\nab",
"ab\nabaaaba",
"ab`\naa`ab",
"acda`bb\naa",
"ab\nab`aaba",
"a... |
p03097 AtCoder Grand Contest 031 - Differ by 1 Bit | You are given integers N,\ A and B. Determine if there exists a permutation (P_0,\ P_1,\ ...\ P_{2^N-1}) of (0,\ 1,\ ...\ 2^N-1) that satisfies all of the following conditions, and create one such permutation if it exists.
* P_0=A
* P_{2^N-1}=B
* For all 0 \leq i < 2^N-1, the binary representations of P_i and P_{i+1} ... | {
"input": [],
"output": []
} | {
"input": [
"3 2 1",
"2 1 3"
],
"output": [
"NO",
"YES\n1 0 2 3"
]
} | {
"input": [
"2 1 0",
"2 0 0",
"1 0 1",
"2 2 0",
"1 2 3",
"1 3 2",
"2 3 2",
"2 0 2",
"2 2 3",
"2 3 1",
"2 0 1",
"1 1 0",
"1 -2 -1",
"1 -1 -2",
"4 0 0",
"7 0 0",
"6 2 1",
"1 0 0",
"5 0 0",
"5 2 1",
"2 2 1",
"1 1 1",
"2 2 2",
... |
p03243 AtCoder Beginner Contest 111 - AtCoder Beginner Contest 111 | Kurohashi has never participated in AtCoder Beginner Contest (ABC).
The next ABC to be held is ABC N (the N-th ABC ever held). Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.
What is the earliest ABC where Kurohashi can make his debut?
Constraints
* 100 \leq N... | {
"input": [],
"output": []
} | {
"input": [
"750",
"112",
"111"
],
"output": [
"777",
"222",
"111"
]
} | {
"input": [
"426",
"101",
"638",
"268",
"457",
"000",
"985",
"846",
"198",
"706",
"110",
"001",
"409",
"100",
"662",
"011",
"010",
"514",
"583",
"223",
"625",
"266",
"645",
"195",
"398",
"155",
"517",
"375... |
p03396 AtCoder Grand Contest 022 - Shopping | Yui loves shopping. She lives in Yamaboshi City and there is a train service in the city. The city can be modelled as a very long number line. Yui's house is at coordinate 0.
There are N shopping centres in the city, located at coordinates x_{1}, x_{2}, ..., x_{N} respectively. There are N + 2 train stations, one loca... | {
"input": [],
"output": []
} | {
"input": [
"5 100\n10 19 28 47 68\n200 200 200 200 200",
"2 10\n5 8\n10 5",
"8 1000000000\n2018 123456 1719128 1929183 9129198 10100101 77777777 120182018\n99999999 1000000000 1000000000 11291341 1 200 1 123812831",
"2 10\n5 8\n10 4"
],
"output": [
"1200",
"60",
"14000000000",
"4... | {
"input": [
"0 100\n10 19 28 47 68\n200 200 200 200 200",
"2 13\n5 8\n10 5",
"8 1000000000\n2018 123456 1719128 1929183 9129198 10100101 77777777 120182018\n99999999 1000000000 1000000000 11291341 1 148 1 123812831",
"2 10\n0 8\n10 4",
"2 10\n0 8\n10 7",
"0 10\n0 8\n10 7",
"0 7\n0 7\n1 8"... |
p03561 AtCoder Regular Contest 084 - Finite Encyclopedia of Integer Sequences | In Finite Encyclopedia of Integer Sequences (FEIS), all integer sequences of lengths between 1 and N (inclusive) consisting of integers between 1 and K (inclusive) are listed.
Let the total number of sequences listed in FEIS be X. Among those sequences, find the (X/2)-th (rounded up to the nearest integer) lexicograph... | {
"input": [],
"output": []
} | {
"input": [
"2 4",
"5 14",
"3 2"
],
"output": [
"1 2 2 2",
"3 3 3 3 3 3 3 3 3 3 3 3 2 2",
"2 1"
]
} | {
"input": [
"0 4",
"8 14",
"0 14",
"1 14",
"2 14",
"2 1",
"0 1",
"2 5",
"2 26",
"2 2",
"0 5",
"9 14",
"0 28",
"2 10",
"0 2",
"3 1",
"1 5",
"2 11",
"0 3",
"9 12",
"1 28",
"1 10",
"4 2",
"1 4",
"3 11",
"9 18",
"... |
p03714 AtCoder Beginner Contest 062 - 3N Numbers | Let N be a positive integer.
There is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}). Snuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements. Here, the score of a' is defined as follows: (the sum of the elements ... | {
"input": [],
"output": []
} | {
"input": [
"2\n3 1 4 1 5 9",
"1\n1 2 3",
"3\n8 2 2 7 4 6 5 3 8"
],
"output": [
"1",
"-1",
"5"
]
} | {
"input": [
"2\n3 1 4 1 7 9",
"3\n8 2 2 7 4 6 6 3 8",
"2\n3 1 4 1 7 0",
"1\n1 0 5",
"1\n1 -1 5",
"3\n8 1 2 7 4 6 6 0 8",
"1\n0 0 5",
"2\n3 2 4 2 11 0",
"3\n8 2 2 7 4 6 4 0 15",
"3\n8 2 2 7 4 6 4 -1 15",
"3\n8 2 2 13 4 6 4 -1 15",
"3\n8 2 2 13 4 6 4 0 11",
"3\n8 2 2... |
p03875 CODE FESTIVAL 2016 Grand Final - AB=C Problem | Snuke received two matrices A and B as birthday presents. Each of the matrices is an N by N matrix that consists of only 0 and 1.
Then he computed the product of the two matrices, C = AB. Since he performed all computations in modulo two, C was also an N by N matrix that consists of only 0 and 1. For each 1 ≤ i, j ≤ N... | {
"input": [],
"output": []
} | {
"input": [
"2\n0 1\n1 0",
"10\n1 0 0 1 1 1 0 0 1 0\n0 0 0 1 1 0 0 0 1 0\n0 0 1 1 1 1 1 1 1 1\n0 1 0 1 0 0 0 1 1 0\n0 0 1 0 1 1 1 1 1 1\n1 0 0 0 0 1 0 0 0 0\n1 1 1 0 1 0 0 0 0 1\n0 0 0 1 0 0 1 0 1 0\n0 0 0 1 1 1 0 0 0 0\n1 0 1 0 0 1 1 1 1 1"
],
"output": [
"6",
"741992411"
]
} | {
"input": [
"2\n0 1\n1 -1",
"10\n1 0 0 1 1 1 0 0 1 0\n0 0 0 1 1 0 0 0 1 0\n0 0 1 1 1 1 1 1 1 1\n0 1 0 1 0 0 0 1 1 0\n0 0 1 0 1 1 1 1 1 1\n1 0 0 0 0 1 0 0 0 0\n1 1 1 0 1 0 0 0 0 1\n0 0 0 1 0 0 1 0 1 0\n0 0 0 1 1 0 0 0 0 0\n1 0 1 0 0 1 1 1 1 1",
"10\n1 0 0 1 1 1 0 0 1 0\n0 0 0 1 1 0 0 0 1 0\n0 0 1 1 1 1 1 ... |
p04037 AtCoder Grand Contest 002 - Candy Piles | There are N piles of candies on the table. The piles are numbered 1 through N. At first, pile i contains a_i candies.
Snuke and Ciel are playing a game. They take alternating turns. Snuke goes first. In each turn, the current player must perform one of the following two operations:
1. Choose a pile with the largest n... | {
"input": [],
"output": []
} | {
"input": [
"3\n1 2 1",
"2\n1 3",
"3\n1 2 3"
],
"output": [
"First",
"First",
"Second"
]
} | {
"input": [
"3\n1 0 1",
"2\n0 3",
"3\n1 1 3",
"3\n2 0 1",
"3\n1 1 4",
"3\n3 0 1",
"3\n1 0 4",
"3\n5 0 1",
"3\n0 0 4",
"3\n1 0 2",
"3\n1 4 1",
"2\n1 4",
"3\n1 2 5",
"2\n1 0",
"3\n1 1 6",
"3\n2 1 1",
"3\n1 0 6",
"3\n4 0 1",
"3\n2 -1 4",
"3... |
p00118 Property Distribution | Mr. Tanaka died leaving the orchard of HW Earl. The orchard is divided into H x W plots in the north, south, east, and west directions, and apples, oysters, and oranges are planted in each plot. Mr. Tanaka left such a will.
Divide the orchard into as many relatives as possible on a parcel basis. However, if the same k... | {
"input": [],
"output": []
} | {
"input": [
"10 10\n*****@\n@#@@@@#*#*\n@##***@@@*\n****#*@**\n@*#@@*##\n*@@@@*@@@#\n***#@*@##*\n*@@@*@@##@\n*@*#*@##**\n@****#@@#@\n0 0",
"10 10\n####*****@\n@#@@@@#*#*\n@##***@@@*\n#****#*@**\n##@*#@@*##\n*@@@@*@@@#\n***#@*@##*\n*@@@*@@##@\n*@*#*@##**\n@****#@@#@\n0 0"
],
"output": [
"33",
"33"... | {
"input": [
"10 10\n*****@\n@#@@@@#*#*\n@##***@@@*\n****#*@**\n@*#?@*##\n*@@@@*@@@#\n***#@*@##*\n*@@@*@@##@\n*@*#*@##**\n@****#@@#@\n0 0",
"10 10\n*****@\n@#@@@@#*#*\n@##***@@@*\n****#*@**\n@*#?@*##\n*@@@@*@@A#\n***#@*@##*\n@@@@*@*##@\n*@*#*@##**\n@****#@@#@\n0 0",
"10 10\n*****@\n@#@@@@#*#*\n@##***@@@*\... |
p00251 Points for a Perfect Scorer | Welcome to PC Koshien, players. This year marks the 10th anniversary of Computer Koshien, but the number of questions and the total score will vary from year to year. Scores are set for each question according to the difficulty level. When the number of questions is 10 and the score of each question is given, create a ... | {
"input": [],
"output": []
} | {
"input": [
"1\n2\n3\n4\n5\n6\n7\n8\n9\n10"
],
"output": [
"55"
]
} | {
"input": [
"1\n2\n4\n4\n5\n6\n7\n8\n9\n10",
"1\n2\n8\n4\n5\n6\n7\n8\n9\n10",
"1\n2\n8\n4\n3\n6\n7\n8\n9\n10",
"1\n2\n8\n3\n3\n6\n7\n8\n9\n10",
"1\n2\n8\n3\n3\n6\n7\n5\n9\n10",
"1\n2\n8\n4\n3\n6\n7\n5\n9\n10",
"1\n2\n2\n4\n3\n6\n7\n5\n9\n10",
"1\n2\n2\n4\n3\n6\n7\n5\n12\n10",
"1\n... |
p00432 Sheets | There are several rectangular sheets placed on a flat surface. Create a program to find the area and perimeter of the part covered by these sheets.
However, when the plane is regarded as the coordinate plane, the arrangement of the sheets shall satisfy the following conditions (1) and (2).
(1) The x and y coordinates... | {
"input": [],
"output": []
} | {
"input": [
"5 1\n0 0 3 2\n1 1 2 5\n0 4 6 5\n3 3 5 6\n5 0 7 6\n5 2\n0 0 3 2\n1 1 2 5\n0 4 6 5\n3 3 5 6\n5 0 7 6\n2 2\n0 0 8 9\n0 0 9 8\n3 2\n2 2 8 8\n3 0 4 9\n5 0 7 9\n0 0"
],
"output": [
"29\n29\n38\n80\n36\n45\n36"
]
} | {
"input": [
"5 1\n0 0 3 2\n1 1 2 5\n0 4 6 5\n3 3 5 6\n5 0 7 6\n5 2\n0 0 3 2\n1 1 2 5\n0 4 6 5\n3 3 5 6\n5 0 7 6\n2 2\n0 0 8 9\n0 1 9 8\n3 2\n2 2 8 8\n3 0 4 9\n5 0 7 9\n0 0",
"5 1\n0 0 3 2\n1 1 2 5\n0 4 6 5\n3 3 5 6\n5 0 7 6\n5 2\n0 0 3 2\n1 1 2 5\n0 4 6 5\n3 3 5 6\n5 0 7 6\n2 2\n0 0 8 3\n0 1 9 8\n3 2\n2 2 8 ... |
p00628 Yes | Dr .: Peter, do you know "Yes, I have a number"?
Peter: I used to do it on TV the other day. You remember something by the number of characters in each word contained in a sentence. "Yes, I have a number", so it means "the number 3.14" and is a keyword for remembering pi.
Dr .: Peter, that's not the case. This should... | {
"input": [],
"output": []
} | {
"input": [
"Yes I have a number\nHow I wish I could calculate an unused color for space\nThank you\nEND OF INPUT"
],
"output": [
"31416\n31415926535\n53"
]
} | {
"input": [
"Yes I have a number\nHow I wish I could calculate an unused bolor for space\nThank you\nEND OF INPUT",
"Yes I have a rebmun\nHow I wish I could calculate an unused bolor for space\nThank you\nEND OF INPUT",
"Yes I have a rebmun\nHow J wish I could calculate an unused bolor for space\nThank y... |
p00772 Rotate and Rewrite | Rotate and Rewrite
Two sequences of integers A: A1 A2 ... An and B: B1 B2 ... Bm and a set of rewriting rules of the form "x1 x2 ... xk -> y" are given. The following transformations on each of the sequences are allowed an arbitrary number of times in an arbitrary order independently.
* Rotate: Moving the first eleme... | {
"input": [],
"output": []
} | {
"input": [
"3 3 3\n1 2 3\n4 5 6\n2 1 2 5\n2 6 4 3\n2 5 3 1\n3 3 2\n1 1 1\n2 2 1\n2 1 1 2\n2 2 2 1\n7 1 2\n1 1 2 1 4 1 2\n4\n3 1 4 1 4\n3 2 4 2 4\n16 14 5\n2 1 2 2 1 3 2 1 3 2 2 1 1 3 1 2\n2 1 3 1 1 2 3 1 2 2 2 2 1 3\n2 3 1 3\n3 2 2 2 1\n3 2 2 1 2\n3 1 2 2 2\n4 2 1 2 2 2\n0 0 0"
],
"output": [
"2\n-1\n1\... | {
"input": [
"3 3 3\n1 2 3\n4 5 6\n2 1 2 5\n2 6 4 3\n2 5 3 1\n3 3 2\n1 1 2\n2 2 1\n2 1 1 2\n2 2 2 1\n7 1 2\n1 1 2 1 4 1 2\n4\n3 1 4 1 4\n3 2 4 2 4\n16 14 5\n2 1 2 2 1 3 2 1 3 2 2 1 1 3 1 2\n2 1 3 1 1 2 3 1 2 2 2 2 1 3\n2 3 1 3\n3 2 2 2 1\n3 2 2 1 2\n3 1 2 2 2\n4 2 1 2 2 2\n0 0 0",
"3 3 3\n1 2 3\n4 5 6\n2 1 2 ... |
p00903 Round Trip | Jim is planning to visit one of his best friends in a town in the mountain area. First, he leaves his hometown and goes to the destination town. This is called the go phase. Then, he comes back to his hometown. This is called the return phase. You are expected to write a program to find the minimum total cost of this t... | {
"input": [],
"output": []
} | {
"input": [
"3 6\n3 1\n1 2 1\n2 3 1\n3 2 1\n2 1 1\n1 3 4\n3 1 4\n3 6\n5 1\n1 2 1\n2 3 1\n3 2 1\n2 1 1\n1 3 4\n3 1 4\n4 5\n3 1\n3 1\n1 2 5\n2 3 5\n3 4 5\n4 2 5\n3 1 5\n2 1\n2 1 1\n0 0"
],
"output": [
"7\n8\n36\n-1"
]
} | {
"input": [
"3 6\n3 1\n1 2 1\n2 3 1\n3 2 1\n2 1 1\n1 3 4\n3 1 4\n3 6\n5 1\n2 2 1\n2 3 1\n3 2 1\n2 1 1\n1 3 4\n3 1 4\n4 5\n3 1\n3 1\n1 2 5\n2 3 5\n3 4 5\n4 2 5\n3 1 5\n2 1\n2 1 1\n0 0",
"3 6\n3 1\n1 2 1\n2 3 1\n3 3 1\n2 1 1\n1 3 4\n3 1 4\n3 6\n5 1\n1 2 1\n2 3 1\n3 2 1\n2 1 1\n1 3 4\n3 1 4\n4 5\n3 1\n3 1\n1 2 ... |
p01036 Yu-kun Likes To Play Darts | Background
The kindergarten attached to the University of Aizu is a kindergarten where children who love programming gather. Yu, one of the kindergarten children, loves darts as much as programming. Yu-kun was addicted to darts recently, but he got tired of ordinary darts, so he decided to make his own darts board.
S... | {
"input": [],
"output": []
} | {
"input": [
"1 2 2 1\n4 1\n0 0\n5 0\n5 5\n0 5",
"1 2 2 1\n4 1\n0 0\n2 0\n2 2\n0 2",
"1 10 10 1\n4 10\n0 0\n1 0\n1 1\n0 1",
"4 3 3 2\n3 1\n1 1\n3 3\n1 5\n4 2\n2 0\n5 0\n4 2\n3 2\n3 3\n4 3\n6 1\n6 5\n4 4\n3 4\n4 4\n5 6\n2 6"
],
"output": [
"1.0000000000",
"0.2500000000",
"0.0000000000",... | {
"input": [
"1 2 2 1\n4 1\n-1 0\n5 0\n5 5\n0 5",
"1 2 2 1\n4 1\n0 0\n1 0\n2 2\n0 2",
"4 3 3 2\n3 1\n1 1\n3 3\n1 5\n4 2\n2 0\n5 0\n4 2\n3 2\n3 3\n4 3\n6 1\n6 5\n4 1\n3 4\n4 4\n5 6\n2 6",
"1 2 3 1\n4 1\n0 0\n1 0\n2 2\n0 2",
"4 3 4 2\n3 1\n1 1\n3 3\n1 5\n4 2\n2 0\n5 0\n4 2\n3 2\n3 3\n4 3\n6 1\n6 5\n... |
p01170 Robots' Crash | Prof. Jenifer A. Gibson is carrying out experiments with many robots. Since those robots are expensive, she wants to avoid their crashes during her experiments at her all effort. So she asked you, her assistant, as follows.
“Suppose that we have n (2 ≤ n ≤ 100000) robots of the circular shape with the radius of r, and... | {
"input": [],
"output": []
} | {
"input": [
"2\n1.0 0.0\n0.5\n0.0 0.0 1\n2.0 0.0 -1\n2\n1.0 0.0\n0.5\n0.0 0.0 -1\n2.0 0.0 1\n0"
],
"output": [
"0.500000\nSAFE"
]
} | {
"input": [
"2\n1.0 0.0\n0.5\n0.0 0.0 1\n2.0 0.7806891925202921 -1\n2\n1.0 0.0\n0.5\n0.0 0.0 -1\n2.0 0.0 1\n0",
"2\n1.0 0.0\n0.5\n0.0 0.0 1\n2.0 0.0 -1\n0\n1.0 0.0\n0.5\n0.0 0.0 -1\n2.0 0.0 1\n0",
"2\n1.5695571290886796 0.0\n0.5\n0.0 0.0 1\n2.0 0.7806891925202921 -1\n2\n1.0 0.0\n0.7495161301689056\n0.0 0... |
p01306 Unit Converter | In the International System of Units (SI), various physical quantities are expressed in the form of "numerical value + prefix + unit" using prefixes such as kilo, mega, and giga. For example, "3.5 kilometers", "5.1 milligrams", and so on.
On the other hand, these physical quantities can be expressed as "3.5 * 10 ^ 3 m... | {
"input": [],
"output": []
} | {
"input": [
"7\n12.3 kilo meters\n0.45 mega watts\n0.000000000000000000000001 yotta grams\n1000000000000000000000000 yocto seconds\n42 amperes\n0.42 joules\n1234.56789012345678901234567890 hecto pascals"
],
"output": [
"1.23 * 10^4 meters\n4.5 * 10^5 watts\n1 * 10^0 grams\n1.000000000000000000000000 * 10... | {
"input": [
"7\n12.3 kilo meters\n0.45 mega watts\n0.000000000000000000000001 yotta grams\n1000000000000000000000000 yocto seconds\n42 amperes\n0.951642419825234 joules\n1234.56789012345678901234567890 hecto pascals",
"7\n12.3 kilo meters\n0.45 mega watts\n0.5868394692236264 yotta grams\n10000000000000000000... |
p01475 Plane Division | Problem statement
The curve given by one implicit function $ Ax ^ 2 + Bxy + Cy ^ 2 + Dx + Ey + F = 0 $ and the straight line given by $ N $ implicit functions $ A_ix + B_iy + C_i = 0 $ is there. Find out how many regions the plane is divided by these curves and straight lines.
The following is a diagram of the Sample... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 0 -1 0 0 -1\n3 0 6\n-5 0 -10",
"2\n1 0 0 0 -1 0\n2 -1 -1\n6 9 1",
"1\n1 0 1 0 0 -1\n1 -1 0"
],
"output": [
"6",
"7",
"4"
]
} | {
"input": [
"2\n1 0 -1 0 0 0\n3 0 6\n-5 0 -10",
"2\n1 0 0 0 -1 0\n2 -1 -1\n10 9 1",
"1\n1 0 1 0 0 -1\n1 -2 0",
"2\n1 0 0 0 -1 1\n2 -1 -1\n10 9 1",
"2\n1 -1 -1 0 0 0\n3 0 6\n-5 1 -10",
"2\n1 0 0 0 -1 0\n1 -1 -1\n10 9 1",
"2\n1 -1 -1 0 0 -1\n3 0 6\n-5 0 -6",
"1\n-2 2 -1 0 0 0\n0 -1 1",
... |
p01635 Time Complexity | ICPC World Finals Day 1
In programming contests, it is important to know the execution time of the program. If you make a mistake in estimating the execution time and write code that exceeds the time limit, you will lose that much time. This is especially true in team battles where only one computer can be used, such ... | {
"input": [],
"output": []
} | {
"input": [
"n T\nf(n)"
],
"output": [
"101010000"
]
} | {
"input": [
"n T\ng(n)",
"m T\ng(n)",
"n T\n)n(g",
"n S\n)n(g",
"n S\n)n(h",
"n S\nh(n)",
"n R\nh(n)",
"n R\nh(n(",
"n R\nh((n",
"m R\nh((n",
"m R\n((hn",
"m R\n(h(n",
"m R\nnh((",
"m R\nnh()",
"m R\nmh()",
"m Q\nmh()",
"n Q\nmh()",
"n R\nmh()",... |
p01787 RLE Replacement | H - RLE Replacement
Problem Statement
In JAG Kingdom, ICPC (Intentionally Compressible Programming Code) is one of the common programming languages. Programs in this language only contain uppercase English letters and the same letters often appear repeatedly in ICPC programs. Thus, programmers in JAG Kingdom prefer t... | {
"input": [],
"output": []
} | {
"input": [
"R 100 L 20 E 10 \\$\nR 5 L 10 \\$\nX 20 \\$"
],
"output": [
"R 95 X 20 L 10 E 10 \\$"
]
} | {
"input": [
"R 100 L 20 E 10 \\$\nR 5 L 6 \\$\nX 20 \\$",
"R 100 L 20 E 6 \\$\nR 5 L 10 \\$\nX 20 $\\",
"R 100 L 23 E 10 \\$\nR 5 L 6 \\$\nX 20 $\\",
"R 100 K 20 E 10 \\$\nS 1 L 11 \\#\nX 20 \\$",
"R 100 L 20 D 10 \\$\nS 1 L 11 \\%\nW 20 \\$",
"R 100 L 15 E 6 \\$\nR 5 L 10 \\$\nX 20 $\\",
... |
p01922 Love Permutation | G: Koi no Junretsu Run! Run! Run! --Love Permutation, Run run run! -
story
Big Junretsu Ranran Randebu ♪ Hello, Hoshizora Ran Nya! My favorite data structure is Starry Sky Tree Nya!
Ran recently enrolled in the Department of Physics, but apparently he has to do programming there as well. Orchids, I like the theory o... | {
"input": [],
"output": []
} | {
"input": [
"5\n3 4 2 1 5\n3\n1 2 3"
],
"output": [
"Yes"
]
} | {
"input": [
"5\n3 4 4 1 5\n3\n1 2 3",
"5\n3 3 2 1 5\n3\n1 2 3",
"5\n3 4 2 2 5\n3\n1 2 3",
"5\n3 4 4 1 5\n3\n1 2 6",
"5\n3 3 2 0 5\n3\n1 2 3",
"5\n3 4 4 2 5\n3\n1 2 3",
"5\n3 4 4 1 5\n3\n1 0 6",
"5\n3 4 4 2 5\n3\n1 2 5",
"5\n2 4 4 2 5\n3\n1 2 5",
"5\n1 3 2 1 5\n3\n1 2 3",
"... |
p02060 Four Tea | A: four tea
problem
Tea is indispensable for programming contests. Tea has the effect of relieving constant tension [citation needed]
There are N players participating in the contest, so I would like to prepare tea for this number of people. There are four types of tea packages, A, B, C, and D, all of which are the ... | {
"input": [],
"output": []
} | {
"input": [
"10\n1 2 3 4\n1 2 4 8"
],
"output": [
"6"
]
} | {
"input": [
"10\n1 2 3 2\n1 2 4 8",
"10\n1 1 3 2\n0 2 3 8",
"10\n1 1 3 2\n0 2 3 16",
"10\n0 1 3 2\n1 2 3 16",
"10\n1 2 3 4\n1 3 4 8",
"10\n1 1 3 2\n0 2 3 1",
"10\n0 1 6 1\n0 0 1 50",
"10\n0 2 1 4\n0 1 0 8",
"10\n1 2 3 2\n0 0 4 3",
"10\n1 1 6 2\n1 1 2 1",
"10\n1 1 5 1\n0 1 ... |
p02202 Gag | Gag
Segtree has $ N $ of "gags", each with a value of $ V_i $.
Segtree decided to publish all the gags in any order.
Here, the "joy" you get when you publish the $ i $ th gag to the $ j $ th is expressed as $ V_i --j $.
Find the maximum sum of the "joy" you can get.
input
Input is given from standard input in the... | {
"input": [],
"output": []
} | {
"input": [
"1\n59549"
],
"output": [
"59548"
]
} | {
"input": [
"1\n114525",
"1\n105905",
"1\n196252",
"1\n26794",
"1\n22977",
"1\n6310",
"1\n12378",
"1\n20899",
"1\n6312",
"1\n6759",
"1\n1599",
"1\n1545",
"1\n545",
"1\n834",
"1\n736",
"1\n1350",
"1\n1692",
"1\n1144",
"1\n456",
"1\n372",
... |
p02356 The Number of Windows | For a given array $a_1, a_2, a_3, ... , a_N$ of $N$ elements and $Q$ integers $x_i$ as queries, for each query, print the number of combinations of two integers $(l, r)$ which satisfies the condition: $1 \leq l \leq r \leq N$ and $a_l + a_{l+1} + ... + a_{r-1} + a_r \leq x_i$.
Constraints
* $1 \leq N \leq 10^5$
* $1 ... | {
"input": [],
"output": []
} | {
"input": [
"6 5\n1 2 3 4 5 6\n6 9 12 21 15"
],
"output": [
"9\n12\n15\n21\n18"
]
} | {
"input": [
"6 5\n1 2 3 4 7 6\n6 9 12 21 15",
"6 5\n1 2 3 2 7 6\n6 9 12 21 15",
"6 5\n1 2 3 2 7 6\n6 12 12 21 15",
"6 5\n1 2 3 2 7 6\n0 12 12 21 15",
"6 5\n1 2 3 5 5 6\n6 9 12 21 15",
"6 5\n1 2 3 4 7 6\n6 9 12 21 21",
"6 5\n1 2 3 2 7 6\n6 1 12 21 15",
"6 5\n1 4 3 2 7 6\n6 1 12 21 15",... |
bytesg | Do you like Treasure Hunts? I like treasure hunts. Love ‘em. And TROIKA 2013 has the best one ever in ‘MIST’ (apps.facebook.com/mist_troika).
Just like a normal treasure hunt, you are given several clues and you have to get the right answer to progress to the next level and so on, until you reach the ultimate prize! B... | {
"input": [],
"output": []
} | {
"input": [
"Sachin Ramesh Tendulkar\nSach\nRam\nsAcH Tendul\nsach Tendulkar\nSachin Ram Tendulkar\nSAChin TENduLkaR",
"Sachin Ramesh Tendulkar\nSach\nRam\nsAcH Tendul\nsach Tendulkar\nSachin Ram Tendulkar\nRamesh TENduLkaR"
],
"output": [
"No\nNo\nNo\nNo\nNo\nYes",
"No\nNo\nNo\nNo\nNo\nYes"
]
... | {
"input": [],
"output": []
} |
cooling | The chef has just finished baking several pies, and it's time to place them on cooling racks.
The chef has exactly as many cooling racks as pies. Each cooling rack can only hold one pie, and each pie may only be held by one cooling rack,
but the chef isn't confident that the cooling racks can support the weight of the... | {
"input": [],
"output": []
} | {
"input": [
"2\n3\n10 30 20\n30 10 20\n5\n9 7 16 4 8\n8 3 14 10 10"
],
"output": [
"3\n4\n"
]
} | {
"input": [
"2\n3\n10 30 20\n30 10 20\n5\n9 7 16 4 8\n8 3 14 5 10",
"2\n3\n10 30 20\n30 10 20\n5\n9 7 16 4 8\n2 3 14 5 10",
"2\n3\n19 30 20\n30 10 20\n5\n9 7 16 4 4\n2 3 14 5 10",
"2\n3\n19 30 20\n30 10 20\n5\n8 7 16 4 4\n2 5 14 5 10",
"2\n3\n8 53 4\n30 10 40\n5\n4 7 16 2 1\n2 1 21 5 10",
"2\... |
gmb01 | All of us must have played the game of jumping monkeys in our childhood. It was a simple game where one had to put a monkey on a tree using a catapult. The catapult threw the monkey into a specific height in the air such that it may landed on an artificial tree.
This summer one of your cousin visited you during your va... | {
"input": [],
"output": []
} | {
"input": [
"2\n3 7\n10 12 15 4 7 1 3\n4 9\n12 15 2 14 21 18 4 25 7"
],
"output": [
"Yes\nNo"
]
} | {
"input": [
"2\n3 7\n10 12 15 4 7 1 1\n4 9\n12 15 2 14 21 18 4 25 7",
"2\n3 7\n10 12 15 4 4 1 1\n4 9\n12 15 2 14 21 18 4 25 7",
"2\n12 -2\n2 145 0 2 -4 0 2\n18 3\n33 28 4 -1 0 0 -5 14 0",
"2\n3 7\n10 12 15 4 4 1 1\n4 9\n1 15 2 14 21 18 4 25 7",
"2\n3 7\n10 21 15 4 4 1 1\n4 9\n1 15 2 14 21 18 4 25... |
marcha1 | A tutorial for this problem is now available on our blog. Click here to read it.
The following problem appeared in the CodeChef March '09 Challenge
In the mysterious country of Byteland, everything is quite different from what you'd
normally expect. In most places, if you were approached by two mobsters in a dark al... | {
"input": [],
"output": []
} | {
"input": [
"5\n3 3\n1\n1\n1\n5 11\n1\n2\n4\n8\n16\n5 23\n1\n2\n4\n8\n16\n5 13\n1\n5\n5\n10\n10\n20 132\n17\n6\n4\n998\n254\n137\n259\n153\n154\n3\n28\n19\n123\n542\n857\n23\n687\n35\n99\n999"
],
"output": [
"Yes\nYes\nYes\nNo\nYes\n"
]
} | {
"input": [
"5\n3 3\n1\n1\n1\n5 11\n1\n2\n4\n8\n16\n5 23\n1\n2\n4\n8\n16\n5 13\n1\n5\n5\n10\n10\n20 132\n17\n6\n4\n998\n254\n137\n259\n153\n154\n3\n28\n19\n123\n542\n857\n23\n687\n35\n126\n999",
"5\n3 3\n1\n1\n1\n5 11\n1\n2\n4\n14\n16\n5 23\n1\n2\n4\n8\n16\n5 13\n1\n0\n5\n10\n10\n20 132\n17\n6\n4\n998\n254\n... |
qucobic | STATEMENT
You are sitting in your class getting bored and wondering how long will it be before you can get back to your room and contine solving the
current long challenge @ codechef. You look at the clock and it shows the time as HH:MM (24-hour format). Just to pass the time you
consider the problem of what maximal... | {
"input": [],
"output": []
} | {
"input": [
"3\n1234\n123\n1234\n120\n0000\n0"
],
"output": [
"1237\n1236\n0000"
]
} | {
"input": [],
"output": []
} |
toffees | Teacher Suki loves her students very much. Now, she wants to distribute toffees among her students. She has a bag full of toffees. Since, she doesn't have time for counting, each time she randomly picks up some toffees from the bag and gives them to a student. Now, she doesn't want to be called a bad teacher, so she wa... | {
"input": [],
"output": []
} | {
"input": [
"2\n3\n2 2 1\n3\n1 5 4"
],
"output": [
"GOOD\nBAD"
]
} | {
"input": [
"2\n3\n2 2 1\n3\n1 6 4",
"2\n0\n2 4 1\n0\n1 6 2",
"2\n-2\n3 0 2\n-1\n0 0 0",
"2\n-1\n2 1 1\n2\n2 2 2",
"2\n0\n2 2 1\n3\n1 6 4",
"2\n0\n2 2 1\n3\n1 6 2",
"2\n0\n2 2 1\n0\n1 6 2",
"2\n1\n2 4 1\n0\n1 6 2",
"2\n1\n2 4 1\n-1\n1 6 2",
"2\n1\n2 0 1\n-1\n1 6 2",
"2\n1\... |
1250_J. The Parade | The Berland Army is preparing for a large military parade. It is already decided that the soldiers participating in it will be divided into k rows, and all rows will contain the same number of soldiers.
Of course, not every arrangement of soldiers into k rows is suitable. Heights of all soldiers in the same row should... | {
"input": [],
"output": []
} | {
"input": [
"5\n3 4\n7 1 13\n1 1\n100\n1 3\n100\n2 1\n1000000000000 1000000000000\n4 1\n10 2 11 1\n"
],
"output": [
"\n16\n100\n99\n2000000000000\n13\n"
]
} | {
"input": [],
"output": []
} |
1335_E1. Three Blocks Palindrome (easy version) | The only difference between easy and hard versions is constraints.
You are given a sequence a consisting of n positive integers.
Let'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) and is as follows: [\underbrace{a, a, ... | {
"input": [],
"output": []
} | {
"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 3 1 1\n3\n1 3 3\n4\n1 10 10 1\n1\n26\n2\n2 1\n3\n1 1 1\n",
"6\n8\n1 1 2 2 3 2 1 1\n3\n1 3 3\n4\n1 10 14 1\n1\n26\n2\n2 1\n3\n1 1 1\n",
"6\n8\n1 1 2 4 3 2 1 1\n3\n1 3 3\n4\n1 10 14 1\n1\n26\n2\n2 1\n3\n1 1 1\n",
"6\n8\n1 1 2 4 3 2 1 1\n3\n1 3 3\n4\n2 10 14 1\n1\n26\n2\n2 1... |
1399_B. Gifts Fixing | You have n gifts and you want to give all of them to children. Of course, you don't want to offend anyone, so all gifts should be equal between each other. The i-th gift consists of a_i candies and b_i oranges.
During one move, you can choose some gift 1 ≤ i ≤ n and do one of the following operations:
* eat exactly... | {
"input": [],
"output": []
} | {
"input": [
"5\n3\n3 5 6\n3 2 3\n5\n1 2 3 4 5\n5 4 3 2 1\n3\n1 1 1\n2 2 2\n6\n1 1000000000 1000000000 1000000000 1000000000 1000000000\n1 1 1 1 1 1\n3\n10 12 8\n7 5 4\n"
],
"output": [
"6\n16\n0\n4999999995\n7\n"
]
} | {
"input": [
"5\n3\n3 5 6\n3 2 3\n5\n1 2 3 4 5\n5 4 3 2 1\n3\n1 1 1\n2 2 2\n6\n1 1000000000 1000000000 1000000000 1000000000 1000000000\n1 1 2 1 1 1\n3\n10 12 8\n7 5 4\n",
"5\n3\n3 5 6\n3 2 3\n5\n1 2 3 4 5\n5 4 3 2 1\n3\n1 1 1\n2 1 2\n6\n1 1000000000 1000000000 1000000000 1000000000 1000000000\n1 1 1 1 1 1\n3... |
964_E. Cutting Rectangle | A rectangle with sides A and B is cut into rectangles with cuts parallel to its sides. For example, if p horizontal and q vertical cuts were made, (p + 1) ⋅ (q + 1) rectangles were left after the cutting. After the cutting, rectangles were of n different types. Two rectangles are different if at least one side of one r... | {
"input": [],
"output": []
} | {
"input": [
"2\n2 3 20\n2 4 40\n",
"2\n1 2 5\n2 3 5\n",
"1\n1 1 9\n"
],
"output": [
"6",
"0",
"3"
]
} | {
"input": [
"2\n2 3 27\n2 4 40\n",
"2\n1 2 5\n1 3 5\n",
"2\n2 4 27\n4 2 40\n",
"2\n2 2 20\n2 4 40\n",
"1\n1 2 9\n",
"2\n2 4 50\n2 2 40\n",
"1\n1 1 16\n",
"2\n2 3 27\n2 2 40\n",
"2\n1 2 5\n1 3 9\n",
"2\n2 4 27\n2 2 40\n",
"2\n1 2 5\n1 3 16\n",
"2\n1 2 5\n1 3 22\n",
... |
check-if-its-a-check | In a game of chess, Check is a game position in which a player's King is under attack by any of the opponent's pieces.
Bob is playing with Chess pieces. He randomly arranges three pieces on 8x8 chessboard: a black's King , a white's King and any one of the white's Queen, Knight, Bishop or Rook. Positions of these piec... | {
"input": [],
"output": []
} | {
"input": [
"4\ne8 e1\nq a4\ne7 d3\nb f6\nh6 g4 \nk h4\nd8 e1\nr d3\n\nSAMPLE"
],
"output": [
"check\ncheck\n-1\ncheck"
]
} | {
"input": [
"4\ne8 e1\nq a4\ne7 d3\nb f6\nh6 g4 \nk h4\nd8 e1\nr d3\n\nELPMAS",
"4\ne8 e1\nr a4\ne7 d3\nb f6\nh5 g4 \nk h4\nd8 e1\nr d3\n\nSAMOLE",
"4\ne8 e1\nq a4\ne7 d3\nb g6\nh6 g4 \nk h4\nd8 e1\nr d3\n\nELPMAS",
"4\ne8 e1\nq a4\nf7 d3\nb f7\nh4 g3 \nk h5\ne8 d1\nr d4\n\nSAMPLE",
"4\ne8 e1\np ... |
mr-smoothy | Mr. Smoothy is a restaurant that serves mostly smoothies at which Ben and his friends are regular customers. The titular mascot is a cup with face and legs that holds a smaller cup. It serves the strangest assortment of flavors in its smoothies, made to order.
The restaurant was about to open, and there was crowd gathe... | {
"input": [],
"output": []
} | {
"input": [
"1\n5 5 6 3 4 8\n\nSAMPLE"
],
"output": [
"4\n"
]
} | {
"input": [
"1\n5 5 6 3 7 8\n\nSAMPLE",
"1\n5 5 6 5 4 8\n\nSAMPLE",
"1\n5 3 10 3 7 8\n\nSAMPLE",
"1\n5 8 6 0 4 14\n\nSAMPLE",
"1\n5 5 6 5 7 14\n\nSAMPLE",
"1\n5 8 6 0 4 3\n\nMASPLE",
"1\n5 3 3 3 10 13\n\nELPMAS",
"1\n5 8 9 0 4 3\n\nMASPLE",
"1\n5 3 3 0 1 1\n\nELPMAS",
"1\n5 6 ... |
prateek-and-theories-3 | Scientists, researchers, mathematicians and thinkers propose theories for a number of things.
For explaining a single thing, a number of theories are proposed. A number of theories are rendered
invalid after a new and more relevant theory surfaces, giving a better and a more valid explanation for the
subject of the ... | {
"input": [],
"output": []
} | {
"input": [
"1\n5\n1 10\n2 4\n3 5\n11 12\n12 13\n\nSAMPLE"
],
"output": [
"3"
]
} | {
"input": [
"1\n5\n1 12\n2 4\n3 5\n11 12\n12 13\n\nSAMPLE",
"1\n5\n1 12\n2 8\n6 5\n11 12\n12 13\n\nSAMPLE",
"1\n5\n0 12\n2 10\n6 5\n11 2\n12 13\n\nSAMPLE",
"1\n5\n1 12\n2 8\n3 5\n11 12\n1 13\n\nSAMPLE",
"1\n5\n1 12\n2 8\n3 5\n11 12\n12 13\n\nSAMPLE",
"1\n5\n1 12\n4 8\n6 5\n11 12\n12 13\n\nSAM... |
welcome-to-ooty | Find a*b, for all given number pairs
SAMPLE INPUT
5
4 6
3 7
SAMPLE OUTPUT
24
21 | {
"input": [],
"output": []
} | {
"input": [
"5\n4 6\n3 7\n\nSAMPLE"
],
"output": [
"24\n21\n"
]
} | {
"input": [
"5\n4 6\n3 7\n\nTAMPLE",
"5\n4 6\n3 7\n\nSAMPKE",
"5\n4 6\n3 7\n\nELPMAT",
"5\n4 6\n3 7\n\nSALPKE",
"5\n4 6\n3 7\n\nTAMLPE",
"5\n4 6\n3 7\n\nSAMOKE",
"5\n4 6\n3 7\n\nTLMPAE",
"5\n4 6\n3 7\n\nSEMOKA",
"5\n4 6\n3 7\n\nTAMPLD",
"5\n4 6\n3 7\n\nAKOMES",
"5\n4 6\n3 ... |
p02621 AtCoder Beginner Contest 172 - Calc | Given an integer a as input, print the value a + a^2 + a^3.
Constraints
* 1 \leq a \leq 10
* a is an integer.
Input
Input is given from Standard Input in the following format:
a
Output
Print the value a + a^2 + a^3 as an integer.
Examples
Input
2
Output
14
Input
10
Output
1110 | {
"input": [],
"output": []
} | {
"input": [
"2",
"10"
],
"output": [
"14",
"1110"
]
} | {
"input": [
"1",
"0",
"3",
"4",
"6",
"7",
"-1",
"-2",
"5",
"-3",
"9",
"-4",
"-8",
"-6",
"-14",
"-9",
"-15",
"-11",
"-29",
"-7",
"-10",
"-5",
"-13",
"-12",
"-26",
"8",
"12",
"14",
"20",
"-20",
"... |
p02752 Social Infrastructure Information Systems Division Hitachi Programming Contest 2020 - Preserve Diameter | We have a tree G with N vertices numbered 1 to N. The i-th edge of G connects Vertex a_i and Vertex b_i.
Consider adding zero or more edges in G, and let H be the graph resulted.
Find the number of graphs H that satisfy the following conditions, modulo 998244353.
* H does not contain self-loops or multiple edges.
* ... | {
"input": [],
"output": []
} | {
"input": [
"9\n1 2\n2 3\n4 2\n1 7\n6 1\n2 5\n5 9\n6 8",
"6\n1 6\n2 1\n5 2\n3 4\n2 3",
"19\n2 4\n15 8\n1 16\n1 3\n12 19\n1 18\n7 11\n11 15\n12 9\n1 6\n7 14\n18 2\n13 12\n13 5\n16 13\n7 1\n11 10\n7 17",
"3\n1 2\n2 3"
],
"output": [
"27",
"3",
"78732",
"1"
]
} | {
"input": [
"6\n1 6\n2 1\n5 1\n3 4\n2 3",
"19\n2 4\n15 8\n1 16\n0 3\n12 19\n1 18\n7 11\n11 15\n12 9\n1 6\n7 14\n18 2\n13 12\n13 5\n16 13\n7 1\n11 10\n7 17",
"6\n1 6\n2 1\n5 0\n3 4\n2 3",
"19\n2 4\n15 8\n1 16\n0 3\n12 19\n1 18\n7 11\n11 15\n12 9\n1 6\n7 14\n18 2\n13 12\n13 5\n0 13\n7 1\n11 10\n7 17",
... |
p02887 AtCoder Beginner Contest 143 - Slimes | There are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.
Adjacent slimes with the same color will fuse into one larger slime withou... | {
"input": [],
"output": []
} | {
"input": [
"20\nxxzaffeeeeddfkkkkllq",
"5\naaaaa",
"10\naabbbbaaca"
],
"output": [
"10",
"1",
"5"
]
} | {
"input": [
"20\nxxzaffeeeeedfkkkkllq",
"5\naaaab",
"10\naabbcbaaca",
"20\nxfzaffeeeeedxkkkkllq",
"20\nxfzaffeeeeedxkkkkmlq",
"5\naa`ab",
"10\nacaaacbbaa",
"20\nxfzaffedeeedxkkkkmlq",
"5\naa``b",
"20\nxfzaefedeeedxkkkkmlq",
"5\nba_`a",
"10\n`abcbaaaca",
"20\nmlqkkz... |
p03022 AtCoder Grand Contest 034 - RNG and XOR | Snuke found a random number generator. It generates an integer between 0 and 2^N-1 (inclusive). An integer sequence A_0, A_1, \cdots, A_{2^N-1} represents the probability that each of these integers is generated. The integer i (0 \leq i \leq 2^N-1) is generated with probability A_i / S, where S = \sum_{i=0}^{2^N-1} A_i... | {
"input": [],
"output": []
} | {
"input": [
"4\n337 780 799 10 796 875 331 223 941 67 148 483 390 565 116 355",
"2\n1 1 1 1",
"2\n1 2 1 2"
],
"output": [
"0\n468683018\n635850749\n96019779\n657074071\n24757563\n745107950\n665159588\n551278361\n143136064\n557841197\n185790407\n988018173\n247117461\n129098626\n789682908",
"0\... | {
"input": [
"4\n337 780 799 10 796 875 331 223 941 67 268 483 390 565 116 355",
"2\n1 1 1 2",
"2\n1 2 1 3",
"4\n337 780 799 10 796 875 331 223 1804 67 268 483 390 565 116 355",
"2\n1 1 1 3",
"2\n2 2 1 3",
"4\n337 780 799 10 796 875 331 223 1804 67 268 483 390 565 20 355",
"2\n2 1 1 1"... |
p03162 Educational DP Contest - Vacation | Taro's summer vacation starts tomorrow, and he has decided to make plans for it now.
The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day:
* A: Swim in the sea. Gain a_i points of happiness.
* B: Catch bugs in the mountains. Gain b_i... | {
"input": [],
"output": []
} | {
"input": [
"3\n10 40 70\n20 50 80\n30 60 90",
"1\n100 10 1",
"7\n6 7 8\n8 8 3\n2 5 2\n7 8 6\n4 6 8\n2 3 4\n7 5 1"
],
"output": [
"210",
"100",
"46"
]
} | {
"input": [
"3\n1 40 70\n20 50 80\n30 60 90",
"1\n100 16 1",
"7\n6 7 8\n8 8 3\n2 5 2\n7 8 6\n4 6 8\n2 3 4\n7 7 1",
"1\n000 16 1",
"7\n6 7 14\n8 8 3\n2 5 2\n7 8 6\n4 6 8\n2 3 4\n7 7 1",
"3\n1 40 34\n20 50 80\n30 35 90",
"3\n1 76 34\n20 50 80\n30 35 90",
"1\n000 25 2",
"7\n5 7 14\n7... |
p03305 SoundHound Inc. Programming Contest 2018 -Masters Tournament- - Saving Snuuk | Kenkoooo is planning a trip in Republic of Snuke. In this country, there are n cities and m trains running. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Any city can be reached from any city by changing trains.
Two currencies are used in the country: yen and snuuk.... | {
"input": [],
"output": []
} | {
"input": [
"8 12 3 8\n2 8 685087149 857180777\n6 7 298270585 209942236\n2 4 346080035 234079976\n2 5 131857300 22507157\n4 8 30723332 173476334\n2 6 480845267 448565596\n1 4 181424400 548830121\n4 5 57429995 195056405\n7 8 160277628 479932440\n1 6 475692952 203530153\n3 5 336869679 160714712\n2 7 389775999 1991... | {
"input": [
"8 12 3 8\n2 8 685087149 857180777\n6 7 298270585 209942236\n2 4 346080035 234079976\n2 5 131857300 22507157\n4 8 30723332 173476334\n2 6 480845267 706415811\n1 4 181424400 548830121\n4 5 57429995 195056405\n7 8 160277628 479932440\n1 6 475692952 203530153\n3 5 336869679 160714712\n2 7 389775999 1991... |
p03465 AtCoder Grand Contest 020 - Median Sum | You are given N integers A_1, A_2, ..., A_N.
Consider the sums of all non-empty subsequences of A. There are 2^N - 1 such sums, an odd number.
Let the list of these sums in non-decreasing order be S_1, S_2, ..., S_{2^N - 1}.
Find the median of this list, S_{2^{N-1}}.
Constraints
* 1 \leq N \leq 2000
* 1 \leq A_i \... | {
"input": [],
"output": []
} | {
"input": [
"3\n1 2 1",
"1\n58"
],
"output": [
"2",
"58"
]
} | {
"input": [
"3\n1 2 0",
"1\n32",
"1\n62",
"1\n26",
"3\n1 2 -1",
"1\n4",
"3\n1 3 -1",
"1\n7",
"1\n0",
"3\n3 5 -1",
"3\n3 9 -1",
"3\n-3 6 1",
"3\n-3 14 3",
"3\n-2 8 0",
"3\n-2 16 0",
"3\n-2 13 0",
"3\n0 11 2",
"3\n0 19 3",
"3\n0 31 2",
"3\... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.