name stringlengths 2 112 | description stringlengths 29 13k | private_tests dict | public_tests dict | generated_tests dict |
|---|---|---|---|---|
p01120 Tally Counters | <!--
Problem D
-->
Tally Counters
A number of tally counters are placed in a row. Pushing the button on a counter will increment the displayed value by one, or, when the value is already the maximum, it goes down to one. All the counters are of the same model with the same maximum value.
<image> Fig. D-1 Tally Cou... | {
"input": [],
"output": []
} | {
"input": [
"4 5\n2 3 1 4\n2 5 5 2\n3 100\n1 10 100\n1 10 100\n5 10000\n4971 7482 1238 8523 1823\n3287 9013 9812 297 1809\n0 0"
],
"output": [
"4\n0\n14731"
]
} | {
"input": [
"4 5\n2 3 1 4\n2 5 5 2\n3 100\n1 10 100\n1 10 100\n5 10000\n4971 7482 1238 8523 1823\n3287 9013 9928 297 1809\n0 0",
"4 5\n2 3 1 4\n2 5 5 2\n3 100\n1 10 100\n1 14 100\n5 10000\n4971 7482 1238 8523 1823\n3287 9013 9928 297 1809\n0 0",
"4 5\n2 3 1 4\n2 5 5 2\n3 100\n1 10 100\n1 10 100\n5 10000\... |
p01258 Memory Match | Memory match is a single-player game which employs a set of 2M cards. Each card is labeled with a number between 1 and M on its face. For each number i (1 ≤ i ≤ M), there are exactly two cards which have the number i. At the start of the game, all cards are shuffled and laid face down on a table. In each turn you choos... | {
"input": [],
"output": []
} | {
"input": [
"2\n4\n6\n8\n10\n52\n0"
],
"output": [
"0.0000000000\n0.6666666667\n1.3333333333\n1.9238095238\n2.5523809524\n15.4435236099"
]
} | {
"input": [
"2\n4\n6\n8\n10\n38\n0",
"2\n4\n6\n8\n4\n38\n0",
"2\n4\n0\n8\n4\n38\n0",
"2\n4\n12\n8\n4\n38\n0",
"2\n4\n12\n8\n2\n38\n0",
"2\n4\n12\n10\n2\n38\n0",
"2\n6\n0\n1\n1\n44\n-2",
"2\n4\n6\n16\n10\n38\n0",
"2\n4\n12\n8\n4\n72\n0",
"2\n4\n6\n8\n2\n38\n0",
"2\n0\n0\n8\... |
p01419 On or Off | Saving electricity is very important!
You are in the office represented as R \times C grid that consists of walls and rooms. It is guaranteed that, for any pair of rooms in the office, there exists exactly one route between the two rooms. It takes 1 unit of time for you to move to the next room (that is, the grid adja... | {
"input": [],
"output": []
} | {
"input": [
"3 3 5\n...\n.##\n..#\n1 1 1\n1 0 0\n1 1 0\n3 3 3\n3 0 0\n3 3 0\n5 4 5\n4 0 0\n5 4 0\n1 0\n2 1\n0 2\n2 0\n0 0",
"1 3 2\n...\n1 1 1\n1 2 1\n1 1 1\n0 0\n0 2",
"5 5 10\n.###\n....\n.#\n..#.#\n....\n0 12 0 0 0\n0 4 3 2 10\n0 0 0 99 0\n11 13 0 2 0\n0 1 1 2 1\n0 4 0 0 0\n0 13 8 2 4\n0 0 0 16 0\n1 1... | {
"input": [
"3 3 5\n...\n.##\n..#\n1 1 1\n1 0 0\n1 1 0\n3 3 3\n3 0 0\n5 3 0\n5 4 5\n4 0 0\n5 4 0\n1 0\n2 1\n0 2\n2 0\n0 0",
"1 3 2\n...\n1 1 1\n1 2 1\n1 1 1\n0 1\n0 2",
"5 5 10\n.###\n....\n.#\n..#.#\n....\n0 12 0 0 0\n0 4 3 2 10\n0 0 0 99 0\n11 13 0 2 0\n0 1 1 2 1\n0 4 0 0 0\n0 13 8 2 4\n0 0 0 16 0\n1 1... |
p01573 Complex Integer Solutions | Let f(x) = a0 + a1x + a2x2 + ... + adxd be the function where each ai (0 ≤ i ≤ d) is a constant integer (and ad is non-zero) and x is a variable. Your task is to write a program that finds all complex integer solutions of the equation f(x) = 0 for a given f(x). Here, by complex integers, we mean complex numbers whose r... | {
"input": [],
"output": []
} | {
"input": [
"4\n-2 0 0 0 2",
"8\n0 0 25 15 17 -10 1 -1 1"
],
"output": [
"4\n-1 -i i 1",
"5\n-1-2i -1+2i 0 2-i 2+i"
]
} | {
"input": [],
"output": []
} |
p01735 Optimal alpha beta pruning | Fox Ciel is developing an artificial intelligence (AI) for a game. This game is described as a game tree T with n vertices. Each node in the game has an evaluation value which shows how good a situation is. This value is the same as maximum value of child nodes’ values multiplied by -1. Values on leaf nodes are evaluat... | {
"input": [],
"output": []
} | {
"input": [
"3\n0 1 1\n2 2 3\n0\n0"
],
"output": [
"2 2"
]
} | {
"input": [
"3\n0 2 1\n2 2 3\n0\n0",
"3\n0 2 2\n2 2 3\n0\n0",
"3\n-1 2 2\n2 2 3\n0\n0",
"3\n-1 2 0\n2 2 3\n0\n0",
"3\n0 1 2\n2 2 3\n0\n0",
"3\n-1 1 2\n2 2 3\n0\n0",
"3\n-1 2 0\n2 2 3\n0\n1",
"3\n-1 2 1\n2 2 3\n0\n1",
"3\n-1 1 1\n2 2 3\n0\n1",
"3\n-1 0 1\n2 2 3\n0\n1",
"3\n... |
p01875 Complex Oracle | D: Complex Oracle --Complex Oracle-
problem
* This problem is a reactive problem. In other words, it is necessary to create a program that derives the correct answer by interactively responding to the program prepared on the server side. Also, since the program on the server side also shares computer resources, the s... | {
"input": [],
"output": []
} | {
"input": [
""
],
"output": [
""
]
} | {
"input": [],
"output": []
} |
p02011 Enlarge Circles | You are given $N$ distinct points on the 2-D plane. For each point, you are going to make a single circle whose center is located at the point. Your task is to maximize the sum of perimeters of these $N$ circles so that circles do not overlap each other. Here, "overlap" means that two circles have a common point which ... | {
"input": [],
"output": []
} | {
"input": [
"9\n91 -18\n13 93\n73 -34\n15 2\n-46 0\n69 -42\n-23 -13\n-87 41\n38 68",
"3\n0 0\n5 0\n0 5",
"3\n0 0\n3 0\n5 0"
],
"output": [
"1049.191683488",
"53.630341225",
"31.415926535"
]
} | {
"input": [],
"output": []
} |
p02154 Equilateral Triangle | Problem
Given a convex polygon consisting of $ N $ vertices.
When considering an equilateral triangle that includes all the vertices of the convex polygon, find the minimum value of the length of one side of the equilateral triangle.
Constraints
The input satisfies the following conditions.
* $ 3 \ le N \ le 10000... | {
"input": [],
"output": []
} | {
"input": [
"4\n2 3\n1 2\n2 1\n3 2",
"7\n-96469 25422\n-55204 -45592\n-29140 -72981\n98837 -86795\n92303 63297\n19059 96012\n-67980 70342"
],
"output": [
"3.04720672",
"310622.35426197"
]
} | {
"input": [
"4\n2 3\n1 2\n2 0\n3 2",
"7\n-96469 25422\n-55204 -45592\n-29140 -72981\n98837 -86795\n92303 69138\n19059 96012\n-67980 70342",
"4\n2 3\n1 2\n2 0\n3 1",
"7\n-96469 25422\n-55204 -45592\n-29140 -72981\n98837 -16961\n92303 69138\n19059 96012\n-67980 70342",
"4\n2 3\n1 0\n2 0\n3 1",
... |
p02295 Cross Point | For given two segments s1 and s2, print the coordinate of the cross point of them.
s1 is formed by end points p0 and p1, and s2 is formed by end points p2 and p3.
Constraints
* 1 ≤ q ≤ 1000
* -10000 ≤ xpi, ypi ≤ 10000
* p0 ≠ p1 and p2 ≠ p3.
* The given segments have a cross point and are not in parallel.
Input
The... | {
"input": [],
"output": []
} | {
"input": [
"3\n0 0 2 0 1 1 1 -1\n0 0 1 1 0 1 1 0\n0 0 1 1 1 0 0 1"
],
"output": [
"1.0000000000 0.0000000000\n0.5000000000 0.5000000000\n0.5000000000 0.5000000000"
]
} | {
"input": [
"3\n0 0 2 0 2 1 1 -1\n0 0 1 1 0 1 1 0\n0 0 1 1 1 0 0 1",
"3\n0 0 2 0 2 2 1 -1\n0 0 1 1 0 1 1 0\n0 0 1 1 1 0 0 1",
"3\n0 0 2 0 2 2 0 -1\n0 0 1 1 0 1 1 0\n0 0 1 1 1 0 0 1",
"3\n0 0 2 0 2 1 0 -1\n0 0 1 1 0 1 1 0\n0 0 1 1 1 0 0 1",
"3\n0 0 2 0 2 1 0 -1\n0 0 1 1 0 1 1 0\n0 0 1 0 1 0 0 1",
... |
p02442 Lexicographical Comparison | Compare given two sequence $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and $B = \\{b_0, b_1, ..., b_{m-1}$ lexicographically.
Constraints
* $1 \leq n, m \leq 1,000$
* $0 \leq a_i, b_i \leq 1,000$
Input
The input is given in the following format.
$n$
$a_0 \; a_1, ..., \; a_{n-1}$
$m$
$b_0 \; b_1, ..., \; b_{m-1}$
The num... | {
"input": [],
"output": []
} | {
"input": [
"3\n1 1 2\n4\n1 1 2 2",
"3\n1 2 3\n2\n2 4",
"4\n5 4 7 0\n5\n1 2 3 4 5"
],
"output": [
"1",
"1",
"0"
]
} | {
"input": [
"3\n1 1 2\n4\n1 2 2 2",
"4\n1 4 3 1\n4\n0 4 5 4 2",
"3\n1 4 3\n2\n2 4",
"4\n0 4 7 0\n5\n1 2 3 4 5",
"3\n1 1 2\n4\n1 3 2 2",
"3\n1 4 3\n2\n2 2",
"4\n0 4 7 0\n5\n1 2 3 4 1",
"3\n1 1 2\n4\n1 3 3 2",
"3\n1 4 3\n3\n2 2",
"4\n0 4 7 0\n5\n1 2 5 4 1",
"3\n1 1 2\n4\n1 3... |
cake1am | Your friend Сhef has prepared a rectangular cake for you. Both of you want to divide the cake among yourselves. Your friend is generous enough to let you choose your share first. You have decided to take two pieces.For the first piece you make a rectangular cut (each side of this cut is parallel to the corresponding si... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 1 10 10\n11 11 20 20\n1 1 20 20\n11 11 30 30"
],
"output": [
"162\n641\n"
]
} | {
"input": [
"2\n1 1 10 10\n11 7 20 20\n1 1 20 20\n11 11 30 30",
"2\n1 1 10 10\n11 7 20 20\n1 1 20 20\n11 11 30 55",
"2\n1 1 10 4\n11 11 20 20\n1 1 20 20\n11 11 30 30",
"2\n1 1 10 10\n11 8 20 20\n1 1 20 20\n11 11 30 30",
"2\n1 1 10 20\n11 7 20 20\n1 1 20 20\n11 11 30 55",
"2\n1 1 10 4\n11 11 2... |
cops | There are 100 houses located on a straight line. The first house is numbered 1 and the last one is numbered 100. Some M houses out of these 100 are occupied by cops.
Thief Devu has just stolen PeePee's bag and is looking for a house to hide in.
PeePee uses fast 4G Internet and sends the message to all the cops that a t... | {
"input": [],
"output": []
} | {
"input": [
"3\n4 7 8\n12 52 56 8\n2 10 2\n21 75\n2 5 8\n10 51"
],
"output": [
"0\n18\n9\n"
]
} | {
"input": [
"3\n4 7 8\n12 52 56 8\n2 11 2\n21 75\n2 5 8\n10 51",
"3\n4 7 8\n19 52 56 8\n2 20 2\n21 75\n2 5 8\n10 51",
"3\n4 7 8\n12 52 56 8\n2 10 2\n21 75\n2 5 8\n10 49",
"3\n4 7 8\n19 52 56 8\n2 20 2\n21 75\n2 7 8\n10 51",
"3\n4 7 8\n7 52 56 8\n2 11 2\n21 75\n2 9 8\n10 51",
"3\n4 7 3\n3 52 5... |
goc203 | Prof. R.K.Vats of NIT Hamirpur has given a problem to the whole class and has imposed a condition that he won't give attendance to those who don't solve it within time. He gave the equation ,
ax+by=c
where a, b, c are three positive integers. The problem is to determine if there exists at least one solution for some in... | {
"input": [],
"output": []
} | {
"input": [
"2\n2 4 8\n3 6 7"
],
"output": [
"Case 1: Yes\nCase 2: No"
]
} | {
"input": [],
"output": []
} |
masnum | Mason is yet again in danger.
Consider an N digit number A.
let the new number formed by reversing the digits of A be called B .
Mason has to tell that how many N digit numbers A exist such that A + B = 10^N - 1 ?
Note: A should not have any leading zeroes !
Quick. Help. over and out.
Input
First line will cont... | {
"input": [],
"output": []
} | {
"input": [
"2\n5\n2"
],
"output": [
"0\n9\n"
]
} | {
"input": [
"2\n0\n2",
"2\n-1\n2",
"2\n-2\n1",
"2\n-1\n1",
"2\n-1\n4",
"2\n-2\n4",
"2\n-1\n6",
"2\n4\n-1",
"2\n6\n-1",
"2\n8\n-2",
"2\n8\n-1",
"2\n18\n-4",
"2\n-18\n32",
"2\n-1\n60",
"2\n-1\n114",
"2\n0\n114",
"2\n0\n174",
"2\n1\n18",
"2\n2\... |
racelane | You are in charge of painting the lanes on a 500 meter race track for a forthcoming amateur track event. There are 9 lanes in total which means you must paint 10 lines around the track to delimit these lanes. Fortunately, you have special equipment that will help you paint these lanes very quickly.
This equipment has... | {
"input": [],
"output": []
} | {
"input": [
"3\n2\n1 3 1\n2 5 2\n2\n1 3 1\n2 5 3\n5\n60 60 4\n60 61 5\n61 61 6\n100 100 8\n100 100 9"
],
"output": [
"498\n500\n497"
]
} | {
"input": [
"3\n2\n1 1 1\n2 5 2\n2\n1 3 1\n2 5 3\n5\n60 60 4\n60 61 5\n61 61 6\n100 100 8\n100 100 9",
"3\n2\n1 3 1\n2 5 2\n2\n1 3 1\n1 5 3\n5\n60 60 4\n60 61 5\n61 61 6\n100 100 8\n100 100 9",
"3\n2\n1 1 1\n2 5 2\n2\n1 3 1\n2 5 3\n5\n60 60 7\n60 61 5\n61 61 6\n100 100 8\n100 100 9",
"3\n2\n0 3 1\n2 ... |
torr | Problem description.
One day Toretto wanted to make some extra money. We all know his obsession with cars so all he could manage to get hold of, was some information regarding the buying and selling prices of cars for the next N days.
The buying and selling prices for one car on day i are same and equal to Pi where (... | {
"input": [],
"output": []
} | {
"input": [
"3\n2 5\n4 8\n4 100\n10 7 6 4\n4 100\n10 6 7 4"
],
"output": [
"9\n100\n116"
]
} | {
"input": [],
"output": []
} |
1250_L. Divide The Students | A group of students has recently been admitted to the Faculty of Computer Sciences at the Berland State University. Now the programming teacher wants to divide them into three subgroups for practice sessions.
The teacher knows that a lot of programmers argue which language is the best. The teacher doesn't want to hear... | {
"input": [],
"output": []
} | {
"input": [
"5\n3 5 7\n4 8 4\n13 10 13\n1000 1000 1000\n13 22 7\n",
"5\n1 3 4\n1000 1000 1\n4 1 2\n325 226 999\n939 861 505\n"
],
"output": [
"\n5\n6\n13\n1000\n14\n",
"\n3\n667\n3\n517\n769\n"
]
} | {
"input": [],
"output": []
} |
1335_F. Robots on a Grid | There is a rectangular grid of size n × m. Each cell of the grid is colored black ('0') or white ('1'). The color of the cell (i, j) is c_{i, j}. You are also given a map of directions: for each cell, there is a direction s_{i, j} which is one of the four characters 'U', 'R', 'D' and 'L'.
* If s_{i, j} is 'U' then t... | {
"input": [],
"output": []
} | {
"input": [
"3\n1 2\n01\nRL\n3 3\n001\n101\n110\nRLL\nDLD\nULL\n3 3\n000\n000\n000\nRRD\nRLD\nULL\n"
],
"output": [
"2 1\n4 3\n2 2\n"
]
} | {
"input": [
"3\n1 2\n01\nRL\n3 3\n000\n101\n110\nRLL\nDLD\nULL\n3 3\n000\n000\n000\nRRD\nRLD\nULL\n",
"3\n1 2\n01\nRL\n3 3\n011\n101\n110\nRLL\nDLD\nULL\n3 3\n010\n000\n000\nRRD\nRLD\nULL\n",
"3\n1 2\n01\nRL\n3 3\n001\n001\n110\nRLL\nDLD\nULL\n3 3\n000\n110\n000\nRRD\nRLD\nULL\n",
"3\n1 2\n01\nRL\n3 ... |
1399_D. Binary String To Subsequences | You are given a binary string s consisting of n zeros and ones.
Your task is to divide the given string into the minimum number of subsequences in such a way that each character of the string belongs to exactly one subsequence and each subsequence looks like "010101 ..." or "101010 ..." (i.e. the subsequence should no... | {
"input": [],
"output": []
} | {
"input": [
"4\n4\n0011\n6\n111111\n5\n10101\n8\n01010000\n"
],
"output": [
"2\n1 2 2 1 \n6\n1 2 3 4 5 6 \n1\n1 1 1 1 1 \n4\n1 1 1 1 1 2 3 4 \n"
]
} | {
"input": [
"4\n4\n0011\n6\n111111\n5\n10101\n8\n01000000\n",
"4\n4\n1011\n6\n111111\n5\n10101\n8\n01000000\n",
"4\n4\n1011\n6\n111111\n5\n10101\n8\n01010000\n",
"4\n4\n0001\n6\n111111\n5\n10101\n8\n01000000\n",
"4\n4\n0000\n6\n111111\n5\n10101\n8\n01000000\n",
"4\n4\n0010\n6\n111111\n5\n1010... |
311_B. Cats Transport | Zxr960115 is owner of a large farm. He feeds m cute cats and employs p feeders. There's a straight road across the farm and n hills along the road, numbered from 1 to n from left to right. The distance between hill i and (i - 1) is di meters. The feeders live in hill 1.
One day, the cats went out to play. Cat i went o... | {
"input": [],
"output": []
} | {
"input": [
"4 6 2\n1 3 5\n1 0\n2 1\n4 9\n1 10\n2 10\n3 12\n"
],
"output": [
"3\n"
]
} | {
"input": [
"4 6 2\n1 3 5\n1 0\n2 1\n4 9\n1 1\n2 10\n3 12\n",
"4 6 2\n1 3 5\n1 0\n4 1\n4 9\n1 1\n2 10\n3 12\n",
"4 6 2\n1 3 5\n1 0\n4 1\n4 9\n1 1\n2 6\n3 12\n",
"4 6 2\n1 3 10\n1 0\n4 1\n4 9\n1 1\n2 6\n3 12\n",
"4 6 2\n0 3 10\n1 0\n4 1\n4 9\n1 1\n2 6\n3 12\n",
"4 6 2\n1 3 5\n1 0\n4 1\n4 9\n1 ... |
double-factorial-1 | Kuldeep is tired from all the fun he's having with Christie, so now all he needs is a good night's sleep to get some rest.
Being a math nerd, he even dreams about maths.
But in this dreamland some mathematical entities have slightly different definition. For example factorial of a number n in dreamland is defined a... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 4\n1 2\n\nSAMPLE"
],
"output": [
"1\n1\n"
]
} | {
"input": [
"2\n1 1\n1 2\n\nSAMPLE",
"2\n1 1\n2 2\n\nSAMPLE",
"2\n1 0\n2 2\n\nSAEPLM",
"2\n1 1\n1 0\n\nSAMPLE",
"2\n2 1\n2 2\n\nSAEPLM",
"2\n2 4\n1 2\n\nELPMAS",
"2\n2 1\n4 2\n\nSAEPLM",
"2\n1 0\n3 3\n\nSAMPLE",
"2\n3 7\n1 2\n\nELPMAS",
"2\n1 0\n1 3\n\nSAMPME",
"2\n0 0\n0 ... |
greater-bigger | Given a word w, rearrange the letters of w to construct another word s in such a way that s is lexicographic-ally greater than w. In case of multiple possible answers, find the lexicographic-ally smallest one.
Input Format
The first line of input contains t, the number of test cases. Each of the next t lines contains... | {
"input": [],
"output": []
} | {
"input": [
"5\nab\nbb\nhefg\ndhck\ndkhc\n\nSAMPLE"
],
"output": [
"ba\nno answer\nhegf\ndhkc\nhcdk\n"
]
} | {
"input": [
"5\nab\nbb\nhefg\ndhck\ndkhc\n\nSAPMLE",
"5\nba\nbb\nhefg\ndhck\ndkhc\n\nSAPMLE",
"5\nab\nbb\nehfg\ndhck\ndkhc\n\nSAPMLE",
"5\nab\nbb\nehfg\ndhcl\ndkhc\n\nSAPMLE",
"5\nab\nbb\nehfg\ndhcl\nkdhc\n\nSAPMLE",
"5\naa\nbb\nehfg\ndhcl\nkdhc\n\nSAPMLE",
"5\naa\nbb\ngfhe\ndhcl\nkdhc\n\... |
my-girlfriend-and-her-love-for-cats-1 | Ashima has brought home n cats. Now, being a cat lover, she is taking care of the cats and has asked me to bring cat food for them. Being a guy with no idea what to buy, I brought some n packets of cat food (I atleast knew that each and every cat being a good junkie will completely eat a whole packet of cat food and wo... | {
"input": [],
"output": []
} | {
"input": [
"2\n3 1\n4 3\n\nSAMPLE"
],
"output": [
"15\n"
]
} | {
"input": [
"2\n3 1\n4 3\n\nSLMPAE",
"2\n3 1\n6 3\n\nEAPMLS",
"2\n3 1\n6 1\n\nSLMPAE",
"2\n3 1\n9 1\n\nLSMOAE",
"2\n3 1\n9 0\n\nLSMOAE",
"2\n6 1\n9 1\n\nLSMOAE",
"2\n0 1\n9 1\n\nKSMAOE",
"2\n-1 1\n9 1\n\nEOAMSK",
"2\n-2 1\n9 1\n\nEOAMSK",
"2\n-2 1\n1 1\n\nFOBMSK",
"2\n-2 1... |
precedence-rule | In the Mathematical world of Dr. Ramanujam, every new student must have to pass a exam to take the classes of Advance mathematics from Dr. Ramanujam.
One day Ram wants to have classes of Advance mathematics, so he arrived at class of Dr. Ramanujam. He asked ram to solve a given mathematical expression then only he will... | {
"input": [],
"output": []
} | {
"input": [
"2\n2+3*5\n1*2*3\n\nSAMPLE"
],
"output": [
"17\n6\n"
]
} | {
"input": [
"2\n2+3+5\n1*2*3\n\nSAMPLE",
"2\n2+3*5\n1*2*3\n\nSALPME",
"2\n2+3+5\n1+2*3\n\nSAMPLE",
"2\n2+4+5\n1*3*2\n\nSAMPLE",
"2\n2+4+5\n1*3+2\n\nSAMQLE",
"2\n2+3+5\n1*3*3\n\nSAMPLE",
"2\n2+3*5\n1*3*3\n\nSALPME",
"2\n2+5*3\n1*2*2\n\nSAMPLE",
"2\n2+3+6\n1+2*3\n\nSAMPLE",
"2\n... |
p02623 AtCoder Beginner Contest 172 - Tsundoku | We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.
It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).
Consider the following action:
* Ch... | {
"input": [],
"output": []
} | {
"input": [
"5 4 1\n1000000000 1000000000 1000000000 1000000000 1000000000\n1000000000 1000000000 1000000000 1000000000",
"3 4 240\n60 90 120\n80 150 80 150",
"3 4 730\n60 90 120\n80 150 80 150"
],
"output": [
"0",
"3",
"7"
]
} | {
"input": [
"5 4 1\n1000000000 1000000000 1000000000 1000000000 1000000000\n1000000000 1000000000 1000000010 1000000000",
"3 4 194\n60 90 120\n80 150 80 150",
"3 4 730\n60 9 120\n80 150 80 150",
"3 4 194\n60 90 120\n80 34 80 150",
"3 4 376\n60 9 120\n80 150 80 150",
"3 4 449\n60 9 120\n80 150... |
p02754 AtCoder Beginner Contest 158 - Count Balls | Takahashi has many red balls and blue balls. Now, he will place them in a row.
Initially, there is no ball placed.
Takahashi, who is very patient, will do the following operation 10^{100} times:
* Place A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.
How ... | {
"input": [],
"output": []
} | {
"input": [
"8 0 4",
"8 3 4",
"6 2 4"
],
"output": [
"0",
"4",
"2"
]
} | {
"input": [
"8 0 1",
"8 3 7",
"8 1 1",
"8 1 7",
"8 1 5",
"6 1 0",
"5 12 0",
"10 12 0",
"9 24 -1",
"7 24 -1",
"8 1 0",
"0 -1 12",
"18 12 0",
"19 12 0",
"27 12 0",
"11 16 0",
"20 19 0",
"27 24 1",
"15 10 0",
"12 14 -1",
"12 4 -1",
... |
p02889 AtCoder Beginner Contest 143 - Travel by Car | There are N towns numbered 1 to N and M roads. The i-th road connects Town A_i and Town B_i bidirectionally and has a length of C_i.
Takahashi will travel between these towns by car, passing through these roads. The fuel tank of his car can contain at most L liters of fuel, and one liter of fuel is consumed for each u... | {
"input": [],
"output": []
} | {
"input": [
"4 0 1\n1\n2 1",
"5 4 4\n1 2 2\n2 3 2\n3 4 3\n4 5 2\n20\n2 1\n3 1\n4 1\n5 1\n1 2\n3 2\n4 2\n5 2\n1 3\n2 3\n4 3\n5 3\n1 4\n2 4\n3 4\n5 4\n1 5\n2 5\n3 5\n4 5",
"3 2 5\n1 2 3\n2 3 3\n2\n3 2\n1 3"
],
"output": [
"-1",
"0\n0\n1\n2\n0\n0\n1\n2\n0\n0\n0\n1\n1\n1\n0\n0\n2\n2\n1\n0",
"... | {
"input": [
"4 0 0\n1\n2 1",
"5 4 4\n1 2 2\n2 3 2\n3 4 3\n4 5 2\n20\n2 1\n3 1\n4 1\n5 1\n1 2\n3 2\n4 2\n5 2\n1 3\n2 4\n4 3\n5 3\n1 4\n2 4\n3 4\n5 4\n1 5\n2 5\n3 5\n4 5",
"5 4 4\n1 2 2\n2 3 2\n3 4 3\n4 5 2\n20\n2 1\n3 1\n3 1\n5 1\n1 2\n3 2\n4 2\n5 2\n1 3\n2 3\n4 3\n5 3\n1 4\n2 4\n3 4\n5 4\n1 5\n2 5\n3 5\n... |
p03024 M-SOLUTIONS Programming Contest - Sumo | Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament.
The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S cons... | {
"input": [],
"output": []
} | {
"input": [
"oxoxoxoxoxoxox",
"xxxxxxxx"
],
"output": [
"YES",
"NO"
]
} | {
"input": [
"xoxoxoxoxoxoxo",
"oxoxowoxoxoxox",
"oxoxowoooxoxxx",
"xxxoxooowoxoxo",
"xoxoxooxwoxoxo",
"xoxoyoxoxoxoxo",
"xxxoxoooooxwxo",
"xoxowooxwoxoxo",
"oxoxoxoxoyoxox",
"xoxoxoxoxoyoxo",
"xxxoxooovoxoxo",
"xoxowooxwoxowo",
"oxoxoyoxoyoxox",
"oxoyoxoxoxoxox... |
p03165 Educational DP Contest - LCS | You are given strings s and t. Find one longest string that is a subsequence of both s and t.
Constraints
* s and t are strings consisting of lowercase English letters.
* 1 \leq |s|, |t| \leq 3000
Input
Input is given from Standard Input in the following format:
s
t
Output
Print one longest string that is a su... | {
"input": [],
"output": []
} | {
"input": [
"abracadabra\navadakedavra",
"a\nz",
"axyb\nabyxb",
"aa\nxayaz"
],
"output": [
"aaadara",
"",
"axb",
"aa"
]
} | {
"input": [
"abracadabra\navaeakedavra",
"`xyb\nabyxb",
"aa\nxaybz",
"byx`\nabyxb",
"`yxb\nabyxb",
"`yxb\nzbaxb",
"bxy`\nzbaxb",
"xy_c\nzbaxb",
"abracbdaara\navadakedavra",
"axya\nabyxb",
"aa\nxayay",
"abrac`dabra\navaeakedavra",
"byx`\nabywb",
"ba\nbayyz",
... |
p03307 AtCoder Beginner Contest 102 - Multiple of 2 and N | You are given a positive integer N. Find the minimum positive integer divisible by both 2 and N.
Constraints
* 1 \leq N \leq 10^9
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
Output
Print the minimum positive integer divisible by both 2 and N.
Example... | {
"input": [],
"output": []
} | {
"input": [
"999999999",
"3",
"10"
],
"output": [
"1999999998",
"6",
"10"
]
} | {
"input": [
"1604548808",
"5",
"17",
"1558666763",
"8",
"20",
"1031129102",
"12",
"30",
"1937535494",
"1",
"31",
"2049048611",
"0",
"21",
"1295498732",
"9",
"1537692078",
"-1",
"4",
"964913573",
"7",
"1433974404",
"-4",
... |
p03467 AtCoder Grand Contest 020 - Encoding Subsets | Consider the following set of rules for encoding strings consisting of `0` and `1`:
* Strings `0` and `1` can be encoded as `0` and `1`, respectively.
* If strings A and B can be encoded as P and Q, respectively, then string AB can be encoded as PQ.
* If string A can be encoded as P and K \geq 2 is a positive integer,... | {
"input": [],
"output": []
} | {
"input": [
"101110",
"0000",
"001110111010110001100000100111",
"011"
],
"output": [
"156",
"10",
"363383189",
"9"
]
} | {
"input": [
"100110",
"0001",
"011110111010110001100000100111",
"001",
"000110",
"011110111010110001100000110111",
"111",
"000100",
"0100",
"011110111010110001100100110111",
"000",
"000101",
"1001",
"011110111010110001100101110111",
"010",
"010101",
... |
p03629 AtCoder Regular Contest 081 - Don't Be a Subsequence | A subsequence of a string S is a string that can be obtained by deleting zero or more characters from S without changing the order of the remaining characters. For example, `arc`, `artistic` and (an empty string) are all subsequences of `artistic`; `abc` and `ci` are not.
You are given a string A consisting of lowerca... | {
"input": [],
"output": []
} | {
"input": [
"frqnvhydscshfcgdemurlfrutcpzhopfotpifgepnqjxupnskapziurswqazdwnwbgdhyktfyhqqxpoidfhjdakoxraiedxskywuepzfniuyskxiyjpjlxuqnfgmnjcvtlpnclfkpervxmdbvrbrdn",
"abcdefghijklmnopqrstuvwxyz",
"atcoderregularcontest"
],
"output": [
"aca",
"aa",
"b"
]
} | {
"input": [
"frqnvhydscshfcgdemurlfrutcpzhopfotpifgepnqjxupnskapziurswqazdwnwbgdhzktfyhqqxpoidfhjdakoxraiedxskywuepzfniuyskxiyjpjlxuqnfgmnjcvtlpnclfkpervxmdbvrbrdn",
"atcoddrregularcontest",
"ndrbrvbdmxvrepkflcnpltvcjnmgenquxldpjyhxksyuhnfzpeuwykpxdeiarxojajjhfdiopxqqhyftkzhdgbwnwdzaqwsruizpaksnpuxjqnpeg... |
p03787 AtCoder Grand Contest 011 - Squared Graph | Takahashi has received an undirected graph with N vertices, numbered 1, 2, ..., N. The edges in this graph are represented by (u_i, v_i). There are no self-loops and multiple edges in this graph.
Based on this graph, Takahashi is now constructing a new graph with N^2 vertices, where each vertex is labeled with a pair ... | {
"input": [],
"output": []
} | {
"input": [
"7 5\n1 2\n3 4\n3 5\n4 5\n2 6",
"3 1\n1 2"
],
"output": [
"18",
"7"
]
} | {
"input": [
"7 5\n1 2\n3 4\n3 5\n4 1\n2 6",
"7 5\n1 2\n3 7\n3 5\n4 1\n2 6",
"7 5\n1 2\n3 7\n3 5\n4 1\n2 2",
"7 5\n1 2\n3 7\n6 5\n4 1\n2 2",
"12 5\n1 2\n3 4\n3 5\n4 1\n2 6",
"7 5\n1 2\n3 7\n3 7\n4 1\n2 3",
"12 5\n1 2\n3 4\n3 5\n4 1\n2 2",
"7 5\n1 2\n2 6\n6 5\n4 1\n2 2",
"7 5\n2 2\n... |
p03955 AtCoder Grand Contest 006 - Rotate 3x3 | We have a grid with 3 rows and N columns. The cell at the i-th row and j-th column is denoted (i, j). Initially, each cell (i, j) contains the integer i+3j-3.
<image>
A grid with N=5 columns
Snuke can perform the following operation any number of times:
* Choose a 3×3 subrectangle of the grid. The placement of inte... | {
"input": [],
"output": []
} | {
"input": [
"7\n21 12 1 16 13 6 7\n20 11 2 17 14 5 8\n19 10 3 18 15 4 9",
"5\n9 6 15 12 1\n8 5 14 11 2\n7 4 13 10 3",
"6\n15 10 3 4 9 16\n14 11 2 5 8 17\n13 12 1 6 7 18",
"5\n1 4 7 10 13\n2 5 8 11 14\n3 6 9 12 15",
"5\n1 2 3 4 5\n6 7 8 9 10\n11 12 13 14 15"
],
"output": [
"No",
"Yes",... | {
"input": [
"7\n21 12 1 16 13 6 7\n20 11 2 20 14 5 8\n19 10 3 18 15 4 9",
"5\n9 6 15 12 1\n10 5 14 11 2\n7 4 13 10 3",
"6\n15 10 3 4 9 5\n14 11 2 5 8 17\n13 12 1 6 7 18",
"5\n1 2 3 0 5\n6 7 8 9 10\n11 12 13 14 15",
"7\n21 12 1 16 14 6 7\n20 11 2 20 14 5 8\n19 10 3 18 15 4 9",
"5\n9 6 3 12 1\n... |
p00045 Sum and Average | Create a program that reads the sales unit price and sales quantity and outputs the total sales amount and the average sales quantity.
Input
The input is given in the following format:
Sales unit price, sales quantity
Sales unit price, sales quantity
::
::
A comma-separated pair of unit price and quantity is gi... | {
"input": [],
"output": []
} | {
"input": [
"100,20\n50,10\n70,35"
],
"output": [
"4950\n22"
]
} | {
"input": [
"100,20\n50,10\n80,35",
"100,20\n01,05\n80,35",
"100,20\n01,05\n80,36",
"100,20\n01,05\n81,35",
"000,20\n01,05\n80,36",
"100,20\n50,10\n81,35",
"000,10\n01,05\n80,36",
"100,20\n50,01\n81,35",
"000,10\n10,05\n80,36",
"100,20\n00,15\n81,35",
"100,20\n01,05\n70,35... |
p00177 Distance Between Two Cities | Create a program that calculates and outputs the surface distance by inputting the north latitude and east longitude of two cities on the earth. However, the earth is a sphere with a radius of 6,378.1 km, and the surface distance between two points is the shortest distance along this sphere. Also, in the southern hemis... | {
"input": [],
"output": []
} | {
"input": [
"35.68 139.77 51.15 359.82\n1.37 103.92 41.78 272.25\n51.15 359.82 -34.58 301.52\n-1 -1 -1 -1"
],
"output": [
"9609\n15092\n11112"
]
} | {
"input": [
"35.997652258458864 139.77 51.15 359.82\n1.37 103.92 41.78 272.25\n51.15 359.82 -34.58 301.52\n-1 -1 -1 -1",
"35.68 139.77 51.15 359.82\n1.37 103.92 41.78 272.25\n51.15 359.82 -34.03920544232073 301.52\n-1 -1 -1 -1",
"35.997652258458864 139.77 51.15 359.82\n1.37 103.92 41.78 272.25\n51.15 359... |
p00333 New Town | In Aizu prefecture, we decided to create a new town to increase the population. To that end, we decided to cultivate a new rectangular land and divide this land into squares of the same size. The cost of developing this land is proportional to the number of plots, but the prefecture wants to minimize this cost.
Create... | {
"input": [],
"output": []
} | {
"input": [
"27 6 1",
"10 20 5"
],
"output": [
"18",
"10"
]
} | {
"input": [
"9 6 1",
"10 20 9",
"10 20 16",
"4 11 1",
"8 20 16",
"6 11 1",
"8 20 11",
"3 11 1",
"2 1 11",
"3 3 1",
"2 0 11",
"3 3 2",
"2 -1 18",
"2 -1 23",
"2 -1 43",
"3 -1 43",
"3 -1 1",
"3 -1 2",
"5 -1 2",
"5 -1 1",
"4 -1 1",
"... |
p00515 Average Score | problem
Five students, Taro, Jiro, Saburo, Shiro, and Hanako, participated in the JOI High School class.
In this class, a final exam was conducted. All five people took the final exam. For students with a final exam score of 40 or higher, the final exam score was used as is. All students with a final exam score of le... | {
"input": [],
"output": []
} | {
"input": [
"10\n65\n100\n30\n95"
],
"output": [
"68"
]
} | {
"input": [
"10\n65\n101\n30\n95",
"10\n65\n111\n30\n95",
"10\n65\n010\n30\n95",
"10\n62\n010\n30\n95",
"10\n9\n100\n30\n95",
"10\n65\n111\n30\n47",
"10\n65\n110\n30\n24",
"10\n65\n010\n30\n100",
"10\n115\n010\n30\n95",
"10\n9\n110\n30\n95",
"10\n13\n010\n24\n95",
"10\... |
p00691 Fermat's Last Theorem | In the 17th century, Fermat wrote that he proved for any integer $n \geq 3$, there exist no positive integers $x$, $y$, $z$ such that $x^n + y^n = z^n$. However he never disclosed the proof. Later, this claim was named Fermat's Last Theorem or Fermat's Conjecture.
If Fermat's Last Theorem holds in case of $n$, then it... | {
"input": [],
"output": []
} | {
"input": [
"6\n4\n2\n0"
],
"output": [
"27\n10\n6"
]
} | {
"input": [
"6\n6\n2\n0",
"6\n6\n0\n0",
"6\n4\n4\n0",
"6\n4\n0\n-1",
"6\n5\n2\n0",
"6\n0\n0\n1",
"6\n3\n2\n0",
"6\n5\n0\n1",
"6\n7\n4\n0",
"6\n2\n2\n0",
"6\n2\n4\n0",
"6\n8\n0\n0",
"6\n2\n0\n2",
"6\n13\n0\n0",
"6\n8\n2\n0",
"6\n2\n7\n0",
"6\n12\n0\n... |
p00832 Dice Puzzle | Let’s try a dice puzzle. The rules of this puzzle are as follows.
1. Dice with six faces as shown in Figure 1 are used in the puzzle.
<image>
Figure 1: Faces of a die
2. With twenty seven such dice, a 3 × 3 × 3 cube is built as shown in Figure 2.
<image>
Figure 2: 3 × 3 × 3 cube
3. When building up a cube made o... | {
"input": [],
"output": []
} | {
"input": [
"4\n1 1 1\n1 1 1\n1 1 1\n2 2 2\n2 2 2\n2 2 2\n4 3 3\n5 2 2\n4 3 3\n6 1 1\n6 1 1\n6 1 0\n1 0 0\n0 2 0\n0 0 0\n5 1 2\n5 1 2\n0 0 0\n2 0 0\n0 3 0\n0 0 0\n0 0 0\n0 0 0\n3 0 1"
],
"output": [
"27\n24\n32 33 36\n0"
]
} | {
"input": [
"4\n1 1 1\n1 1 1\n1 1 1\n2 2 2\n2 2 2\n2 2 2\n4 3 3\n5 2 2\n4 3 3\n6 1 1\n6 1 1\n6 1 -1\n1 0 0\n0 2 0\n0 0 0\n5 1 2\n5 1 2\n0 0 0\n2 0 0\n0 3 0\n0 0 0\n0 0 0\n0 0 0\n3 0 1",
"4\n1 1 1\n1 2 1\n1 1 1\n2 2 2\n2 2 2\n2 2 2\n4 3 3\n5 2 2\n4 3 3\n6 1 1\n6 1 1\n6 1 -1\n1 0 0\n0 2 0\n0 0 0\n5 1 2\n5 1 2\... |
p00963 Rendezvous on a Tetrahedron | Problem G Rendezvous on a Tetrahedron
One day, you found two worms $P$ and $Q$ crawling on the surface of a regular tetrahedron with four vertices $A$, $B$, $C$ and $D$. Both worms started from the vertex $A$, went straight ahead, and stopped crawling after a while.
When a worm reached one of the edges of the tetrahe... | {
"input": [],
"output": []
} | {
"input": [
"CD 30 1\nDB 30 1"
],
"output": [
"YES"
]
} | {
"input": [
"CD 51 1\nDB 30 1",
"CD 51 0\nDB 55 1",
"CD 51 1\nDB 55 1",
"CD 51 1\nDB 19 1",
"CD 51 1\nDB 55 0",
"CD 51 0\nDB 56 1",
"CD 14 1\nDB 55 0",
"CD 20 1\nDB 55 0",
"CD 30 1\nDB 30 2",
"CD 51 0\nDB 54 1",
"CD 51 1\nDB 19 0",
"CD 51 1\nDB 56 1",
"CD 14 1\nDB ... |
p01096 Daruma Otoshi | Daruma Otoshi
You are playing a variant of a game called "Daruma Otoshi (Dharma Block Striking)".
At the start of a game, several wooden blocks of the same size but with varying weights are stacked on top of each other, forming a tower. Another block symbolizing Dharma is placed atop. You have a wooden hammer with it... | {
"input": [],
"output": []
} | {
"input": [
"4\n1 2 3 4\n4\n1 2 3 1\n5\n5 1 2 3 6\n14\n8 7 1 4 3 5 4 1 6 8 10 4 6 5\n5\n1 3 5 1 3\n0"
],
"output": [
"4\n4\n2\n12\n0"
]
} | {
"input": [
"4\n1 2 3 4\n4\n1 2 3 1\n5\n5 1 2 3 6\n14\n8 7 1 4 3 5 4 1 6 8 10 4 6 5\n5\n1 3 5 2 3\n0",
"4\n1 2 3 2\n4\n1 2 3 1\n5\n2 1 2 3 6\n14\n8 7 1 4 3 5 4 2 6 8 10 4 6 5\n5\n1 3 5 2 3\n0",
"4\n1 0 3 2\n4\n1 2 3 1\n5\n2 1 2 3 6\n14\n8 7 1 4 3 5 4 2 6 8 10 4 1 5\n5\n1 3 5 2 3\n0",
"4\n1 0 3 2\n4\n... |
p01232 Ancient Expression | Your friend's archaeologist was excavating the ruins. One day he found a large number of slate engraved with a series of dubious symbols. He was delighted with this great discovery and immediately began to decipher the symbols engraved on the slate. After weeks of his deciphering efforts, it was apparently found that t... | {
"input": [],
"output": []
} | {
"input": [
"2\n3\nR 1 =\nL 2 + -\nL 2 * /\n6\na+b*c-d\n(p-q)/q/d\na+b*c=d-e\nt+t+t+t+t\ns=s=s=s=s\n(((((z)))))\n3\nR 3 = < >\nL 3 & | ^\nL 4 + - * /\n1\na>b*c=d<e|f+g^h&i<j>k"
],
"output": [
"((a+(b*c))-d)\n(((p-q)/q)/d)\n((a+(b*c))=(d-e))\n((((t+t)+t)+t)+t)\n(s=(s=(s=(s=s))))\nz\n\n(a>((b*c)=(d<((((e|(... | {
"input": [
"2\n3\nR 1 =\nL 2 + -\nL 2 * /\n6\na+b*c-c\n(p-q)/q/d\na+b*c=d-e\nt+t+t+t+t\ns=s=s=s=s\n(((((z)))))\n3\nR 3 = < >\nL 3 & | ^\nL 4 + - * /\n1\na>b*c=d<e|f+g^h&i<j>k",
"2\n3\nR 1 =\nL 2 + -\nL 2 * /\n6\na+b*c-d\n(p-q)/q/d\na+b*c=d-e\nt+t+t+t+t\ns=s=s=s=s\n(((((z)))))\n3\nR 3 = < >\nL 3 & | ^\nL 4 +... |
p01366 Road Construction | King Mercer is the king of ACM kingdom. There are one capital and some cities in his kingdom. Amazingly, there are no roads in the kingdom now. Recently, he planned to construct roads between the capital and the cities, but it turned out that the construction cost of his plan is much higher than expected.
In order to ... | {
"input": [],
"output": []
} | {
"input": [
"3 3\n1 2 1 2\n2 3 2 1\n3 1 3 2\n5 5\n1 2 2 2\n2 3 1 1\n1 4 1 1\n4 5 1 1\n5 3 1 1\n5 10\n1 2 32 10\n1 3 43 43\n1 4 12 52\n1 5 84 23\n2 3 58 42\n2 4 86 99\n2 5 57 83\n3 4 11 32\n3 5 75 21\n4 5 23 43\n5 10\n1 2 1 53\n1 3 1 65\n1 4 1 24\n1 5 1 76\n2 3 1 19\n2 4 1 46\n2 5 1 25\n3 4 1 13\n3 5 1 65\n4 5 1 ... | {
"input": [
"3 3\n1 2 1 2\n2 3 2 1\n3 1 3 2\n5 5\n1 2 2 2\n2 3 1 1\n1 4 1 1\n4 5 1 1\n5 3 1 1\n5 10\n1 2 32 10\n1 3 43 43\n1 4 12 52\n1 5 84 23\n2 3 58 42\n2 4 86 99\n2 5 57 83\n3 4 11 32\n3 5 75 21\n4 5 23 43\n5 10\n1 2 1 53\n1 3 1 65\n1 4 1 24\n1 5 1 76\n2 3 2 19\n2 4 1 46\n2 5 1 25\n3 4 1 13\n3 5 1 65\n4 5 1 ... |
p01548 Audition | Idol --- It's the eternal longing of girls. However, only a handful stand at the top. You have decided to enter such a survival world as an idol producer. And today, I will take your idol and challenge an important audition.
The three elements that determine the audition are visual, dance, and vocal. There are m appea... | {
"input": [],
"output": []
} | {
"input": [
"4 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1",
"9 9\n13 5 19\n19 21 37\n15 1 7\n7 11 15\n21 23 25\n33 29 19\n13 19 11\n21 5 15\n7 13 1",
"4 10\n1 1 1\n10 10 10\n10 10 10\n10 10 10"
],
"output": [
"2.777777777778",
"4.678837855075",
"-2.335340954780"
]
} | {
"input": [
"4 1\n1 1 1\n1 1 1\n1 1 2\n1 1 1",
"9 9\n13 5 19\n19 21 37\n15 1 7\n7 11 24\n21 23 25\n33 29 19\n13 19 11\n21 5 15\n7 13 1",
"9 10\n13 5 19\n19 21 37\n15 1 7\n7 11 24\n21 23 25\n33 29 19\n13 19 11\n21 5 15\n7 13 1",
"9 10\n13 5 19\n19 21 37\n15 1 7\n7 11 24\n21 23 25\n33 29 19\n13 19 11\n... |
p01704 Flowers | Problem Statement
We have planted $N$ flower seeds, all of which come into different flowers. We want to make all the flowers come out together.
Each plant has a value called vitality, which is initially zero. Watering and spreading fertilizers cause changes on it, and the $i$-th plant will come into flower if its vi... | {
"input": [],
"output": []
} | {
"input": [
"3\n10\n4 3 4 10\n5 4 5 20\n6 5 6 30\n3\n7\n-4 3 4 -10\n5 4 5 20\n6 5 6 30\n3\n1\n-4 3 4 -10\n-5 4 5 -20\n6 5 6 30\n3\n10\n-4 3 4 -10\n-5 4 5 -20\n-6 5 6 -30\n0"
],
"output": [
"43.5\n36\n13.5\n0"
]
} | {
"input": [
"3\n10\n5 3 4 10\n5 4 5 20\n6 5 6 30\n3\n7\n-4 3 4 -10\n5 4 5 20\n6 5 6 30\n3\n1\n-4 3 4 -10\n-5 4 5 -20\n6 5 6 30\n3\n10\n-4 3 4 -10\n-5 4 5 -20\n-6 5 6 -30\n0",
"3\n10\n4 3 4 10\n5 4 5 20\n6 5 6 30\n3\n7\n-4 3 4 -10\n5 4 5 20\n6 5 6 30\n3\n1\n-4 3 4 -10\n-4 4 5 -20\n6 5 6 30\n3\n10\n-4 3 4 -10\... |
p01848 Early Morning Work at Summer Camp | Early morning in summer camp
The morning of JAG summer training camp is early. To be exact, it is not so fast, but many participants feel that it is fast.
At the facility that is the venue for the training camp every year, participants must collect and clean the sheets when they move out. If even one room is delayed,... | {
"input": [],
"output": []
} | {
"input": [
"2\n0.60 1 2\n0.60 0\n2\n0.60 1 2\n0.60 1 1\n5\n0.10 1 2\n0.20 1 3\n0.30 1 4\n0.40 1 5\n0.50 1 1\n5\n0.10 0\n0.20 1 1\n0.30 1 1\n0.40 1 1\n0.50 1 1\n5\n0.10 4 2 3 4 5\n0.20 0\n0.30 0\n0.40 0\n0.50 0\n4\n0.10 1 2\n0.20 0\n0.30 1 4\n0.40 1 3\n5\n0.10 0\n0.20 0\n0.30 0\n0.40 0\n0.50 0\n0"
],
"output... | {
"input": [
"2\n0.60 1 2\n0.60 0\n2\n0.60 1 2\n0.60 1 1\n5\n0.10 1 2\n0.20 1 3\n0.30 1 4\n0.40 1 5\n0.50 1 1\n5\n0.10 0\n0.20 1 1\n0.8904968944594156 1 1\n0.40 1 1\n0.50 1 1\n5\n0.10 4 2 3 4 5\n0.20 0\n0.30 0\n0.40 0\n0.50 0\n4\n0.10 1 2\n0.20 0\n0.30 1 4\n0.40 1 3\n5\n0.10 0\n0.20 0\n0.30 0\n0.40 0\n0.50 0\n0",... |
p01984 Tanka Number | Number of tanka
Wishing to die in the spring under the flowers
This is one of the famous tanka poems that Saigyo Hoshi wrote. Tanka is a type of waka poem that has been popular in Japan for a long time, and most of it consists of five phrases and thirty-one sounds of 5, 7, 5, 7, and 7.
By the way, the number 57577 c... | {
"input": [],
"output": []
} | {
"input": [
"1\n2\n3\n390\n1124\n1546\n314159265358979323\n0"
],
"output": [
"10\n12\n13\n2020\n25252\n57577\n7744444777744474777777774774744777747477444774744744"
]
} | {
"input": [
"1\n2\n3\n390\n216\n1546\n314159265358979323\n0",
"1\n2\n2\n390\n1124\n1546\n314159265358979323\n0",
"1\n2\n3\n390\n216\n1546\n31125328462643205\n0",
"1\n2\n2\n390\n1124\n1546\n211760204581026131\n0",
"1\n2\n3\n104\n216\n1546\n31125328462643205\n0",
"1\n0\n2\n390\n1124\n1546\n2117... |
p02130 Combine Two Elements | Problem
Given $ N $ a pair of non-negative integers $ (a_i, b_i) $ and non-negative integers $ A $, $ B $.
I want to do as many of the following operations as possible.
* $ | a_i --b_i | \ leq A $ or $ B \ leq | a_i --b_i | \ leq Take out and delete the element $ i $ that satisfies 2A $
* $ | (a_i + a_j)-(b_i + b_j)... | {
"input": [],
"output": []
} | {
"input": [
"10 7 12\n34 70\n36 0\n12 50\n76 46\n33 45\n61 21\n0 1\n24 3\n98 41\n23 84",
"5 3 5\n7 2\n13 1\n1 1\n2 9\n2 4"
],
"output": [
"5",
"4"
]
} | {
"input": [
"10 7 12\n34 70\n36 0\n12 50\n76 46\n33 45\n61 21\n0 0\n24 3\n98 41\n23 84",
"5 3 4\n7 2\n13 1\n1 1\n2 9\n2 4",
"10 7 12\n34 70\n36 0\n12 50\n19 46\n33 45\n61 21\n0 0\n24 3\n98 41\n23 84",
"2 3 4\n7 3\n13 1\n1 1\n2 9\n2 4",
"2 3 5\n7 3\n13 1\n1 1\n2 9\n2 4",
"10 1 12\n34 70\n36 0\... |
p02271 Exhaustive Search | Write a program which reads a sequence A of n elements and an integer M, and outputs "yes" if you can make M by adding elements in A, otherwise "no". You can use an element only once.
You are given the sequence A and q questions where each question contains Mi.
Notes
You can solve this problem by a Burte Force appro... | {
"input": [],
"output": []
} | {
"input": [
"5\n1 5 7 10 21\n8\n2 4 17 8 22 21 100 35"
],
"output": [
"no\nno\nyes\nyes\nyes\nyes\nno\nno"
]
} | {
"input": [
"5\n1 5 7 10 21\n8\n2 4 17 10 22 21 100 35",
"5\n1 5 7 3 21\n8\n2 4 17 10 22 21 100 42",
"5\n1 5 7 3 21\n8\n0 4 17 10 22 21 100 42",
"5\n1 5 7 3 21\n8\n0 4 17 11 22 21 010 42",
"5\n0 5 7 3 21\n8\n0 4 17 11 22 21 010 42",
"5\n0 5 10 3 21\n8\n0 4 17 11 22 14 010 42",
"5\n0 5 10 ... |
p02418 Ring | Write a program which finds a pattern $p$ in a ring shaped text $s$.
<image>
Constraints
* $1 \leq $ length of $p \leq $ length of $s \leq 100$
* $s$ and $p$ consists of lower-case letters
Input
In the first line, the text $s$ is given.
In the second line, the pattern $p$ is given.
Output
If $p$ is in $s$, prin... | {
"input": [],
"output": []
} | {
"input": [
"vanceknowledgetoad\nadvance",
"vanceknowledgetoad\nadvanced"
],
"output": [
"Yes",
"No"
]
} | {
"input": [
"vanceknowledgetoad\nedvanca",
"vanceknowledgetoad\nbdvanced",
"vanceknowledgetoad\nedvamca",
"vanceknowledgetoad\ncdvanced",
"daotegdelwonkecnav\nedvamca",
"vanceknowmedgetoad\ncdvanced",
"daotegdelwonkecnav\nadvamce",
"vbnceknowmedgetoad\ncdvanced",
"daovegdelwonkecn... |
bestbats | A cricket team consists of 11 players and some are good at batting, others are good at bowling and some of them are good at both batting and bowling. The batting coach wants to select exactly K players having maximum possible sum of scores. Given the batting score of each of the 11 players, find the number of ways in w... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 2 3 4 5 6 7 8 9 10 11\n3\n2 5 1 2 4 1 6 5 2 2 1\n6"
],
"output": [
"1\n6\n"
]
} | {
"input": [
"2\n1 2 3 4 5 6 14 8 9 10 11\n3\n2 5 1 2 4 1 6 5 2 2 1\n6",
"2\n1 2 3 4 5 6 14 8 9 10 11\n3\n2 5 1 2 4 1 6 5 2 2 1\n11",
"2\n1 2 3 4 5 11 14 11 9 6 11\n3\n0 5 1 2 4 1 4 5 1 2 1\n11",
"2\n2 1 3 4 5 11 14 11 9 6 12\n3\n0 5 1 2 4 1 4 5 1 2 1\n11",
"2\n1 2 3 4 5 6 14 11 9 6 11\n3\n3 5 1 2... |
cn03 | So, as you all know free WiFis are being
installed in our institute.
These are a special
type of WiFi and they start to interfere when
there is a signal coming from two different
WiFis at a single location. The WiFi
installation task is given to you.
There are N suitable locations for the
installation of WiFi. ... | {
"input": [],
"output": []
} | {
"input": [
"5 3\n1\n2\n8\n4\n9"
],
"output": [
"3"
]
} | {
"input": [],
"output": []
} |
forestga | Chef is the head of commercial logging industry that recently bought a farm containing N trees. You are given initial height of the i-th tree by Hi and the rate of growth of height as Ri meters per month. For simplicity, you can assume that all the trees are perfect cylinders of equal radius. This allows us to consider... | {
"input": [],
"output": []
} | {
"input": [
"3 74 51\n2 2\n5 7\n2 9"
],
"output": [
"7\n"
]
} | {
"input": [
"3 74 82\n2 2\n5 7\n2 9",
"3 74 51\n3 2\n5 7\n2 9",
"3 51 141\n2 2\n1 7\n2 9",
"3 62 82\n2 2\n1 7\n1 4",
"3 74 51\n3 2\n5 7\n2 3",
"3 74 30\n2 2\n1 7\n2 12",
"3 93 82\n0 2\n7 7\n2 9",
"3 74 30\n2 2\n1 7\n2 18",
"3 51 113\n0 2\n2 7\n2 9",
"1 74 0\n3 2\n5 7\n2 5",
... |
linnum | Stuart is obsessed to numbers. He like all type of numbers in fact he is having a great collection of numbers in his room. His collection includes N different large numbers. But today he is searching for a number which is having maximum frequency of digit X. Numbers are large so he can’t do the task on his own. Help hi... | {
"input": [],
"output": []
} | {
"input": [
"2\n5\n345 1323 165 98 456\n3\n5\n335 876 98 1323 349\n3"
],
"output": [
"1323\n335"
]
} | {
"input": [
"2\n5\n345 1323 165 98 456\n3\n5\n335 876 98 1323 349\n4",
"2\n5\n345 1323 257 98 456\n3\n5\n335 876 98 1323 474\n4",
"2\n5\n345 1683 216 98 456\n3\n5\n335 876 98 1323 474\n4",
"2\n5\n345 1079 216 55 456\n3\n5\n335 746 101 1323 474\n1",
"2\n5\n345 1079 216 55 456\n3\n2\n335 746 101 13... |
pree02 | Problem Statement
You have a number N and you want to calculate how many divisors of N are special.
A number is said to be special if it is possible to remove some digits from it to get a number having 3, 5 or 6 only.For exemple number 38597 is special since it is posible to remove digits 8, 9, 7 to get 35. You can... | {
"input": [],
"output": []
} | {
"input": [
"2\n15\n75"
],
"output": [
"3\n5"
]
} | {
"input": [],
"output": []
} |
tadelive | Andy and Bob are the only two delivery men of Pizza-chef store. Today, the store received N orders.
It's known that the amount of tips may be different when handled by different delivery man.
More specifically, if Andy takes the i^th order, he would be tipped Ai dollars and if Bob takes this order,
the tip would be Bi ... | {
"input": [],
"output": []
} | {
"input": [
"5 3 3\n1 2 3 4 5\n5 4 3 2 1"
],
"output": [
"21\n"
]
} | {
"input": [
"5 3 3\n1 2 3 4 5\n5 4 3 0 1",
"5 3 3\n1 0 3 5 5\n5 4 3 0 1",
"5 3 3\n1 2 3 4 5\n2 4 2 0 2",
"5 3 3\n1 1 3 4 5\n10 4 1 0 1",
"5 3 3\n1 1 3 4 7\n10 4 1 0 1",
"5 3 3\n1 1 3 8 7\n10 4 1 0 1",
"5 3 3\n1 2 5 4 5\n2 4 2 1 3",
"5 3 3\n1 1 1 8 7\n10 4 1 0 1",
"5 3 3\n1 1 1 7 7... |
1267_J. Just Arrange the Icons | BerPhone X is almost ready for release with n applications being preinstalled on the phone. A category of an application characterizes a genre or a theme of this application (like "game", "business", or "education"). The categories are given as integers between 1 and n, inclusive; the i-th application has category c_i.... | {
"input": [],
"output": []
} | {
"input": [
"3\n11\n1 5 1 5 1 5 1 1 1 1 5\n6\n1 2 2 2 2 1\n5\n4 3 3 1 2\n"
],
"output": [
"3\n3\n4\n"
]
} | {
"input": [
"3\n11\n1 5 1 3 1 5 1 1 1 1 5\n6\n1 2 2 2 2 1\n5\n4 3 3 1 2\n",
"3\n11\n1 5 1 3 1 2 1 1 1 1 5\n6\n1 2 2 2 4 1\n5\n4 3 3 1 2\n",
"3\n11\n1 5 1 3 2 2 1 1 1 1 5\n6\n1 2 2 2 4 2\n5\n4 3 3 1 2\n",
"3\n11\n1 5 1 2 2 2 1 1 1 1 5\n6\n1 2 2 2 4 2\n5\n4 3 3 1 2\n",
"3\n11\n2 5 1 5 1 5 1 1 1 1 5... |
130_J. Date calculation | In Gregorian calendar a typical year consists of 365 days and 12 months. The numbers of days in the months are: 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31. If year index is divisible by 400, or divisible by 4 but not by 100, the year becomes leap year, with one extra day in the second month (the one which typically... | {
"input": [],
"output": []
} | {
"input": [
"2011\n324\n",
"2012\n274\n"
],
"output": [
"20 11\n",
"30 9\n"
]
} | {
"input": [],
"output": []
} |
258_E. Little Elephant and Tree | The Little Elephant loves trees very much, he especially loves root trees.
He's got a tree consisting of n nodes (the nodes are numbered from 1 to n), with root at node number 1. Each node of the tree contains some list of numbers which initially is empty.
The Little Elephant wants to apply m operations. On the i-th... | {
"input": [],
"output": []
} | {
"input": [
"5 1\n1 2\n1 3\n3 5\n3 4\n2 3\n",
"11 3\n1 2\n2 3\n2 4\n1 5\n5 6\n5 7\n5 8\n6 9\n8 10\n8 11\n2 9\n3 6\n2 8\n"
],
"output": [
"0 3 3 3 3 \n",
"0 6 7 6 0 2 0 5 4 5 5 \n"
]
} | {
"input": [
"11 3\n1 2\n2 3\n2 4\n1 5\n5 6\n5 7\n5 8\n6 9\n8 10\n8 11\n4 9\n3 6\n2 8\n",
"11 3\n1 2\n2 3\n2 4\n1 5\n5 6\n5 7\n5 8\n6 9\n8 10\n8 11\n3 9\n3 6\n2 8\n",
"11 3\n1 3\n2 3\n2 4\n1 5\n7 6\n5 7\n5 8\n6 9\n8 10\n8 11\n3 9\n3 6\n2 8\n",
"11 3\n1 2\n2 3\n2 4\n1 5\n5 6\n4 7\n5 8\n6 9\n8 10\n8 11\... |
661_B. Seasons | You are given a name of a month. Output the season of the year to which it belongs (based on Northern hemisphere).
Input
The input consists of a single string containing the name of one of the twelve months (January, February, March, April, May, June, July, August, September, October, November or December). The strin... | {
"input": [],
"output": []
} | {
"input": [
"April\n",
"November\n"
],
"output": [
"spring\n",
"autumn\n"
]
} | {
"input": [],
"output": []
} |
72_G. Fibonacci army | King Cambyses loves Fibonacci numbers. He has several armies. Today he wants to make a new army for himself and he wants the number of men in this army to be the n-th Fibonacci number.
Given n you should find n-th Fibonacci number. The set of Fibonacci numbers start with f0 = f1 = 1 and for each i ≥ 2, fi = fi - 1 + f... | {
"input": [],
"output": []
} | {
"input": [
"2\n",
"1\n"
],
"output": [
"2\n",
"1\n"
]
} | {
"input": [],
"output": []
} |
amit-chahals-love-for-juices-and-dhruv-katyals-astrology | Amit Chahal has a pious love for all kind of fruit juices. Almost every day ,he buys One litre pack of juice. For past one month , Amit Chahal is having a very bad time. One day while he was on a date, he Reverse Peristalsis . Amit Chahal guessed it is probably due to juices he has been drinking for a while.
Amit Chah... | {
"input": [],
"output": []
} | {
"input": [
"3\n22\n3\n7\n\nSAMPLE"
],
"output": [
"NO\nYES\nYES"
]
} | {
"input": [
"3\n22\n5\n7\n\nSAMPLE",
"3\n22\n9\n7\n\nSAMPLE",
"3\n15\n17\n19\n\nSAMQLE",
"3\n23\n17\n19\n\nSAMQLE",
"3\n17\n16\n19\n\nSAMQLE",
"3\n21\n16\n23\n\nSAMQLE",
"3\n21\n16\n46\n\nSAMPME",
"3\n38\n39\n21\n\nTANOLE",
"3\n22\n9\n7\n\nSAMQLE",
"3\n15\n9\n7\n\nSAMQLE",
... |
dfs-2 | You have some boxes. All of them are assigned a unique positive integer. This number is written on them with a marker. Your task is simple that is to evaluate a number of queries. The description of a single query is
given below:
The query consists of 2 positive integers L and R.
You have to report total number of bo... | {
"input": [],
"output": []
} | {
"input": [
"5\n4 3 2 1 1\n4\n1 2\n2 3\n5 6\n1 1\n\nSAMPLE"
],
"output": [
"3\n2\n0\n2\n"
]
} | {
"input": [
"5\n4 3 2 1 1\n4\n1 2\n2 3\n5 6\n1 1\n\nMASPLE",
"5\n4 3 1 1 1\n4\n1 2\n2 3\n5 6\n1 1\n\nMASPLE",
"5\n3 3 2 1 1\n4\n1 2\n2 3\n5 6\n1 1\n\nSAMPLE",
"5\n3 3 2 1 1\n4\n2 2\n2 3\n5 6\n1 1\n\nSAMPLE",
"5\n4 3 2 1 1\n4\n1 2\n1 3\n5 6\n1 1\n\nMASPLF",
"5\n4 3 2 1 1\n4\n1 2\n1 3\n5 8\n1 2... |
strings-awesomeness | Vivek likes strings a lot but moreover he likes Awesome strings. Vivek calls a string str Awesome if zero or more letters of the string str can be rearranged to form the string "HackerEarth" (case insensitive). For eg : strings HackerEarth , Earthhacker , haeackerrth are all Awesome strings whereas strings HE, Mycareer... | {
"input": [],
"output": []
} | {
"input": [
"HackerEarthhACKEReARTH\n5\n1 11\n2 15\n5 15\n7 20\n7 22\n\nSAMPLE"
],
"output": [
"1\n4\n1\n4\n6"
]
} | {
"input": [],
"output": []
} |
p02601 M-SOLUTIONS Programming Contest 2020 - Magic 2 | M-kun has the following three cards:
* A red card with the integer A.
* A green card with the integer B.
* A blue card with the integer C.
He is a genius magician who can do the following operation at most K times:
* Choose one of the three cards and multiply the written integer by 2.
His magic is successful if... | {
"input": [],
"output": []
} | {
"input": [
"7 4 2\n3",
"7 2 5\n3"
],
"output": [
"No",
"Yes"
]
} | {
"input": [
"7 4 4\n3",
"37 2 2\n9",
"4 2 5\n3",
"7 4 4\n5",
"4 2 5\n6",
"7 2 4\n5",
"4 2 3\n6",
"7 2 4\n9",
"1 2 3\n6",
"7 3 4\n9",
"1 2 4\n6",
"12 3 4\n9",
"1 2 5\n6",
"12 4 4\n9",
"12 4 2\n9",
"12 2 2\n9",
"21 2 2\n9",
"7 4 4\n4",
"7 2 5\... |
p02732 AtCoder Beginner Contest 159 - Banned K | We have N balls. The i-th ball has an integer A_i written on it.
For each k=1, 2, ..., N, solve the following problem and print the answer.
* Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
Constraint... | {
"input": [],
"output": []
} | {
"input": [
"8\n1 2 1 4 2 1 4 1",
"5\n1 1 2 1 2",
"4\n1 2 3 4",
"5\n3 3 3 3 3"
],
"output": [
"5\n7\n5\n7\n7\n5\n7\n5",
"2\n2\n3\n2\n3",
"0\n0\n0\n0",
"6\n6\n6\n6\n6"
]
} | {
"input": [
"8\n1 2 1 6 2 1 4 1",
"5\n0 1 2 1 2",
"4\n2 2 3 4",
"5\n3 3 2 3 3",
"8\n1 3 1 6 2 1 4 1",
"5\n0 1 2 1 0",
"5\n0 3 2 3 3",
"8\n1 3 1 6 2 0 4 1",
"8\n1 2 1 6 2 0 4 1",
"8\n1 1 1 6 2 0 4 1",
"5\n1 0 2 1 1",
"8\n1 1 1 3 1 0 4 1",
"5\n0 0 2 1 0",
"5\n0 -... |
p02865 NIKKEI Programming Contest 2019-2 - Sum of Two Integers | How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
Constraints
* 1 \leq N \leq 10^6
* N is an integer.
Input
Input is given from Standard Input in the following format:
N
Output
Print the answer.
Examples
Input
4
Output
1
Input
999999
Output
499999 | {
"input": [],
"output": []
} | {
"input": [
"4",
"999999"
],
"output": [
"1",
"499999"
]
} | {
"input": [
"3",
"1527191",
"5",
"1743342",
"0",
"3256265",
"1412384",
"1",
"1339977",
"-2",
"133044",
"245898",
"-6",
"135077",
"-9",
"183385",
"-16",
"121596",
"235323",
"-4",
"76195",
"11230",
"22459",
"25408",
"-1... |
p03000 AtCoder Beginner Contest 130 - Bounding | A ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \leq i \leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.
How many times will the ball make a bounce where the coordinate is at most X?
Constraints
* 1 \leq N \leq 100
* 1 \leq L_i ... | {
"input": [],
"output": []
} | {
"input": [
"4 9\n3 3 3 3",
"3 6\n3 4 5"
],
"output": [
"4",
"2"
]
} | {
"input": [
"4 9\n3 6 3 3",
"4 9\n5 6 2 6",
"4 9\n3 2 3 3",
"4 9\n3 2 0 3",
"3 9\n16 5 1 12",
"4 9\n3 6 2 3",
"4 9\n3 6 2 6",
"1 9\n5 6 2 6",
"1 9\n4 6 2 6",
"4 6\n3 3 3 3",
"3 6\n3 1 5",
"4 9\n4 6 2 3",
"4 9\n5 5 2 6",
"1 9\n4 10 2 6",
"4 6\n3 3 3 1",
... |
p03141 NIKKEI Programming Contest 2019 - Different Strokes | There are N dishes of cuisine placed in front of Takahashi and Aoki. For convenience, we call these dishes Dish 1, Dish 2, ..., Dish N.
When Takahashi eats Dish i, he earns A_i points of happiness; when Aoki eats Dish i, she earns B_i points of happiness.
Starting from Takahashi, they alternately choose one dish and ... | {
"input": [],
"output": []
} | {
"input": [
"3\n20 10\n20 20\n20 30",
"3\n10 10\n20 20\n30 30",
"6\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000"
],
"output": [
"20",
"20",
"-2999999997"
]
} | {
"input": [
"3\n20 10\n16 20\n20 30",
"3\n10 10\n20 34\n30 30",
"6\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000001",
"3\n20 10\n16 20\n20 7",
"3\n10 10\n20 4\n30 30",
"6\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n2 1000000001",
... |
p03285 AtCoder Beginner Contest 105 - Cakes and Donuts | La Confiserie d'ABC sells cakes at 4 dollars each and doughnuts at 7 dollars each. Determine if there is a way to buy some of them for exactly N dollars. You can buy two or more doughnuts and two or more cakes, and you can also choose to buy zero doughnuts or zero cakes.
Constraints
* N is an integer between 1 and 10... | {
"input": [],
"output": []
} | {
"input": [
"40",
"3",
"11"
],
"output": [
"Yes",
"No",
"Yes"
]
} | {
"input": [
"17",
"22",
"1",
"19",
"2",
"9",
"18",
"4",
"6",
"15",
"7",
"30",
"25",
"48",
"41",
"81",
"-1",
"55",
"-2",
"57",
"-3",
"95",
"-5",
"94",
"-6",
"8",
"-11",
"5",
"-14",
"12",
"-28",
... |
p03441 AtCoder Petrozavodsk Contest 001 - Antennas on Tree | We have a tree with N vertices. The vertices are numbered 0 through N - 1, and the i-th edge (0 ≤ i < N - 1) comnnects Vertex a_i and b_i. For each pair of vertices u and v (0 ≤ u, v < N), we define the distance d(u, v) as the number of edges in the path u-v.
It is expected that one of the vertices will be invaded by ... | {
"input": [],
"output": []
} | {
"input": [
"2\n0 1",
"5\n0 1\n0 2\n0 3\n3 4",
"10\n2 8\n6 0\n4 1\n7 6\n2 3\n8 6\n6 9\n2 4\n5 8"
],
"output": [
"1",
"2",
"3"
]
} | {
"input": [
"2\n0 2",
"2\n0 4",
"2\n0 5",
"2\n0 9",
"2\n0 18",
"2\n0 12",
"2\n0 17",
"2\n1 17",
"2\n1 21",
"2\n2 21",
"2\n2 27",
"2\n2 8",
"2\n0 8",
"2\n0 3",
"2\n1 3",
"2\n0 34",
"2\n2 17",
"2\n0 10",
"2\n2 14",
"2\n3 21",
"2\n2 7",... |
p03599 AtCoder Beginner Contest 074 - Sugar Water | Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.
* Operation 1: Pour 100A grams of water into the beaker.
* Operation 2: Pour 100B grams of water into the beaker.... | {
"input": [],
"output": []
} | {
"input": [
"1 2 1 2 100 1000",
"1 2 10 20 15 200",
"17 19 22 26 55 2802"
],
"output": [
"200 100",
"110 10",
"2634 934"
]
} | {
"input": [
"1 2 10 20 15 179",
"26 19 22 26 55 2802",
"1 2 5 20 15 179",
"26 29 22 26 55 2802",
"1 1 5 20 27 179",
"17 19 22 47 55 2802",
"14 29 22 26 55 2802",
"1 3 10 20 15 243",
"5 31 22 26 55 2802",
"2 1 1 20 17 179",
"1 2 13 20 15 200",
"5 31 22 26 55 915",
"... |
p03760 AtCoder Beginner Contest 058 - ∵∴∵ | Snuke signed up for a new website which holds programming competitions. He worried that he might forget his password, and he took notes of it. Since directly recording his password would cause him trouble if stolen, he took two notes: one contains the characters at the odd-numbered positions, and the other contains the... | {
"input": [],
"output": []
} | {
"input": [
"atcoderbeginnercontest\natcoderregularcontest",
"xyz\nabc"
],
"output": [
"aattccooddeerrbreeggiunlnaerrccoonntteesstt",
"xaybzc"
]
} | {
"input": [
"atcoderbeeinnercontgst\natcoderregularcontest",
"xyz\nacc",
"atcoderbeeinnercontgst\natcoaerreguldrcontest",
"xyz\nadc",
"atcoderbfeinnercontgst\natcoaerreguldrcontest",
"xyy\nadc",
"atcoderbfeinnercontgst\natcoaerreguldrcnntest",
"xyy\nacd",
"ftcoderbaeinnercontgst\n... |
p03922 CODE FESTIVAL 2016 Final (Parallel) - Pair Cards | Takahashi is playing with N cards.
The i-th card has an integer X_i on it.
Takahashi is trying to create as many pairs of cards as possible satisfying one of the following conditions:
* The integers on the two cards are the same.
* The sum of the integers on the two cards is a multiple of M.
Find the maximum numb... | {
"input": [],
"output": []
} | {
"input": [
"7 5\n3 1 4 1 5 9 2",
"15 10\n1 5 6 10 11 11 11 20 21 25 25 26 99 99 99"
],
"output": [
"3",
"6"
]
} | {
"input": [
"7 5\n3 1 4 1 5 9 3",
"15 10\n1 5 6 10 11 11 11 20 21 25 25 26 99 83 99",
"15 10\n1 5 6 10 11 11 11 20 21 25 25 26 99 83 56",
"15 10\n1 5 6 10 11 11 11 20 21 25 25 26 99 124 99",
"7 5\n3 1 4 1 5 8 3",
"15 10\n1 5 6 10 11 11 11 20 21 1 25 26 99 124 99",
"7 8\n4 2 5 1 5 9 3",
... |
p00023 Circles Intersection | You are given circle $A$ with radius $r_a$ and with central coordinate $(x_a, y_a)$ and circle $B$ with radius $r_b$ and with central coordinate $(x_b, y_b)$.
Write a program which prints:
* "2" if $B$ is in $A$,
* "-2" if $A$ is in $B$,
* "1" if circumference of $A$ and $B$ intersect, and
* "0" if $A$ and $B$ do not... | {
"input": [],
"output": []
} | {
"input": [
"2\n0.0 0.0 5.0 0.0 0.0 4.0\n0.0 0.0 2.0 4.1 0.0 2.0"
],
"output": [
"2\n0"
]
} | {
"input": [
"2\n0.0 0.0 5.0 0.0 0.0 4.0\n0.0 0.0 2.0 4.1 0.0 2.4515674947137622",
"2\n0.0 0.0 5.0 0.0 1.5542884595470625 4.0\n0.0 0.0 2.0 4.1 0.0 2.4515674947137622",
"2\n3.1147350602004042 10.32674830176415 10.748453312336865 4.001069425760041 6.490549081480047 6.328774266228958\n7.521092820860991 2.963... |
p00154 Sum of Cards | Let's play the game using a bag containing several cards with integers written on it. In each game, participants first declare one of their favorite number n. Then, take out an appropriate number of cards from the bag at a time, and if the sum of the numbers written on those cards is equal to n, you will receive a luxu... | {
"input": [],
"output": []
} | {
"input": [
"5\n1 10\n5 3\n10 3\n25 2\n50 2\n4\n120\n500\n100\n168\n7\n1 10\n3 10\n5 10\n10 10\n25 10\n50 10\n100 10\n3\n452\n574\n787\n0"
],
"output": [
"16\n0\n12\n7\n9789\n13658\n17466"
]
} | {
"input": [
"5\n1 10\n5 3\n10 3\n25 2\n50 2\n4\n120\n500\n100\n168\n7\n1 10\n3 10\n5 10\n10 10\n25 10\n10 10\n100 10\n3\n452\n574\n787\n0",
"5\n2 10\n5 3\n10 3\n25 2\n50 2\n4\n120\n500\n100\n168\n7\n1 10\n3 10\n5 10\n10 10\n25 10\n10 10\n100 10\n3\n452\n574\n787\n0",
"5\n2 10\n5 3\n5 3\n25 2\n50 2\n4\n12... |
p00311 Fishing Competition | The brothers Hiroshi and Kenjiro came to Lake Inawashiro for fishing. The two decided to score as follows and compete with the total score of the fish they caught.
* One char is a point
* One yamame trout b points
* Add c points for every 10 chars
* Add d points for every 20 yamame trout
Create a program to determi... | {
"input": [],
"output": []
} | {
"input": [
"5 1\n3 1\n1 2 5 5",
"0 20\n10 0\n1 1 10 0",
"5 1\n4 2\n1 2 5 5"
],
"output": [
"hiroshi",
"even",
"kenjiro"
]
} | {
"input": [
"9 1\n3 1\n1 2 5 5",
"0 20\n10 0\n2 1 10 0",
"5 0\n4 1\n0 0 6 -1",
"5 1\n4 1\n1 2 5 5",
"9 1\n3 1\n1 2 5 3",
"0 13\n10 0\n2 1 10 0",
"5 1\n4 1\n1 2 5 1",
"9 2\n3 1\n1 2 5 3",
"0 9\n10 0\n2 1 10 0",
"5 1\n4 1\n1 2 5 0",
"9 2\n2 1\n1 2 5 3",
"0 11\n10 0\n2 1 ... |
p00475 Exposition | problem
JOI City will hold a large-scale exposition.
There are two themes for this exposition, and each of the N exhibition facilities in JOI City will exhibit on one of the two themes.
The location of the facility is represented by plane coordinates (x, y). To move from the facility at position (x, y) to the facili... | {
"input": [],
"output": []
} | {
"input": [
"5\n0 0\n1 0\n-1 -2\n0 1\n-1 1"
],
"output": [
"3"
]
} | {
"input": [
"5\n-1 0\n1 0\n-1 -2\n0 1\n-1 1",
"5\n-2 0\n1 0\n0 -2\n0 2\n-1 1",
"5\n0 0\n2 0\n0 -1\n-2 6\n-4 2",
"5\n0 1\n2 1\n0 -1\n-2 4\n-4 1",
"5\n-1 1\n1 1\n0 -1\n-2 8\n-5 1",
"5\n-2 2\n-1 2\n0 -1\n-2 26\n-9 1",
"5\n-2 2\n-1 3\n0 -2\n-2 26\n-9 1",
"5\n-2 2\n-1 2\n0 -2\n-3 26\n-13 1... |
p00667 11224111122411 | My arm is stuck and I can't pull it out.
I tried to pick up something that had rolled over to the back of my desk, and I inserted my arm while illuminating it with the screen of my cell phone instead of a flashlight, but I accidentally got caught in something and couldn't pull it out. It hurts if you move it forcibly.... | {
"input": [],
"output": []
} | {
"input": [
"1\n11\n111111\n111111111111\n12345\n11111111119999999999\n11111111113333333333\n11111111118888888888\n11111111112222222222111111111\n11111111110000000000444444444\n11224111122411\n888888888888999999999999888888888888999999999999999999\n666666666666666777333333333338888888888\n11111144444411111114444... | {
"input": [
"1\n11\n111111\n111111111111\n12345\n11111111119999999999\n11111111113333333333\n11111111118888888888\n11111111112222222222111111111\n11111111110000000000444444444\n6395268301430\n888888888888999999999999888888888888999999999999999999\n666666666666666777333333333338888888888\n111111444444111111144449... |
p00810 Super Star | During a voyage of the starship Hakodate-maru (see Problem A), researchers found strange synchronized movements of stars. Having heard these observations, Dr. Extreme proposed a theory of "super stars". Do not take this term as a description of actors or singers. It is a revolutionary theory in astronomy.
According to... | {
"input": [],
"output": []
} | {
"input": [
"4\n10.00000 10.00000 10.00000\n20.00000 10.00000 10.00000\n20.00000 20.00000 10.00000\n10.00000 20.00000 10.00000\n4\n10.00000 10.00000 10.00000\n10.00000 50.00000 50.00000\n50.00000 10.00000 50.00000\n50.00000 50.00000 10.00000\n0"
],
"output": [
"7.07107\n34.64102"
]
} | {
"input": [
"4\n10.00000 10.00000 10.00000\n20.00000 10.00000 10.00000\n20.00000 20.00000 10.00000\n10.00000 20.00000 10.00000\n4\n10.00000 10.063097698119668 10.00000\n10.00000 50.00000 50.00000\n50.00000 10.00000 50.00000\n50.00000 50.00000 10.00000\n0",
"4\n10.00000 10.00000 10.00000\n20.00000 10.00000 10... |
p00941 Do Geese See God? | Example
Input
crc
1
Output
crc | {
"input": [],
"output": []
} | {
"input": [
"crc\n1"
],
"output": [
"crc"
]
} | {
"input": [
"crb\n1",
"bqc\n1",
"bcq\n2",
"ccq\n2",
"cdq\n2",
"dcq\n2",
"dcq\n4",
"qcd\n3",
"qce\n3",
"qce\n4",
"pde\n1",
"pdf\n1",
"ode\n0",
"ecp\n0",
"dcp\n0",
"ecp\n2",
"pce\n3",
"eep\n0",
"fep\n0",
"feq\n0",
"ffq\n0",
"ffp\n0... |
p01074 Unhappy Class | Problem
Yamano Mifune Gakuen's 1st grade G group is a class where female students carrying misfortune gather. They face various challenges every day with the goal of being happy.
In their class, they can take practical happiness courses as part of the test of happiness.
From Monday to Friday, there are classes from 1... | {
"input": [],
"output": []
} | {
"input": [
"3 7 3\n0 1 1 1\n0 1 1 2\n1 1 3 4\n1 1 1 1\n1 2 1 2\n2 1 1 3\n2 2 2 1",
"5 10 5\n0 1 1 2\n0 2 1 2\n0 1 2 3\n1 2 1 2\n1 4 2 3\n2 1 1 1\n2 1 1 2\n3 3 2 3\n4 1 1 2\n4 2 1 2"
],
"output": [
"9",
"13"
]
} | {
"input": [
"3 7 3\n0 1 1 1\n0 1 1 2\n1 1 3 4\n1 1 1 1\n1 2 1 2\n3 1 1 3\n2 2 2 1",
"5 10 5\n0 1 1 2\n0 2 1 2\n0 1 2 3\n1 2 0 2\n1 4 2 3\n2 1 1 1\n2 1 1 2\n3 3 2 3\n4 1 1 2\n4 2 1 2",
"5 10 5\n0 1 1 2\n0 2 1 2\n0 1 2 3\n1 2 0 2\n1 4 2 3\n2 1 1 1\n2 1 1 2\n3 3 2 4\n4 1 1 2\n4 2 0 2",
"3 7 3\n0 1 1 1\n... |
p01208 Turn Left | Taro got a driver’s license with a great effort in his campus days, but unfortunately there had been no opportunities for him to drive. He ended up obtaining a gold license.
One day, he and his friends made a plan to go on a trip to Kyoto with you. At the end of their meeting, they agreed to go around by car, but ther... | {
"input": [],
"output": []
} | {
"input": [
"2 1\nKarasumaKitaoji 0 6150\nKarasumaNanajo 0 0\nKarasumaNanajo KarasumaKitaoji\nKarasumaKitaoji KarasumaNanajo\n3 2\nKujoOmiya 0 0\nKujoAburanokoji 400 0\nOmiyaNanajo 0 1150\nKujoOmiya KujoAburanokoji\nKujoOmiya OmiyaNanajo\nKujoAburanokoji OmiyaNanajo\n10 12\nKarasumaGojo 745 0\nHorikawaShijo 0 87... | {
"input": [
"2 1\nKarasumaKitaoji 0 6150\nKarasumaNanajo 0 0\nKarasumaNanajo KarasumaKitaoji\nKarasumaKitaoji KarasumaNanajo\n3 2\nKujoOmiya 0 0\nKujoAburanokoji 400 0\nOmiyaNanajo 0 1150\nKujoOmiya KujoAburanokoji\nKujoOmiya OmiyaNanajo\nKujoAburanokoji OmiyaNanajo\n10 12\nKarasumaGojo 745 0\nHorikawaShijo 0 87... |
p01344 Bouldering | Bouldering is a style of rock climbing. Boulderers are to climb up the rock with bare hands without supporting ropes. Your friend supposed that it should be interesting and exciting, so he decided to come to bouldering gymnasium to practice bouldering. Since your friend has not tried bouldering yet, he chose beginner’s... | {
"input": [],
"output": []
} | {
"input": [
"7\n4 2 4\n11 18\n14 18\n10 14\n13 14\n14 17\n17 21\n16 26",
"6\n2 3 3\n11 22\n12 20\n10 15\n11 17\n13 23\n16 22",
"6\n2 2 4\n12 22\n13 21\n14 15\n10 16\n16 24\n10 35",
"6\n4 3 3\n10 17\n15 14\n10 15\n11 12\n16 18\n15 22"
],
"output": [
"3",
"-1",
"-1",
"3"
]
} | {
"input": [
"7\n2 2 4\n11 18\n14 18\n10 14\n13 14\n14 17\n17 21\n16 26",
"6\n2 3 3\n11 22\n12 20\n10 15\n10 17\n13 23\n11 22",
"6\n2 6 3\n11 22\n12 20\n10 27\n10 17\n13 23\n3 22",
"6\n2 3 3\n11 22\n12 20\n10 15\n10 17\n13 23\n16 22",
"6\n2 2 4\n12 22\n13 21\n14 15\n10 21\n16 24\n10 35",
"6\n4... |
p01512 Tree Allocation | A tree is one of the most popular data structures in computer science. Tree itself is very elegant, but it is incompatible with current computer architecture. In the current architecture, memory can be regarded as a one-dimensional array. Since a tree is not a one-dimensional structure, cache efficiency may come into q... | {
"input": [],
"output": []
} | {
"input": [
"3 1\n1\n2\n3 2\n1\n1\n10 4\n1\n1\n2\n3\n3\n4\n4\n4\n5\n0 0"
],
"output": [
"Case 1:\n3\n2\n3\nCase 2:\n2\n2\n2\nCase 3:\n2\n2\n2\n2\n2\n2\n2\n2\n2\n3"
]
} | {
"input": [
"3 1\n1\n2\n3 1\n1\n1\n10 4\n1\n1\n2\n3\n3\n4\n4\n4\n5\n0 0",
"3 1\n1\n2\n3 1\n1\n1\n10 4\n1\n1\n2\n1\n3\n4\n4\n4\n5\n0 0",
"3 1\n1\n2\n3 2\n1\n1\n10 4\n1\n2\n2\n3\n3\n4\n4\n4\n5\n0 0",
"3 1\n1\n1\n3 1\n1\n1\n10 4\n1\n1\n2\n1\n3\n1\n2\n4\n5\n0 0",
"3 1\n1\n2\n3 1\n1\n2\n10 4\n1\n1\n2\... |
p01682 Shipura | Problem Statement
Dr. Suposupo developed a programming language called Shipura. Shipura supports only one binary operator ${\tt >>}$ and only one unary function ${\tt S<\ >}$.
$x {\tt >>} y$ is evaluated to $\lfloor x / 2^y \rfloor$ (that is, the greatest integer not exceeding $x / 2^y$), and ${\tt S<} x {\tt >}$ is ... | {
"input": [],
"output": []
} | {
"input": [
"S< S< 12 >> 2 > >\n123 >> 1 >> 1\n1000000000 >>129\nS<S<S<S<S<2>>>>>\nS <S< S<2013 >>> 11 >>> 10 >\n#"
],
"output": [
"81\n30\n0\n294967268\n14592400"
]
} | {
"input": [
"S< S< 12 >> 2 > >\n123 >> 1 >> 1\n1000000000 >>129\nS<S<S<S<S<2>>>>>\nS <S< S<2013 >>> 13 >>> 10 >\n#",
"S< S< 12 >> 2 > >\n202 >> 1 >> 1\n1000010000 >>129\nS<S<S<S<S<2>>>>>\nS <S< S<2013 >>> 13 >>> 10 >\n#",
"S< S< 12 >> 2 > >\n249 >> 1 >> 1\n1000010000 >>129\nS<S<S<S<S<2>>>>>... |
p01826 Live Programming | Example
Input
2 10
10 200 1
10 100 100
Output
200 | {
"input": [],
"output": []
} | {
"input": [
"2 10\n10 200 1\n10 100 100"
],
"output": [
"200"
]
} | {
"input": [
"2 10\n10 200 1\n10 100 101",
"2 10\n10 137 1\n10 100 101",
"0 10\n10 200 0\n10 100 100",
"2 10\n6 331 1\n0 110 100",
"3 10\n1 349 1\n16 100 101",
"2 10\n6 554 1\n0 100 100",
"1 10\n1 470 -1\n15 101 101",
"2 10\n6 28 1\n10 100 101",
"3 10\n6 318 1\n10 100 101",
"3 ... |
p01961 RPG Maker | You are planning to create a map of an RPG. This map is represented by a grid whose size is $H \times W$. Each cell in this grid is either '@', '*', '#', or '.'. The meanings of the symbols are as follows.
* '@': The start cell. The story should start from this cell.
* '*': A city cell. The story goes through or ends ... | {
"input": [],
"output": []
} | {
"input": [
"11 7\n.......\n.......\n*.....*\n.......\n..@....\n.......\n*......\n.......\n....*..\n.......\n.......",
"7 11\n........*..\n...........\n...........\n...........\n....*...*..\n...........\n..*.@...*.."
],
"output": [
".......\n.......\n*#####*\n......#\n..@...#\n..#.###\n*##.#..\n#...#... | {
"input": [
"11 7\n.......\n.......\n*.....*\n.......\n..@....\n.......\n......*\n.......\n....*..\n.......\n.......",
"11 7\n.......\n.......\n*.....*\n.......\n..@....\n.......\n......*\n.......\n..*....\n.......\n.......",
"11 7\n.......\n.......\n*.....*\n.......\n..@....\n.......\n*......\n.......\n... |
p02108 Donuts Purchase | Problem
Lahuy had no time off and was free, and somehow wanted to eat donuts, so he decided to go around the store and buy donuts.
There is one donut shop in each city, and all donut shops are closed on odd days.
Lahuy has a taste for donuts, so the degree of satisfaction you get depends on the store.
So Lahuy decided... | {
"input": [],
"output": []
} | {
"input": [
"2 1\n1 2\n0 1",
"5 5\n1 1 1 1 1\n0 1\n1 2\n2 3\n3 0\n3 4",
"4 4\n1 1 1 1\n0 1\n1 2\n2 0\n2 3"
],
"output": [
"1",
"3",
"4"
]
} | {
"input": [
"5 5\n1 1 1 1 1\n0 1\n1 2\n2 3\n3 0\n3 3",
"4 4\n1 1 2 1\n0 1\n1 2\n2 0\n1 3",
"4 1\n0 1 2 1\n0 1\n1 2\n2 0\n1 3",
"2 1\n1 0\n0 1",
"2 1\n2 0\n0 1",
"4 4\n2 1 1 1\n0 1\n0 2\n2 0\n2 3",
"4 4\n0 1 4 1\n0 1\n1 2\n2 0\n1 3",
"4 4\n1 1 1 1\n0 1\n1 2\n2 0\n1 3",
"4 4\n0 1 2 ... |
p02248 String Search | Find places where a string P is found within a text T. Print all indices of T where P found. The indices of T start with 0.
Constraints
* 1 ≤ length of T ≤ 1000000
* 1 ≤ length of P ≤ 10000
* The input consists of alphabetical characters and digits
Input
In the first line, a text T is given. In the second line, a s... | {
"input": [],
"output": []
} | {
"input": [
"xyzz\nyz",
"aabaaa\naa"
],
"output": [
"1",
"0\n3\n4"
]
} | {
"input": [
"aaabaa\naa",
"aabbaa\naa",
"aabaab\naa",
"aababb\naa",
"aaabaa\nab",
"aabba`\na`",
"cbabaa\nba",
"cbaaaa\nba",
"dbaaba\nba",
"dbaaba\nab",
"babaaa\naa",
"aaaaab\naa",
"baaaab\naa",
"eababa\nba",
"yzyz\nyz",
"aaaabb\naa",
"`aaabb\naa",
... |
p02396 Print Test Cases | In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets.
Write a program which reads an integer x and print it as is. Note that multiple datasets are give... | {
"input": [],
"output": []
} | {
"input": [
"3\n5\n11\n7\n8\n19\n0"
],
"output": [
"Case 1: 3\nCase 2: 5\nCase 3: 11\nCase 4: 7\nCase 5: 8\nCase 6: 19"
]
} | {
"input": [
"3\n5\n11\n3\n8\n19\n0",
"3\n5\n11\n7\n8\n34\n0",
"3\n5\n11\n4\n8\n19\n0",
"3\n5\n11\n7\n14\n34\n0",
"3\n5\n11\n4\n2\n19\n0",
"3\n5\n11\n7\n26\n34\n0",
"3\n5\n9\n4\n2\n19\n0",
"3\n2\n11\n7\n26\n34\n0",
"3\n4\n11\n7\n26\n34\n0",
"3\n4\n11\n7\n2\n34\n0",
"3\n4\n1... |
c4 | The Chef is having a dinner party and invited over all his friends. His guests
being fairly health conscious have exact protein requirements, and The Chef wishes to oblige them all.
The Chef will cook dishes for each individual guest using the ingredients in his kitchen. Each ingredient has a specific amount of pro... | {
"input": [],
"output": []
} | {
"input": [
"3\n5 12 1 12 4 4\nacccdadceb\n2\n3 5 4 6\nabcbacbabcc\n15\n2 3 4\nbaba\n7"
],
"output": [
"IMPOSSIBLE\naaa\nab"
]
} | {
"input": [
"3\n5 12 1 12 4 4\nacccdadceb\n4\n3 5 4 6\nabcbacbabcc\n15\n2 3 4\nbaba\n7",
"3\n5 12 1 12 4 4\nacccdadceb\n4\n3 5 4 6\nabcbacbabcc\n15\n2 3 4\nbaba\n4",
"3\n4 12 1 12 1 4\nacccdadceb\n4\n3 5 4 2\nabcbacbabcc\n15\n2 3 4\nbaaa\n4",
"3\n4 10 1 12 1 4\nacccdadceb\n8\n3 5 4 2\nabcbacbabcc\n15... |
coop5 | Bala's room is in a mess. He's been so busy doing research that he hasn't bothered to clean out his room for months. Now he has decided to sort out all the items in his room and keep only the essential ones. He knows the usefulness of each of the 'N' items that he has, and wants to keep only the 'K' most useful items. ... | {
"input": [],
"output": []
} | {
"input": [
"2\n\n5 2\n10 23 47 3 17\n\n10 4\n87 45 99 27 58 100 38 50 31 62"
],
"output": [
"70\n348\n"
]
} | {
"input": [
"2\n\n5 2\n10 23 47 3 17\n\n10 4\n87 45 99 27 58 100 40 50 31 62",
"2\n\n5 2\n10 23 47 3 17\n\n10 4\n87 45 99 27 58 100 40 50 31 14",
"2\n\n5 2\n10 23 47 3 17\n\n10 4\n87 48 99 27 58 100 73 50 31 14",
"2\n\n5 2\n10 23 47 3 17\n\n10 4\n87 45 99 27 97 100 40 50 31 14",
"2\n\n5 2\n10 23 ... |
goc202 | Aniket Verma aka Math Bond flaunts his mathematics skill whenever he gets the opportunity. But this time he gets into trouble when he meets Sakshi, another mathematician. Sakshi gave him a problem and asked him to solve. Help Aniket to solve the problem.
Given a number N, find the sum of all products x*y such that N/x... | {
"input": [],
"output": []
} | {
"input": [
"3\n2\n3\n5"
],
"output": [
"4\n8\n21"
]
} | {
"input": [],
"output": []
} |
marcha2 | The following problem appeared in the CodeChef March '09 Challenge. A discussion of possible approaches to solving this problem can be found in our blog.
One evening Johnny found some funny looking beens in his grandfather's garden shed, and decided to plant one of them. Next morning, to his surprise he found an enorm... | {
"input": [],
"output": []
} | {
"input": [
"2\n3\n0 1 2\n3\n0 0 3"
],
"output": [
"Yes\nNo\n"
]
} | {
"input": [
"2\n3\n0 1 2\n3\n0 0 0",
"2\n3\n0 1 0\n3\n0 0 3",
"2\n3\n0 1 0\n3\n0 0 4",
"2\n3\n0 2 0\n3\n0 1 2",
"2\n3\n0 1 2\n3\n0 0 -1",
"2\n3\n0 1 1\n3\n0 0 0",
"2\n3\n0 1 1\n3\n0 1 0",
"2\n3\n1 1 1\n3\n0 1 0",
"2\n3\n0 1 2\n3\n0 -1 3",
"2\n3\n0 1 2\n3\n-1 0 0",
"2\n3\n0... |
quest | Smaug, the dragon, rules under The Mountain, Erabor which was originally the ruling place of Dwarf King. King Thorin, who is the rightful heir to the throne is on his way to take back his kingdom from Smaug. With the help of a map, King Thorin is able to find a secret entry into the mountain. But now when he has reache... | {
"input": [],
"output": []
} | {
"input": [
"cdcdcdcdeeeef"
],
"output": [
"YES"
]
} | {
"input": [],
"output": []
} |
tomjer | Jerry is not good in studies, but he likes to solve puzzles and always challenges his friend Tom. Today Jerry challenged Tom to solve a new riddle. He says "You are given a Pascal's triangle of infinite height, and you are supposed to find the sum of all the integers present at the given height." As usual Tom is conf... | {
"input": [],
"output": []
} | {
"input": [
"3\n1\n5\n10"
],
"output": [
"1\n16\n512\n"
]
} | {
"input": [
"3\n1\n9\n10",
"3\n1\n9\n13",
"3\n1\n9\n19",
"3\n1\n10\n19",
"3\n1\n10\n15",
"3\n1\n14\n15",
"3\n1\n14\n1",
"3\n1\n14\n2",
"3\n1\n19\n2",
"3\n1\n4\n10",
"3\n1\n9\n5",
"3\n1\n9\n11",
"3\n1\n10\n11",
"3\n1\n24\n2",
"3\n1\n7\n1",
"3\n1\n8\n2",
... |
1250_K. Projectors | There are n lectures and m seminars to be conducted today at the Faculty of Approximate Sciences. The i-th lecture starts at a_i and ends at b_i (formally, time of the lecture spans an interval [a_i, b_i), the right bound is exclusive). The j-th seminar starts at p_j and ends at q_j (similarly, time of the seminar span... | {
"input": [],
"output": []
} | {
"input": [
"2\n2 2 2 2\n1 5\n2 5\n1 5\n1 4\n2 0 2 10\n1 3\n1 3\n",
"3\n1 2 1 1\n3 4\n2 4\n1 3\n3 4 2 3\n5 7\n1 3\n1 7\n4 8\n2 5\n1 6\n2 8\n0 1 1 0\n1 1000000\n"
],
"output": [
"\nYES\n2 1 4 3 \nYES\n2 1 \n",
"\nYES\n1 2 1 \nNO\nYES\n1 \n"
]
} | {
"input": [],
"output": []
} |
1335_E2. Three Blocks Palindrome (hard 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 2 1 1\n3\n1 3 3\n4\n1 10 10 1\n1\n26\n2\n2 2\n3\n1 1 1\n",
"6\n8\n1 1 2 2 3 2 1 1\n3\n1 3 2\n4\n1 10 10 1\n1\n26\n2\n2 1\n3\n1 1 1\n",
"6\n8\n1 1 2 2 1 2 1 2\n3\n1 3 3\n4\n1 10 10 1\n1\n26\n2\n2 2\n3\n1 1 1\n",
"6\n8\n1 1 2 2 3 2 1 1\n3\n1 3 2\n4\n1 10 10 1\n1\n26\n2\n2 1... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.