name stringlengths 2 112 | description stringlengths 29 13k | private_tests dict | public_tests dict | generated_tests dict |
|---|---|---|---|---|
brcktsrm | Problem description.
Vipul is a hardworking super-hero who maintains the bracket ratio of all the strings in the world. Recently he indulged himself in saving the string population so much that he lost his ability for checking brackets (luckily, not permanently ).Being his super-hero friend help him in his time of hard... | {
"input": [],
"output": []
} | {
"input": [
"3\n((()))\n(())()\n()(()"
],
"output": [
"YES\nYES\nNO"
]
} | {
"input": [
"3\n((()))\n(())()\n()())",
"3\n((()()\n(())()\n()(()",
"3\n((()))\n(())))\n()())",
"3\n)))(((\n(())))\n()())",
"3\n((()))\n(())()\n))(((",
"3\n((()()\n(())()\n()(((",
"3\n((()))\n(())()\n()()(",
"3\n((()()\n'())()\n()(((",
"3\n)))(((\n(())))\n()(*)",
"3\n)(()()\n'... |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line t... | {
"input": [],
"output": []
} | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [
"3\n1\n0 1\n0 -1\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1",
"3\n2\n0 1\n0 -1\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1",
"3\n2\n0 -1\n0 -1\n1 0\n2\n0 0\n0 0\n1 0\n2\n1 0\n1 2\n2 1",
"3\n2\n0 -1\n-1 -1\n2 0\n2\n1 0\n0 -1\n1 -1\n2\n1 0\n1 2\n1 1",
"3\n2\n0 -1\n0 -1\n2 0\n2\n2 0\n0 -1\n1 ... |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 d... | {
"input": [],
"output": []
} | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [
"2\n3 6\n10 11",
"2\n1 3\n10 11",
"2\n0 6\n10 11",
"2\n0 6\n0 11",
"2\n3 6\n8 22",
"2\n3 6\n8 4",
"2\n5 2\n10 2",
"2\n4 10\n8 6",
"2\n7 14\n8 6",
"2\n7 14\n8 4",
"2\n2 6\n5 2",
"2\n0 14\n16 2",
"2\n0 11\n10 1",
"2\n0 14\n16 1",
"2\n1 3\n10 5",
... |
luckybal | A Little Elephant from the Zoo of Lviv likes lucky strings, i.e., the strings that consist only of the lucky digits 4 and 7.
The Little Elephant calls some string T of the length M balanced if there exists at least one integer X (1 ≤ X ≤ M) such that the number of digits 4 in the substring T[1, X - 1] is equal to the n... | {
"input": [],
"output": []
} | {
"input": [
"4\n47\n74\n477\n4747477"
],
"output": [
"2\n2\n3\n23\n"
]
} | {
"input": [
"4\n47\n47\n477\n4747477",
"4\n7\n47\n477\n4747477",
"4\n4\n47\n477\n4747477",
"4\n7\n7\n477\n4747477",
"4\n7\n44\n477\n4747477",
"4\n44\n74\n477\n4747477",
"4\n7\n44\n7\n4747477",
"4\n47\n44\n477\n4747477",
"4\n47\n4\n477\n4747477",
"4\n7\n7\n447\n4747477",
"4... |
prpaln | Given a string s. Can you make it a palindrome by deleting exactly one character? Note that size of the string after deletion would be one less than it was before.
Input
First line of the input contains a single integer T denoting number of test cases.
For each test case, you are given a single line containing string... | {
"input": [],
"output": []
} | {
"input": [
"4\naaa\nabc\nabdbca\nabba"
],
"output": [
"YES\nNO\nYES\nYES\n"
]
} | {
"input": [
"4\naaa\nabc\nabdbca\nabca",
"4\naaa\nabc\nabdbc`\naaca",
"4\naab\nacc\n`bd`cb\naaad",
"4\nbaa\nabc\n`bd`bb\naabd",
"4\nbab\nabb\nbb`db`\naabd",
"4\nbaa\n`aa\nbb`c`b\ndba`",
"4\nba`\n`aa\nbb`c_c\ndba`",
"4\n`a_\naa`\ndda`^c\nca^a",
"4\n_c`\n]`_\ncdad^`\n`c_^",
"4\n... |
tf01 | An established group of scientists are working on finding solution to NP hard problems. They claim Subset Sum as an NP-hard problem. The problem is to determine whether there exists a subset of a given set S whose sum is a given number K.
You are a computer engineer and you claim to solve this problem given that all... | {
"input": [],
"output": []
} | {
"input": [
"2\n5 10\n3 4 6 1 9\n3 2\n1 3 4"
],
"output": [
"1\n0"
]
} | {
"input": [],
"output": []
} |
1170_E. Sliding Doors | Imagine that you are the CEO of a big old-fashioned company. Unlike any modern and progressive company (such as JetBrains), your company has a dress code. That's why you have already allocated a spacious room for your employees where they can change their clothes. Moreover, you've already purchased an m-compartment war... | {
"input": [],
"output": []
} | {
"input": [
"3 10\n2 3 2\n6\n1 5\n2 1 10\n2 2 9\n2 5 6\n3 1 7 8\n4 1 2 3 4\n"
],
"output": [
"\nYES\nYES\nNO\nNO\nYES\nNO\n"
]
} | {
"input": [],
"output": []
} |
1250_B. The Feast and the Bus | Employees of JebTrains are on their way to celebrate the 256-th day of the year! There are n employees and k teams in JebTrains. Each employee is a member of some (exactly one) team. All teams are numbered from 1 to k. You are given an array of numbers t_1, t_2, ..., t_n where t_i is the i-th employee's team number.
J... | {
"input": [],
"output": []
} | {
"input": [
"6 3\n3 1 2 3 2 3\n",
"10 1\n1 1 1 1 1 1 1 1 1 1\n",
"12 4\n1 2 3 1 2 3 4 1 2 1 2 1\n"
],
"output": [
"\n6\n",
"\n10\n",
"\n12\n"
]
} | {
"input": [],
"output": []
} |
1311_F. Moving Points | There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ... | {
"input": [],
"output": []
} | {
"input": [
"3\n1 3 2\n-100 2 3\n",
"2\n2 1\n-3 0\n",
"5\n2 1 4 3 5\n2 2 2 3 4\n"
],
"output": [
"3\n",
"0\n",
"19\n"
]
} | {
"input": [
"3\n1 3 2\n-100 2 6\n",
"2\n2 1\n-4 0\n",
"2\n0 1\n-4 0\n",
"2\n0 2\n-4 0\n",
"3\n1 5 2\n-167 2 6\n",
"3\n1 3 2\n-75 1 0\n",
"3\n1 7 2\n-255 0 6\n",
"3\n1 3 8\n-75 1 0\n",
"3\n1 3 8\n-75 1 1\n",
"3\n0 4 8\n-75 1 1\n",
"3\n0 4 8\n-75 1 0\n",
"5\n2 1 4 3 5\n0... |
1490_G. Old Floppy Drive | Polycarp was dismantling his attic and found an old floppy drive on it. A round disc was inserted into the drive with n integers written on it.
Polycarp wrote the numbers from the disk into the a array. It turned out that the drive works according to the following algorithm:
* the drive takes one positive number x... | {
"input": [],
"output": []
} | {
"input": [
"3\n3 3\n1 -3 4\n1 5 2\n2 2\n-2 0\n1 2\n2 2\n0 1\n1 2\n"
],
"output": [
"\n0 6 2 \n-1 -1 \n1 3 \n"
]
} | {
"input": [
"3\n3 3\n1 -3 4\n1 5 2\n2 2\n-4 0\n1 2\n2 2\n0 1\n1 2\n",
"3\n3 3\n1 -3 4\n1 5 2\n2 2\n-2 0\n1 2\n2 2\n0 2\n1 2\n",
"3\n3 3\n2 -3 4\n1 5 2\n2 2\n-4 0\n1 2\n2 2\n0 1\n1 2\n",
"3\n3 3\n0 -3 4\n1 5 2\n2 2\n-4 0\n1 1\n2 2\n0 1\n1 2\n",
"3\n3 3\n1 -3 4\n1 5 4\n2 2\n-2 0\n1 2\n2 2\n0 2\n1 2... |
470_F. Pairwise Sums | You are given an array of n integers. For each element output the sum of itself and the previous element. For the first element, output the sum of the first and the last elements of the array.
Input
The input consists of a single line of space-separated integers. The first number is n (2 ≤ n ≤ 50) — the size of the a... | {
"input": [],
"output": []
} | {
"input": [
"4 1 2 3 4\n",
"5 5 46 372 81 9\n"
],
"output": [
"5 3 5 7 ",
"14 51 418 453 90 "
]
} | {
"input": [],
"output": []
} |
roys-life-cycle | Roy is going through the dark times of his life. Recently his girl friend broke up with him and to overcome the pain of acute misery he decided to restrict himself to Eat-Sleep-Code life cycle. For N days he did nothing but eat, sleep and code.
A close friend of Roy kept an eye on him for last N days. For every sing... | {
"input": [],
"output": []
} | {
"input": [
"4\nSSSSEEEECCCCEECCCC\nCCCCCSSSSEEECCCCSS\nSSSSSEEESSCCCCCCCS\nEESSSSCCCCCCSSEEEESAMPLE"
],
"output": [
"7 9\n"
]
} | {
"input": [
"4\nSSSSEEEECCCCEECCCC\nCCCCCSSSSEEECCCCSS\nSCCCCCCCSSEEESSSSS\nEESSSSCCCCCCSSEEEESAMPLE",
"4\nCCCCEECBCCEEEESSSS\nCCCCCSSSSEEECCCCSS\nSSSSSEEESSCCCCCCCS\nEESSSSCCCCCCSSEEEESAMPLE",
"4\nSSSSEEEECCCCEECCCC\nCCCCSSSSSEEECCCCSC\nSCCCCCCCSSEEESSSSS\nEESSSSCCCCCCSSEEEESAMPLE",
"4\nSESSEEEECCBD... |
vowel | Rakesh have learn about vowel in school and is given an assignment by his teacher in which he has to list all vowel together from the word's given to him,but he is busy in watching cricket match and want your help to solve the assignment.
5 vowel (a,e,i,o,u) and you should also take care of uppercase vowel (A,E,I,O,U)... | {
"input": [],
"output": []
} | {
"input": [
"3\nSdfgAe\nOut\nGet\n\nSAMPLE"
],
"output": [
"Ae\nOu\ne\n"
]
} | {
"input": [
"3\nfdSgAe\nOut\nGet\n\nSAMPLE",
"3\nfdSgAe\ntuO\nFet\n\nSAMPLE",
"3\nBdSgfe\ntuO\nFet\n\nSAMPLD",
"3\nefgSdB\nOut\nteF\n\nDLPMAS",
"3\nefgSdB\nOut\ntfF\n\nDLPMAS",
"3\nBfgSde\nuOt\ntFg\n\nDLPMAS",
"3\nBcgSge\ntPu\nteF\n\nDMONAR",
"3\nBcgSge\ntPu\nteE\n\nDMONAR",
"3\nB... |
p02613 AtCoder Beginner Contest 173 - Judge Status Summary | Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.
The problem has N test cases.
For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`,... | {
"input": [],
"output": []
} | {
"input": [
"6\nAC\nTLE\nAC\nAC\nWA\nTLE",
"10\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC"
],
"output": [
"AC x 3\nWA x 1\nTLE x 2\nRE x 0",
"AC x 10\nWA x 0\nTLE x 0\nRE x 0"
]
} | {
"input": [],
"output": []
} |
p02744 Panasonic Programming Contest 2020 - String Equivalence | In this problem, we only consider strings consisting of lowercase English letters.
Strings s and t are said to be isomorphic when the following conditions are satisfied:
* |s| = |t| holds.
* For every pair i, j, one of the following holds:
* s_i = s_j and t_i = t_j.
* s_i \neq s_j and t_i \neq t_j.
For example, `a... | {
"input": [],
"output": []
} | {
"input": [
"1",
"2"
],
"output": [
"a",
"aa\nab"
]
} | {
"input": [
"4",
"6",
"3",
"7",
"5",
"8",
"4",
"3",
"5",
"6",
"8",
"7"
],
"output": [
"aaaa\naaab\naaba\naabb\naabc\nabaa\nabab\nabac\nabba\nabbb\nabbc\nabca\nabcb\nabcc\nabcd\n",
"aaaaaa\naaaaab\naaaaba\naaaabb\naaaabc\naaabaa\naaabab\naaabac\naaabba\naaab... |
p02879 AtCoder Beginner Contest 144 - 9x9 | Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together. He cannot do any other calculation.
Given are two integers A and B.
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1` instead.
Constraints
* 1 \leq A \leq 20
* 1 \leq B ... | {
"input": [],
"output": []
} | {
"input": [
"2 5",
"9 9",
"5 10"
],
"output": [
"10",
"81",
"-1"
]
} | {
"input": [
"2 8",
"9 5",
"7 10",
"3 8",
"9 8",
"7 7",
"6 8",
"7 9",
"7 8",
"7 3",
"7 2",
"9 2",
"9 4",
"9 6",
"5 6",
"2 6",
"2 2",
"8 5",
"5 1",
"4 8",
"3 9",
"2 3",
"2 4",
"2 1",
"5 3",
"1 3",
"4 5",
"1 ... |
p03013 AtCoder Beginner Contest 129 - Typical Stairs | There is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step. He can climb up one or two steps at a time.
However, the treads of the a_1-th, a_2-th, a_3-th, \ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.
How many are there to climb ... | {
"input": [],
"output": []
} | {
"input": [
"100 5\n1\n23\n45\n67\n89",
"10 2\n4\n5",
"6 1\n3"
],
"output": [
"608200469",
"0",
"4"
]
} | {
"input": [
"100 5\n1\n23\n45\n47\n89",
"10 2\n4\n1",
"4 1\n3",
"100 3\n1\n23\n45\n47\n89",
"100 0\n1\n23\n45\n47\n89",
"10 2\n3\n2",
"101 0\n0\n35\n44\n58\n89",
"101 5\n1\n23\n45\n67\n89",
"6 1\n1",
"100 5\n1\n23\n21\n47\n89",
"10 0\n4\n1",
"4 1\n2",
"100 3\n1\n23... |
p03153 KEYENCE Programming Contest 2019 - Connecting Cities | There are N cities in Republic of AtCoder. The size of the i-th city is A_{i}. Takahashi would like to build N-1 bidirectional roads connecting two cities so that any city can be reached from any other city by using these roads.
Assume that the cost of building a road connecting the i-th city and the j-th city is |i-j... | {
"input": [],
"output": []
} | {
"input": [
"3 1\n1 100 1",
"12 5\n43 94 27 3 69 99 56 25 8 15 46 8",
"3 1000\n1 100 1",
"6 14\n25 171 7 1 17 162"
],
"output": [
"106",
"658",
"2202",
"497"
]
} | {
"input": [
"3 1\n2 100 1",
"12 5\n43 94 27 3 69 99 56 25 15 15 46 8",
"3 1000\n1 101 1",
"6 24\n25 171 7 1 17 162",
"3 1\n0 100 1",
"12 5\n43 94 27 3 69 99 56 25 27 15 46 8",
"3 1001\n1 101 1",
"6 24\n46 171 7 1 17 162",
"12 5\n43 94 27 3 69 99 56 25 27 15 46 7",
"6 24\n46 17... |
p03297 AtCoder Grand Contest 026 - rng_10s | Ringo Mart, a convenience store, sells apple juice.
On the opening day of Ringo Mart, there were A cans of juice in stock in the morning. Snuke buys B cans of juice here every day in the daytime. Then, the manager checks the number of cans of juice remaining in stock every night. If there are C or less cans, D new can... | {
"input": [],
"output": []
} | {
"input": [
"24\n1 2 3 4\n1 2 4 3\n1 3 2 4\n1 3 4 2\n1 4 2 3\n1 4 3 2\n2 1 3 4\n2 1 4 3\n2 3 1 4\n2 3 4 1\n2 4 1 3\n2 4 3 1\n3 1 2 4\n3 1 4 2\n3 2 1 4\n3 2 4 1\n3 4 1 2\n3 4 2 1\n4 1 2 3\n4 1 3 2\n4 2 1 3\n4 2 3 1\n4 3 1 2\n4 3 2 1",
"14\n9 7 5 9\n9 7 6 9\n14 10 7 12\n14 10 8 12\n14 10 9 12\n14 10 7 11\n14 1... | {
"input": [
"24\n1 2 3 4\n1 2 4 3\n1 3 2 4\n1 3 4 2\n1 4 1 3\n1 4 3 2\n2 1 3 4\n2 1 4 3\n2 3 1 4\n2 3 4 1\n2 4 1 3\n2 4 3 1\n3 1 2 4\n3 1 4 2\n3 2 1 4\n3 2 4 1\n3 4 1 2\n3 4 2 1\n4 1 2 3\n4 1 3 2\n4 2 1 3\n4 2 3 1\n4 3 1 2\n4 3 2 1",
"14\n9 7 5 9\n9 7 6 9\n14 10 7 12\n14 10 8 12\n14 10 9 12\n14 10 7 11\n14 1... |
p03455 AtCoder Beginner Contest 086 - Product | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
Constraints
* 1 ≤ a,b ≤ 10000
* a and b are integers.
Input
Input is given from Standard Input in the following format:
a b
Output
If the product is odd, print `Odd`; if it is even, print `Even`.
E... | {
"input": [],
"output": []
} | {
"input": [
"3 4",
"1 21"
],
"output": [
"Even",
"Odd"
]
} | {
"input": [
"4 4",
"1 15",
"2 4",
"2 15",
"3 0",
"2 26",
"3 -1",
"2 32",
"0 -1",
"1 32",
"0 -2",
"1 17",
"-1 -2",
"0 17",
"-2 -2",
"0 15",
"-2 -1",
"0 0",
"-4 -1",
"0 1",
"-6 -1",
"0 2",
"-6 0",
"1 2",
"-1 0",
"1 ... |
p03616 AtCoder Regular Contest 082 - Sandglass | We have a sandglass consisting of two bulbs, bulb A and bulb B. These bulbs contain some amount of sand. When we put the sandglass, either bulb A or B lies on top of the other and becomes the upper bulb. The other bulb becomes the lower bulb.
The sand drops from the upper bulb to the lower bulb at a rate of 1 gram per... | {
"input": [],
"output": []
} | {
"input": [
"100\n5\n48 141 231 314 425\n7\n0 19\n50 98\n143 30\n231 55\n342 0\n365 100\n600 10",
"180\n3\n60 120 180\n3\n30 90\n61 1\n180 180",
"100\n1\n100000\n4\n0 100\n90 100\n100 100\n101 100"
],
"output": [
"19\n52\n91\n10\n58\n42\n100",
"60\n1\n120",
"100\n10\n0\n0"
]
} | {
"input": [
"100\n5\n48 141 231 554 425\n7\n0 19\n50 98\n143 30\n231 55\n342 0\n365 100\n600 10",
"180\n3\n60 120 180\n3\n30 16\n61 1\n180 180",
"100\n1\n100010\n4\n0 100\n90 100\n100 100\n101 100",
"180\n3\n60 74 180\n3\n30 16\n61 1\n180 180",
"100\n5\n48 179 231 554 425\n7\n0 19\n50 98\n143 30\... |
p03774 AtCoder Beginner Contest 057 - Checkpoints | There are N students and M checkpoints on the xy-plane.
The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j).
When the teacher gives a signal, each student has to go to the nearest checkpoint measured in Manhattan distance.
T... | {
"input": [],
"output": []
} | {
"input": [
"3 4\n10 10\n-10 -10\n3 3\n1 2\n2 3\n3 5\n3 5",
"2 2\n2 0\n0 0\n-1 0\n1 0",
"5 5\n-100000000 -100000000\n-100000000 100000000\n100000000 -100000000\n100000000 100000000\n0 0\n0 0\n100000000 100000000\n100000000 -100000000\n-100000000 100000000\n-100000000 -100000000"
],
"output": [
"3... | {
"input": [
"3 4\n10 10\n-10 -10\n3 3\n1 2\n2 3\n3 5\n3 10",
"2 2\n2 0\n0 0\n-1 -1\n1 0",
"3 4\n10 10\n-10 -10\n3 3\n1 4\n2 3\n3 5\n3 5",
"2 2\n2 0\n0 -1\n-1 0\n1 0",
"5 5\n-100000000 -100000000\n-100000000 100000000\n100000000 -100000000\n100000000 100000000\n0 0\n0 0\n100000000 100000000\n10000... |
p03943 AtCoder Beginner Contest 047 - Fighting over Candies | Two students of AtCoder Kindergarten are fighting over candy packs.
There are three candy packs, each of which contains a, b, and c candies, respectively.
Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible.
Not... | {
"input": [],
"output": []
} | {
"input": [
"56 25 31",
"10 30 20",
"30 30 100"
],
"output": [
"Yes",
"Yes",
"No"
]
} | {
"input": [
"106 25 31",
"4 24 20",
"10 29 20",
"30 47 100",
"8 25 31",
"4 29 20",
"30 26 100",
"16 25 31",
"30 16 100",
"16 16 31",
"4 45 20",
"43 16 100",
"16 16 42",
"4 45 8",
"6 16 100",
"16 2 42",
"1 45 8",
"6 16 101",
"28 2 42",
"1... |
p00035 Is it Convex? | 4 different points on the plane Read the coordinates of $ A (x_a, y_a) $, $ B (x_b, y_b) $, $ C (x_c, y_c) $, $ D (x_d, y_d) $ and read those 4 points Create a program that outputs YES if there is no dent in the quadrangle $ ABCD $ with the coordinates as the vertices, and NO if there is a dent.
A quadrangle with a de... | {
"input": [],
"output": []
} | {
"input": [
"0.0,0.0,1.0,0.0,1.0,1.0,0.0,1.0\n0.0,0.0,3.0,0.0,1.0,1.0,1.0,3.0"
],
"output": [
"YES\nNO"
]
} | {
"input": [
"0.0,0.0,1.0,0.0,1.0,1.0,0.0,0.1\n0.0,0.0,3.0,0.0,1.0,1.0,1.0,3.0",
"1.0,0.0,0.1,0.1,0.0,0.1,0.0,0.0\n0.3,0.1,0.1,1.1,0.0,0.3,0.0,0.0",
"1.0,0.0,0.2,0.1,0.0,0.1,0.0,1.0\n0.3,0.0,0.1,0.1,0.0,0.3,0.0,0.0",
"1.0,0.0,0.1,0.1,0.0,0.2,0.0,0.0\n0.3,0.1,0.1,1.1,0.0,0.3,0.0,0.0",
"0.0,0.0,1.0,... |
p00167 Bubble Sort | Sorting algorithms for sorting data are basic algorithms indispensable in computer science. For example, as shown in the figure below, the operation of "sorting the elements of an array of integer values in ascending order" is alignment.
<image>
Many alignment algorithms have been devised, but one of the basic alg... | {
"input": [],
"output": []
} | {
"input": [
"5\n5\n3\n2\n1\n4\n6\n1\n2\n3\n4\n5\n6\n3\n3\n2\n1\n0"
],
"output": [
"7\n0\n3"
]
} | {
"input": [
"5\n5\n3\n2\n1\n7\n6\n1\n2\n3\n4\n5\n6\n3\n3\n2\n1\n0",
"5\n5\n3\n2\n1\n7\n6\n1\n2\n3\n4\n0\n6\n3\n3\n2\n1\n0",
"5\n5\n3\n2\n1\n4\n6\n1\n2\n2\n4\n5\n6\n3\n3\n2\n1\n0",
"5\n5\n3\n2\n1\n7\n6\n1\n2\n3\n4\n5\n6\n3\n3\n3\n1\n0",
"5\n5\n3\n2\n1\n7\n6\n1\n2\n3\n8\n5\n6\n3\n3\n3\n1\n0",
"... |
p00323 Metal Recycling | PCK, which recycles Aizu's precious metal, Aizunium, has a network all over the country and collects Aizunium with many collection vehicles. This company standardizes the unit of weight and number of lumps for efficient processing.
A unit called "bokko" is used for the weight of the lump. x Bocco's Aidunium weighs 2 x... | {
"input": [],
"output": []
} | {
"input": [
"1\n100000 2",
"3\n2 1\n1 3\n2 2"
],
"output": [
"100002 0",
"3 0\n5 0"
]
} | {
"input": [
"1\n100010 2",
"3\n2 1\n1 3\n2 0",
"1\n100010 3",
"3\n2 1\n1 3\n2 1",
"1\n100011 3",
"3\n2 1\n1 5\n2 2",
"1\n000011 3",
"3\n2 1\n1 5\n3 2",
"1\n000011 1",
"3\n3 1\n1 5\n3 2",
"3\n3 1\n1 5\n2 2",
"1\n100111 1",
"3\n2 1\n1 5\n4 2",
"1\n101111 1",
... |
p00493 Zig-Zag Numbers | problem
If you write a positive integer in decimal notation (without leading 0) and look at the digit numbers in order, when the number increases and decreases alternately, the number is "zigza". Let's call it. For example, 2947 is a zigzag number because the digit numbers are in the order of 2 → 9 → 4 → 7 and increas... | {
"input": [],
"output": []
} | {
"input": [
"100\n200\n5"
],
"output": [
"13"
]
} | {
"input": [
"100\n303\n5",
"100\n256\n5",
"100\n407\n5",
"100\n407\n2",
"100\n407\n3",
"100\n407\n6",
"100\n812\n6",
"100\n160\n5",
"100\n155\n5",
"100\n100\n5",
"100\n389\n2",
"100\n265\n6",
"100\n830\n6",
"100\n241\n5",
"100\n286\n5",
"100\n125\n7",
... |
p00680 KND Factory | Problem
KND is a student programmer at the University of Aizu. There are N towns around his town. He loves cream so he built a factory in a town to eat cream every day. The factory produces F liters of fresh cream daily. Every time you carry the cream, it will be damaged by the absolute difference between the temperat... | {
"input": [],
"output": []
} | {
"input": [
"3\n3 0 2 5\n1 1 1 6\n3 2 1 10\n1 -2 3 6\n2\n1 2\n3 3\n1\n2\n3\n0\n3 0 2 5\n1 1 1 6\n3 2 1 10\n1 -2 3 6\n2\n1 2\n2 2\n1\n2\n2\n0\n10 2 7 20\n8 9 -5 6 -9 5 1 0 4 9 4\n3 -1 -8 0 -5 4 3 0 -3 2 4\n-4 5 8 -4 1 -8 -6 3 3 5 -7\n-7 0 2 5 8 -5 -9 -8 1 -2 -1\n3 8 1 -3 8 2 -5 8 -3 4 -4\n-2 5 0 -2 -4 4 -3 9 6 -1... | {
"input": [
"3\n3 0 2 5\n1 1 1 6\n3 2 1 10\n1 -2 3 6\n2\n1 2\n3 3\n1\n2\n3\n0\n3 0 2 5\n1 1 1 6\n3 2 1 10\n1 -2 3 6\n2\n1 2\n2 2\n1\n2\n2\n0\n10 2 7 20\n8 9 -5 6 -9 5 1 0 4 9 4\n3 -1 -8 0 -5 4 3 0 -3 2 4\n-4 5 8 -4 1 -8 -6 3 3 5 -7\n-7 0 2 5 8 -5 -9 -8 1 -2 -1\n3 8 1 -3 8 2 -5 8 -3 4 -4\n-2 5 0 -2 -4 4 -3 9 6 -1... |
p00822 Weather Forecast | You are the God of Wind.
By moving a big cloud around, you can decide the weather: it invariably rains under the cloud, and the sun shines everywhere else.
But you are a benign God: your goal is to give enough rain to every field in the countryside, and sun to markets and festivals. Small humans, in their poor vocabu... | {
"input": [],
"output": []
} | {
"input": [
"1\n0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0\n7\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n1 0 0 0 0 0 1 0 0 0 0 1 1 0 0 1\n0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1\n0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0\n0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0\n1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1\n0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0\n7\n0 0 0 0 0 0 0 0 1 0 0 0 0 0... | {
"input": [
"1\n0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0\n7\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n1 0 0 0 0 0 1 0 0 0 0 1 1 0 0 1\n0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1\n0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0\n0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0\n1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1\n0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0\n7\n0 0 0 0 0 0 0 0 1 0 0 0 0 0... |
p00953 Animal Companion in Maze | Example
Input
2 1
1 2 2
Output
1 | {
"input": [],
"output": []
} | {
"input": [
"2 1\n1 2 2"
],
"output": [
"1"
]
} | {
"input": [
"2 0\n1 2 2",
"4 1\n4 2 2",
"2 0\n2 2 2",
"2 0\n4 2 2",
"4 0\n4 2 2",
"4 0\n4 2 1",
"6 0\n4 2 1",
"2 0\n4 2 1",
"3 0\n4 2 1",
"4 0\n4 2 0",
"4 -1\n4 2 0",
"4 -1\n8 2 0",
"4 -1\n8 0 0",
"4 -1\n5 0 0",
"4 -1\n5 1 0",
"4 -2\n5 0 0",
"4 -2\n... |
p01086 Short Phrase | Short Phrase
A Short Phrase (aka. Tanku) is a fixed verse, inspired by Japanese poetry Tanka and Haiku. It is a sequence of words, each consisting of lowercase letters 'a' to 'z', and must satisfy the following condition:
> (The Condition for a Short Phrase)
> The sequence of words can be divided into five sections ... | {
"input": [],
"output": []
} | {
"input": [
"9\ndo\nthe\nbest\nand\nenjoy\ntoday\nat\nacm\nicpc\n14\noh\nyes\nby\nfar\nit\nis\nwow\nso\nbad\nto\nme\nyou\nknow\nhey\n15\nabcde\nfghijkl\nmnopq\nrstuvwx\nyzz\nabcde\nfghijkl\nmnopq\nrstuvwx\nyz\nabcde\nfghijkl\nmnopq\nrstuvwx\nyz\n0"
],
"output": [
"1\n2\n6"
]
} | {
"input": [
"9\ndo\nhte\nbest\nand\nenjoy\ntoday\nat\nacm\nicpc\n14\noh\nyes\nby\nfar\nit\nis\nwow\nso\nbad\nto\nme\nyou\nknow\nhey\n15\nabcde\nfghijkl\nmnopq\nrstuvwx\nyzz\nabcde\nfghijkl\nmnopq\nrstuvwx\nyz\nabcde\nfghijkl\nmnopq\nrstuvwx\nyz\n0",
"9\ndo\nhet\nbest\n`nd\nenjoy\ntoday\nat\nacm\nicpc\n0\noh\... |
p01222 Walk under a Scorching Sun | Edward R. Nelson is visiting a strange town for some task today. This city is built on a two-dimensional flat ground with several vertical buildings each of which forms a convex polygon when seen from above on it (that is to say, the buidlings are convex polygon columns). Edward needs to move from the point S to the po... | {
"input": [],
"output": []
} | {
"input": [
"1 1\n4 10 0 0 10 0 10 10 0 10\n-5 -20 30 15\n135 45\n0 -15 15 0\n0 0"
],
"output": [
"11.213"
]
} | {
"input": [
"1 1\n4 10 0 0 9 0 10 10 0 10\n-5 -20 30 15\n135 45\n0 -15 15 0\n0 0",
"1 1\n4 10 0 0 9 0 10 10 0 10\n-5 -20 30 15\n238 45\n0 -15 15 0\n0 0",
"1 1\n4 10 0 0 9 0 10 10 0 10\n-5 -20 30 15\n135 24\n0 -15 15 0\n0 0",
"1 1\n4 10 -1 0 10 0 10 14 0 10\n-5 -20 30 15\n135 23\n0 -15 15 0\n0 0",
... |
p01356 Nearest Station | I have n tickets for a train with a rabbit. Each ticket is numbered from 0 to n − 1, and you can use the k ticket to go to p⋅ak + q⋅bk station.
Rabbit wants to go to the all-you-can-eat carrot shop at the station m station ahead of the current station, but wants to walk as short as possible. The stations are lined up ... | {
"input": [],
"output": []
} | {
"input": [
"6 1 2 3 4 5",
"6 200 2 3 4 5"
],
"output": [
"1",
"1"
]
} | {
"input": [
"6 1 2 3 4 7",
"6 106 2 3 4 5",
"6 2 2 3 4 7",
"6 159 2 3 4 5",
"6 200 2 3 8 8",
"6 159 2 3 3 5",
"6 3 1 3 4 8",
"22 144 2 3 3 5",
"17 144 2 3 6 5",
"9 5 1 3 15 9",
"17 22 2 3 6 7",
"6 373 2 3 4 5",
"6 200 2 4 8 5",
"6 159 2 4 4 5",
"9 4 2 3 8 7... |
p01538 Kakezan | Taro is an elementary school student who has just learned multiplication. Somehow, he likes multiplication, so when he sees numbers, he wants to multiply. He seems to like to do the following for integers greater than or equal to 0. (Processing flow)
* Procedure 1. If a certain integer n greater than or equal to 0 is ... | {
"input": [],
"output": []
} | {
"input": [
"2\n999999\n1000000",
"3\n9\n99\n123"
],
"output": [
"12\n1",
"0\n2\n3"
]
} | {
"input": [
"2\n999999\n1000100",
"3\n9\n99\n238",
"2\n999999\n1010100",
"3\n9\n99\n39",
"2\n999999\n1010110",
"3\n16\n120\n59",
"3\n16\n127\n59",
"3\n16\n127\n21",
"3\n16\n127\n5",
"3\n3\n127\n5",
"3\n0\n42\n4",
"3\n0\n37\n4",
"2\n89961\n1000000",
"3\n9\n99\n1... |
p01694 Step Aerobics | Step up and down
Kazuki, commonly known as Kerr, who attends JAG University, was invited by your friend this summer to participate in the ICPC (International Collegiate Potchari Contest). ICPC is a sports contest and requires a high degree of athletic ability. However, Mr. Kerr was always in front of the computer, and... | {
"input": [],
"output": []
} | {
"input": [
"4\nlu ru ld rd\n4\nlu ld lu ru\n1\nlu\n10\nru lu ld rd ru rd ru lu rd ld\n0"
],
"output": [
"2\n1\n0\n4"
]
} | {
"input": [
"4\nlu ru ld rd\n4\nlu ld lu ru\n0\nlu\n10\nru lu ld rd ru rd ru lu rd ld\n0",
"4\nlu ru ld rd\n0\nlu ld lu ru\n0\nul\n10\nvr lu ld rd rv rd ru lu rc kd\n0",
"4\nlu ru ld rd\n4\nlu ld lu ru\n0\nul\n10\nru lu ld rd ru rd ru lu rd ld\n0",
"4\nlu ru ld rd\n4\nlu ld lu ru\n0\nlu\n10\nru lu ld... |
p01838 Optimal Tournament | Example
Input
4 3
1 3 4 7
Output
6 | {
"input": [],
"output": []
} | {
"input": [
"4 3\n1 3 4 7"
],
"output": [
"6"
]
} | {
"input": [
"4 3\n1 3 2 7",
"4 4\n1 3 2 4",
"4 4\n1 0 2 4",
"4 3\n1 3 2 8",
"2 4\n1 3 2 4",
"4 4\n1 -1 2 4",
"4 3\n1 3 2 13",
"2 4\n1 2 2 4",
"4 2\n1 3 2 13",
"14 5\n2 4 1 -1",
"7 5\n1 3 2 13",
"4 2\n1 3 4 13",
"21 5\n2 4 1 -1",
"4 2\n0 3 2 7",
"4 6\n1 3 2 ... |
p01974 Pigeonhole principle | problem
Given $ N $ different natural numbers $ a_i $. I decided to make a pair by choosing a different natural number from the given natural numbers. Output one pair that can be created with a value difference that is a multiple of $ N -1 $.
It should be noted that such a pair always exists.
Example
Input
5
1... | {
"input": [],
"output": []
} | {
"input": [
"5\n1 2 4 7 10"
],
"output": [
"2 10"
]
} | {
"input": [
"5\n2 2 4 7 10",
"5\n1 2 22 7 0",
"5\n1 2 4 3 10",
"5\n0 2 3 7 1",
"5\n0 2 1 7 1",
"5\n1 2 4 3 15",
"5\n3 2 6 5 24",
"5\n0 2 0 7 1",
"5\n0 2 7 13 24",
"5\n-1 2 3 7 13",
"5\n4 4 22 7 24",
"5\n2 3 30 7 0",
"5\n1 2 4 11 20",
"5\n4 2 5 7 5",
"5\n1 2... |
p02120 Cluster Network | Problem
A large-scale cluster † type supercomputer (commonly known as "SAKURA") cluster at Maze University consists of $ N $ computers (nodes) and $ M $ physical communication channels that can communicate with each other. .. In addition, each node is assigned an identification number from 1 to $ N $.
This time, the ... | {
"input": [],
"output": []
} | {
"input": [
"9 10\n1 2 3 4 5 6 7 8 9\n1 2\n2 3\n2 4\n3 4\n4 5\n4 6\n2 7\n7 8\n7 9\n9 1",
"2 1\n1 2\n1 2",
"16 19\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16\n1 2\n2 3\n3 4\n3 5\n1 6\n6 7\n6 8\n7 8\n8 9\n8 10\n10 11\n11 12\n12 10\n1 13\n13 14\n14 15\n15 13\n14 16\n15 16"
],
"output": [
"44\n25\n42\n30... | {
"input": [
"9 10\n1 2 3 4 5 6 7 8 9\n1 2\n2 1\n2 4\n3 4\n4 5\n4 6\n2 7\n7 8\n7 9\n9 1",
"16 19\n1 2 3 4 5 6 7 8 9 10 10 12 13 14 15 16\n1 2\n2 3\n3 4\n3 5\n1 6\n6 7\n6 8\n7 8\n8 9\n8 10\n10 11\n11 12\n12 10\n1 13\n13 14\n14 15\n15 13\n14 16\n15 16",
"16 19\n2 2 3 4 5 6 7 8 9 10 10 12 13 14 15 16\n1 2\n2... |
p02260 Selection Sort | Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
SelectionSort(A)
1 for i = 0 to A.length-1
2 mini = i
3 for j = i to A.length-1
4 if A[j] < A[mini]
5 mini = j
6 swap A[i] and A[mini]... | {
"input": [],
"output": []
} | {
"input": [
"6\n5 2 4 6 1 3",
"6\n5 6 4 2 1 3"
],
"output": [
"1 2 3 4 5 6\n3",
"1 2 3 4 5 6\n4"
]
} | {
"input": [
"6\n5 2 4 6 1 0",
"6\n5 6 4 4 1 3",
"6\n6 2 4 6 1 0",
"6\n5 6 4 4 1 2",
"6\n6 2 4 6 0 0",
"6\n5 6 4 3 1 2",
"6\n6 2 8 6 0 0",
"6\n5 6 4 2 1 2",
"6\n6 4 8 6 0 0",
"6\n9 6 4 2 1 3",
"6\n6 4 8 6 0 -1",
"6\n9 6 2 2 1 3",
"6\n6 4 8 0 0 -1",
"6\n6 6 2 2 1... |
p02408 Finding Missing Cards | Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers).
The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.
Note
解説
Input
In the first line, the number of cards n (n ≤ 52) is given.
In the following n line... | {
"input": [],
"output": []
} | {
"input": [
"47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 5\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD 10\nD 11\nD 12\nD 13"
],
"output": [
"S 1\nH 3\nH 7\nC 12\nD... | {
"input": [
"47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 7\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD 10\nD 11\nD 12\nD 13",
"47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 3\nS ... |
cdva1502 | Your task is very simple. Given K numbers A1, A2, ..., AK. You need to find f(N) mod max(A1, A2, ..., AK) .
f(N)=N!
Input
First line contains single integer T denoting the number of test cases..
First line of each test case contains two integers N and K.
Next line contains K integers Ak
Output
For each test case,... | {
"input": [],
"output": []
} | {
"input": [
"1\n5 3\n200 6 9"
],
"output": [
"120"
]
} | {
"input": [
"1\n5 3\n200 12 9",
"1\n9 3\n200 12 9",
"1\n7 3\n200 12 9",
"1\n7 3\n141 12 9",
"1\n9 0\n141 12 9",
"1\n17 0\n141 12 9",
"1\n34 0\n141 12 16",
"1\n54 0\n141 12 4",
"1\n29 0\n141 12 4",
"1\n44 0\n141 12 3",
"1\n15 0\n141 12 3",
"1\n1 3\n200 6 9",
"1\n19 ... |
dbyz15t | Problem Desrcription
Shil likes to play with trees a lot.He is playing with an undirected tree containing N nodes.He wants to find out total number of unordered triplets (A,B,C) such that A is not connected to B, B is not connected to C and A is not connected to C by a direct edge (No two of A, B, C are mutually conne... | {
"input": [],
"output": []
} | {
"input": [
"5\n1 2\n1 3\n3 4\n2 5"
],
"output": [
"1"
]
} | {
"input": [],
"output": []
} |
ig01 | This is a simple game you must have played around with during your school days, calculating FLAMES of you and your crush! Given the names of two people, cancel out the common letters (repeated occurrence of a letter is treated separately, so 2A's in one name and one A in the other would cancel one A in each name), coun... | {
"input": [],
"output": []
} | {
"input": [
"2\nSHILPA\nAAMIR\nMATT\nDENISE"
],
"output": [
"ENEMIES\nLOVE"
]
} | {
"input": [],
"output": []
} |
muffins3 | Now that Chef has finished baking and frosting his cupcakes, it's time to package them. Chef has N cupcakes, and needs to decide how many cupcakes to place in each package. Each package must contain the same number of cupcakes. Chef will choose an integer A between 1 and N, inclusive, and place exactly A cupcakes into ... | {
"input": [],
"output": []
} | {
"input": [
"2\n2\n5"
],
"output": [
"2\n3\n"
]
} | {
"input": [
"2\n2\n7",
"2\n2\n3",
"2\n1\n3",
"2\n3\n5",
"2\n4\n4",
"2\n3\n8",
"2\n4\n7",
"2\n4\n8",
"2\n2\n16",
"2\n2\n14",
"2\n4\n14",
"2\n7\n14",
"2\n4\n3",
"2\n7\n26",
"2\n4\n26",
"2\n4\n46",
"2\n2\n46",
"2\n1\n5",
"2\n1\n46",
"2\n1\n... |
rrcode | You are given a simple code of a function and you would like to know what it will return.
F(N, K, Answer, Operator, A[N]) returns int;
begin
for iK do
for jN do
AnswerAnswer operator Aj)
return Answer
end
Here N, K, Answer and the value returned by the function F are integers;... | {
"input": [],
"output": []
} | {
"input": [
"3\n3 1 0\n1 2 3\nXOR\n3 1 0\n1 2 3\nAND\n3 1 0\n1 2 3\nOR"
],
"output": [
"0\n0\n3\n"
]
} | {
"input": [
"3\n3 1 0\n1 2 6\nXOR\n3 1 0\n1 2 3\nAND\n3 1 0\n1 2 3\nOR",
"3\n3 1 0\n1 2 3\nXOR\n3 1 0\n1 2 3\nAND\n3 1 0\n1 2 4\nOR",
"3\n3 1 0\n1 3 3\nXOR\n3 1 0\n1 2 3\nAND\n3 1 0\n1 2 4\nOR",
"3\n3 1 0\n1 3 3\nXOR\n3 1 0\n1 2 3\nAND\n3 1 0\n0 2 4\nOR",
"3\n3 1 0\n2 2 3\nXOR\n3 1 0\n1 2 3\nAND\... |
walk | Chef and his girlfriend are going to have a promenade. They are walking along the straight road which consists of segments placed one by one. Before walking Chef and his girlfriend stay at the beginning of the first segment, they want to achieve the end of the last segment.
There are few problems:
At the beginning ... | {
"input": [],
"output": []
} | {
"input": [
"2\n5\n6 5 4 3 2\n5\n3 4 3 1 1"
],
"output": [
"6\n5\n"
]
} | {
"input": [
"2\n5\n6 5 4 3 2\n5\n3 4 6 1 1",
"2\n5\n6 5 4 3 2\n5\n3 7 9 1 1",
"2\n5\n6 5 4 3 3\n5\n3 7 9 1 1",
"2\n5\n6 5 4 3 2\n5\n3 8 3 1 1",
"2\n5\n6 5 4 5 2\n5\n3 7 6 1 1",
"2\n5\n6 5 4 4 2\n5\n3 8 3 1 1",
"2\n5\n6 5 2 3 0\n5\n3 4 12 1 1",
"2\n5\n6 6 2 3 0\n5\n3 4 12 1 1",
"2\... |
1211_I. Unusual Graph | Ivan on his birthday was presented with array of non-negative integers a_1, a_2, …, a_n. He immediately noted that all a_i satisfy the condition 0 ≤ a_i ≤ 15.
Ivan likes graph theory very much, so he decided to transform his sequence to the graph.
There will be n vertices in his graph, and vertices u and v will prese... | {
"input": [],
"output": []
} | {
"input": [
"4 4\n1 2\n2 3\n3 4\n4 1\n",
"3 0\n"
],
"output": [
"\n0 1 0 1 \n",
"\n0 0 0 \n"
]
} | {
"input": [],
"output": []
} |
1277_E. Two Fairs | There are n cities in Berland and some pairs of them are connected by two-way roads. It is guaranteed that you can pass from any city to any other, moving along the roads. Cities are numerated from 1 to n.
Two fairs are currently taking place in Berland — they are held in two different cities a and b (1 ≤ a, b ≤ n; a ... | {
"input": [],
"output": []
} | {
"input": [
"3\n7 7 3 5\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 5\n4 5 2 3\n1 2\n2 3\n3 4\n4 1\n4 2\n4 3 2 1\n1 2\n2 3\n4 1\n"
],
"output": [
"4\n0\n1\n"
]
} | {
"input": [
"3\n7 7 3 5\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 5\n4 5 2 4\n1 2\n2 3\n3 4\n4 1\n4 2\n4 3 2 1\n1 2\n2 3\n4 1\n",
"3\n7 7 3 5\n1 2\n2 3\n3 4\n2 5\n5 6\n6 7\n7 5\n4 5 2 4\n1 2\n2 3\n3 4\n4 1\n4 2\n4 3 2 1\n1 2\n2 3\n4 1\n",
"3\n7 7 3 5\n1 2\n2 3\n1 4\n2 5\n5 6\n6 7\n7 5\n4 5 2 4\n1 2\n2 3\n3 4\n4 1... |
1297_E. Modernization of Treeland | Treeland consists of n cities and n-1 two-way roads connecting pairs of cities. From every city, you can reach every other city moving only by the roads. You are right, the system of cities and roads in this country forms an undirected tree.
The government has announced a program for the modernization of urban infrast... | {
"input": [],
"output": []
} | {
"input": [
"4\n10 4\n4 5\n5 2\n2 1\n1 3\n1 9\n9 10\n2 7\n7 8\n5 6\n4 3\n1 2\n2 3\n3 4\n5 3\n1 2\n1 3\n1 4\n1 5\n4 1\n1 2\n2 4\n2 3\n"
],
"output": [
"\nYes\n9\n1 2 4 5 6 7 8 9 10 \nNo\nYes\n4\n1 3 4 5 \nYes\n1\n4 \n"
]
} | {
"input": [],
"output": []
} |
1320_F. Blocks and Sensors | Polycarp plays a well-known computer game (we won't mention its name). Every object in this game consists of three-dimensional blocks — axis-aligned cubes of size 1 × 1 × 1. These blocks are unaffected by gravity, so they can float in the air without support. The blocks are placed in cells of size 1 × 1 × 1; each cell ... | {
"input": [],
"output": []
} | {
"input": [
"1 1 1\n\n0\n\n0\n\n1337\n\n0\n\n0\n\n0\n",
"1 1 1\n\n1337\n\n1337\n\n1337\n\n1337\n\n1337\n\n1337\n",
"1 1 1\n\n0\n\n0\n\n0\n\n0\n\n0\n\n0\n",
"4 3 2\n\n1 4\n3 2\n6 5\n\n1 4\n3 2\n6 7\n\n1 4\n1 4\n0 0\n0 7\n\n6 5\n6 5\n0 0\n0 7\n\n1 3 6\n1 3 6\n0 0 0\n0 0 7\n\n4 3 5\n4 2 5\n0 0 0\n0 0 7\... | {
"input": [
"1 1 1\n\n0\n\n0\n\n2344\n\n0\n\n0\n\n0\n",
"1 1 1\n\n0\n\n0\n\n0\n\n0\n\n0\n\n1\n",
"4 3 2\n\n1 4\n3 2\n6 5\n\n1 4\n3 2\n6 7\n\n1 4\n1 4\n0 0\n0 7\n\n6 5\n6 5\n0 0\n0 7\n\n1 3 6\n1 6 6\n0 0 0\n0 0 7\n\n4 3 5\n4 2 5\n0 0 0\n0 0 7\n",
"1 1 1\n\n0\n\n0\n\n0\n\n0\n\n0\n\n2\n",
"4 3 2\n\n... |
1361_E. James and the Chase | James Bond has a new plan for catching his enemy. There are some cities and directed roads between them, such that it is possible to travel between any two cities using these roads. When the enemy appears in some city, Bond knows her next destination but has no idea which path she will choose to move there.
The city ... | {
"input": [],
"output": []
} | {
"input": [
"4\n3 3\n1 2\n2 3\n3 1\n3 6\n1 2\n2 1\n2 3\n3 2\n1 3\n3 1\n7 10\n1 2\n2 3\n3 1\n1 4\n4 5\n5 1\n4 6\n6 7\n7 4\n6 1\n6 8\n1 2\n2 3\n3 4\n4 5\n5 6\n6 1\n6 2\n5 1\n"
],
"output": [
"1 2 3 \n-1\n1 2 3 5 \n-1\n"
]
} | {
"input": [
"4\n3 3\n1 2\n2 3\n3 1\n3 6\n1 2\n2 1\n2 3\n3 2\n1 3\n3 1\n7 10\n1 2\n2 3\n3 1\n1 4\n4 5\n5 1\n4 6\n6 7\n7 4\n6 1\n6 8\n1 2\n2 3\n3 4\n4 5\n4 6\n6 1\n6 2\n5 1\n",
"4\n3 3\n1 2\n2 3\n3 1\n3 6\n1 2\n2 1\n2 3\n3 2\n1 3\n3 1\n7 10\n1 2\n2 3\n3 1\n1 4\n2 5\n5 1\n4 6\n6 7\n7 4\n6 1\n6 8\n1 2\n2 3\n3 4\... |
1402_A. Fancy Fence | Everybody knows that Balázs has the fanciest fence in the whole town. It's built up from N fancy sections. The sections are rectangles standing closely next to each other on the ground. The ith section has integer height h_i and integer width w_i. We are looking for fancy rectangles on this fancy fence. A rectangle is ... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 2\n1 2\n"
],
"output": [
"\n12\n"
]
} | {
"input": [],
"output": []
} |
1424_N. BubbleSquare Tokens | BubbleSquare social network is celebrating 13^{th} anniversary and it is rewarding its members with special edition BubbleSquare tokens. Every member receives one personal token. Also, two additional tokens are awarded to each member for every friend they have on the network. Yet, there is a twist – everyone should end... | {
"input": [],
"output": []
} | {
"input": [
"2 1\n1 2\n",
"3 3\n1 2\n1 3\n2 3\n"
],
"output": [
"1\n1 \n1 2 0\n",
"0\n\n1 2 0\n1 3 2\n2 3 1\n"
]
} | {
"input": [
"2 0\n1 2\n",
"2 1\n1 3\n",
"3 3\n1 2\n1 5\n2 3\n",
"2 0\n1 0\n",
"4 0\n1 0\n",
"4 0\n1 -1\n",
"0 0\n1 2\n",
"2 0\n1 1\n",
"6 0\n1 0\n",
"4 0\n0 -1\n",
"0 0\n1 0\n",
"8 0\n0 -1\n",
"0 -1\n1 0\n",
"8 0\n0 0\n",
"0 -1\n1 -1\n",
"-1 -1\n1 -1\n"... |
1497_D. Genius | Please note the non-standard memory limit.
There are n problems numbered with integers from 1 to n. i-th problem has the complexity c_i = 2^i, tag tag_i and score s_i.
After solving the problem i it's allowed to solve problem j if and only if IQ < |c_i - c_j| and tag_i ≠ tag_j. After solving it your IQ changes and be... | {
"input": [],
"output": []
} | {
"input": [
"5\n4\n1 2 3 4\n5 10 15 20\n4\n1 2 1 2\n5 10 15 20\n4\n2 2 4 1\n2 8 19 1\n2\n1 1\n6 9\n1\n1\n666\n"
],
"output": [
"\n35\n30\n42\n0\n0\n"
]
} | {
"input": [
"5\n4\n1 2 3 4\n5 10 15 20\n4\n1 2 1 2\n5 10 15 20\n4\n2 2 4 1\n2 8 19 2\n2\n1 1\n6 9\n1\n1\n666\n",
"5\n4\n1 2 3 4\n5 10 15 20\n4\n1 2 2 2\n5 10 15 20\n4\n2 2 4 1\n2 8 19 2\n2\n1 1\n6 9\n1\n1\n666\n",
"5\n4\n1 3 0 4\n5 10 15 20\n4\n1 2 2 2\n5 10 19 20\n4\n2 2 4 1\n2 8 19 2\n2\n1 1\n6 9\n1\n1... |
996_F. Game | Allen and Bessie are playing a simple number game. They both know a function f: \{0, 1\}^n → R, i. e. the function takes n binary arguments and returns a real value. At the start of the game, the variables x_1, x_2, ..., x_n are all set to -1. Each round, with equal probability, one of Allen or Bessie gets to make a mo... | {
"input": [],
"output": []
} | {
"input": [
"2 0\n1 1 1 1\n",
"2 2\n0 1 2 3\n2 5\n0 4\n",
"1 0\n2 3\n"
],
"output": [
"1.0000000000\n",
"1.5000000000\n2.2500000000\n3.2500000000\n",
"2.5000000000\n"
]
} | {
"input": [
"2 0\n1 1 0 1\n",
"2 2\n0 1 2 3\n2 1\n0 4\n",
"1 0\n2 1\n",
"2 0\n1 0 0 1\n",
"2 2\n0 1 2 4\n2 1\n0 4\n",
"2 2\n0 1 2 4\n3 1\n0 4\n",
"2 2\n0 1 0 4\n3 1\n0 4\n",
"2 2\n0 1 0 4\n2 1\n0 4\n",
"2 2\n0 1 2 3\n3 5\n0 4\n",
"2 2\n0 1 0 3\n2 1\n0 4\n",
"1 0\n4 1\n",
... |
hermione-vs-draco | Draco Malfoy and Hermione Granger have gotten into a "battle of brains". Draco was foolish enough to challenge her to a Arithmancy problem. Septima Vector, Arithmancy teacher at Hogwarts, has agreed to give them both a problem which they should solve overnight.
The problem is as follows :-
Firstly, a function F (fro... | {
"input": [],
"output": []
} | {
"input": [
"6\n3\n60\n100\n1024\n23456\n8735373\n\nSAMPLE"
],
"output": [
"0\n14\n24\n253\n5861\n2183837\n"
]
} | {
"input": [
"6\n3\n60\n100\n1024\n23456\n8735373\n\nELPMAS",
"6\n5\n60\n100\n1024\n23456\n8735373\n\nELPMAS",
"6\n5\n21\n100\n1024\n23456\n8735373\n\nELPMAS",
"6\n4\n21\n100\n1024\n23456\n8735373\n\nEMPMAS",
"6\n4\n21\n100\n1024\n17256\n8735373\n\nEMPMAS",
"6\n4\n21\n100\n57\n17256\n8735373\n... |
new-world-11 | The time has arrived when the world is going to end. But don't worry, because the new world yuga will start soon. Manu (carrier of mankind) has been assigned the job to carry all the necessary elements of current yuga to the upcoming yuga.
There are N stones arranged in a straight line. In order to fulfill the task, M... | {
"input": [],
"output": []
} | {
"input": [
"2\n4 1\n2 15 36 43 \n3 2\n27 30 35 \n\nSAMPLE"
],
"output": [
"41\n5\n"
]
} | {
"input": [
"2\n4 1\n2 15 36 43 \n3 2\n27 29 35 \n\nSAMPLE",
"2\n4 1\n4 15 36 43 \n3 2\n27 29 35 \n\nSAMPLE",
"2\n4 1\n2 15 36 43 \n3 2\n18 30 35 \n\nSAMPLE",
"2\n4 1\n0 15 36 43 \n3 2\n27 29 35 \n\nSAMPLE",
"2\n3 1\n2 15 36 43 \n3 2\n18 30 35 \n\nSAMPLE",
"2\n3 1\n4 15 36 43 \n3 2\n18 30 35 ... |
p02652 AtCoder Grand Contest 045 - 01 Unbalanced | Given is a string S, where each character is `0`, `1`, or `?`.
Consider making a string S' by replacing each occurrence of `?` with `0` or `1` (we can choose the character for each `?` independently). Let us define the unbalancedness of S' as follows:
* (The unbalancedness of S') = \max \\{ The absolute difference be... | {
"input": [],
"output": []
} | {
"input": [
"??00????0??0????0?0??00??1???11?1?1???1?11?111???1",
"0??0",
"0??"
],
"output": [
"4",
"2",
"1"
]
} | {
"input": [
"0?0?",
"00??",
"??00????0??1????0?0??00??1???11?1?1???1?11?111???1",
"1???11??11?1???1?1?11???1??00??0?0?1??1??0>>??00??",
"1???111?11?1???111?11???1??00??0?0?@?????0????00??",
"????111?11?1?1?111?11???1??00??0???@?????0???000??",
"????111111?1???0?1?11???1??00????00?0????0??... |
p02781 AtCoder Beginner Contest 154 - Almost Everywhere Zero | Find the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.
Constraints
* 1 \leq N < 10^{100}
* 1 \leq K \leq 3
Input
Input is given from Standard Input in the following format:
N
K
Output
Print the count.
Examples
Input
100
1
Output
19
Inpu... | {
"input": [],
"output": []
} | {
"input": [
"9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n3",
"314159\n2",
"25\n2",
"100\n1"
],
"output": [
"117879300",
"937",
"14",
"19"
]
} | {
"input": [
"314159\n1",
"25\n1",
"100\n2",
"314159\n3",
"9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n2",
"25\n4",
"9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n1",
"100\... |
p02916 AtCoder Beginner Contest 140 - Buffet | Takahashi went to an all-you-can-eat buffet with N kinds of dishes and ate all of them (Dish 1, Dish 2, \ldots, Dish N) once.
The i-th dish (1 \leq i \leq N) he ate was Dish A_i.
When he eats Dish i (1 \leq i \leq N), he gains B_i satisfaction points.
Additionally, when he eats Dish i+1 just after eating Dish i (1 \... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 2\n50 50\n50",
"4\n2 3 4 1\n13 5 8 24\n45 9 15",
"3\n3 1 2\n2 5 4\n3 6"
],
"output": [
"150",
"74",
"14"
]
} | {
"input": [
"2\n1 0\n50 50\n50",
"4\n2 3 4 1\n13 5 1 24\n45 9 15",
"4\n2 3 4 1\n13 5 1 24\n45 9 16",
"4\n2 3 4 1\n14 5 1 24\n45 9 16",
"4\n2 3 4 1\n7 5 1 24\n45 9 16",
"3\n3 1 2\n2 5 3\n3 6",
"4\n2 3 4 1\n20 5 1 24\n45 9 16",
"3\n3 1 2\n2 1 3\n3 6",
"4\n2 3 4 1\n14 5 1 24\n4 6 16"... |
p03052 diverta 2019 Programming Contest - Edge Ordering | You are given a simple connected undirected graph G consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M.
Edge i connects Vertex a_i and b_i bidirectionally. It is guaranteed that the subgraph consisting of Vertex 1,2,\ldots,N and Edge 1,2,\ldots,N-1 is a spanning t... | {
"input": [],
"output": []
} | {
"input": [
"4 4\n1 2\n3 2\n3 4\n1 3",
"15 28\n10 7\n5 9\n2 13\n2 14\n6 1\n5 12\n2 10\n3 9\n10 15\n11 12\n12 6\n2 12\n12 8\n4 10\n15 3\n13 14\n1 15\n15 12\n4 14\n1 7\n5 11\n7 13\n9 10\n2 7\n1 9\n5 6\n12 14\n5 2",
"3 3\n1 2\n2 3\n1 3"
],
"output": [
"50",
"657573092",
"6"
]
} | {
"input": [
"15 28\n10 7\n5 9\n2 13\n2 14\n6 1\n9 12\n2 10\n3 9\n10 15\n11 12\n12 6\n2 12\n12 8\n4 10\n15 3\n13 14\n1 15\n15 12\n4 14\n1 7\n5 11\n7 13\n9 10\n2 7\n1 9\n5 6\n12 14\n5 2",
"4 4\n1 2\n4 2\n3 4\n1 3",
"4 4\n1 2\n4 1\n3 4\n1 3",
"15 28\n10 7\n5 9\n2 13\n2 14\n6 1\n5 12\n2 10\n3 9\n10 15\n1... |
p03194 CADDi 2018 for Beginners - Product and GCD | There are N integers a_1, a_2, ..., a_N not less than 1. The values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \times a_2 \times ... \times a_N = P.
Find the maximum possible greatest common divisor of a_1, a_2, ..., a_N.
Constraints
* 1 \leq N \leq 10^{12}
* 1 \leq P \leq 10^{12}
Input
Input is... | {
"input": [],
"output": []
} | {
"input": [
"5 1",
"4 972439611840",
"3 24",
"1 111"
],
"output": [
"1",
"206",
"2",
"111"
]
} | {
"input": [
"5 2",
"1 972439611840",
"1 110",
"1 2",
"1 534720932937",
"1 18",
"1 010",
"1 3",
"1 867963093279",
"1 15",
"1 011",
"1 5",
"1 100",
"1 1431379180228",
"1 101",
"1 243501193440",
"1 4",
"1 1472895801034",
"1 8",
"1 249458889... |
p03343 AtCoder Regular Contest 098 - Range Minimum Queries | You are given an integer sequence A of length N and an integer K. You will perform the following operation on this sequence Q times:
* Choose a contiguous subsequence of length K, then remove the smallest element among the K elements contained in the chosen subsequence (if there are multiple such elements, choose one ... | {
"input": [],
"output": []
} | {
"input": [
"11 7 5\n24979445 861648772 623690081 433933447 476190629 262703497 211047202 971407775 628894325 731963982 822804784",
"5 3 2\n4 3 1 5 2",
"10 1 6\n1 1 2 3 5 8 13 21 34 55"
],
"output": [
"451211184",
"1",
"7"
]
} | {
"input": [
"11 7 5\n24979445 861648772 623690081 433933447 476190629 262703497 147009374 971407775 628894325 731963982 822804784",
"5 3 2\n4 3 1 10 2",
"10 1 6\n1 1 2 3 5 8 4 21 34 55",
"10 1 4\n1 1 2 3 5 10 4 21 34 55",
"9 1 4\n1 1 2 5 5 10 4 21 34 55",
"10 1 6\n1 1 2 3 4 8 13 21 34 55",
... |
p03503 AtCoder Beginner Contest 080 - Shopping Street | Joisino is planning to open a shop in a shopping street.
Each of the five weekdays is divided into two periods, the morning and the evening. For each of those ten periods, a shop must be either open during the whole period, or closed during the whole period. Naturally, a shop must be open during at least one of those ... | {
"input": [],
"output": []
} | {
"input": [
"1\n1 1 0 1 0 0 0 1 0 1\n3 4 5 6 7 8 9 -2 -3 4 -2",
"3\n1 1 1 1 1 1 0 0 1 1\n0 1 0 1 1 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -8 -8 4 8 7 -6 2 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 7 -9 6 -5 8 0 -9 -7 -7",
"2\n1 1 1 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\n0 -2 -2 -2... | {
"input": [
"2\n1 1 1 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\n0 -2 -2 -2 -1 -2 -1 -1 -1 -1 -1",
"1\n1 1 0 1 0 0 0 1 0 1\n3 4 5 6 7 8 9 -4 -3 4 -2",
"2\n1 1 1 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -4 -2 -1 -1 -1 -1 -1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1",
"2\n1 1 1 1... |
p03664 AtCoder Regular Contest 078 - Mole and Abandoned Mine | Mole decided to live in an abandoned mine. The structure of the mine is represented by a simple connected undirected graph which consists of N vertices numbered 1 through N and M edges. The i-th edge connects Vertices a_i and b_i, and it costs c_i yen (the currency of Japan) to remove it.
Mole would like to remove som... | {
"input": [],
"output": []
} | {
"input": [
"15 22\n8 13 33418\n14 15 55849\n7 10 15207\n4 6 64328\n6 9 86902\n15 7 46978\n8 14 53526\n1 2 8720\n14 12 37748\n8 3 61543\n6 5 32425\n4 11 20932\n3 12 55123\n8 2 45333\n9 12 77796\n3 9 71922\n12 15 70793\n2 4 25485\n11 6 1436\n2 7 81563\n7 11 97843\n3 1 40491",
"2 1\n1 2 1",
"4 6\n1 2 100\n... | {
"input": [
"4 6\n1 2 101\n3 1 100\n2 4 100\n4 3 100\n1 4 100\n3 2 100",
"15 22\n8 13 33418\n14 15 55849\n7 10 15207\n4 6 64328\n6 9 86902\n15 7 46978\n8 14 53526\n1 2 8720\n14 12 37748\n8 3 61543\n6 5 32425\n4 11 20932\n3 12 55123\n8 2 45333\n9 12 77796\n3 9 71922\n12 15 70793\n3 4 25485\n11 6 1436\n2 7 815... |
p03819 AtCoder Regular Contest 068 - Snuke Line | Snuke has decided to play a game, where the player runs a railway company. There are M+1 stations on Snuke Line, numbered 0 through M. A train on Snuke Line stops at station 0 and every d-th station thereafter, where d is a predetermined constant for each train. For example, if d = 3, the train stops at station 0, 3, 6... | {
"input": [],
"output": []
} | {
"input": [
"3 3\n1 2\n2 3\n3 3",
"7 9\n1 7\n5 9\n5 7\n5 9\n1 1\n6 8\n3 4"
],
"output": [
"3\n2\n2",
"7\n6\n6\n5\n4\n5\n5\n3\n2"
]
} | {
"input": [
"7 9\n1 9\n5 9\n5 7\n5 9\n1 1\n6 8\n3 4",
"7 9\n1 9\n9 9\n5 7\n5 9\n1 1\n6 8\n3 4",
"7 11\n1 9\n5 9\n5 7\n5 9\n1 1\n6 8\n3 4",
"7 9\n1 9\n9 9\n5 7\n5 9\n1 1\n8 8\n3 4",
"7 9\n1 6\n5 13\n5 7\n5 9\n1 1\n6 8\n3 4",
"7 11\n1 2\n5 9\n5 7\n5 9\n1 1\n6 8\n3 4",
"7 9\n1 9\n9 9\n5 5\n5... |
p03986 AtCoder Grand Contest 005 - STring | We have a string X, which has an even number of characters. Half the characters are `S`, and the other half are `T`.
Takahashi, who hates the string `ST`, will perform the following operation 10^{10000} times:
* Among the occurrences of `ST` in X as (contiguous) substrings, remove the leftmost one. If there is no occ... | {
"input": [],
"output": []
} | {
"input": [
"TSTTSS",
"SSTTST",
"TSSTTTSS"
],
"output": [
"4",
"0",
"4"
]
} | {
"input": [
"SSTTTSST",
"STTTSS",
"SSSTTT",
"TTTSSS",
"TTTTSSSS",
"TSTSST",
"SSTTTS",
"TSSTST",
"STTSST",
"TSSSTT",
"TTSSST",
"TSSTTS",
"STSTST",
"TSTSTS",
"TSSTTSST",
"STSTTS",
"TTSTSSST",
"STTSTS",
"TTSSTS",
"STSSTT",
"SSTTSTST",
... |
p00074 Videotape | There is a 120 minute videotape with standard recording. When I set the VCR counter to 00:00:00 with the tape completely rewound and recorded in standard recording mode, I got a certain counter value. Enter this counter value (hours, minutes, seconds), find the length of the remaining tape (recordable time), and create... | {
"input": [],
"output": []
} | {
"input": [
"1 30 0\n-1 -1 -1"
],
"output": [
"00:30:00\n01:30:00"
]
} | {
"input": [
"1 36 0\n-1 -1 -1",
"0 30 0\n-1 -1 -1",
"0 32 0\n-1 -1 -1",
"1 16 0\n-1 -1 -1",
"0 36 0\n-1 -1 -1",
"0 22 0\n-1 -1 -1",
"0 55 0\n-1 -1 -1",
"0 22 1\n-1 -1 -1",
"0 31 1\n-1 -1 -1",
"0 26 1\n-1 -1 -1",
"0 9 1\n-1 -1 -1",
"1 36 1\n-1 -1 -1",
"1 8 0\n-1 -1 ... |
p00206 Next Trip | You want to go on a trip with a friend. However, friends who have a habit of spending money cannot easily save travel expenses. I don't know when my friends will go on a trip if they continue their current lives. So, if you want to travel early, you decide to create a program to help your friends save in a planned mann... | {
"input": [],
"output": []
} | {
"input": [
"10000\n5000 3150\n5000 5000\n0 0\n5000 1050\n5000 3980\n5000 210\n5000 5000\n5000 5000\n0 0\n5000 2100\n5000 2100\n5000 2100\n29170\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n10... | {
"input": [
"10000\n5000 3150\n5000 5000\n0 0\n5000 1050\n5000 3980\n5000 210\n5000 5000\n5000 5000\n0 0\n5000 2100\n5000 2100\n5000 2100\n29170\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 101000\n100000 100000\n100000 100000\n100000 100000\n10... |
p00365 Age Difference | A trick of fate caused Hatsumi and Taku to come to know each other. To keep the encounter in memory, they decided to calculate the difference between their ages. But the difference in ages varies depending on the day it is calculated. While trying again and again, they came to notice that the difference of their ages w... | {
"input": [],
"output": []
} | {
"input": [
"2008 2 29\n2015 3 1",
"1999 9 9\n2001 11 3"
],
"output": [
"8",
"3"
]
} | {
"input": [
"2008 2 29\n2015 1 1",
"1505 9 9\n2001 11 3",
"1505 9 9\n2619 11 3",
"1505 13 9\n2619 11 3",
"573 1 44\n2015 1 1",
"595 2 44\n2015 2 1",
"597 2 44\n2015 2 1",
"246 21 0\n2619 11 5",
"246 21 0\n5129 11 5",
"431 21 0\n5129 11 5",
"597 2 19\n895 -2 1",
"51 16 ... |
p00573 Commuter Pass | There are N stations in the city where JOI lives, and they are numbered 1, 2, ..., and N, respectively. In addition, there are M railway lines, numbered 1, 2, ..., and M, respectively. The railway line i (1 \ leq i \ leq M) connects station A_i and station B_i in both directions, and the fare is C_i yen.
JOI lives nea... | {
"input": [],
"output": []
} | {
"input": [
"6 6\n1 6\n1 4\n1 2 1\n2 3 1\n3 5 1\n2 4 3\n4 5 2\n5 6 1"
],
"output": [
"2"
]
} | {
"input": [
"6 6\n1 6\n1 4\n1 2 1\n2 3 1\n2 5 1\n2 4 3\n4 5 2\n5 6 1",
"11 6\n1 6\n1 4\n1 2 1\n4 3 1\n2 5 1\n2 4 3\n4 5 0\n5 6 1",
"11 6\n1 1\n1 2\n1 2 1\n4 3 1\n2 5 1\n2 4 3\n4 5 0\n5 6 1",
"11 6\n2 6\n1 4\n1 2 1\n4 3 1\n2 5 1\n2 4 3\n4 5 2\n5 6 1",
"14 6\n1 1\n1 4\n1 2 1\n2 3 1\n2 5 1\n2 4 3\n4... |
p00720 Earth Observation with a Mobile Robot Team | A new type of mobile robot has been developed for environmental earth observation. It moves around on the ground, acquiring and recording various sorts of observational data using high precision sensors. Robots of this type have short range wireless communication devices and can exchange observational data with ones ne... | {
"input": [],
"output": []
} | {
"input": [
"3 5 10\nred\n0 0 0\n5 0 0\ngreen\n0 5 5\n5 6 1\nblue\n0 40 5\n5 0 0\n3 10 5\natom\n0 47 32\n5 -10 -7\n10 1 0\npluto\n0 0 0\n7 0 0\n10 3 3\ngesicht\n0 25 7\n5 -7 -2\n10 -1 10\n4 100 7\nimpulse\n0 -500 0\n100 10 1\nfreedom\n0 -491 0\n100 9 2\ndestiny\n0 -472 0\n100 7 4\nstrike\n0 -482 0\n100 8 3\n0 0 ... | {
"input": [
"3 5 10\nred\n0 0 0\n5 0 0\ngreen\n0 5 5\n5 6 1\nblue\n0 40 5\n5 0 0\n3 10 5\nbtom\n0 47 32\n5 -10 -7\n10 1 0\npluto\n0 0 0\n7 0 0\n10 3 3\ngesicht\n0 25 7\n5 -7 -2\n10 -1 10\n4 100 7\nimpulse\n0 -500 0\n100 10 1\nfreedom\n0 -491 0\n100 9 2\ndestiny\n0 -472 0\n100 7 4\nstrike\n0 -482 0\n100 8 3\n0 0 ... |
p00860 The Morning after Halloween | You are working for an amusement park as an operator of an obakeyashiki, or a haunted house, in which guests walk through narrow and dark corridors. The house is proud of their lively ghosts, which are actually robots remotely controlled by the operator, hiding here and there in the corridors. One morning, you found th... | {
"input": [],
"output": []
} | {
"input": [
"5 5 2\n#####\n#A#B#\n# #\n#b#a#\n#####\n16 4 3\n################\n## ########## ##\n# ABCcba #\n################\n16 16 3\n################\n### ## # ##\n## # ## # c#\n# ## ########b#\n# ## # # # #\n# # ## # # ##\n## a# # # # #\n### ## #### ## #\n## # # # #\n# ####... | {
"input": [
"5 5 2\n#####\n#A#B#\n# #\n#b#a#\n#####\n16 4 3\n################\n## ########## ##\n# ABCcba #\n################\n16 16 3\n################\n### ## # ##\n## # ## # c#\n# ## ########b#\n# ## # # # #\n# # ## # # ##\n## a# # # # #\n### ## #### ## #\n## # # # #\n# ####... |
p00991 Grid | Two coordinates (a1, a2) and (b1, b2) on a two-dimensional grid of r × c are given. The cost of moving from a cell (e, f) to one of the cells (e + 1, f), (e-1, f), (e, f + 1), (e, f-1) is 1. And. You can also move between (e, c-1) and (e, 0), and between (r-1, f) and (0, f) at a cost of 1. At this time, find the number... | {
"input": [],
"output": []
} | {
"input": [
"500 500 0 0 200 200",
"4 4 0 0 1 1",
"4 4 0 0 3 3",
"2 3 0 0 1 2"
],
"output": [
"34807775",
"2",
"2",
"4"
]
} | {
"input": [
"500 500 0 0 107 200",
"4 1 0 0 1 1",
"4 4 1 0 3 3",
"2 3 0 0 1 1",
"500 500 0 0 107 239",
"2 1 0 0 1 1",
"678 500 0 0 107 168",
"500 500 0 0 200 277",
"500 500 1 0 107 239",
"678 353 0 0 107 239",
"1174 500 0 0 4 168",
"272 500 0 0 200 277",
"4 7 0 0 1... |
p01123 Let's Move Tiles! | <!--
Problem G
-->
Let's Move Tiles!
You have a framed square board forming a grid of square cells. Each of the cells is either empty or with a square tile fitting in the cell engraved with a Roman character. You can tilt the board to one of four directions, away from you, toward you, to the left, or to the right, ... | {
"input": [],
"output": []
} | {
"input": [
"4\n..E.\n.AD.\nB...\n..C.\nD\n4\n..E.\n.AD.\nB...\n..C.\nDR\n3\n...\n.A.\nBC.\n((URD)3L)2R\n5\n...P.\nPPPPP\nPPP..\nPPPPP\n..P..\nLRLR(LR)12RLLR\n20\n....................\n....................\n.III..CC..PPP...CC..\n..I..C..C.P..P.C..C.\n..I..C....P..P.C....\n..I..C....PPP..C....\n..I..C....P....C..... | {
"input": [],
"output": []
} |
p01262 Adaptive Time Slicing Quantization | Nathan O. Davis is a student at the department of integrated systems. Today he learned digital quanti- zation in a class. It is a process that approximates analog data (e.g. electrical pressure) by a finite set of discrete values or integers.
He had an assignment to write a program that quantizes the sequence of real ... | {
"input": [],
"output": []
} | {
"input": [
"5 2 1\n0.1 0.2 0.3 0.4 0.5\n6 2 2\n0.1 0.2 0.3 0.4 0.5 0.6\n0 0 0"
],
"output": [
"0.01\n0.00"
]
} | {
"input": [
"5 2 1\n0.1 0.2 0.3 0.5915213038191143 0.5\n6 2 2\n0.1 0.2 0.3 0.4 0.5 0.6\n0 0 0",
"5 2 1\n0.1 0.3034585214713487 0.3 0.5915213038191143 0.5\n6 2 2\n0.1 0.2 0.3 0.4 0.5 0.6\n0 0 0",
"5 2 1\n0.1 0.3034585214713487 1.0488885934387808 0.5915213038191143 0.5\n6 2 2\n0.1 0.2 0.48010372072768065 0... |
p01422 Beautiful Currency | KM country has N kinds of coins and each coin has its value a_i.
The king of the country, Kita_masa, thought that the current currency system is poor, and he decided to make it beautiful by changing the values of some (possibly no) coins.
A currency system is called beautiful if each coin has an integer value and the... | {
"input": [],
"output": []
} | {
"input": [
"3\n6 11 24",
"3\n6 11 30",
"3\n6 11 12"
],
"output": [
"0.090909090909",
"0.166666666667",
"0.090909090909"
]
} | {
"input": [
"3\n6 13 24",
"3\n6 4 30",
"3\n12 11 12",
"3\n6 20 24",
"3\n6 7 30",
"3\n11 20 24",
"3\n10 7 30",
"3\n1 15 12",
"3\n8 7 30",
"3\n1 1 12",
"3\n11 12 15",
"3\n8 7 11",
"3\n14 14 26",
"3\n7 15 28",
"3\n19 14 28",
"3\n19 14 5",
"3\n6 11 1",
... |
p01576 Exciting Bicycle | You happened to get a special bicycle. You can run with it incredibly fast because it has a turbo engine. You can't wait to try it off road to enjoy the power.
You planned to go straight. The ground is very rough with ups and downs, and can be seen as a series of slopes (line segments) when seen from a lateral view. T... | {
"input": [],
"output": []
} | {
"input": [
"2 10\n0 0\n10000 0",
"4 50\n0 10000\n1 10000\n2 0\n10000 0",
"5 10\n0 0\n10 10\n20 0\n30 10\n40 0",
"4 10000\n0 0\n1 1\n9999 0\n10000 10000"
],
"output": [
"10000.00000000",
"7741.23024274",
"22.22335598",
"11.21323169"
]
} | {
"input": [
"4 50\n0 10000\n1 10000\n2 1\n10000 0",
"4 10001\n0 0\n1 1\n9999 0\n10000 10000",
"4 100\n0 10000\n1 10000\n2 1\n10000 0",
"4 10001\n0 0\n1 1\n9999 -1\n10000 10000",
"4 100\n0 10000\n1 10010\n2 1\n10000 0",
"4 10001\n0 0\n1 1\n9999 -1\n10000 10100",
"4 100\n0 10100\n1 10010\n2... |
p01738 Gravity Point | You are practicing a juggle that involves in a number of square tiles. They all look the same in their size, but actually there are three different kinds of the tiles, A, B and X. The kind of a tile can be distinguishable by its mass. All the tiles of the same kind have exactly the same mass. The mass of type A tiles i... | {
"input": [],
"output": []
} | {
"input": [
"3 3\n2 4 1 2 1\nXAX\nB.B\nXAX"
],
"output": [
"0.0000000000000"
]
} | {
"input": [
"3 3\n2 4 1 0 1\nXAX\nB.B\nXAX",
"3 6\n2 4 1 1 1\nXXA\nB.B\nXAX",
"10 6\n1 9 1 2 3\nYXA\nB.B\nYXA",
"10 6\n1 14 1 2 3\nYXA\nB.B\nYXA",
"10 6\n1 24 1 2 3\nYXA\nB.B\nYXA",
"10 6\n0 24 1 2 3\nYXA\nB.B\nYXA",
"10 6\n0 34 1 2 3\nYXA\nB.B\nYXA",
"10 6\n0 34 1 2 3\nYXB\nB.B\nYXA"... |
p01878 Destiny Draw | G: Destiny Draw-
problem
Mr. D will play a card game. This card game uses a pile of N cards. Also, the pile cards are numbered 1, 2, 3, ..., N in order from the top.
He can't afford to be defeated, carrying everything that starts with D, but unfortunately Mr. D isn't good at card games. Therefore, I decided to win b... | {
"input": [],
"output": []
} | {
"input": [
"4 1 1 6\n3 2 3"
],
"output": [
"1"
]
} | {
"input": [
"4 1 1 12\n3 2 3",
"4 1 1 16\n3 2 3",
"4 1 1 16\n2 2 3",
"4 1 1 6\n3 1 3",
"4 0 1 12\n3 2 3",
"4 1 1 22\n3 2 3",
"4 1 1 31\n2 2 3",
"4 1 1 6\n3 1 1",
"4 0 1 12\n3 2 2",
"4 1 2 22\n3 2 3",
"8 1 1 31\n2 2 3",
"4 0 1 6\n3 1 1",
"4 1 4 22\n3 2 3",
"4 0 ... |
p02014 Rough Sorting | For skilled programmers, it is very easy to implement a sorting function. Moreover, they often avoid full sorting to reduce computation time if it is not necessary. Here, we consider "rough sorting" which sorts an array except for some pairs of elements. More formally, we define an array is "$K$-roughly sorted" if an a... | {
"input": [],
"output": []
} | {
"input": [
"3 100\n3\n2\n1",
"3 1\n3\n2\n1",
"5 3\n5\n3\n2\n1\n4",
"5 3\n1\n2\n3\n4\n5"
],
"output": [
"3\n2\n1",
"1\n3\n2",
"1\n3\n5\n2\n4",
"1\n2\n3\n4\n5"
]
} | {
"input": [
"3 2\n3\n2\n1",
"3 4\n3\n2\n1",
"3 0\n3\n2\n1",
"3 001\n3\n2\n1",
"5 1\n5\n3\n2\n1\n4",
"5 6\n1\n2\n3\n4\n5",
"5 2\n5\n3\n2\n1\n4",
"3 100\n3\n1\n2",
"1 2\n1\n2\n3\n4\n5",
"2 3\n1\n2\n2\n0\n1",
"3 000\n3\n2\n1",
"3 110\n3\n2\n1",
"3 7\n3\n2\n1",
"3 ... |
p02157 Shuffle 2 | Problem
There is a bundle of $ n $ cards, with $ i $ written on the $ i $ th card from the bottom. Shuffle this bundle as defined below $ q $ times.
* When looking at the bundle from below, consider a bundle $ x $ made by stacking odd-numbered cards on top, and a bundle $ y $ made by stacking even-numbered cards on ... | {
"input": [],
"output": []
} | {
"input": [
"4 2 3 1",
"7834164883628 15 2189823423122 5771212644938",
"4 2 1 1",
"4 1 1 4"
],
"output": [
"0\n1",
"0\n1\n1\n1\n1\n1\n0\n1\n0\n1\n0\n0\n0\n0\n0",
"0\n0",
"-1"
]
} | {
"input": [
"6 2 3 1",
"7834164883628 15 2189823423122 7725883688276",
"4 2 1 4",
"7 1 3 2",
"4 3 3 1",
"4 2 2 1",
"6 2 1 1",
"4 4 1 1",
"7834164883628 43 2189823423122 4045849112944",
"8936240519454 43 2189823423122 4045849112944",
"8936240519454 43 2390027137311 40458491... |
p02298 Is-Convex | For a given polygon g, print "1" if g is a convex polygon, "0" otherwise. Here, in a convex polygon, all interior angles are less than or equal to 180 degrees.
g is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 ≤ i ≤ n-1) are sides of the polygon. The line segment con... | {
"input": [],
"output": []
} | {
"input": [
"5\n0 0\n2 0\n1 1\n2 2\n0 2",
"4\n0 0\n3 1\n2 3\n0 3"
],
"output": [
"0",
"1"
]
} | {
"input": [
"5\n0 0\n2 1\n1 1\n2 2\n0 2",
"4\n0 0\n3 0\n2 1\n0 3",
"4\n0 0\n3 1\n2 1\n0 3",
"5\n0 0\n3 1\n1 1\n2 2\n0 2",
"5\n0 0\n3 1\n1 1\n3 2\n0 2",
"4\n0 0\n3 0\n2 0\n0 3",
"5\n0 0\n3 1\n1 1\n3 2\n1 2",
"4\n0 0\n3 1\n2 0\n0 3",
"5\n0 0\n3 1\n1 1\n5 2\n1 2",
"4\n0 0\n3 1\n2... |
p02445 Swap | Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation:
* swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$.
Constraints
* $1 \leq n \leq 1,000$
* $-1,000,000,0... | {
"input": [],
"output": []
} | {
"input": [
"11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7"
],
"output": [
"1 8 9 10 5 6 7 2 3 4 11"
]
} | {
"input": [
"11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7",
"11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1",
"11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1",
"11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1",
"11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1",
"11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1",
"11\n1 0 3 3 5 6 2 8 14 10 1... |
bogosort | Recently Johnny have learned bogosort sorting algorithm. He thought that it is too ineffective. So he decided to improve it. As you may know this algorithm shuffles the sequence randomly until it is sorted. Johnny decided that we don't need to shuffle the whole sequence every time. If after the last shuffle several fir... | {
"input": [],
"output": []
} | {
"input": [
"3\n2\n6\n10"
],
"output": [
"2\n1826/189\n877318/35343\n"
]
} | {
"input": [
"3\n2\n4\n10",
"3\n2\n6\n12",
"3\n4\n6\n12",
"3\n4\n6\n19",
"3\n2\n4\n19",
"3\n2\n3\n12",
"3\n4\n11\n12",
"3\n4\n5\n19",
"3\n2\n2\n19",
"3\n2\n3\n21",
"3\n4\n7\n19",
"3\n2\n2\n23",
"3\n2\n3\n7",
"3\n4\n7\n11",
"3\n4\n2\n23",
"3\n4\n7\n3",
... |
colarr | Chef had a hard time arguing with his friend, and after getting a great old kick Chef saw a colored array with N cells, numbered from 1 to N.
The kick was so strong that Chef suddenly understood the rules of the game.
Each cell is painted with a color. Here the colors are numbered from 1 to M.
For any cell i, Chef c... | {
"input": [],
"output": []
} | {
"input": [
"1\n4 2 1\n1 1 2 2\n1 1\n1 1\n1 1\n3 1\n0 1\n0 1\n1 0\n1 0"
],
"output": [
"5"
]
} | {
"input": [],
"output": []
} |
gameaam | Two players are playing a game. The game is played on a sequence of positive integer pairs. The players make their moves alternatively. During his move the player chooses a pair and decreases the larger integer in the pair by a positive multiple of the smaller integer in the pair in such a way that both integers in the... | {
"input": [],
"output": []
} | {
"input": [
"3\n1\n2 3\n2\n4 5\n5 6\n2\n2 3\n3 5"
],
"output": [
"NO\nNO\nYES"
]
} | {
"input": [
"3\n1\n2 3\n2\n4 5\n5 6\n2\n2 3\n1 5",
"3\n1\n2 3\n2\n4 5\n5 6\n1\n2 3\n3 5",
"3\n1\n1 3\n2\n6 5\n5 6\n1\n2 6\n5 5",
"3\n1\n2 3\n2\n4 5\n5 3\n1\n2 3\n3 5",
"3\n1\n2 3\n2\n6 2\n5 6\n1\n2 6\n3 5",
"3\n1\n2 1\n2\n6 5\n5 6\n1\n2 3\n1 5",
"3\n1\n2 4\n2\n10 5\n5 6\n1\n2 6\n5 0",
... |
lucky5 | Chef loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Chef has a positive integer N. He can apply any of the following operations as many times as he want... | {
"input": [],
"output": []
} | {
"input": [
"3\n25\n46\n99"
],
"output": [
"2\n1\n2\n"
]
} | {
"input": [
"3\n2\n46\n99",
"3\n0\n7\n61",
"3\n25\n46\n24",
"3\n2\n60\n99",
"3\n0\n8\n24",
"3\n25\n46\n35",
"3\n0\n5\n153",
"3\n0\n12\n5",
"3\n61\n4\n32",
"3\n4\n1\n132",
"3\n0\n13\n131",
"3\n3\n4\n70",
"3\n15\n15\n34",
"3\n15\n15\n19",
"3\n32\n5\n7",
"... |
proposal | In PrimeLand, there existed a very handsome young prince named Prima. He greatly desired the Princess of Mathematics – Facie. However, before accepting his hand in marriage, Facie asked Prima to solve the following problem:
The figure below shows a simple multiplication problem. However, not all the decimal digits ar... | {
"input": [],
"output": []
} | {
"input": [
"5\n2 3 4 6 8"
],
"output": [
"1"
]
} | {
"input": [
"5\n2 3 0 6 8",
"5\n2 3 4 6 5",
"5\n2 3 4 6 7",
"5\n2 3 0 6 7",
"5\n2 -1 8 6 4",
"5\n6 0 8 5 2",
"5\n6 0 4 5 2",
"5\n3 1 9 6 15",
"5\n3 1 9 4 15",
"5\n3 5 9 1 2",
"5\n3 5 4 1 2",
"5\n3 9 4 1 2",
"5\n5 18 4 1 2",
"5\n5 8 4 1 2",
"5\n5 8 4 0 2",
... |
tech07 | You are given a square with 'n' points on each side of the square. None of these points co-incide with the corners of this square. You have to compute the total number of triangles that can be formed using these '4n' points (n points on each side of the square) as vertices of the triangle.
Input
First line contains ... | {
"input": [],
"output": []
} | {
"input": [
"1\n1"
],
"output": [
"4"
]
} | {
"input": [
"1\n2",
"1\n0",
"1\n-1",
"1\n-2",
"1\n-4",
"1\n-5",
"1\n-8",
"1\n-11",
"1\n3",
"1\n4",
"1\n6",
"1\n10",
"1\n-3",
"1\n-7",
"1\n11",
"1\n17",
"1\n30",
"1\n7",
"1\n9",
"1\n16",
"1\n31",
"1\n58",
"1\n60",
"1\n56",... |
1100_D. Dasha and Chess | This is an interactive task.
Dasha and NN like playing chess. While playing a match they decided that normal chess isn't interesting enough for them, so they invented a game described below.
There are 666 black rooks and 1 white king on the chess board of size 999 × 999. The white king wins if he gets checked by rook... | {
"input": [],
"output": []
} | {
"input": [
"999 999\n1 1\n1 2\n2 1\n2 2\n1 3\n2 3\n<...>\n26 13\n26 14\n26 15\n26 16\n\n1 700 800\n\n2 1 2\n\n<...>\n\n-1 -1 -1\n"
],
"output": [
"998 998\n"
]
} | {
"input": [
"999 999\n1 1\n1 2\n2 1\n2 2\n1 3\n2 0\n<...>\n26 13\n26 14\n26 15\n26 16\n\n1 700 800\n\n2 1 2\n\n<...>\n\n-1 -1 -1\n",
"999 999\n1 1\n1 2\n2 1\n2 2\n1 3\n2 0\n<...>\n26 13\n26 14\n26 15\n26 16\n\n1 700 126\n\n2 1 2\n\n<...>\n\n-1 -1 -1\n",
"999 999\n1 1\n1 2\n2 1\n2 ... |
1170_B. Bad Days | Every day Kotlin heroes analyze the statistics of their website. For n days, they wrote out n numbers a_1, a_2, ..., a_n, where a_i is the number of visits on the i-th day.
They believe that a day is bad if there are at least 2 days before it with a strictly greater number of visits. For example, if n=8 and a=[3, 1, 4... | {
"input": [],
"output": []
} | {
"input": [
"8\n3 1 4 1 5 9 2 6\n",
"5\n1 1 1 1 1\n",
"13\n2 7 1 8 2 8 1 8 2 8 4 5 9\n"
],
"output": [
"\n2\n",
"\n0\n",
"\n6\n"
]
} | {
"input": [],
"output": []
} |
1291_B. Array Sharpening | You're given an array a_1, …, a_n of n non-negative integers.
Let's call it sharpened if and only if there exists an integer 1 ≤ k ≤ n such that a_1 < a_2 < … < a_k and a_k > a_{k+1} > … > a_n. In particular, any strictly increasing or strictly decreasing array is sharpened. For example:
* The arrays [4], [0, 1], [... | {
"input": [],
"output": []
} | {
"input": [
"10\n1\n248618\n3\n12 10 8\n6\n100 11 15 9 7 8\n4\n0 1 1 0\n2\n0 0\n2\n0 1\n2\n1 0\n2\n1 1\n3\n0 1 0\n3\n1 0 1\n"
],
"output": [
"Yes\nYes\nYes\nNo\nNo\nYes\nYes\nYes\nYes\nNo\n"
]
} | {
"input": [
"10\n1\n248618\n3\n12 10 8\n6\n100 11 15 9 2 8\n4\n0 1 1 0\n2\n0 0\n2\n0 1\n2\n1 0\n2\n1 1\n3\n0 1 0\n3\n1 0 1\n",
"10\n1\n451008\n3\n12 10 8\n6\n000 11 15 9 2 8\n4\n0 1 1 0\n2\n0 0\n2\n0 1\n2\n0 0\n2\n1 1\n3\n0 1 0\n3\n1 0 1\n",
"10\n1\n248618\n3\n12 10 8\n6\n000 11 15 9 7 8\n4\n0 1 1 0\n2\n... |
1466_C. Canine poetry | After his wife's tragic death, Eurydice, Orpheus descended to the realm of death to see her. Reaching its gates was uneasy, but passing through them proved to be even more challenging. Mostly because of Cerberus, the three-headed hound of Hades.
Orpheus, a famous poet, and musician plans to calm Cerberus with his poe... | {
"input": [],
"output": []
} | {
"input": [
"7\nbabba\nabaac\ncodeforces\nzeroorez\nabcdcba\nbbbbbbb\na\n"
],
"output": [
"\n1\n1\n0\n1\n1\n4\n0\n"
]
} | {
"input": [
"7\nabbab\nabaac\ncodeforces\nzeroorez\nabcdcba\nbbbbbbb\na\n",
"7\nabbab\nabaac\ncodeforces\nzeroorez\nabadcbc\nbbbbbbb\na\n",
"7\nabbab\nabaac\ncodeforces\nzeroorez\nabadcbc\nbbbbabb\na\n",
"7\nbbbaa\nabaac\ncodeforces\nyeroorez\nabadcbc\nbbabbbb\na\n",
"7\nabcab\nabaac\ncodeforcer\... |
1490_D. Permutation Transformation | A permutation — is a sequence of length n integers from 1 to n, in which all the numbers occur exactly once. For example, [1], [3, 5, 2, 1, 4], [1, 3, 2] — permutations, and [2, 3, 2], [4, 3, 1], [0] — no.
Polycarp was recently gifted a permutation a[1 ... n] of length n. Polycarp likes trees more than permutations, s... | {
"input": [],
"output": []
} | {
"input": [
"3\n5\n3 5 2 1 4\n1\n1\n4\n4 3 1 2\n"
],
"output": [
"\n1 0 2 3 1 \n0 \n0 1 3 2 \n"
]
} | {
"input": [
"3\n5\n3 5 1 2 4\n1\n1\n4\n4 3 1 2\n",
"3\n5\n4 5 2 1 3\n1\n1\n4\n4 3 1 2\n",
"3\n5\n3 4 2 1 5\n1\n1\n4\n4 3 1 2\n",
"3\n5\n2 5 3 1 4\n1\n1\n4\n4 3 1 2\n",
"3\n5\n4 5 1 2 3\n1\n1\n4\n4 3 1 2\n"
],
"output": [
"1 0 3 2 1\n0\n0 1 3 2\n",
"1 0 2 3 1\n0\n0 1 3 2\n",
"2 1 2... |
1512_G. Short Task | Let us denote by d(n) the sum of all divisors of the number n, i.e. d(n) = ∑_{k | n} k.
For example, d(1) = 1, d(4) = 1+2+4=7, d(6) = 1+2+3+6=12.
For a given number c, find the minimum n such that d(n) = c.
Input
The first line contains one integer t (1 ≤ t ≤ 10^4). Then t test cases follow.
Each test case is char... | {
"input": [],
"output": []
} | {
"input": [
"12\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n39\n691\n"
],
"output": [
"\n1\n-1\n2\n3\n-1\n5\n4\n7\n-1\n-1\n18\n-1\n"
]
} | {
"input": [
"12\n1\n2\n3\n6\n5\n6\n7\n8\n9\n10\n39\n691\n",
"12\n1\n2\n3\n6\n5\n6\n7\n8\n9\n6\n39\n691\n",
"12\n1\n2\n3\n6\n5\n6\n6\n8\n9\n6\n39\n691\n",
"12\n1\n2\n3\n4\n5\n6\n6\n8\n9\n6\n39\n691\n",
"12\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n33\n691\n",
"12\n1\n2\n3\n12\n5\n6\n7\n8\n9\n6\n39\n691\... |
153_E. Euclidean Distance | You are given a multiset of points on the plane with integer coordinates. Find the maximum distance between two points from this multiset.
Input
The first line of input contains the number of points n (2 ≤ n ≤ 50). Next, n pairs of lines follow, each describing a single point: the first line contains x-coordinate, th... | {
"input": [],
"output": []
} | {
"input": [
"3\n0\n1\n2\n3\n4\n5\n",
"3\n10\n12\n-5\n8\n10\n12\n"
],
"output": [
"5.656854249\n",
"15.5241747\n"
]
} | {
"input": [],
"output": []
} |
188_D. Asterisks | You are given a number n. Print n lines, i-th line should consist of i characters "*". Lines' indices are 1-based.
Input
The only line of input contains an integer n (1 ≤ n ≤ 50).
Output
Output the described pattern.
Examples
Input
3
Output
*
**
***
Input
6
Output
*
**
***
****
*****
****** | {
"input": [],
"output": []
} | {
"input": [
"3\n",
"6\n"
],
"output": [
"*\n**\n***\n",
"*\n**\n***\n****\n*****\n******\n"
]
} | {
"input": [],
"output": []
} |
470_C. Eval | You are given a simple arithmetic expression of the form a?b, where a and b are integer constants, and ? can be one of the following operations: '+' (addition), '-' (subtraction), '*' (multiplication), '/' (integer division) or '%' (modulo operation).
Output the result of evaluation of this expression.
Input
The inp... | {
"input": [],
"output": []
} | {
"input": [
"123+456\n",
"192/5\n",
"945%19\n"
],
"output": [
"579\n",
"38\n",
"14\n"
]
} | {
"input": [],
"output": []
} |
633_H. Fibonacci-ish II | Yash is finally tired of computing the length of the longest Fibonacci-ish sequence. He now plays around with more complex things such as Fibonacci-ish potentials.
Fibonacci-ish potential of an array ai is computed as follows:
1. Remove all elements j if there exists i < j such that ai = aj.
2. Sort the remain... | {
"input": [],
"output": []
} | {
"input": [
"5 10\n2 1 2 1 2\n2\n2 4\n4 5\n"
],
"output": [
"3\n3\n"
]
} | {
"input": [
"5 10\n2 1 2 2 2\n2\n2 4\n4 5\n",
"5 10\n2 1 2 2 1\n2\n2 4\n4 5\n",
"5 10\n3 1 4 2 1\n2\n2 4\n4 5\n",
"5 10\n3 2 4 2 1\n2\n2 4\n4 5\n",
"5 10\n3 2 4 2 1\n2\n2 1\n4 5\n",
"5 10\n2 1 4 1 2\n2\n2 4\n4 5\n",
"5 10\n3 1 2 2 1\n2\n1 4\n4 5\n",
"5 10\n3 1 4 2 1\n2\n4 4\n4 5\n",
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.