name stringlengths 2 112 | description stringlengths 29 13k | private_tests dict | public_tests dict | generated_tests dict |
|---|---|---|---|---|
1547_D. Co-growing Sequence | A sequence of non-negative integers a_1, a_2, ..., a_n is called growing if for all i from 1 to n - 1 all ones (of binary representation) in a_i are in the places of ones (of binary representation) in a_{i + 1} (in other words, a_i \:\&\: a_{i + 1} = a_i, where \& denotes [bitwise AND](http://tiny.cc/xpy9uz)). If n = 1... | {
"input": [],
"output": []
} | {
"input": [
"5\n4\n1 3 7 15\n4\n1 2 4 8\n5\n1 2 3 4 5\n4\n11 13 15 1\n1\n0\n"
],
"output": [
"0 0 0 0\n0 1 3 7\n0 1 0 3 2\n0 2 0 14\n0\n"
]
} | {
"input": [
"5\n4\n1 3 7 15\n4\n1 2 4 5\n5\n1 2 3 4 5\n4\n11 13 15 1\n1\n0\n",
"5\n4\n1 3 7 15\n4\n1 2 4 5\n5\n1 2 0 4 5\n4\n11 13 15 1\n1\n0\n",
"5\n4\n1 3 7 15\n4\n1 2 4 5\n5\n1 0 0 4 5\n4\n11 13 15 1\n1\n0\n",
"5\n4\n1 3 7 15\n4\n1 2 4 5\n5\n2 0 0 4 5\n4\n11 13 15 1\n1\n0\n",
"5\n4\n1 3 7 15\n... |
climbing-ladder-1 | Euler's phi function for a positive integer N is usually denoted as φ(N) and defined as the number of positive integers less than or equal to N that are coprime with N.
DA-IICT is organising its sports event in the month of October and this time they have introduced a new game called climbing ladder.
The game is as f... | {
"input": [],
"output": []
} | {
"input": [
"2\n4\n1 2 3 4\n2\n1 1\n\nSAMPLE"
],
"output": [
"14\n2"
]
} | {
"input": [],
"output": []
} |
magic-inversion | An inversion in an array is a pair of indices (i, j) such that A[i] > A[j] and i < j, but you are given two arrays A and B and pairs such that A[i] > B[j] and i < j is called Inversion.
If total number of inversions T, is a prime number then the that will be called a MAGIC INVERSION, otherwise it will be a SIMPLE INV... | {
"input": [],
"output": []
} | {
"input": [
"3\n5 6 7\n1 2 3\n\nSAMPLE"
],
"output": [
"MAGIC INVERSION\n"
]
} | {
"input": [
"3\n5 6 7\n1 2 3\n\nSAEPLM",
"3\n4 6 7\n1 2 3\n\nSAMPLE",
"3\n5 6 7\n1 1 3\n\nSAEPLM",
"3\n4 6 7\n1 2 3\n\nSEMPLA",
"3\n5 6 7\n1 1 3\n\nS@EPLM",
"3\n2 6 7\n1 1 3\n\nS@EPLM",
"3\n2 6 7\n1 1 3\n\nMLPE@S",
"3\n5 12 7\n1 2 3\n\nSAEPLM",
"3\n5 6 7\n1 1 5\n\nSAEPLM",
"3\... |
sherlock-and-magic | Sherlock is following N criminals, which are right now in a 2D grid. Each criminal at t=0, decides to move in certain fixed direction. Each criminal moves with same speed. These fixed directions are North, East, West and South. Two or more criminals, however, vanish whenever they meet at any place at same time, t>0. ... | {
"input": [],
"output": []
} | {
"input": [
"1\n4\n0 0 N\n10 10 W\n20 20 N\n30 30 E\n\nSAMPLE"
],
"output": [
"2"
]
} | {
"input": [],
"output": []
} |
xsquare-and-array-operations | Xsquare loves to play with arrays a lot. Today, he has an array A consisting of N distinct integers. He wants to perform following operation over his array A.
Select a pair of consecutive integers say (Ai,Ai+1) for some 1 ≤ i < N. Replace the selected pair of integers with the max(Ai,Ai+1).
Replace N with the new size ... | {
"input": [],
"output": []
} | {
"input": [
"2\n3\n1 2 3\n3\n1 3 2\n\nSAMPLE"
],
"output": [
"5\n6"
]
} | {
"input": [
"2\n3\n1 2 3\n3\n1 3 2\n\nSALPLE",
"2\n3\n1 2 3\n3\n1 5 2\n\nSALPLE",
"2\n3\n1 2 4\n3\n1 3 2\n\nSALPLE",
"2\n3\n0 2 5\n3\n1 3 2\n\nSAMPLE",
"2\n3\n1 2 0\n3\n1 3 1\n\nSAMPLE",
"2\n3\n0 2 5\n3\n1 0 2\n\nSAMPLE",
"2\n3\n0 2 5\n3\n0 0 2\n\nSAMPLE",
"2\n3\n0 2 0\n3\n0 0 2\n\nSA... |
p02653 AtCoder Grand Contest 045 - Range Set | Snuke has a string x of length N. Initially, every character in x is `0`.
Snuke can do the following two operations any number of times in any order:
* Choose A consecutive characters in x and replace each of them with `0`.
* Choose B consecutive characters in x and replace each of them with `1`.
Find the number o... | {
"input": [],
"output": []
} | {
"input": [
"4 2 3",
"10 7 2",
"1000 100 10"
],
"output": [
"11",
"533",
"828178524"
]
} | {
"input": [
"15 7 2",
"1000 101 10",
"1100 101 10",
"1100 111 10",
"7 2 3",
"20 7 2",
"15 3 2",
"1000 101 3",
"1100 100 10",
"1100 101 19",
"7 1 3",
"20 13 2",
"17 3 2",
"1000 111 3",
"11 2 3",
"20 8 2",
"3 3 2",
"1000 100 3",
"11 2 4",
... |
p02782 AtCoder Beginner Contest 154 - Many Many Paths | Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction.
Let us define a function f(r, c) as follows:
* f(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operati... | {
"input": [],
"output": []
} | {
"input": [
"314 159 2653 589",
"1 1 2 2"
],
"output": [
"602215194",
"14"
]
} | {
"input": [
"314 159 2856 589",
"1 1 4 2",
"139 159 2856 589",
"139 159 2699 589",
"139 211 2699 589",
"314 226 2653 589",
"357 159 2856 589",
"1 1 0 2",
"139 39 2856 589",
"139 159 2699 481",
"139 211 4894 589",
"314 20 2653 589",
"684 159 2856 589",
"139 39 2... |
p02917 AtCoder Beginner Contest 140 - Maximal Value | There is an integer sequence A of length N whose values are unknown.
Given is an integer sequence B of length N-1 which is known to satisfy the following:
B_i \geq \max(A_i, A_{i+1})
Find the maximum possible sum of the elements of A.
Constraints
* All values in input are integers.
* 2 \leq N \leq 100
* 0 \leq B_i... | {
"input": [],
"output": []
} | {
"input": [
"2\n3",
"6\n0 153 10 10 23",
"3\n2 5"
],
"output": [
"6",
"53",
"9"
]
} | {
"input": [
"2\n5",
"6\n0 153 10 14 23",
"3\n2 9",
"2\n4",
"6\n0 153 10 14 17",
"3\n2 12",
"2\n1",
"6\n0 153 10 14 26",
"3\n1 12",
"2\n0",
"3\n4 12",
"2\n2",
"6\n0 164 10 7 26",
"3\n7 12",
"2\n-1",
"6\n0 164 10 7 48",
"3\n7 9",
"2\n-2",
"6\n... |
p03053 AtCoder Grand Contest 033 - Darker and Darker | You are given a grid of squares with H horizontal rows and W vertical columns, where each square is painted white or black. HW characters from A_{11} to A_{HW} represent the colors of the squares. A_{ij} is `#` if the square at the i-th row from the top and the j-th column from the left is black, and A_{ij} is `.` if t... | {
"input": [],
"output": []
} | {
"input": [
"3 3\n...\n.#.\n...",
"6 6\n..#..#\n......\n..#..\n......\n.#....\n....#."
],
"output": [
"2",
"3"
]
} | {
"input": [
"2 3\n...\n.#.\n...",
"6 6\n..#..#\n......\n..#..\n......\n.#....\n-...#.",
"2 6\n#.#...\n......\n..#0.\n......\n.#.-..\n--..#-",
"2 3\n...\n.#.\n..-",
"2 3\n/..\n.#.\n..-",
"2 3\n/..\n.#.\n..,",
"3 3\n...\n/#.\n...",
"2 3\n...\n.#.\n..,",
"3 3\n../\n/#.\n...",
"3 ... |
p03197 CADDi 2018 - Harlequin | There is an apple tree that bears apples of N colors. The N colors of these apples are numbered 1 to N, and there are a_i apples of Color i.
You and Lunlun the dachshund alternately perform the following operation (starting from you):
* Choose one or more apples from the tree and eat them. Here, the apples chosen at ... | {
"input": [],
"output": []
} | {
"input": [
"3\n100000\n30000\n20000",
"2\n1\n2"
],
"output": [
"second",
"first"
]
} | {
"input": [
"3\n100000\n30000\n29639",
"2\n0\n2",
"2\n1\n0",
"3\n000000\n30000\n29639",
"2\n1\n1",
"3\n000001\n30000\n29639",
"2\n2\n1",
"3\n000011\n30000\n29639",
"3\n000010\n30000\n29639",
"2\n2\n2",
"3\n100010\n30000\n29639",
"2\n2\n3",
"3\n100010\n24068\n29639"... |
p03344 AtCoder Regular Contest 098 - Donation | There is a simple undirected graph with N vertices and M edges. The vertices are numbered 1 through N, and the edges are numbered 1 through M. Edge i connects Vertex U_i and V_i. Also, Vertex i has two predetermined integers A_i and B_i. You will play the following game on this graph.
First, choose one vertex and stan... | {
"input": [],
"output": []
} | {
"input": [
"5 8\n6 4\n15 13\n15 19\n15 1\n20 7\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5\n3 5\n4 5",
"9 10\n131 2\n98 79\n242 32\n231 38\n382 82\n224 22\n140 88\n209 70\n164 64\n6 8\n1 6\n1 4\n1 3\n4 7\n4 9\n3 7\n3 9\n5 9\n2 5",
"4 5\n3 1\n1 2\n4 1\n6 2\n1 2\n2 3\n2 4\n1 4\n3 4"
],
"output": [
"44",
"58... | {
"input": [
"5 8\n6 8\n15 13\n15 19\n15 1\n20 7\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5\n3 5\n4 5",
"4 5\n3 1\n1 2\n4 1\n6 2\n1 2\n1 3\n2 4\n1 4\n3 4",
"5 8\n6 4\n15 13\n15 19\n15 0\n20 7\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5\n3 5\n4 5",
"9 10\n131 2\n98 79\n242 32\n231 38\n382 82\n224 22\n140 139\n209 70\n164 64\n6 8... |
p03504 AtCoder Beginner Contest 080 - Recording | Joisino is planning to record N TV programs with recorders.
The TV can receive C channels numbered 1 through C.
The i-th program that she wants to record will be broadcast from time s_i to time t_i (including time s_i but not t_i) on Channel c_i.
Here, there will never be more than one program that are broadcast on ... | {
"input": [],
"output": []
} | {
"input": [
"9 4\n56 60 4\n33 37 2\n89 90 3\n32 43 1\n67 68 3\n49 51 3\n31 32 3\n70 71 1\n11 12 3",
"3 2\n1 7 2\n7 8 1\n8 12 1",
"3 4\n1 3 2\n3 4 4\n1 4 3"
],
"output": [
"2",
"2",
"3"
]
} | {
"input": [
"9 4\n56 60 4\n33 37 2\n89 90 3\n32 43 1\n67 68 3\n71 51 3\n31 32 3\n70 71 1\n11 12 3",
"3 4\n1 3 2\n2 4 4\n1 4 3",
"2 4\n56 60 4\n33 37 2\n89 90 3\n32 43 1\n67 68 3\n71 51 3\n31 32 3\n70 71 1\n11 12 3",
"2 4\n56 60 4\n26 37 2\n89 90 3\n32 43 1\n67 68 3\n71 51 3\n31 32 3\n70 71 1\n11 12 3... |
p03665 AtCoder Grand Contest 017 - Biscuits | There are N bags of biscuits. The i-th bag contains A_i biscuits.
Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags.
He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such wa... | {
"input": [],
"output": []
} | {
"input": [
"3 0\n1 1 1",
"1 1\n50",
"2 0\n1 3",
"45 1\n17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 66 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26"
],
"output": [
"4",
"0",
"2",
"17592186044416"
]
} | {
"input": [
"1 1\n67",
"45 1\n17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 68 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26",
"3 1\n1 1 1",
"2 0\n1 1",
"1 1\n42",
"45 1\n17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 68 25 9 89 71 41 16 53 11 61... |
p03820 AtCoder Regular Contest 068 - Solitaire | Snuke has decided to play with N cards and a deque (that is, a double-ended queue). Each card shows an integer from 1 through N, and the deque is initially empty.
Snuke will insert the cards at the beginning or the end of the deque one at a time, in order from 1 to N. Then, he will perform the following action N times... | {
"input": [],
"output": []
} | {
"input": [
"2 1",
"2000 1000",
"17 2"
],
"output": [
"1",
"674286644",
"262144"
]
} | {
"input": [
"2000 1100",
"4 2",
"4 1",
"1 1",
"3 1",
"13 2",
"5 2",
"5 1",
"10 1",
"9 2",
"19 1",
"9 1",
"38 1",
"25 1",
"2000 1001",
"12 1",
"13 3",
"5 4",
"10 2",
"9 4",
"19 2",
"38 2",
"7 1",
"6 2",
"12 2",
"4 ... |
p03987 AtCoder Grand Contest 005 - Minimum Sum | One day, Snuke was given a permutation of length N, a_1, a_2, ..., a_N, from his friend.
Find the following:
<image>
Constraints
* 1 ≦ N ≦ 200,000
* (a_1, a_2, ..., a_N) is a permutation of (1, 2, ..., N).
Input
The input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
Output
Print th... | {
"input": [],
"output": []
} | {
"input": [
"3\n2 1 3",
"4\n1 3 2 4",
"8\n5 4 8 1 2 6 7 3"
],
"output": [
"9",
"19",
"85"
]
} | {
"input": [
"3\n3 1 2",
"3\n1 2 3",
"4\n2 3 1 4",
"4\n1 3 4 2",
"8\n5 3 8 1 2 6 7 4",
"4\n3 2 4 1",
"8\n4 5 8 1 2 6 7 3",
"3\n1 3 2",
"3\n2 3 1",
"3\n3 2 1",
"4\n2 3 4 1",
"4\n1 2 3 4",
"3\n3 1 2",
"3\n3 2 1",
"3\n1 2 3",
"3\n1 3 2",
"3\n2 3 1",
... |
p00075 BMI | Obesity is cited as the cause of many adult diseases. In the past, with a few exceptions, it was unrelated to high school students. However, it is no longer unrealistic to suffer from lack of exercise due to excessive studying for entrance exams, or to become bulimia nervosa due to stress. It may be a problem that high... | {
"input": [],
"output": []
} | {
"input": [
"1001,50.0,1.60\n1002,60.0,1.70\n1003,70.0,1.80\n1004,80.0,1.70\n1005,90.0,1.60"
],
"output": [
"1004\n1005"
]
} | {
"input": [
"1011,50.0,1.60\n1002,60.0,1.70\n1003,70.0,1.80\n1004,80.0,1.70\n1005,90.0,1.60",
"1010,50.0,1.60\n1002,60.0,1.70\n1003,70.0,1.80\n1400,80.0,1.70\n1005,90.0,1.60",
"1001,50.0,1.60\n1002,60.0,1.70\n1003,70.0,1.80\n1003,80.0,1.70\n1005,90.0,1.60",
"1011,50.0,1.60\n1002,60.0,1.70\n1003,70.0,... |
p00207 Block | Relative B came to Mr. A's house. He is 3 years old and loves blocks. The block he has is shaped like Figure 1.
<image>
Figure 1
Mr. B is laying blocks on the board. When I asked him, "What are you making?", He replied cheerfully, "Maze !!". The maze he says is the arrangement of blocks that are in contact with each... | {
"input": [],
"output": []
} | {
"input": [
"20 20\n1 1\n9 9\n7\n2 0 1 1\n5 1 1 3\n2 1 3 3\n1 1 5 2\n5 1 7 3\n2 0 2 7\n2 0 6 8\n20 20\n9 9\n1 1\n6\n2 0 1 1\n1 0 5 1\n2 1 1 3\n5 0 1 7\n3 1 5 5\n4 1 8 5\n0 0"
],
"output": [
"OK\nNG"
]
} | {
"input": [
"20 20\n1 1\n9 9\n7\n2 0 1 1\n5 1 1 3\n2 1 3 3\n1 1 5 2\n5 1 7 3\n2 0 2 7\n2 0 6 8\n20 20\n9 9\n1 1\n6\n2 0 1 1\n1 0 5 1\n2 1 1 3\n5 0 1 7\n3 1 6 5\n4 1 8 5\n0 0",
"20 20\n1 1\n9 9\n7\n2 0 1 1\n5 1 1 3\n2 1 3 3\n1 1 5 2\n5 1 7 3\n2 0 4 7\n2 -1 6 8\n20 20\n9 9\n1 1\n6\n2 0 1 1\n1 0 5 1\n2 1 1 3\n5... |
p00366 Electronic Metronome | A boy PCK is playing with N electric metronomes. The i-th metronome is set to tick every t_i seconds. He started all of them simultaneously.
He noticed that, even though each metronome has its own ticking interval, all of them tick simultaneously from time to time in certain intervals. To explore this interesting phen... | {
"input": [],
"output": []
} | {
"input": [
"3\n3\n6\n8",
"2\n10\n10"
],
"output": [
"3",
"0"
]
} | {
"input": [
"3\n5\n6\n8",
"2\n10\n4",
"3\n5\n5\n8",
"2\n10\n6",
"3\n8\n5\n8",
"2\n10\n2",
"2\n18\n4",
"2\n34\n4",
"2\n34\n8",
"2\n35\n15",
"2\n4\n57",
"2\n4\n43",
"2\n5\n43",
"2\n5\n62",
"2\n5\n17",
"2\n10\n31",
"2\n14\n31",
"2\n15\n8",
"2\n... |
p00574 Snake Escaping | The JOI Institute has 2 ^ L venomous snakes, numbered 0, 1, ..., and 2 ^ L -1 respectively. All venomous snakes are divided into L parts in order from the head, and each part is blue or red. For the poisonous snake i, when i is expressed in binary and i = $ \ sum_ {k = 1} ^ {L} $ c_k2 ^ {L-k} (0 \ leq c_k \ leq 1)
* I... | {
"input": [],
"output": []
} | {
"input": [
"3 5\n12345678\n000\n0??\n1?0\n?11\n???"
],
"output": [
"1\n10\n12\n12\n36"
]
} | {
"input": [
"3 5\n12345678\n000\n0??\n0?1\n?11\n???",
"3 5\n12345678\n100\n0??\n0?1\n?11\n???",
"3 5\n12345678\n000\n0??\n0?1\n?01\n???",
"3 5\n12345678\n000\n0??\n0?1\n0?1\n???",
"3 5\n12345678\n000\n1??\n1?0\n?11\n???",
"3 5\n12345678\n000\n0??\n1?0\n0?1\n???",
"3 5\n12345678\n000\n1??\... |
p00721 Cleaning Robot | Here, we want to solve path planning for a mobile robot cleaning a rectangular room floor with furniture.
Consider the room floor paved with square tiles whose size fits the cleaning robot (1 × 1). There are 'clean tiles' and 'dirty tiles', and the robot can change a 'dirty tile' to a 'clean tile' by visiting the tile... | {
"input": [],
"output": []
} | {
"input": [
"7 5\n.......\n.o...*.\n.......\n.*...*.\n.......\n15 13\n.......x.......\n...o...x....*..\n.......x.......\n.......x.......\n.......x.......\n...............\nxxxxx.....xxxxx\n...............\n.......x.......\n.......x.......\n.......x.......\n..*....x....*..\n.......x.......\n10 10\n..........\n..o... | {
"input": [
"7 5\n.......\n.o...*.\n.......\n.*...*.\n.......\n15 13\n.......x.......\n...o...x....*..\n.......x.......\n.......x.......\n.......x.......\n.-.............\nxxxxx.....xxxxx\n...............\n.......x.......\n.......x.......\n.......x.......\n..*....x....*..\n.......x.......\n10 10\n..........\n..o... |
p00861 Bug Hunt | In this problem, we consider a simple programming language that has only declarations of one- dimensional integer arrays and assignment statements. The problem is to find a bug in the given program.
The syntax of this language is given in BNF as follows:
<image>
where <new line> denotes a new line character (LF).
C... | {
"input": [],
"output": []
} | {
"input": [
"a[3]\na[0]=a[1]\n.\nx[1]\nx[0]=x[0]\n.\na[0]\na[0]=1\n.\nb[2]\nb[0]=2\nb[1]=b[b[0]]\nb[0]=b[1]\n.\ng[2]\nG[10]\ng[0]=0\ng[1]=G[0]\n.\na[2147483647]\na[0]=1\nB[2]\nB[a[0]]=2\na[B[a[0]]]=3\na[2147483646]=a[2]\n.\n."
],
"output": [
"2\n2\n2\n3\n4\n0"
]
} | {
"input": [
"a[3]\na[0]=a[1]\n.\nx[1]\nx[0]=x[0]\n.\na[0]\na[0]=1\n.\nb[2]\nb[0]=2\nb[1]=b[b[0]]\nb[0]=b[1]\n.\ng[2]\nG[10]\ng[0]=0\ng[1]=G[0]\n.\na[2147483647]\na[0]=1\nB[2]\nB[a[0]]=2\na[B[a[0]]]=3\na[2147483646]=b[2]\n.\n.",
"a[3]\na[0]=a[1]\n.\nx[1]\nx[0]=x[0]\n.\na[0]\na[0]=1\n.\nb[2]\nb[0]=2\nb[1]=b[b[... |
p00992 War | Two countries, Country A and Country B, are at war. As a soldier in Country A, you will lead n soldiers to occupy the territory of Country B.
The territory of Country B is represented by a two-dimensional grid. The first place you occupy is a square on the 2D grid. Each of the soldiers you lead has h_i health. Each so... | {
"input": [],
"output": []
} | {
"input": [
"10\n10\n10\n10\n10\n10\n10\n10\n10\n10\n10",
"2\n5\n5",
"5\n1\n2\n3\n4\n5"
],
"output": [
"93",
"11",
"15"
]
} | {
"input": [
"10\n10\n10\n14\n10\n10\n10\n10\n10\n10\n10",
"2\n3\n5",
"5\n1\n2\n5\n4\n5",
"10\n6\n10\n14\n10\n10\n10\n10\n10\n10\n10",
"2\n3\n6",
"5\n2\n2\n5\n4\n5",
"10\n6\n10\n14\n10\n10\n10\n10\n10\n10\n20",
"2\n3\n4",
"5\n2\n3\n5\n4\n5",
"10\n6\n10\n14\n10\n10\n10\n10\n10\n... |
p01124 Addition on Convex Polygons | <!--
Problem H
-->
Addition on Convex Polygons
Mr. Convexman likes convex polygons very much. During his study on convex polygons, he has come up with the following elegant addition on convex polygons.
The sum of two points in the xy-plane, (x1, y1) and (x2, y2) is defined as (x1 + x2, y1 + y2). A polygon is treat... | {
"input": [],
"output": []
} | {
"input": [
"5 3\n0 0\n2 0\n2 1\n1 2\n0 2\n0 0\n1 0\n0 1\n4 4\n0 0\n5 0\n5 5\n0 5\n0 0\n2 0\n2 2\n0 2\n3 3\n0 0\n1 0\n0 1\n0 1\n0 0\n1 1\n3 3\n0 0\n1 0\n1 1\n0 0\n1 0\n1 1\n4 4\n0 0\n2 0\n2 2\n0 2\n0 0\n1 0\n1 2\n0 2\n4 4\n0 0\n3 0\n3 1\n0 1\n0 0\n1 0\n1 1\n0 1\n0 0"
],
"output": [
"3\n2\n2\n1\n0\n2"
]... | {
"input": [
"5 3\n0 0\n2 0\n2 1\n1 2\n0 2\n0 0\n1 0\n0 1\n4 4\n0 0\n5 0\n5 5\n0 5\n0 0\n2 0\n2 2\n0 2\n3 3\n0 0\n1 0\n0 1\n0 1\n0 0\n1 1\n3 3\n0 0\n1 0\n1 1\n0 0\n1 1\n1 1\n4 4\n0 0\n2 0\n2 2\n0 2\n0 0\n1 0\n1 2\n0 2\n4 4\n0 0\n3 0\n3 1\n0 1\n0 0\n1 0\n1 1\n0 1\n0 0",
"5 3\n0 0\n2 0\n2 1\n1 2\n0 2\n0 0\n1 0\... |
p01263 Reaction | You are a hero of a role playing game, asked by the king to defeat monsters threating people’s life.
You have been making a long journey with your colleagues, and you are now in the town closest to the final dungeon where the head of monsters dwells. You have heard from people that the head monster hits with his stron... | {
"input": [],
"output": []
} | {
"input": [
"2 2\n1 1\n1 1\n4\nA 10\nB 20\nC 30\nD 40\n4\n1 1 3 A A A\n1 2 2 B C\n2 1 1 D\n2 2 3 A A B\n2 2\n1 2\n2 1\n3\nScroll 50\nBastard 100\nHeal100 10\n3\n1 1 1 Scroll\n2 1 1 Bastard\n2 2 1 Heal100\n0 0"
],
"output": [
"90\n200"
]
} | {
"input": [],
"output": []
} |
p01423 Rabbit Party | A rabbit Taro decided to hold a party and invite some friends as guests. He has n rabbit friends, and m pairs of rabbits are also friends with each other. Friendliness of each pair is expressed with a positive integer. If two rabbits are not friends, their friendliness is assumed to be 0.
When a rabbit is invited to t... | {
"input": [],
"output": []
} | {
"input": [
"3 3\n1 2 3\n2 3 1\n3 1 2",
"2 1\n1 2 5",
"4 5\n1 2 4\n1 3 3\n2 3 7\n2 4 5\n3 4 6",
"1 0"
],
"output": [
"6",
"10",
"16",
"0"
]
} | {
"input": [
"3 3\n1 4 3\n2 3 1\n3 1 2",
"2 2\n1 2 5",
"4 5\n1 2 4\n1 3 3\n2 3 7\n2 4 3\n3 4 6",
"2 0",
"4 2\n1 2 10",
"4 5\n2 2 6\n1 3 3\n2 2 7\n2 4 4\n3 4 6",
"3 4\n1 2 3\n4 5 0\n3 1 2",
"4 5\n2 2 0\n1 3 6\n2 1 8\n2 4 5\n3 6 5",
"7 7\n1 1 2\n14 5 0\n6 1 1",
"4 5\n1 2 4\n1 3 3... |
p01577 Magic Walls | You are a magician and have a large farm to grow magical fruits.
One day, you saw a horde of monsters, approaching your farm. They would ruin your magical farm once they reached your farm. Unfortunately, you are not strong enough to fight against those monsters. To protect your farm against them, you decided to build ... | {
"input": [],
"output": []
} | {
"input": [
"4\n0 0\n0 3\n1 1\n3 0",
"5\n2 0\n0 1\n1 3\n4 2\n3 4"
],
"output": [
"3.0",
"7.5"
]
} | {
"input": [
"4\n0 1\n0 3\n1 1\n3 0",
"5\n2 -1\n0 1\n1 3\n4 2\n3 4",
"4\n0 2\n0 3\n1 1\n3 0",
"5\n3 -1\n0 1\n1 3\n4 2\n3 4",
"4\n0 2\n0 3\n1 1\n2 0",
"5\n6 -1\n0 1\n1 3\n4 0\n3 4",
"5\n6 -1\n0 0\n1 3\n4 0\n3 4",
"5\n6 -1\n0 0\n1 3\n6 1\n3 4",
"5\n6 -1\n0 0\n1 3\n6 2\n3 4",
"5\n... |
p01739 Multi Path Story | You are a programmer who loves pretty girl games (a sub-genre of dating simulation games). A game, which is titled "Floatable Heart" and was released last Friday, has arrived at your home just now. This game has multiple stories. When you complete all of those stories, you can get a special figure of the main heroine, ... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 2 2\n0"
],
"output": [
"2"
]
} | {
"input": [
"2\n1 2 2\n-1",
"2\n1 3 3\n-1",
"2\n1 3 5\n-2",
"2\n1 2 4\n0",
"2\n1 3 0\n0",
"2\n1 3 1\n-2",
"2\n1 2 8\n0",
"2\n1 3 6\n0",
"2\n1 3 9\n-7",
"2\n1 3 7\n0",
"2\n1 3 10\n0",
"2\n1 3 17\n0",
"2\n1 2 16\n0",
"2\n1 3 11\n-2",
"2\n1 2 12\n-3",
"2\n... |
p01879 About Our Effort | H: About Our Effort-About Our Effort-
problem
* I would appreciate it if you could consider this problem as an extra problem, and if possible, I would like you to enjoy the other problems first. I would like to challenge those who are willing to crush in this contest.
D Sorry for the slow query for the problem. But ... | {
"input": [],
"output": []
} | {
"input": [
"4\n4 1 3 2\n2\n1 3\n2 4"
],
"output": [
"2\n1"
]
} | {
"input": [
"4\n4 1 3 2\n2\n1 3\n1 4",
"4\n4 1 3 2\n2\n1 4\n2 4",
"4\n4 1 3 2\n1\n1 3\n1 4",
"4\n4 1 3 4\n1\n1 1\n1 1",
"4\n4 1 2 2\n2\n1 3\n2 4",
"4\n4 1 3 4\n2\n1 1\n1 1",
"4\n4 1 3 2\n1\n1 4\n1 4",
"4\n4 1 2 2\n2\n1 2\n2 4",
"4\n4 1 2 1\n2\n1 3\n2 4",
"4\n4 1 4 2\n2\n1 1\n1... |
p02016 Twins | B: Twins
One twin was angry that it was not well known which of them was the older brother and which was the younger brother.
Create a program that outputs "square1001" when "ani" is entered and "e869120" when "otouto" is entered.
input
You will be given either the string "ani" or "otouto" as input.
output
Please... | {
"input": [],
"output": []
} | {
"input": [
"ani"
],
"output": [
"square1001"
]
} | {
"input": [],
"output": []
} |
p02158 Rings | Problem
A dolphin who lives in a certain aquarium will be rewarded if he jumps and goes through the $ N $ ring.
* Dolphin jumps from coordinates $ (0,0) $ and lands at $ (T,0) $.
* The trajectory of the jump is a parabola.
* The $ i $ th ring is determined to have passed through when the jump trajectory intersects th... | {
"input": [],
"output": []
} | {
"input": [
"64 15\n38 133177 927361\n48 177920 668766\n12 680425 790550\n43 6853 384115\n17 214954 723798\n62 63843 153825\n28 399349 482937\n2 336136 367001\n33 138008 733496\n6 203462 911631\n58 321974 527734\n17 696940 781678\n55 265874 507640\n41 56037 880001\n34 279422 528651",
"100 5\n50 1 5\n50 5 10\... | {
"input": [
"64 15\n38 133177 927361\n48 177920 668766\n12 680425 790550\n43 6853 384115\n17 214954 723798\n62 63843 153825\n28 57040 482937\n2 336136 367001\n33 138008 733496\n6 203462 911631\n58 321974 527734\n17 696940 781678\n55 265874 507640\n41 56037 880001\n34 279422 528651",
"100 5\n50 1 4\n50 5 10\n... |
p02299 Polygon-Point Containment | For a given polygon g and target points t, print "2" if g contains t, "1" if t is on a segment of g, "0" otherwise.
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 connecting pn and p1 is also a side of the poly... | {
"input": [],
"output": []
} | {
"input": [
"4\n0 0\n3 1\n2 3\n0 3\n3\n2 1\n0 2\n3 2"
],
"output": [
"2\n1\n0"
]
} | {
"input": [
"4\n0 0\n3 1\n2 3\n0 3\n3\n2 1\n0 2\n0 2",
"4\n0 0\n3 0\n2 3\n0 1\n3\n2 1\n0 2\n0 2",
"4\n0 -1\n3 1\n2 3\n0 3\n1\n2 1\n0 2\n3 1",
"4\n0 -1\n2 1\n2 3\n0 3\n1\n2 1\n0 1\n3 1",
"4\n0 -1\n3 0\n3 2\n1 3\n1\n0 2\n1 0\n0 1",
"4\n0 -1\n6 -2\n3 -1\n1 4\n2\n0 1\n1 0\n-1 0",
"4\n1 -1\n6 ... |
p02446 Unique | For a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ which is sorted by ascending order, eliminate all equivalent elements.
Constraints
* $1 \leq n \leq 100,000$
* $-1000,000,000 \leq a_i \leq 1,000,000,000$
* $a_0 \leq a_1 \leq ... \leq a_{n-1}$
Input
A sequence is given in the following format.
$n$
$a_... | {
"input": [],
"output": []
} | {
"input": [
"4\n1 2 2 4"
],
"output": [
"1 2 4"
]
} | {
"input": [
"4\n0 2 2 4",
"4\n0 2 2 3",
"4\n0 2 2 2",
"4\n-1 2 2 2",
"4\n0 1 2 2",
"4\n0 0 0 4",
"4\n-1 0 2 2",
"4\n0 0 1 4",
"4\n1 2 2 3",
"4\n0 0 2 8",
"4\n0 1 2 4",
"4\n0 0 0 7",
"4\n-1 0 1 2",
"4\n0 0 0 8",
"4\n0 0 1 7",
"4\n-1 -1 1 2",
"4\n-1 0... |
cd1it2 | Little Chef is learning differentiation and is amazed by the function e^x as it stays the same even after differentiation.
Just for fun, he tries to find out how large is the value of e^x. He is able to see only 10 digits in his calculator so he wants you to answer his endless list of queries for different values of x.... | {
"input": [],
"output": []
} | {
"input": [
"3\n1\n10\n101"
],
"output": [
"1\n5\n44"
]
} | {
"input": [],
"output": []
} |
cteams | The executive chef is trying to bring some competitive spirit into his kitchen. He wants to split the chefs into two teams based on their age - he'll form the young and the old team. To make it fair, he will split them evenly or give the young team one person advantage when there is an odd number of chefs. Ages of all ... | {
"input": [],
"output": []
} | {
"input": [
"5\n2 3\n1 7\n5 5\n3 1\n8 15"
],
"output": [
"3\n4\n5\n4\n9"
]
} | {
"input": [
"5\n2 3\n1 7\n4 5\n3 1\n8 15",
"5\n2 3\n1 7\n4 6\n4 1\n8 15",
"5\n1 3\n1 7\n4 6\n4 1\n8 25",
"5\n1 3\n1 8\n12 6\n4 1\n5 25",
"5\n1 3\n1 8\n12 6\n4 0\n5 25",
"5\n1 3\n1 8\n12 11\n4 0\n5 25",
"5\n0 3\n0 2\n12 11\n4 0\n5 25",
"5\n0 2\n0 2\n12 11\n4 0\n5 25",
"5\n0 2\n0 1\... |
hs08test | Pooja would like to withdraw X $US from an ATM. The cash machine will only accept the transaction if X is a multiple of 5, and Pooja's account balance has enough cash to perform the withdrawal transaction (including bank charges). For each successful withdrawal the bank charges 0.50 $US.
Calculate Pooja's account bal... | {
"input": [],
"output": []
} | {
"input": [
"42 120.00",
"30 120.00",
"300 120.00"
],
"output": [
"120.00\n",
"89.50\n",
"120.00\n"
]
} | {
"input": [
"54 120.00",
"90 120.00",
"20 120.00",
"35 120.00",
"25 120.00",
"10 120.00",
"50 120.00",
"70 120.00",
"0 120.00",
"85 120.00",
"5 120.00",
"95 120.00",
"65 120.00",
"55 120.00",
"75 120.00",
"15 120.00",
"110 120.00",
"80 120.00",
... |
moves | Given a square table sized NxN (3 ≤ N ≤ 5,000; rows and columns are indexed from 1) with a robot on it. The robot has a mission of moving from cell (1, 1) to cell (N, N) using only the directions "right" or "down". You are requested to find the number of different ways for the robot using exactly K turns (we define a "... | {
"input": [],
"output": []
} | {
"input": [
"4 2\n4 3\n5 3\n0 0"
],
"output": [
"4\n8\n18"
]
} | {
"input": [
"2 2\n4 3\n5 3\n0 0",
"2 2\n5 3\n5 3\n0 0",
"2 1\n4 3\n5 3\n0 0",
"2 1\n4 2\n5 3\n0 0",
"2 2\n5 5\n5 2\n0 0",
"2 1\n3 2\n5 3\n0 0",
"2 2\n5 0\n5 3\n0 0",
"2 1\n4 6\n5 3\n0 0",
"2 2\n0 5\n5 3\n0 0",
"2 1\n5 5\n5 2\n0 0",
"2 2\n3 2\n5 3\n0 0",
"2 1\n4 12\n5 3... |
resn05 | Let G(S) denote the sum of the elements of set S and F(n) be the sum of G(s) for all subsets of the set consisting of the first n natural numbers.
For example, F(3) = (1) + (2) + (3) + (1 + 2) + (1 + 3) + (2 + 3) + (1 + 2 + 3) = 24.
Given n, calculate F(1) + F(2) + ... + F(n).
Input
The first line contains the ... | {
"input": [],
"output": []
} | {
"input": [
"3\n1\n2\n3"
],
"output": [
"1\n7\n31\n"
]
} | {
"input": [
"3\n1\n2\n1",
"3\n2\n2\n1",
"3\n2\n2\n2",
"3\n1\n2\n2",
"3\n1\n2\n5",
"3\n1\n1\n1",
"3\n2\n2\n4",
"3\n1\n4\n2",
"3\n1\n1\n5",
"3\n1\n1\n2",
"3\n1\n2\n4",
"3\n1\n1\n6",
"3\n3\n2\n1",
"3\n2\n2\n3",
"3\n1\n2\n6",
"3\n1\n2\n7",
"3\n2\n2\n8",... |
twonim | Nim is a well-known combinatorial game, based on removing stones from piles. In this problem, we'll deal with a similar game, which we'll call Dual Nim. The rules of this game are as follows:
Initially, there are N piles of stones, numbered 1 through N. The i-th pile contains ai stones.
The players take alternate turn... | {
"input": [],
"output": []
} | {
"input": [
"3\n4\n1 2 4 8\n3\n2 3 3\n5\n3 3 3 3 3"
],
"output": [
"First\nSecond\nSecond\n"
]
} | {
"input": [
"3\n4\n1 2 4 8\n3\n2 3 3\n5\n1 3 3 3 3",
"3\n4\n1 2 4 2\n3\n3 3 3\n5\n1 3 2 3 3",
"3\n4\n1 2 8 7\n3\n2 1 3\n5\n1 3 1 3 3",
"3\n4\n1 2 15 7\n3\n2 1 3\n5\n1 3 1 3 0",
"3\n4\n1 2 4 8\n3\n3 3 3\n5\n1 3 3 3 3",
"3\n4\n1 2 4 8\n3\n3 3 3\n5\n1 3 1 3 3",
"3\n4\n1 2 4 12\n3\n2 3 3\n5\n... |
1175_D. Array Splitting | You are given an array a_1, a_2, ..., a_n and an integer k.
You are asked to divide this array into k non-empty consecutive subarrays. Every element in the array should be included in exactly one subarray. Let f(i) be the index of subarray the i-th element belongs to. Subarrays are numbered from left to right and from... | {
"input": [],
"output": []
} | {
"input": [
"4 1\n3 -1 6 0\n",
"7 6\n-3 0 -1 -2 -2 -4 -1\n",
"5 2\n-1 -2 5 -4 8\n"
],
"output": [
"8",
"-45",
"15"
]
} | {
"input": [
"4 1\n3 -2 6 0\n",
"5 2\n-1 -2 5 -7 8\n",
"4 1\n3 -2 1 0\n",
"5 2\n0 -2 5 -7 8\n",
"4 1\n2 -2 1 0\n",
"5 2\n0 -2 1 -7 8\n",
"5 2\n0 -2 2 -7 8\n",
"5 2\n0 -2 2 -7 14\n",
"5 2\n0 -2 4 -7 14\n",
"5 2\n0 0 4 -7 14\n",
"5 2\n0 0 4 -5 14\n",
"5 2\n1 0 4 -5 14\n",... |
1252_I. Mission Possible | Allen, a government secret service, has been assigned to infiltrate a mafia secret base to uncover crucial information regarding the mafia's operations.
The secret base is a rectangular bounded by (x_L,y_L), (x_L,y_R), (x_R,y_L), and (x_R,y_R) in a Cartesian coordinate system where x_L < x_R and y_L < y_R. There are N... | {
"input": [],
"output": []
} | {
"input": [
"3 2 2 50 26\n4 14\n48 14\n15 13 7\n36 16 6\n46 18 3\n",
"1 0 0 1000 1000\n100 501\n900 501\n500 251 250\n"
],
"output": [
"\n2\n13.25 23.1234567\n36.591003 7.1\n",
"\n0\n"
]
} | {
"input": [],
"output": []
} |
1276_B. 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 3\n1 2\n2 3\n4 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\n4 5\n5 6\n6 7\n7 5\n4 5 2 3\n1 2\n2 3\n3 4\n4 1\n4 2\n4 3 4 1\n1 2\n2 3\n4 1\n",
"3\n7 7 6 5\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 5\n4 5 2 3\n1 2\n1 3\n4 4\n4 1... |
1424_E. 5G Antenna Towers | After making a strategic plan with carriers for expansion of mobile network throughout the whole country, the government decided to cover rural areas with the last generation of 5G network.
Since 5G antenna towers will be built in the area of mainly private properties, the government needs an easy way to find informat... | {
"input": [],
"output": []
} | {
"input": [
"10 10 3\n4 2 2 3 2 3 3 2 3\n3 3.5 2 4.5 2 4.5 3\n4 7 8 7.5 8.5 8 8 7.5 9\n5\n2 3.5 0.5\n3.3 2 0.4\n5 2.5 0.5\n7.5 8.5 0.5\n3 7 0.5\n"
],
"output": [
"1.00000000 1 0\n1.50000000 2 0 1\n0.50000000 1 1\n0.25000000 1 2\n0.00000000 0\n"
]
} | {
"input": [
"10 10 3\n4 2 2 3 2 3 3 2 3\n3 3.5 2 4.5 2 4.5 3\n4 7 8 7.5 8.5 8 8 7.5 9\n5\n2 4.481016822762688 0.5\n3.3 2 0.4\n5 2.5 0.5\n7.5 8.5 0.5\n3 7 0.5\n",
"10 10 3\n4 2 2 3 2 3 1 2 3\n3 3.5 2 4.5 2 4.5 3\n4 7 8 7.5 8.5 8 8 7.5 9\n5\n2 4.481016822762688 1.2440888369004288\n3.3 2 0.4\n5 2.5 0.5\n7.5 8.5... |
bajirao-returns | Bajirao's city has N X N police stations P(i,j) (1 ≤ i ≤ N, 1 ≤ j ≤ N) arranged in an N X N square matrix format. Bajirao is a really hardworking police officer and wants to solve all the pending cases of all the police stations in his city. However, the Police Commissioner (his senior) is not allowing him to do so due... | {
"input": [],
"output": []
} | {
"input": [
"3\n1 2 3\n3 1 2\n1 4 1\n\nSAMPLE"
],
"output": [
"10"
]
} | {
"input": [
"3\n1 0 3\n3 1 2\n1 4 1\n\nSAMPLE",
"3\n1 -1 3\n5 1 0\n0 4 1\n\nSAMPLE",
"3\n1 0 5\n5 1 0\n0 4 1\n\nSQMALE",
"3\n1 0 2\n5 0 0\n0 4 1\n\nSQMALE",
"3\n1 0 2\n9 1 0\n0 4 1\n\nSQMALE",
"3\n2 0 4\n9 1 0\n0 4 1\n\nLQMASE",
"3\n2 0 4\n9 1 0\n1 8 1\n\nLMQASE",
"3\n4 0 4\n1 1 0\n2 ... |
have-a-nice-day | A fashion show rates participants according to their level of hotness. Two different fashion shows were organized, one for men and the other for women. A date for the third is yet to be decided ;) .
Now the results of both fashion shows are out. The participants of both the fashion shows have decided to date each othe... | {
"input": [],
"output": []
} | {
"input": [
"2\n2\n1 1\n3 2\n3\n2 3 2\n1 3 2\n\nSAMPLE"
],
"output": [
"5\n15\n"
]
} | {
"input": [
"2\n2\n1 1\n3 2\n3\n2 3 2\n1 6 2\n\nSAMPLE",
"2\n2\n0 1\n3 2\n3\n2 3 2\n1 6 2\n\nSBMPLE",
"2\n2\n0 1\n3 2\n3\n2 3 2\n1 11 2\n\nSBMPLE",
"2\n2\n0 1\n3 2\n3\n1 3 2\n1 11 2\n\nSBMPLE",
"2\n2\n1 1\n3 2\n3\n2 3 2\n1 3 4\n\nSAMPLE",
"2\n2\n1 2\n3 2\n3\n2 3 2\n1 6 2\n\nSAMPLE",
"2\n2... |
problem-7 | The main building of the nation is developing complex patterns as each day progresses.
The task is to find the number of three sided closed figures on the nth day.
(Input – n
Output – number of triangles)
SAMPLE INPUT
2
SAMPLE OUTPUT
5 | {
"input": [],
"output": []
} | {
"input": [
"2\n\nSAMPLE"
],
"output": [
"5\n"
]
} | {
"input": [
"2\n\nELPMAS",
"2\n\nSAMQLE",
"2\n\nSAQMLE",
"2\n\nSAQELM",
"2\n\nSAQELN",
"2\n\nNLEQAS",
"2\n\nNLEQ@S",
"2\n\nNLEQ?S",
"2\n\nS?QELN",
"2\n\nS?QDLN",
"2\n\nNLDQ?S",
"2\n\nNLEQ?R",
"2\n\nNLFQ?R",
"2\n\nQLFN?R",
"2\n\nQLEN?R",
"2\n\nELQN?R",
... |
xenny-and-bitsums | Let f(x) represent the number of set bits (i.e. bit = 1) in the binary representation of non-negative integer x.
For e.g. f(3) = 2, since 3 is represented as '11' in binary.
Xenny's friend Xynazog gave him the following task:
Given two non-negative integers A and B, find the sum of f(x) for all x in range [A, B] (A a... | {
"input": [],
"output": []
} | {
"input": [
"1\n1 3\n\nSAMPLE"
],
"output": [
"4"
]
} | {
"input": [
"1\n1 1\n\nSAMPLE",
"1\n2 1\n\nASMPLE",
"1\n4 1\n\nELPMSA",
"1\n4 0\n\nELPMSA",
"1\n1 3\n\nELPMAS",
"1\n1 2\n\nASMPLE",
"1\n3 1\n\nASMPLE",
"1\n1 4\n\nELPAMT",
"1\n3 0\n\nASNPLE",
"1\n1 6\n\nELPALT",
"1\n1 5\n\nELPALT",
"1\n2 3\n\nASMPLE",
"1\n6 0\n\nEL... |
p02642 AtCoder Beginner Contest 170 - Not Divisible | Given is a number sequence A of length N.
Find the number of integers i \left(1 \leq i \leq N\right) with the following property:
* For every integer j \left(1 \leq j \leq N\right) such that i \neq j , A_j does not divide A_i.
Constraints
* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* 1 \leq A_... | {
"input": [],
"output": []
} | {
"input": [
"5\n24 11 8 3 16",
"10\n33 18 45 28 8 19 89 86 2 4",
"4\n5 5 5 5"
],
"output": [
"3",
"5",
"0"
]
} | {
"input": [
"5\n24 11 8 1 16",
"10\n33 4 45 28 8 19 89 86 2 4",
"10\n33 4 26 28 8 19 89 86 2 4",
"4\n6 8 5 5",
"5\n31 11 8 2 16",
"10\n11 2 41 17 8 25 89 28 3 4",
"10\n11 2 41 17 8 33 89 28 3 4",
"5\n31 11 1 1 16",
"10\n11 2 41 17 8 25 89 28 3 7",
"4\n5 8 5 5",
"5\n31 11 8... |
p02772 AtCoder Beginner Contest 155 - Papers Please | You are an immigration officer in the Kingdom of AtCoder. The document carried by an immigrant has some number of integers written on it, and you need to check whether they meet certain criteria.
According to the regulation, the immigrant should be allowed entry to the kingdom if and only if the following condition is... | {
"input": [],
"output": []
} | {
"input": [
"5\n6 7 9 10 31",
"3\n28 27 24"
],
"output": [
"APPROVED",
"DENIED"
]
} | {
"input": [
"5\n6 7 3 10 31",
"3\n28 27 47",
"5\n6 7 4 10 31",
"3\n28 15 47",
"5\n0 7 4 10 31",
"3\n2 15 47",
"5\n-1 7 4 10 31",
"3\n2 26 47",
"5\n1 7 4 10 31",
"3\n4 26 47",
"5\n1 1 4 10 31",
"3\n4 3 47",
"5\n1 1 4 5 31",
"3\n4 5 47",
"5\n1 1 4 5 32",
... |
p02907 AtCoder Grand Contest 038 - Gachapon | Snuke found a random number generator. It generates an integer between 0 and N-1 (inclusive). An integer sequence A_0, A_1, \cdots, A_{N-1} represents the probability that each of these integers is generated. The integer i (0 \leq i \leq N-1) is generated with probability A_i / S, where S = \sum_{i=0}^{N-1} A_i. The pr... | {
"input": [],
"output": []
} | {
"input": [
"3\n1 3\n2 2\n3 1",
"2\n1 1\n1 1",
"15\n29 3\n78 69\n19 15\n82 14\n9 120\n14 51\n3 7\n6 14\n28 4\n13 12\n1 5\n32 30\n49 24\n35 23\n2 9"
],
"output": [
"971485877",
"3",
"371626143"
]
} | {
"input": [
"3\n1 3\n1 2\n3 1",
"15\n29 2\n78 69\n19 15\n82 14\n9 120\n14 51\n3 7\n6 14\n28 4\n13 12\n1 5\n32 30\n49 24\n35 23\n2 9",
"15\n29 3\n78 57\n19 15\n82 14\n9 120\n14 51\n3 7\n6 14\n28 4\n13 12\n1 5\n32 30\n49 24\n35 23\n2 9",
"3\n1 5\n1 2\n3 1",
"15\n29 3\n78 57\n19 15\n82 14\n9 120\n14... |
p03042 AtCoder Beginner Contest 126 - YYMM or MMYY | You have a digit sequence S of length 4. You are wondering which of the following formats S is in:
* YYMM format: the last two digits of the year and the two-digit representation of the month (example: `01` for January), concatenated in this order
* MMYY format: the two-digit representation of the month and the last t... | {
"input": [],
"output": []
} | {
"input": [
"1905",
"1700",
"0112"
],
"output": [
"YYMM",
"NA",
"AMBIGUOUS"
]
} | {
"input": [
"3367",
"2206",
"1291",
"1211",
"2352",
"2340",
"2265",
"2454",
"2024",
"2460",
"1567",
"4353",
"1471",
"1974",
"6757",
"2050",
"1838",
"3984",
"5490",
"3454",
"1055",
"1701",
"6718",
"4177",
"3708",
"... |
p03184 Educational DP Contest - Grid 2 | There is a grid with H horizontal rows and W vertical columns. Let (i, j) denote the square at the i-th row from the top and the j-th column from the left.
In the grid, N Squares (r_1, c_1), (r_2, c_2), \ldots, (r_N, c_N) are wall squares, and the others are all empty squares. It is guaranteed that Squares (1, 1) and ... | {
"input": [],
"output": []
} | {
"input": [
"5 2 2\n2 1\n4 2",
"100000 100000 1\n50000 50000",
"3 4 2\n2 2\n1 4",
"5 5 4\n3 1\n3 5\n1 3\n5 3"
],
"output": [
"0",
"123445622",
"3",
"24"
]
} | {
"input": [
"5 2 0\n2 1\n4 2",
"100000 100000 1\n50000 23836",
"3 4 2\n2 2\n2 4",
"100000 100000 1\n50000 25003",
"3 4 2\n2 2\n2 8",
"5 4 2\n2 1\n4 2",
"3 4 2\n2 3\n1 4",
"5 5 4\n3 1\n3 5\n1 3\n4 3",
"9 2 0\n2 1\n4 2",
"100000 100000 1\n50000 29731",
"8 2 0\n2 1\n4 4",
... |
p03331 AtCoder Grand Contest 025 - Digits Sum | Takahashi has two positive integers A and B.
It is known that A plus B equals N. Find the minimum possible value of "the sum of the digits of A" plus "the sum of the digits of B" (in base 10).
Constraints
* 2 ≤ N ≤ 10^5
* N is an integer.
Input
Input is given from Standard Input in the following format:
N
Outp... | {
"input": [],
"output": []
} | {
"input": [
"15",
"100000"
],
"output": [
"6",
"10"
]
} | {
"input": [
"22",
"37",
"36",
"3",
"5",
"7",
"26",
"38",
"58",
"78",
"57",
"11",
"24",
"199",
"59",
"178",
"389",
"89",
"99",
"499",
"789",
"1697",
"795",
"989",
"4",
"13",
"18",
"102",
"140",
"234... |
p03490 AtCoder Regular Contest 087 - FT Robot | A robot is put at the origin in a two-dimensional plane. Initially, the robot is facing in the positive x-axis direction.
This robot will be given an instruction sequence s. s consists of the following two kinds of letters, and will be executed in order from front to back.
* `F` : Move in the current direction by dis... | {
"input": [],
"output": []
} | {
"input": [
"TF\n1 0",
"FF\n1 0",
"FFTTFF\n0 0",
"FTFFTFFF\n-2 -2",
"TTTT\n1 0",
"FTFFTFFF\n4 2"
],
"output": [
"No",
"No",
"Yes",
"Yes",
"No",
"Yes"
]
} | {
"input": [
"UF\n1 0",
"FT\n1 0",
"FF\n1 -1",
"FFTTFF\n1 0",
"FTFFTFFF\n-2 -3",
"TTTT\n1 -1",
"FTFFTFFF\n4 0",
"UF\n1 -1",
"FF\n0 -1",
"FFTTFF\n2 0",
"FTFFTFFF\n-2 -1",
"TTTT\n1 -2",
"FTFFTFFF\n4 1",
"FF\n1 -2",
"FFTTFF\n2 -1",
"FTFFTFFF\n-1 -1",
"T... |
p03652 AtCoder Grand Contest 018 - Sports Festival | Takahashi is hosting an sports meet. There are N people who will participate. These people are conveniently numbered 1 through N. Also, there are M options of sports for this event. These sports are numbered 1 through M. Among these options, Takahashi will select one or more sports (possibly all) to be played in the ev... | {
"input": [],
"output": []
} | {
"input": [
"3 3\n2 1 3\n2 1 3\n2 1 3",
"4 5\n5 1 3 4 2\n2 5 3 1 4\n2 3 1 4 5\n2 5 4 3 1"
],
"output": [
"3",
"2"
]
} | {
"input": [
"2 5\n5 1 3 4 2\n2 5 3 1 4\n2 3 1 4 5\n2 5 4 3 1",
"2 3\n2 1 3\n2 1 3\n2 1 3",
"2 5\n5 1 3 4 2\n2 5 3 1 4\n2 3 1 6 5\n2 5 4 3 1",
"2 5\n5 1 3 4 2\n2 5 3 1 4\n2 3 1 6 7\n2 5 4 3 1",
"2 5\n5 1 3 4 2\n2 5 3 1 4\n2 0 1 4 5\n2 5 4 3 1",
"2 5\n5 1 3 4 2\n2 5 3 1 4\n2 3 1 4 5\n2 5 5 3 1"... |
p03808 AtCoder Grand Contest 010 - Boxes | There are N boxes arranged in a circle. The i-th box contains A_i stones.
Determine whether it is possible to remove all the stones from the boxes by repeatedly performing the following operation:
* Select one box. Let the box be the i-th box. Then, for each j from 1 through N, remove exactly j stones from the (i+j)-... | {
"input": [],
"output": []
} | {
"input": [
"4\n1 2 3 1",
"5\n6 9 12 10 8",
"5\n4 5 1 2 3"
],
"output": [
"NO",
"YES",
"YES"
]
} | {
"input": [
"4\n2 2 3 1",
"5\n6 11 12 10 8",
"5\n4 5 2 2 3",
"4\n2 2 3 2",
"5\n6 16 12 10 8",
"5\n4 5 3 2 3",
"4\n2 1 3 2",
"5\n6 26 12 10 8",
"5\n5 5 3 2 3",
"4\n4 1 3 2",
"5\n12 26 12 10 8",
"5\n5 5 3 1 3",
"4\n4 1 3 0",
"5\n12 6 12 10 8",
"5\n5 9 3 1 3",... |
p03976 Kyoto University Programming Contest 2016 - Problem Committee | > Kyoto University Programming Contest is a programming contest voluntarily held by some Kyoto University students. This contest is abbreviated as Kyoto University Programming Contest and called KUPC.
>
> source: Kyoto University Programming Contest Information
The problem-preparing committee met to hold this year's K... | {
"input": [],
"output": []
} | {
"input": [
"9 3\nAPPLE\nANT\nATCODER\nBLOCK\nBULL\nBOSS\nCAT\nDOG\nEGG",
"3 2\nKU\nKYOUDAI\nKYOTOUNIV"
],
"output": [
"3",
"0"
]
} | {
"input": [
"9 3\nAPPLE\nANT\nATCODER\nBLOCK\nBULL\nBOSS\nCAT\nGOD\nEGG",
"3 2\nUK\nKYOUDAI\nKYOTOUNIV",
"3 4\nUK\nKYOVDAI\nKYOTOUNIV",
"9 3\nAPPLE\nBNT\nATCODER\nBLOCK\nBULL\nBOSS\nCTA\nDOG\nEGG",
"9 1\nELQPA\nUNB\nATCODER\nLCOLB\nKLUB\nOSSB\nTCA\nGCO\nGGE",
"9 2\nLAPPE\nBNT\nRCDOETA\nKCOLC\... |
p00065 Trading | There is data that records the customer number of the business partner and the trading date on a monthly basis. Please create a program that reads this month's data and last month's data and outputs the customer number of the company with which you have transactions and the number of transactions for two consecutive mo... | {
"input": [],
"output": []
} | {
"input": [
"123,10\n56,12\n34,14\n\n123,3\n56,4\n123,5"
],
"output": [
"56 2\n123 3"
]
} | {
"input": [
"123,10\n56,12\n35,14\n\n123,3\n56,4\n123,5",
"123,10\n56,12\n45,13\n\n113,4\n56,4\n123,5",
"132,10\n56,12\n45,13\n\n113,4\n56,4\n123,5",
"123,10\n51,62\n34,14\n\n124,3\n56,4\n123,5",
"123,10\n65,12\n34,14\n\n123,3\n56,4\n123,5",
"123,10\n57,12\n35,14\n\n123,3\n57,4\n123,5",
"... |
p00197 Greatest Common Divisor: Euclidean Algorithm | The greatest common divisor is an indispensable element in mathematics handled on a computer. Using the greatest common divisor can make a big difference in the efficiency of the calculation. One of the algorithms to find the greatest common divisor is "Euclidean algorithm". The flow of the process is shown below.
<im... | {
"input": [],
"output": []
} | {
"input": [
"1071 1029\n5 5\n0 0"
],
"output": [
"21 3\n5 1"
]
} | {
"input": [
"1071 1029\n5 3\n0 0",
"1251 1029\n5 3\n0 0",
"1251 1802\n5 3\n0 0",
"1071 446\n5 3\n0 0",
"1071 2\n5 3\n0 0",
"1071 1029\n2 3\n0 0",
"1251 3458\n5 3\n0 0",
"826 2\n5 3\n0 0",
"1251 3458\n10 3\n0 0",
"1164 1029\n4 3\n0 0",
"1251 3458\n10 6\n0 0",
"835 2\n5 ... |
p00351 Evening | At dusk in AIZU, it is crowded with tourists who hold their smartphones in the west sky and stop. AIZU is a big city with countless buildings, and in the west sky where the valleys of the buildings are long, the silhouette of the buildings and the spectacular view of the sunlight leaking from them spreads out.
Accordi... | {
"input": [],
"output": []
} | {
"input": [
"0 2",
"3 2\n-2 1 1\n-1 1 2\n0 2 1"
],
"output": [
"0.00000000",
"1.25065774"
]
} | {
"input": [
"2 2\n-2 1 1\n-1 1 2\n0 2 1",
"2 2\n-4 1 1\n-1 1 2\n0 2 1",
"3 2\n-4 1 1\n-1 1 2\n0 2 1",
"3 2\n-4 1 1\n-1 1 2\n0 2 2",
"2 1\n-2 1 1\n-1 1 2\n0 2 1",
"2 2\n-4 1 1\n-2 1 2\n0 2 1",
"3 2\n-4 1 1\n-1 1 2\n0 2 3",
"2 2\n-4 1 1\n-4 1 2\n-1 2 1",
"3 2\n-4 1 2\n-1 1 4\n0 2 2"... |
p00547 Food stalls | problem
The city of IOI, where JOI lives, has a rectangular shape with H sections in the north-south direction and W sections in the east-west direction, and is divided into H x W sections. The i-th section from the north and the j-th section from the west are represented as (i, j). A large-scale festival is currently... | {
"input": [],
"output": []
} | {
"input": [
"5 5\n..483\n.59.9\n3.866\n79...\n4.8.."
],
"output": [
"20"
]
} | {
"input": [
"5 5\n..483\n.59/9\n3.866\n79...\n4.8..",
"5 5\n..438\n.59.8\n3.866\n78...\n4.8..",
"5 5\n..483\n.59/:\n3.866\n79...\n..84.",
"5 5\n..327\n.69/8\n3.866\n7.9..\n4.8..",
"5 5\n..438\n.59.9\n3.866\n.97..\n4.8..",
"5 5\n..438\n5.9.8\n3.866\n79...\n4.8..",
"5 5\n..583\n.59/9\n3.866... |
p00711 Red and Black | There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles.
Write a program to count the number of black tiles which he can r... | {
"input": [],
"output": []
} | {
"input": [
"6 9\n....#.\n.....#\n......\n......\n......\n......\n......\n@...#\n.#..#.\n11 9\n.#.........\n.#.#######.\n.#.#.....#.\n.#.#.###.#.\n.#.#..@#.#.\n.#.#####.#.\n.#.......#.\n.#########.\n...........\n11 6\n..#..#..#..\n..#..#..#..\n..#..#..###\n..#..#..#@.\n..#..#..#..\n..#..#..#..\n7 7\n..#.#..\n..#... | {
"input": [
"6 9\n....#.\n.....#\n......\n......\n......\n......\n......\n@...#\n.#..#.\n11 9\n.#.........\n.#.#######.\n.#.#.....#.\n.#.#.###.#.\n.#.#..@#.#.\n.#.#####.#.\n.#.......#.\n.#########.\n...........\n11 6\n..#..#..#..\n..#..#..#..\n..#..#..###\n..#..#..#@.\n..#..#..#..\n..#..#..#..\n7 7\n#.#....\n..#... |
p00850 Power Calculus | Starting with x and repeatedly multiplying by x, we can compute x31 with thirty multiplications:
x2 = x × x, x3 = x2 × x, x4 = x3 × x, ... , x31 = x30 × x.
The operation of squaring can appreciably shorten the sequence of multiplications. The following is a way to compute x31 with eight multiplications:
x2 = x × x, ... | {
"input": [],
"output": []
} | {
"input": [
"1\n31\n70\n91\n473\n512\n811\n953\n0"
],
"output": [
"0\n6\n8\n9\n11\n9\n13\n12"
]
} | {
"input": [
"1\n31\n99\n91\n473\n512\n811\n953\n0",
"1\n31\n134\n91\n473\n512\n811\n953\n0",
"1\n31\n134\n91\n40\n512\n811\n953\n0",
"1\n31\n134\n86\n40\n512\n811\n953\n0",
"1\n31\n70\n91\n473\n512\n11\n953\n0",
"1\n31\n99\n91\n473\n512\n326\n953\n0",
"1\n31\n134\n91\n473\n221\n811\n953\n... |
p00982 Twin Trees Bros. | Twin Trees Bros.
To meet the demand of ICPC (International Cacao Plantation Consortium), you have to check whether two given trees are twins or not.
<image>
Example of two trees in the three-dimensional space.
The term tree in the graph theory means a connected graph where the number of edges is one less than the nu... | {
"input": [],
"output": []
} | {
"input": [
"3\n0 0 0\n1 0 0\n3 0 0\n1 2\n2 3\n0 0 0\n0 2 2\n0 3 3\n4 5\n5 6"
],
"output": [
"1"
]
} | {
"input": [
"3\n0 0 0\n1 0 0\n3 0 0\n1 2\n2 3\n0 0 0\n1 2 2\n0 3 3\n4 5\n5 6",
"3\n0 0 0\n1 0 -1\n3 0 0\n1 2\n2 3\n0 0 0\n0 0 2\n0 3 3\n4 5\n5 6",
"3\n0 0 0\n1 0 0\n3 0 0\n1 2\n2 3\n0 1 0\n1 2 2\n0 3 3\n4 5\n5 6",
"3\n0 0 0\n1 -1 0\n3 0 0\n1 2\n2 3\n0 0 0\n0 2 2\n0 3 3\n4 5\n5 6",
"3\n0 0 0\n1 0 ... |
p01114 Equilateral Triangular Fence | Equilateral Triangular Fence
Ms. Misumi owns an orchard along a straight road. Recently, wild boars have been witnessed strolling around the orchard aiming at pears, and she plans to construct a fence around many of the pear trees.
The orchard contains n pear trees, whose locations are given by the two-dimensional Eu... | {
"input": [],
"output": []
} | {
"input": [
"4\n1\n0 1\n1 2\n-1 2\n2 1\n4\n1\n1 1\n2 2\n1 3\n1 4\n4\n1\n1 1\n2 2\n3 1\n4 1\n4\n1\n1 2\n2 1\n3 2\n4 2\n5\n2\n0 1\n0 2\n0 3\n0 4\n0 5\n6\n3\n0 2\n2 2\n1 1\n0 3\n2 3\n1 4\n0"
],
"output": [
"6.000000000000\n6.928203230276\n6.000000000000\n7.732050807569\n6.928203230276\n6.000000000000"
]
} | {
"input": [
"4\n1\n0 1\n1 2\n-1 2\n2 1\n4\n1\n1 1\n2 2\n1 3\n1 4\n4\n1\n1 1\n2 2\n3 1\n4 1\n4\n1\n1 2\n2 1\n3 2\n4 3\n5\n2\n0 1\n0 2\n0 3\n0 4\n0 5\n6\n3\n0 2\n2 2\n1 1\n0 3\n2 3\n1 4\n0",
"4\n1\n0 1\n1 2\n-1 2\n2 1\n4\n1\n1 1\n2 2\n1 3\n1 4\n4\n1\n1 1\n1 2\n3 1\n4 1\n4\n1\n1 2\n2 1\n3 2\n4 3\n5\n2\n0 1\n0 2... |
p01252 Alice and Bob | Alice and Bob are in love with each other, but they have difficulty going out on a date - Alice is a very busy graduate student at the ACM university.
For this reason, Bob came to the ACM university to meet her on a day. He tried to reach the meeting spot but got lost because the campus of the university was very larg... | {
"input": [],
"output": []
} | {
"input": [
"1\n3 3 7 7\n2 2 8 2\n2\n2 5 5 9\n6 1 9 5\n1 5 10 5\n2\n2 1 3 2\n2 3 3 4\n1 1 4 4\n1\n3 3 7 7\n1 5 9 5\n1\n3 3 7 7\n1 5 8 5\n1\n3 3 7 7\n1 5 10 5\n0"
],
"output": [
"0.000\n0.000\n0.000\n5.657\n6.406\n4.992"
]
} | {
"input": [
"1\n3 3 7 7\n2 2 8 2\n2\n2 5 5 9\n6 1 9 5\n1 5 10 3\n2\n2 1 3 2\n2 3 3 4\n1 1 4 4\n1\n3 3 7 7\n1 5 9 5\n1\n3 3 7 7\n1 5 8 5\n1\n3 3 7 7\n1 5 10 5\n0",
"1\n3 3 7 7\n2 2 8 2\n2\n2 5 5 9\n6 1 9 5\n1 5 10 3\n2\n2 1 3 2\n2 3 3 4\n1 1 4 4\n1\n3 3 7 7\n1 9 9 5\n1\n3 3 7 7\n1 5 8 5\n1\n3 3 7 7\n1 5 10 5\... |
p01413 Quest of Merchant | Training is indispensable for achieving good results at ICPC. Rabbit wants to win at ICPC, so he decided to practice today as well.
Today's training is to gain the power of business by running around the city and conducting trade.
I want to earn as much money as possible for future training.
In this world, roads in ... | {
"input": [],
"output": []
} | {
"input": [
"2 3 100 20\nvim 10 10\nemacs 5 10\nvstudio 65 100\n2 1 6\nemacs 4\nvstudio 13\n3 -3 0\nvim 5\nemacs 9\nvstudio 62",
"2 2 100 20\nalfalfa 10 10\ncarrot 5 10\n1 1 6\ncarrot 4\n1 -3 0\nalfalfa 5"
],
"output": [
"183",
"170"
]
} | {
"input": [
"2 3 100 10\nvim 10 10\nemacs 5 10\nvstudio 65 100\n2 1 6\nemacs 4\nvstudio 13\n3 -3 0\nvim 5\nemacs 9\nvstudio 62",
"2 2 100 20\nalfalfa 10 10\ncarrot 5 10\n1 1 6\ncarrot 4\n1 -3 0\nalfalfa 10",
"2 3 100 10\nvim 10 10\nemacs 5 18\nvstudio 65 100\n2 1 6\nemacs 4\nvstudio 13\n3 -3 0\nvim 5\nem... |
p01567 Presentation | You are a researcher investigating algorithms on binary trees. Binary tree is a data structure composed of branch nodes and leaf nodes. Every branch nodes have left child and right child, and each child is either a branch node or a leaf node. The root of a binary tree is the branch node which has no parent.
You are pr... | {
"input": [],
"output": []
} | {
"input": [
"((()(()()))((()(()()))()))",
"(()())",
"(((()())(()()))(()()))",
"((()())(((()())(()()))()))"
],
"output": [
"3",
"0",
"4",
"3"
]
} | {
"input": [],
"output": []
} |
p01729 Air Pollution | In 20XX, the owners of the ICPC (Ikuta's Computer Pollutes Community) shopping district were suffering from air pollution. In order to regain the vitality of the past, the cleanliness of the atmosphere must be kept above a certain level.
The shops in the shopping district are lined up in a row and are numbered from 1 ... | {
"input": [],
"output": []
} | {
"input": [
"3\n3 -1 4\n2 1 3",
"4\n3 -1 -1 3\n1 1 1 1",
"3\n3 -1 4\n2 1 5"
],
"output": [
"1",
"3",
"-1"
]
} | {
"input": [
"3\n3 -1 4\n2 1 6",
"3\n3 -1 6\n1 1 5",
"3\n1 2 2\n1 0 0",
"4\n3 -1 -2 3\n1 1 1 1",
"3\n3 -1 4\n1 1 5",
"3\n3 -1 4\n1 1 6",
"3\n3 0 4\n1 1 6",
"3\n0 -1 6\n1 1 5",
"3\n3 0 4\n1 0 6",
"3\n0 -1 6\n1 1 3",
"3\n4 0 4\n1 0 6",
"3\n0 0 6\n1 1 3",
"3\n4 0 4\n2 ... |
p01867 AddMul | Problem statement
Jota knows only the characters from `a` to` z` and the addition symbol `+`. Jota has an older sister, Tachiko. In addition to that, Tatsuko knows multiplication `*`, parentheses `(`, `)`, and integers (numbers) between `1` and` 9`. However, I don't know how to use multiple parentheses and how to mult... | {
"input": [],
"output": []
} | {
"input": [
"5\na+a+a"
],
"output": [
"3"
]
} | {
"input": [
"5\nb+a+a",
"5\nb+b+b",
"5\na+a+b",
"5\na+b+b",
"5\nb+b+a",
"5\nc+a+a",
"5\nb+a+b",
"5\nc+a+b",
"5\na+c+b",
"5\nd+a+a",
"5\na+c+a",
"5\na+a+d",
"5\nb+a+c",
"5\na+a+c",
"5\nc+a+c",
"5\na+b+a",
"5\nd+a+b",
"5\na+b+c",
"5\nc+b+b",
... |
p02004 GuruGuru | You are playing a game called Guru Guru Gururin. In this game, you can move with the vehicle called Gururin. There are two commands you can give to Gururin: 'R' and 'L'. When 'R' is sent, Gururin rotates clockwise by 90 degrees. Otherwise, when 'L' is sent, Gururin rotates counterclockwise by 90 degrees.
During the ga... | {
"input": [],
"output": []
} | {
"input": [
"LR",
"RRRRLLLLRRRR",
"RLLRLLLLRRRLLLRRR",
"RRLRRLRRRRLRRLRRRRLRRLRRRRLRRLRR"
],
"output": [
"0",
"2",
"0",
"4"
]
} | {
"input": [
"RL",
"RLLRRLLLRRRLLLLRR",
"QL",
"RLLRRLLMRRRLLLLRR",
"LQ",
"KR",
"KQ",
"QK",
"RK",
"SK",
"KS",
"RJ",
"QJ",
"QI",
"PI",
"PJ",
"JP",
"JQ",
"JO",
"OJ",
"OK",
"KO",
"PK",
"KP",
"IQ",
"JR",
"IR",
"... |
p02148 Tousa Tree | Problem
You were asked by your friend Tousa the day before yesterday. He wants to decorate a tree with an arithmetic progression and use it for a birthday party, but the tree is too big to be used alone. Therefore, he wants you, an excellent programmer, to write a program that efficiently decorates a tree with arithme... | {
"input": [],
"output": []
} | {
"input": [
"5 6\n1 0\n2 0\n3 2\n4 1\n1 1 4 0 4\n0 4 1\n1 3 0 7 3\n0 2 2\n1 4 1 8 0\n0 4 2",
"3 3\n0 2\n1 2\n1 1 0 0 1\n0 0 2\n0 0 1"
],
"output": [
"4\n10\n43",
"3\n3"
]
} | {
"input": [
"5 6\n1 0\n2 0\n3 2\n4 1\n1 1 4 0 4\n0 4 1\n1 3 0 7 3\n0 2 2\n1 4 1 8 0\n0 4 1",
"5 6\n1 0\n2 0\n3 2\n4 1\n1 1 4 0 4\n0 4 1\n1 3 0 7 3\n0 3 2\n1 4 1 8 0\n0 4 1",
"5 6\n1 0\n2 0\n3 2\n4 1\n1 1 4 0 4\n0 4 1\n1 3 0 7 3\n0 2 2\n1 4 1 8 1\n0 4 2",
"3 3\n0 2\n1 2\n1 1 0 1 1\n0 0 2\n0 0 1",
... |
p02289 Priority Queue | A priority queue is a data structure which maintains a set $S$ of elements, each of with an associated value (key), and supports the following operations:
* $insert(S, k)$: insert an element $k$ into the set $S$
* $extractMax(S)$: remove and return the element of $S$ with the largest key
Write a program which perfo... | {
"input": [],
"output": []
} | {
"input": [
"insert 8\ninsert 2\nextract\ninsert 10\nextract\ninsert 11\nextract\nextract\nend"
],
"output": [
"8\n10\n11\n2"
]
} | {
"input": [
"insert 8\ninsert 1\nextract\ninsert 10\nextract\ninsert 11\nextract\nextract\nend",
"insert 9\ninsert 2\nextract\ninsert 10\nextract\ninsert 11\nextract\nextract\nend",
"insert 8\ninsert 2\nextract\ninsert 16\nextract\ninsert 11\nextract\nextract\nend",
"insert 8\ninsert 1\nextract\ninse... |
p02436 Queue | Queue is a container of elements that are inserted and deleted according to FIFO (First In First Out).
For $n$ queues $Q_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations.
* enqueue($t$, $x$): Insert an integer $x$ to $Q_t$.
* front($t$): Report the value which should be deleted next from $Q_t... | {
"input": [],
"output": []
} | {
"input": [
"3 9\n0 0 1\n0 0 2\n0 0 3\n0 2 4\n0 2 5\n1 0\n1 2\n2 0\n1 0"
],
"output": [
"1\n4\n2"
]
} | {
"input": [
"3 9\n0 1 1\n0 0 2\n0 0 3\n0 2 4\n0 2 5\n1 0\n1 2\n2 0\n1 0",
"3 9\n0 1 1\n0 0 2\n0 0 3\n0 2 6\n0 2 5\n1 0\n1 2\n2 0\n1 0",
"3 9\n0 1 1\n0 0 2\n0 1 3\n0 2 6\n0 2 5\n1 0\n1 2\n2 0\n1 0",
"3 9\n0 1 1\n0 0 2\n0 1 3\n0 2 6\n0 2 5\n1 1\n1 2\n2 0\n1 0",
"3 9\n0 1 1\n0 0 2\n0 1 3\n0 0 6\n0 2... |
approx | Chef has recently learnt some new facts about the famous number π. For example, he was surprised that ordinary fractions are sometimes used to represent this number approximately. For example, 22/7, 355/113 or even 103993/33102.
Soon, by calculating the value of 22/7 and 355/113 on paper Chef became quite disappointed ... | {
"input": [],
"output": []
} | {
"input": [
"3\n0\n6\n20"
],
"output": [
"3\n3.141592\n3.14159265301190260407\n"
]
} | {
"input": [
"3\n1\n6\n20",
"3\n2\n6\n20",
"3\n0\n8\n20",
"3\n0\n9\n20",
"3\n1\n9\n20",
"3\n0\n13\n20",
"3\n0\n13\n1",
"3\n1\n13\n1",
"3\n1\n13\n0",
"3\n1\n0\n0",
"3\n1\n1\n0",
"3\n2\n1\n0",
"3\n2\n1\n1",
"3\n0\n1\n1",
"3\n1\n1\n1",
"3\n1\n1\n2",
"3\... |
cieldist | In Wolf town there are 2 big markets S and T. The distance between these markets is D. Chef Ciel would like to run 2 restaurants in Wolf town, where the first restaurant will be supplied by the market S and the second one will be supplied by the market T. The markets run delivery service without charge within some dist... | {
"input": [],
"output": []
} | {
"input": [
"4\n15 15 50\n15 15 18\n43 88 200\n2013 2013 2013"
],
"output": [
"20.0\n0\n69.0\n0\n"
]
} | {
"input": [
"4\n15 15 50\n15 15 18\n43 88 200\n2013 1560 2013",
"4\n2 15 50\n15 15 18\n43 88 200\n2013 1560 2013",
"4\n2 25 50\n15 15 28\n43 88 200\n2013 1798 2013",
"4\n2 25 50\n15 12 28\n43 88 200\n2013 1798 2013",
"4\n2 25 50\n15 12 28\n43 88 200\n2715 1798 211",
"4\n2 25 50\n15 12 28\n11 ... |
etmx07 | Mirrored Strings
Davy Jones needs to conquer a ship for his pirates. But the only rule he has to follow is to conquer only those ships whose names are partially mirrored at the end.
For Example: If a ship's name is 'abxyzba' then he can conquer the ship because the string has mirrored string at the beginning and at th... | {
"input": [],
"output": []
} | {
"input": [
"abXYZba",
"codechefdoc"
],
"output": [
"ab",
"cod"
]
} | {
"input": [],
"output": []
} |
lapin | Lapindrome is defined as a string which when split in the middle, gives two halves having the same characters and same frequency of each character. If there are odd number of characters in the string, we ignore the middle character and check for lapindrome. For example gaga is a lapindrome, since the two halves ga and ... | {
"input": [],
"output": []
} | {
"input": [
"6\ngaga\nabcde\nrotor\nxyzxy\nabbaab\nababc"
],
"output": [
"YES\nNO\nYES\nYES\nNO\nNO\n"
]
} | {
"input": [
"6\ngaga\nabcde\nrotor\nxyzxy\nabbbab\nababc",
"6\ngaga\nabcde\nrosor\nxyzxz\nabbbab\nababc",
"6\ngaga\nedcba\nrotor\nxyzxy\nabbaab\nababc",
"6\ngaga\nabcde\nsotor\nxyzxy\nabbbab\nababc",
"6\ngaha\necdba\nrotor\nxy{xy\nabbaab\nababc",
"6\ngaga\nabcde\nrotos\nzyxxy\nabbbab\nabbac",... |
pcsc7 | Yesterday, the CS Club hosted a massive party that put all the frat parties to shame. Today, they have to clean up everything. They also have to restock the strategic supply of Mountain Dew. Phillip hates cleaning and wants to pick up the dew instead. He knows that they intend to distribute the chores by having eve... | {
"input": [],
"output": []
} | {
"input": [
"41 3"
],
"output": [
"31"
]
} | {
"input": [],
"output": []
} |
stem | Given n words w[1..n], which originate from the same stem (e.g. grace, graceful, disgraceful, gracefully), we are interested in the original stem. To simplify the problem, we define the stem as the longest consecutive substring that occurs in all the n words. If there are ties, we will choose the smallest one in the al... | {
"input": [],
"output": []
} | {
"input": [
"1\n4\ngrace graceful disgraceful gracefully"
],
"output": [
"grace\n"
]
} | {
"input": [
"1\n4\necarg graceful disgraceful gracefully",
"1\n4\necarg grbceful lufecargsid gracefully",
"1\n4\ngeacr graceful disgraceful gracefully",
"1\n4\necarg grbceful lufecargsid gradefulmy",
"1\n4\nfcgra grbcdful disgraceeul gracefvlmy",
"1\n4\ngrace gracefuk disgraceful gracefully",... |
1329_B. Dreamoon Likes Sequences | Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | {
"input": [],
"output": []
} | {
"input": [
"10\n1 1000000000\n2 999999999\n3 99999998\n4 9999997\n5 999996\n6 99995\n7 9994\n8 993\n9 92\n10 1\n"
],
"output": [
"1\n3\n5\n11\n17\n23\n29\n59\n89\n0\n"
]
} | {
"input": [
"10\n1 1000000000\n2 999999999\n3 170267273\n4 9999997\n5 999996\n6 99995\n7 9994\n8 993\n9 92\n10 1\n",
"10\n1 1000000000\n2 999999999\n3 170267273\n2 9999997\n5 999996\n6 99995\n7 9994\n8 993\n9 92\n10 1\n",
"10\n1 1000000000\n2 999999999\n3 60966517\n2 9999997\n5 999996\n6 99995\n7 14099\n... |
1508_A. Binary Literature | A bitstring is a string that contains only the characters 0 and 1.
Koyomi Kanou is working hard towards her dream of becoming a writer. To practice, she decided to participate in the Binary Novel Writing Contest. The writing prompt for the contest consists of three bitstrings of length 2n. A valid novel for the contes... | {
"input": [],
"output": []
} | {
"input": [
"2\n1\n00\n11\n01\n3\n011001\n111010\n010001\n"
],
"output": [
"\n010\n011001010\n"
]
} | {
"input": [
"2\n1\n00\n11\n01\n3\n001001\n111010\n010101\n",
"2\n1\n00\n11\n01\n3\n000001\n111110\n010101\n",
"2\n1\n00\n11\n01\n3\n000011\n111111\n010101\n",
"2\n1\n00\n11\n01\n3\n000011\n111011\n010101\n",
"2\n1\n00\n11\n01\n3\n000001\n111100\n010101\n",
"2\n1\n00\n11\n01\n3\n000011\n111001... |
1534_B. Histogram Ugliness | Little Dormi received a histogram with n bars of height a_1, a_2, …, a_n for Christmas. However, the more he played with his new histogram, the more he realized its imperfections, so today he wanted to modify it to his liking.
To modify the histogram, Little Dormi is able to perform the following operation an arbitrar... | {
"input": [],
"output": []
} | {
"input": [
"2\n4\n4 8 9 6\n6\n2 1 7 4 0 0\n"
],
"output": [
"\n17\n12\n"
]
} | {
"input": [
"2\n4\n8 8 9 6\n6\n2 1 7 4 0 0\n",
"2\n4\n8 8 9 8\n6\n2 0 7 4 0 0\n",
"2\n4\n3 8 14 6\n6\n2 1 7 4 0 0\n",
"2\n4\n3 8 14 6\n6\n2 0 7 4 0 0\n",
"2\n4\n3 8 1 6\n6\n2 0 7 4 0 0\n",
"2\n4\n8 8 9 8\n6\n2 1 2 4 0 0\n",
"2\n4\n3 8 1 6\n6\n3 0 7 4 0 0\n",
"2\n4\n3 8 9 6\n6\n2 1 7 0... |
cupcake-challenge-1 | Hansa did not have enough money to pay the bill of the party. Now she loves cupcakes (and can also eat any amount of it apparently), so she came up with a cupcake challenge. She challenges t people individually every time for the challenge. The task is as follows:
Given 3 baskets filled with known amount of cupcakes ... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 1 1\n1 2 3\n\nSAMPLE"
],
"output": [
"NO BILL\nBILL\n"
]
} | {
"input": [
"2\n1 2 1\n1 2 3\n\nSAMPLE",
"2\n0 2 1\n1 4 3\n\nELPMAS",
"2\n0 0 0\n-1 2 5\n\nLBMMES",
"2\n0 2 2\n-1 0 -1\n\nNACROO",
"2\n1 2 1\n1 2 3\n\nELPMAS",
"2\n0 2 1\n1 2 3\n\nELPMAS",
"2\n0 2 1\n1 4 6\n\nELPMAS",
"2\n-1 2 1\n1 4 6\n\nELPMAS",
"2\n-1 2 1\n1 3 6\n\nELPMAS",
... |
rhezo-and-big-powers-1 | Rhezo likes numbers of the form A^B. But computing A^B, for any 2 numbers A and B is a hard task for him. He would like you to help him out in this.
Input:
First line of input contains a single integer A. Second line contains the integer B.
Output:
Help Rhezo find A^B. As this number can be large, print it modulo 10^... | {
"input": [],
"output": []
} | {
"input": [
"4\n3\n\nSAMPLE"
],
"output": [
"64\n"
]
} | {
"input": [
"4\n5\n\nSAMPLE",
"4\n6\n\nSAMPLE",
"4\n9\n\nSAMPLE",
"4\n7\n\nSAMPLE",
"4\n12\n\nEKPMBT",
"4\n22\n\nELPMBT",
"4\n3\n\nELPNBT",
"4\n0\n\nELQNBS",
"4\n18\n\nSAMPLE",
"4\n8\n\nEKPMBT",
"4\n41\n\nELPMBT",
"4\n2\n\nELPNBS",
"4\n4\n\nRAMPLE",
"4\n15\n\nE... |
p02576 AtCoder Beginner Contest 176 - Takoyaki | Takahashi loves takoyaki - a ball-shaped snack.
With a takoyaki machine, he can make at most X pieces of takoyaki at a time, taking T minutes regardless of the number of pieces to make.
How long does it take to make N takoyaki?
Constraints
* 1 \leq N,X,T \leq 1000
* All values in input are integers.
Input
Input i... | {
"input": [],
"output": []
} | {
"input": [
"1000 1 1000",
"20 12 6"
],
"output": [
"1000000",
"12"
]
} | {
"input": [
"20 22 6",
"37 22 6",
"37 22 8",
"37 22 1",
"26 22 0",
"26 22 -1",
"26 11 -1",
"26 2 -1",
"26 4 -1",
"26 3 -1",
"1000 1 1100",
"37 17 6",
"36 11 -1",
"26 2 -2",
"47 4 -1",
"1010 1 1100",
"20 12 5",
"20 5 6",
"37 17 11",
"37 3... |
p02707 AtCoder Beginner Contest 163 - management | A company has N members, who are assigned ID numbers 1, ..., N.
Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number.
When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X.
You are given the information ... | {
"input": [],
"output": []
} | {
"input": [
"7\n1 2 3 4 5 6",
"5\n1 1 2 2",
"10\n1 1 1 1 1 1 1 1 1"
],
"output": [
"1\n1\n1\n1\n1\n1\n0",
"2\n2\n0\n0\n0",
"9\n0\n0\n0\n0\n0\n0\n0\n0\n0"
]
} | {
"input": [
"5\n1 1 2 3",
"7\n1 2 1 4 5 6",
"10\n1 1 1 1 1 2 1 1 1",
"5\n1 2 2 3",
"7\n1 2 3 4 5 4",
"5\n1 2 2 2",
"7\n1 2 2 4 5 6",
"10\n1 1 1 2 1 2 1 1 1",
"7\n1 2 3 4 5 2",
"7\n1 2 2 4 1 6",
"7\n1 2 3 6 5 2",
"7\n1 2 2 2 1 6",
"7\n1 2 3 5 5 6",
"5\n1 1 2 5",... |
p02836 AtCoder Beginner Contest 147 - Palindrome-philia | Takahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice.
Given is a string S. Find the minimum number of hugs needed to make S palindromic.
Constraints
* S is a string consisting of lowercase English ... | {
"input": [],
"output": []
} | {
"input": [
"abcdabc",
"redcoder",
"vvvvvv"
],
"output": [
"2",
"1",
"0"
]
} | {
"input": [
"aacdabc",
"redocder",
"vwwvvv",
"rdebrdeo",
"uuxxuu",
"wvvvvv",
"aacbadc",
"reeocddr",
"vvvvvw",
"cdabcaa",
"rddcoeer",
"vwvvvv",
"ccabcaa",
"rddboeer",
"aacbacc",
"rdeboder",
"vvvwwv",
"aaccacc",
"vvvwxv",
"aacc`cc",
"o... |
p02973 AtCoder Beginner Contest 134 - Sequence Decomposing | You are given a sequence with N integers: A = \\{ A_1, A_2, \cdots, A_N \\}. For each of these N integers, we will choose a color and paint the integer with that color. Here the following condition must be satisfied:
* If A_i and A_j (i < j) are painted with the same color, A_i < A_j.
Find the minimum number of col... | {
"input": [],
"output": []
} | {
"input": [
"4\n0\n0\n0\n0",
"5\n2\n1\n4\n5\n3"
],
"output": [
"4",
"2"
]
} | {
"input": [
"4\n0\n-1\n0\n0",
"4\n1\n0\n0\n0",
"5\n10\n-1\n1\n13\n3",
"5\n0\n0\n0\n0\n0",
"5\n1\n4\n5\n7\n14",
"5\n4\n1\n4\n5\n3",
"4\n1\n-1\n0\n0",
"5\n4\n1\n4\n9\n3",
"5\n7\n1\n4\n9\n3",
"4\n-1\n0\n0\n0",
"5\n12\n1\n4\n9\n3",
"4\n0\n0\n-1\n0",
"5\n12\n0\n4\n9\n3"... |
p03109 AtCoder Beginner Contest 119 - Still TBD | You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.)
Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
Constraints
* S is... | {
"input": [],
"output": []
} | {
"input": [
"2019/04/30",
"2019/11/01"
],
"output": [
"Heisei",
"TBD"
]
} | {
"input": [
"2019/03/30",
"2019/11/00",
"2019/04/20",
"2019/12/01",
"2019/14/20",
"2119/12/01",
"2019/24/10",
"1019/04/30",
"2119/10/01",
"2029/11/00",
"2029/24/10",
"2119/10/11",
"2029/10/00",
"2119/20/11",
"2029/10/01",
"2219/20/11",
"2209/20/11",... |
p03256 AtCoder Grand Contest 027 - ABland Yard | You are given an undirected graph consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition, each vertex has a label, `A` or `B`. The label of Vertex i is s_i. Edge i bidirectionally connects vertex a_i and b_i.
The phantom thief Nusook likes to choose some ... | {
"input": [],
"output": []
} | {
"input": [
"13 17\nBBABBBAABABBA\n7 1\n7 9\n11 12\n3 9\n11 9\n2 1\n11 5\n12 11\n10 8\n1 11\n1 8\n7 7\n9 10\n8 8\n8 12\n6 2\n13 11",
"2 3\nAB\n1 1\n1 2\n2 2",
"4 3\nABAB\n1 2\n2 3\n3 1",
"13 23\nABAAAABBBBAAB\n7 1\n10 6\n1 11\n2 10\n2 8\n2 11\n11 12\n8 3\n7 12\n11 2\n13 13\n11 9\n4 1\n9 7\n9 6\n8 13\... | {
"input": [
"13 17\nBBABBBAABABBA\n7 1\n7 9\n11 12\n3 9\n11 9\n2 1\n11 5\n12 11\n10 8\n1 11\n1 8\n7 7\n9 10\n8 8\n8 12\n6 2\n9 11",
"13 17\nBBABBBAABABBA\n7 1\n7 9\n11 12\n3 9\n11 9\n2 1\n11 5\n10 11\n10 8\n1 11\n1 8\n7 7\n9 10\n8 8\n8 12\n6 2\n9 11",
"4 3\nABAB\n1 1\n2 3\n3 1",
"13 17\nBBABBBAABABBA... |
p03409 AtCoder Beginner Contest 091 - 2D Plane 2N Points | On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i).
A red point and a blue point can form a friendly pair when, the x-coordinate of the red point is smaller than that of the blue point, an... | {
"input": [],
"output": []
} | {
"input": [
"2\n2 2\n3 3\n0 0\n1 1",
"5\n0 0\n7 3\n2 2\n4 8\n1 6\n8 5\n6 9\n5 4\n9 1\n3 7",
"5\n0 0\n1 1\n5 5\n6 6\n7 7\n2 2\n3 3\n4 4\n8 8\n9 9",
"3\n0 0\n1 1\n5 2\n2 3\n3 4\n4 5",
"3\n2 0\n3 1\n1 3\n4 2\n0 4\n5 5"
],
"output": [
"0",
"5",
"4",
"2",
"2"
]
} | {
"input": [
"2\n2 2\n3 5\n0 0\n1 1",
"5\n0 0\n7 3\n2 2\n4 8\n1 6\n8 5\n6 9\n5 4\n9 1\n2 7",
"5\n0 0\n1 1\n5 5\n6 6\n7 11\n2 2\n3 3\n4 4\n8 8\n9 9",
"3\n0 0\n1 1\n10 2\n2 3\n3 4\n4 5",
"5\n0 0\n4 1\n5 5\n6 6\n13 11\n2 2\n3 3\n2 4\n8 8\n9 16",
"2\n0 0\n6 -1\n0 0\n1 1",
"2\n2 2\n3 0\n0 0\n1 ... |
p03572 CODE FESTIVAL 2017 qual C - Three Gluttons | Three men, A, B and C, are eating sushi together. Initially, there are N pieces of sushi, numbered 1 through N. Here, N is a multiple of 3.
Each of the three has likes and dislikes in sushi. A's preference is represented by (a_1,\ ...,\ a_N), a permutation of integers from 1 to N. For each i (1 \leq i \leq N), A's i-t... | {
"input": [],
"output": []
} | {
"input": [
"3\n1 2 3\n2 3 1",
"9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6",
"6\n1 2 3 4 5 6\n2 1 4 3 6 5",
"3\n1 2 3\n1 2 3",
"6\n1 2 3 4 5 6\n6 5 4 3 2 1"
],
"output": [
"2",
"33600",
"80",
"0",
"160"
]
} | {
"input": [
"3\n1 2 3\n3 3 1",
"3\n1 2 0\n3 3 1",
"3\n1 1 0\n3 3 1",
"3\n1 2 3\n2 3 0",
"3\n1 2 3\n3 6 1",
"3\n0 2 0\n3 3 1",
"3\n2 2 3\n3 6 1",
"3\n2 2 3\n1 2 3",
"3\n1 2 0\n2 3 1",
"3\n1 2 1\n2 3 0",
"3\n1 0 3\n3 6 1",
"3\n0 6 0\n3 3 1",
"3\n1 2 0\n2 3 2",
"3... |
p03727 AtCoder Grand Contest 014 - Blue and Red Tree | There is a tree with N vertices numbered 1 through N. The i-th of the N-1 edges connects vertices a_i and b_i.
Initially, each edge is painted blue. Takahashi will convert this blue tree into a red tree, by performing the following operation N-1 times:
* Select a simple path that consists of only blue edges, and remo... | {
"input": [],
"output": []
} | {
"input": [
"5\n1 2\n2 3\n3 4\n4 5\n3 4\n2 4\n1 4\n1 5",
"6\n1 2\n3 5\n4 6\n1 6\n5 1\n5 3\n1 4\n2 6\n4 3\n5 6",
"3\n1 2\n2 3\n1 3\n3 2"
],
"output": [
"YES",
"NO",
"YES"
]
} | {
"input": [
"5\n1 2\n2 3\n3 2\n4 5\n3 4\n2 4\n1 4\n1 5",
"6\n1 2\n3 5\n4 6\n1 6\n5 2\n5 3\n1 4\n2 6\n4 3\n5 6",
"3\n1 0\n2 3\n1 3\n3 2",
"5\n1 2\n2 3\n3 2\n4 5\n3 4\n2 4\n1 3\n1 5",
"3\n1 0\n2 3\n1 5\n3 2",
"5\n1 2\n2 3\n3 0\n4 5\n3 4\n2 4\n1 3\n1 5",
"5\n1 2\n2 3\n5 0\n4 5\n3 4\n2 4\n1 3... |
p03891 CODE FESTIVAL 2016 Relay (Parallel) - Magic Square 2 | A 3×3 grid with a integer written in each square, is called a magic square if and only if the integers in each row, the integers in each column, and the integers in each diagonal (from the top left corner to the bottom right corner, and from the top right corner to the bottom left corner), all add up to the same sum.
... | {
"input": [],
"output": []
} | {
"input": [
"8\n3\n5",
"1\n1\n1"
],
"output": [
"8 3 4\n1 5 9\n6 7 2",
"1 1 1\n1 1 1\n1 1 1"
]
} | {
"input": [
"8\n0\n5",
"1\n0\n1",
"8\n-1\n5",
"1\n0\n2",
"1\n-1\n1",
"1\n-1\n2",
"1\n-1\n4",
"1\n0\n4",
"1\n1\n2",
"1\n-2\n2",
"1\n-2\n3",
"1\n-3\n3",
"1\n0\n3",
"8\n-1\n4",
"8\n0\n6",
"8\n-2\n5",
"1\n-2\n4",
"1\n-1\n3",
"1\n-1\n7",
"1\n... |
p04050 AtCoder Grand Contest 001 - Arrays and Palindrome | Snuke got a present from his mother on his birthday. The present was a pair of two sequences a and b, consisting of positive integers. They satisfied all of the following properties:
* The sum of all elements of a is N.
* The sum of all elements of b is N.
* Any string of length N that satisfies the following two cond... | {
"input": [],
"output": []
} | {
"input": [
"3 2\n2 1",
"55 10\n1 2 3 4 5 6 7 8 9 10",
"6 1\n6"
],
"output": [
"1 2\n1\n3",
"Impossible",
"6\n3\n1 2 3"
]
} | {
"input": [
"3 2\n2 0",
"55 10\n2 2 3 4 5 6 7 8 9 10",
"6 1\n3",
"1 1\n6",
"-1 1\n2 0",
"1 1\n12",
"6 2\n2 1",
"6 1\n5",
"0 2\n1 0",
"-1 2\n3 0",
"1 1\n7",
"1 1\n15",
"1 1\n1",
"3 2\n2 2",
"-1 1\n9",
"1 1\n4",
"1 2\n4",
"3 3\n2 1",
"6 1\n11"... |
p00129 Hide-and-Seek Supporting System | Taro is not good at hide-and-seek. As soon as you hide, you will find it, and it will be difficult to find the hidden child. My father, who couldn't see it, made an ultra-high performance location search system. You can use it to know exactly where your friends are, including your own. Once you become a demon, you can ... | {
"input": [],
"output": []
} | {
"input": [
"3\n6 6 3\n19 7 4\n21 8 1\n6\n5 4 2 11\n12 4 2 11\n11 9 2 11\n14 3 20 5\n17 9 20 5\n20 10 20 5\n0"
],
"output": [
"Safe\nSafe\nDanger\nSafe\nDanger\nSafe"
]
} | {
"input": [
"3\n6 6 3\n19 7 4\n21 8 1\n6\n5 4 2 11\n12 4 2 11\n11 9 2 11\n14 3 22 5\n17 9 20 5\n20 10 20 5\n0",
"3\n6 6 3\n19 7 6\n42 8 1\n6\n5 4 2 11\n12 4 2 11\n11 9 1 11\n14 3 22 5\n17 9 20 5\n20 10 20 5\n0",
"3\n6 6 3\n19 7 6\n42 8 1\n6\n5 4 2 11\n12 4 2 15\n11 9 1 11\n14 2 22 5\n17 9 20 5\n20 10 20 ... |
p00262 Triangle of Blocks | The following sorting operation is repeated for the stacked blocks as shown in Fig. A.
1. Stack all the bottom blocks (white blocks in Figure a) on the right edge (the remaining blocks will automatically drop one step down, as shown in Figure b).
2. If there is a gap between the blocks, pack it to the left to eliminat... | {
"input": [],
"output": []
} | {
"input": [
"6\n1 4 1 3 2 4\n5\n1 2 3 4 5\n10\n1 1 1 1 1 1 1 1 1 1\n9\n1 1 1 1 1 1 1 1 1\n12\n1 4 1 3 2 4 3 3 2 1 2 2\n1\n5050\n3\n10000 10000 100\n0"
],
"output": [
"24\n0\n10\n-1\n48\n5049\n-1"
]
} | {
"input": [
"6\n1 4 1 3 2 4\n5\n1 2 5 4 5\n10\n1 1 1 1 1 1 1 1 1 1\n9\n1 1 1 1 1 1 1 1 1\n12\n1 4 1 3 2 4 3 3 2 1 2 2\n1\n5050\n3\n10000 10000 100\n0",
"6\n1 4 1 3 2 4\n5\n1 2 5 4 5\n10\n1 1 1 1 1 1 1 1 1 1\n9\n1 1 1 1 1 1 1 1 1\n12\n1 4 1 3 2 4 3 1 2 1 2 2\n1\n5050\n3\n10000 10000 100\n0",
"6\n1 4 1 3 2... |
p00449 Boat Travel | problem
There are n islands in JOI, and each island is numbered from 1 to n. Currently, the JOI country is developing a route network connecting each island.
You work at a ticket center that handles ship tickets. There are many people in JOI who want to travel between islands by boat, as cheaply as possible, and they... | {
"input": [],
"output": []
} | {
"input": [
"3 8\n1 3 1 10\n0 2 3\n1 2 3 20\n1 1 2 5\n0 3 2\n1 1 3 7\n1 2 1 9\n0 2 3\n5 16\n1 1 2 343750\n1 1 3 3343\n1 1 4 347392\n1 1 5 5497\n1 2 3 123394\n1 2 4 545492\n1 2 5 458\n1 3 4 343983\n1 3 5 843468\n1 4 5 15934\n0 2 1\n0 4 1\n0 3 2\n0 4 2\n0 4 3\n0 5 3\n0 0"
],
"output": [
"-1\n15\n12\n5955\n... | {
"input": [
"3 8\n1 3 1 10\n0 2 3\n1 2 2 20\n1 1 2 5\n0 3 2\n1 1 3 7\n1 2 1 9\n0 2 3\n5 16\n1 1 2 343750\n1 1 3 3343\n1 1 4 347392\n1 1 5 5497\n1 2 3 123394\n1 2 4 545492\n1 2 5 458\n1 3 4 343983\n1 3 5 843468\n1 4 5 15934\n0 2 1\n0 4 1\n0 3 2\n0 4 2\n0 4 3\n0 5 3\n0 0",
"3 8\n1 3 1 10\n0 2 3\n1 2 2 20\n1 1 ... |
p00640 Distorted Love | Saying that it is not surprising that people want to know about their love, she has checked up his address, name, age, phone number, hometown, medical history, political party and even his sleeping position, every piece of his personal information. The word "privacy" is not in her dictionary. A person like her is calle... | {
"input": [],
"output": []
} | {
"input": [
"3\n800 600\nindex 1\n500 100 700 200 profile\nprofile 2\n100 100 400 200 index\n100 400 400 500 link\nlink 1\n100 100 300 200 index\n9\nclick 600 150\nshow\nclick 200 450\nshow\nback\nback\nshow\nforward\nshow\n0"
],
"output": [
"profile\nlink\nindex\nprofile"
]
} | {
"input": [
"3\n800 600\nindex 1\n842 100 700 200 profile\nprofile 2\n100 100 400 200 index\n100 400 400 500 link\nlink 1\n100 100 300 200 index\n9\nclick 600 150\nshow\nclick 200 450\nshow\nback\nback\nshow\nforward\nshow\n0",
"3\n800 600\nindex 1\n842 100 700 200 profile\nprofile 2\n100 100 400 200 index\n... |
p00783 Napoleon's Grumble | Legend has it that, after being defeated in Waterloo, Napoleon Bonaparte, in retrospect of his days of glory, talked to himself "Able was I ere I saw Elba." Although, it is quite doubtful that he should have said this in English, this phrase is widely known as a typical palindrome.
A palindrome is a symmetric characte... | {
"input": [],
"output": []
} | {
"input": [
"As the first man said to the\nfirst woman:\n\"Madam, I'm Adam.\"\nShe responded:\n\"Eve.\""
],
"output": [
"TOT\n\nMADAMIMADAM MADAM\nERE DED\nEVE"
]
} | {
"input": [
"As the first man said to thf\nfirst woman:\n\"Madam, I'm Adam.\"\nShe responded:\n\"Eve.\"",
"As teh first man said to htf\nfirst wonam:\n\"Madam, I'm Adam.\"\nShe responded:\n\"Eve.\"",
"As teh first man said to htf\nfirst wonam:\n\"Madam, I'm Adam.\"\nShe rfsponded:\n\".evE\"",
"As teh... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.