name stringlengths 2 112 | description stringlengths 29 13k | private_tests dict | public_tests dict | generated_tests dict |
|---|---|---|---|---|
p01699 Elevator Hall Number | Elevator hall number
JAG (Japanese Alumni Group) is a mysterious organization headquartered in a skyscraper somewhere in Tokyo. There are $ N $ elevators in operation in this building, and the $ i $ elevators stop on each floor from the $ low_i $ floor to the $ high_i $ floor ($ 1 \ le i \ le N $).
Mr. X, a new staff... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 11\n1 11\n3\n10 10\n2 2\n11 11\n4\n89 91\n1 12\n1 12\n89 91\n5\n1 8\n2 76\n10 19\n6 16\n33 42\n6\n10 59\n20 69\n30 79\n40 89\n50 99\n50 99\n0"
],
"output": [
"120\n1\n1278\n659520\n15625000000"
]
} | {
"input": [
"2\n1 11\n1 11\n3\n10 10\n2 2\n11 11\n4\n89 91\n1 12\n1 12\n89 91\n5\n1 8\n2 76\n10 19\n6 16\n33 42\n6\n10 59\n20 69\n30 79\n40 89\n50 99\n30 99\n0",
"2\n1 11\n1 11\n3\n10 10\n2 2\n11 11\n4\n89 91\n1 12\n1 12\n89 91\n5\n1 8\n2 76\n10 19\n6 16\n33 42\n6\n13 59\n20 69\n30 79\n40 89\n50 99\n30 99\n0... |
p01843 Campaign | E-Election campaign
Problem Statement
You are a supporter of Mr. X, a candidate for the next election. Mr. X is planning a street speech in front of the station and intends to give a speech in a place that can be seen by as many voters as possible.
The front of the station is given as a two-dimensional plane with $ ... | {
"input": [],
"output": []
} | {
"input": [
"1 2\n4\n5 5\n15 5\n15 15\n5 15\n0 10\n20 10"
],
"output": [
"2"
]
} | {
"input": [
"1 2\n4\n5 5\n15 5\n15 24\n5 15\n0 10\n20 10",
"1 3\n4\n10 6\n15 5\n15 24\n5 15\n0 10\n20 7",
"2 1\n4\n10 5\n29 1\n15 19\n5 20\n0 10\n20 7",
"2 4\n4\n10 5\n15 5\n15 24\n5 17\n0 10\n20 7",
"1 2\n4\n10 5\n15 5\n15 24\n5 15\n0 10\n20 10",
"1 2\n4\n10 5\n15 5\n15 24\n5 15\n0 10\n20 7"... |
p01979 Gochiusa-Number | problem
AOR Ika-chan, who loves feasts, defined "the number of feasts". A feast number is a natural number that includes "$ 51-3 $" in $ 10 $ decimal notation.
$? $ Can be any number from $ 0 $ to $ 9 $.
Find the number of feasts out of the natural numbers below $ N $.
input
$ N $
output
Output the number of fe... | {
"input": [],
"output": []
} | {
"input": [
"5124"
],
"output": [
"3"
]
} | {
"input": [
"2935",
"5957",
"5184",
"1221",
"2333",
"2926",
"3847",
"6645",
"2831",
"8530",
"6790",
"4280",
"6775",
"9020",
"10606",
"1384",
"1586",
"1157",
"286",
"525",
"287",
"81",
"162",
"2",
"1",
"4",
"8"... |
p02125 OOllOll | Problem
Let $ f (x) $ be the sum of each digit when the non-negative integer $ x $ is expressed in binary.
Given a positive integer $ N $, output the largest of $ f (0) $, $ f (1) $, ..., $ f (N) $.
Example of calculating the function $ f (5) $:
When 5 is expressed in binary, it is 101 and the sum of each digit is 1... | {
"input": [],
"output": []
} | {
"input": [
"2",
"9"
],
"output": [
"1",
"3"
]
} | {
"input": [
"14",
"22",
"41",
"70",
"6",
"1",
"170",
"264",
"585",
"1663",
"2604",
"5020",
"10830",
"18",
"21",
"37",
"36",
"11",
"19",
"10",
"5",
"12",
"4",
"75",
"3",
"39",
"13",
"17",
"120",
"8"... |
p02265 Doubly Linked List | Your task is to implement a double linked list.
Write a program which performs the following operations:
* insert x: insert an element with key x into the front of the list.
* delete x: delete the first element which has the key of x from the list. If there is not such element, you need not do anything.
* deleteFirst... | {
"input": [],
"output": []
} | {
"input": [
"9\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\ndeleteFirst\ndeleteLast",
"7\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5"
],
"output": [
"1",
"6 1 2"
]
} | {
"input": [
"7\ntresni 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5",
"7\ntresni 5\ninsert 2\ninsert 3\ninsert 2\ndelete 3\ninsert 6\ndelete 5",
"7\ntretni 5\ninsert 2\ninsers 3\ninsert 2\ndelete 3\ntresni 6\ndelete 5",
"9\ninsert 10\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\... |
p02413 Spreadsheet | Your task is to perform a simple table calculation.
Write a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.
Constraints
* 1 ≤ r, c ≤ 100
* 0 ≤ an element of the table ≤ 100
Input
In the first line, two ... | {
"input": [],
"output": []
} | {
"input": [
"4 5\n1 1 3 4 5\n2 2 2 4 5\n3 3 0 1 1\n2 3 4 4 6"
],
"output": [
"1 1 3 4 5 14\n2 2 2 4 5 15\n3 3 0 1 1 8\n2 3 4 4 6 19\n8 9 9 13 17 56"
]
} | {
"input": [
"4 5\n1 1 3 4 8\n2 2 2 4 5\n3 3 0 1 1\n2 3 4 4 6",
"4 5\n1 1 3 4 8\n2 2 2 4 5\n3 3 0 1 1\n2 3 4 8 6",
"4 5\n1 1 3 4 8\n2 2 2 4 5\n3 3 0 1 1\n2 6 4 8 6",
"4 5\n1 1 3 4 8\n2 2 2 4 5\n3 3 0 1 2\n2 6 4 8 6",
"4 5\n2 1 3 4 8\n2 2 2 4 5\n3 3 0 1 2\n2 6 4 8 6",
"4 5\n1 1 3 1 5\n2 2 2 4 5... |
cexp04 | WonderKing himself is a very genius in mathematics. One day when he was thinking, king got a wonderful idea – circular prime. A circular prime is a prime number with the property that the number generated at each intermediate step when cyclically permuting its (base 10) digits will be a prime. Simply if all the rotatio... | {
"input": [],
"output": []
} | {
"input": [
"5\n3\n113\n67\n9311\n19"
],
"output": [
"Yes\nYes\nNo\nYes\nNo"
]
} | {
"input": [],
"output": []
} |
delish | It's finally summer in Chefland! So our chef is looking forward to prepare some of the best "beat-the-heat" dishes to attract more customers. He summons the Wizard of Dessert to help him with one such dish.
The wizard provides the chef with a sequence of N ingredients where the i^th ingredient has a delish value of D[... | {
"input": [],
"output": []
} | {
"input": [
"2\n5\n1 2 3 4 5\n4\n1 1 -1 -1"
],
"output": [
"13\n4\n"
]
} | {
"input": [
"2\n5\n1 2 3 4 5\n4\n1 1 0 -1",
"2\n5\n1 2 3 6 5\n4\n1 1 0 -1",
"2\n5\n1 2 3 6 5\n4\n1 1 0 -2",
"2\n5\n1 2 3 4 5\n4\n1 1 -2 -1",
"2\n5\n1 2 3 6 6\n4\n1 1 0 -1",
"2\n5\n1 2 3 6 5\n4\n1 1 0 -3",
"2\n5\n1 2 4 4 5\n4\n1 1 -2 -1",
"2\n5\n1 2 3 6 8\n4\n1 1 0 -1",
"2\n5\n1 2 ... |
iitk1p05 | You are given a sequence of N integers, a[1], a[2], , , , a[N].
Find out the maximum possible average value of sub-sequences of array a.
Input
First line of the input contains a single integer T denoting number of test cases
For each test case, first line contains a single integer denoting N, the number of eleme... | {
"input": [],
"output": []
} | {
"input": [
"1\n5\n1 3 2 1 3"
],
"output": [
"3\n"
]
} | {
"input": [
"1\n5\n1 6 2 1 3",
"1\n5\n1 3 2 1 1",
"1\n5\n0 4 2 1 3",
"1\n5\n1 7 2 1 2",
"1\n5\n2 5 4 1 1",
"1\n5\n2 1 0 1 1",
"1\n5\n1 9 2 1 2",
"1\n5\n-2 8 2 2 3",
"1\n5\n1 14 4 1 4",
"1\n5\n0 13 2 2 2",
"1\n5\n-2 16 0 4 2",
"1\n5\n0 26 2 3 0",
"1\n5\n0 11 2 3 0",... |
nbsum | For Turbo C++ Users : Read the following document before attempting the question :
Problem Description
First question is easy to set you up with the online judge. You are given a number 'N'. You need to find the sum of first N terms of the series: 1 - 2 + 3 - 4 + 5 - 6 ...
Input
First line contains T, the number ... | {
"input": [],
"output": []
} | {
"input": [
"3\n3\n1\n2"
],
"output": [
"2\n1\n-1\n"
]
} | {
"input": [
"3\n0\n1\n2",
"3\n0\n0\n2",
"3\n0\n-1\n3",
"3\n0\n-2\n3",
"3\n0\n-2\n5",
"3\n0\n0\n5",
"3\n0\n-1\n0",
"3\n0\n-1\n1",
"3\n1\n0\n2",
"3\n1\n0\n4",
"3\n1\n0\n8",
"3\n2\n0\n8",
"3\n4\n-1\n8",
"3\n4\n-1\n15",
"3\n5\n-1\n15",
"3\n5\n-1\n5",
"3... |
rrmtrx2 | In every contest there should be an easy problem about matrices. December Cook-Off is not an exception.
Given a matrix A which consists of n rows and m columns, and contains integer numbers.
Consider every possible vector v of m elements, such that every 1 ≤ vi ≤ n.
Let value of the vector be product of all Avi, i (1 ... | {
"input": [],
"output": []
} | {
"input": [
"2 2\n1 2\n3 4"
],
"output": [
"24\n"
]
} | {
"input": [
"2 2\n1 3\n3 4",
"2 2\n1 3\n3 3",
"2 2\n1 3\n3 1",
"2 2\n1 3\n2 1",
"2 2\n1 3\n4 1",
"2 2\n1 6\n3 4",
"2 2\n0 3\n3 4",
"2 2\n1 3\n2 0",
"0 2\n1 3\n4 1",
"2 2\n0 1\n3 4",
"1 2\n1 3\n4 1",
"1 2\n2 3\n4 1",
"1 2\n2 2\n4 1",
"2 2\n2 2\n4 1",
"2 2\n0... |
words1 | Some of the secret doors contain a very interesting word puzzle. The team of
archaeologists has to solve it to open that doors. Because there is no
other way to open the doors, the puzzle is very important for us.
There is a large number of magnetic plates on every door. Every plate has one
word written on it. The p... | {
"input": [],
"output": []
} | {
"input": [
"3\n2\ndirecti\ncodechef\n3\nskenzo\nlogicboxes\norderbox\n2\nok\nok"
],
"output": [
"The door cannot be opened.\nOrdering is possible.\nThe door cannot be opened.\n"
]
} | {
"input": [
"3\n2\ndirecti\ncodechef\n3\nskenzo\nlogicboxes\norderbox\n2\nok\npk",
"3\n2\ndirecti\ncndechef\n3\nskenzo\nlogicboxes\norderbox\n2\nko\npk",
"3\n2\ndirecti\ncndechef\n3\nskenzp\nloghcboxes\norderbox\n2\nko\npk",
"3\n2\ndirecti\ncndechef\n3\nskenzp\nloghcboxes\norderbox\n2\nlo\npk",
"... |
1196_D2. RGB Substring (hard version) | The only difference between easy and hard versions is the size of the input.
You are given a string s consisting of n characters, each character is 'R', 'G' or 'B'.
You are also given an integer k. Your task is to change the minimum number of characters in the initial string s so that after the changes there will be ... | {
"input": [],
"output": []
} | {
"input": [
"3\n5 2\nBGGGG\n5 3\nRBRGR\n5 5\nBBBRR\n"
],
"output": [
"1\n0\n3\n"
]
} | {
"input": [
"3\n5 2\nBGGGG\n5 3\nRBRGR\n5 5\nBBRBR\n",
"3\n5 3\nBGGGG\n5 3\nRBRGR\n5 5\nBBBRR\n",
"3\n5 2\nBGGGG\n5 4\nRBRGR\n5 5\nBBRBR\n",
"3\n5 3\nBGGGG\n5 3\nRBRGR\n5 2\nBBBRR\n",
"3\n5 2\nBGGGG\n5 4\nRBRGR\n5 5\nBRBRB\n",
"3\n5 1\nBGGGG\n5 2\nRBRGR\n5 5\nBBRBR\n",
"3\n5 1\nBGGGG\n5 4... |
1237_B. Balanced Tunnel | Consider a tunnel on a one-way road. During a particular day, n cars numbered from 1 to n entered and exited the tunnel exactly once. All the cars passed through the tunnel at constant speeds.
A traffic enforcement camera is mounted at the tunnel entrance. Another traffic enforcement camera is mounted at the tunnel ex... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 2\n1 2\n",
"7\n5 2 3 6 7 1 4\n2 3 6 7 1 4 5\n",
"5\n3 5 2 1 4\n4 3 2 5 1\n"
],
"output": [
"0\n",
"6\n",
"2\n"
]
} | {
"input": [
"2\n1 2\n2 1\n",
"2\n0 2\n0 2\n",
"2\n2 1\n1 2\n",
"2\n0 1\n0 1\n",
"2\n2 1\n2 1\n"
],
"output": [
"1\n",
"0\n",
"1\n",
"0\n",
"0\n"
]
} |
1255_A. Changing Volume | Bob watches TV every day. He always sets the volume of his TV to b. However, today he is angry to find out someone has changed the volume to a. Of course, Bob has a remote control that can change the volume.
There are six buttons (-5, -2, -1, +1, +2, +5) on the control, which in one press can either increase or decrea... | {
"input": [],
"output": []
} | {
"input": [
"3\n4 0\n5 14\n3 9\n"
],
"output": [
"2\n3\n2\n"
]
} | {
"input": [
"3\n4 0\n5 14\n3 13\n",
"3\n4 0\n5 14\n3 2\n",
"3\n6 0\n5 14\n2 13\n",
"3\n4 0\n4 14\n0 2\n",
"3\n6 0\n2 8\n2 13\n",
"3\n2 0\n6 14\n0 1\n",
"3\n2 0\n6 25\n0 1\n",
"3\n6 -1\n6 8\n2 13\n",
"3\n2 -1\n6 25\n0 1\n",
"3\n6 -1\n6 8\n3 13\n",
"3\n2 -1\n6 25\n1 1\n",
... |
1383_B. GameGame | Koa the Koala and her best friend want to play a game.
The game starts with an array a of length n consisting of non-negative integers. Koa and her best friend move in turns and each have initially a score equal to 0. Koa starts.
Let's describe a move in the game:
* During his move, a player chooses any element of... | {
"input": [],
"output": []
} | {
"input": [
"3\n3\n1 2 2\n3\n2 2 3\n5\n0 0 0 2 2\n",
"4\n5\n4 1 5 1 3\n4\n1 0 1 6\n1\n0\n2\n5 4\n"
],
"output": [
"WIN\nLOSE\nDRAW\n",
"WIN\nWIN\nDRAW\nWIN\n"
]
} | {
"input": [
"3\n3\n1 2 2\n3\n2 2 3\n5\n0 0 1 2 2\n",
"3\n3\n1 2 2\n3\n3 2 3\n5\n0 0 0 2 2\n",
"3\n3\n1 2 3\n3\n2 2 3\n5\n0 0 0 2 2\n",
"4\n5\n4 1 5 1 3\n4\n1 0 1 12\n1\n0\n2\n5 4\n",
"3\n3\n1 2 2\n3\n2 2 4\n5\n0 0 1 2 2\n",
"3\n3\n1 2 2\n3\n3 2 5\n5\n0 0 0 2 2\n",
"4\n5\n4 1 5 1 4\n4\n1 0... |
1425_H. Huge Boxes of Animal Toys | Chaneka has a hobby of playing with animal toys. Every toy has a different fun value, a real number. Chaneka has four boxes to store the toys with specification:
* The first box stores toys with fun values in range of (-∞,-1].
* The second box stores toys with fun values in range of (-1, 0).
* The third box s... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 2 0 1\n0 1 0 0\n"
],
"output": [
"Ya Ya Tidak Tidak \nTidak Ya Tidak Tidak \n"
]
} | {
"input": [
"2\n2 2 0 1\n0 1 0 0\n",
"2\n1 2 -1 1\n0 1 0 0\n",
"2\n2 1 0 1\n0 1 0 1\n",
"2\n2 1 1 -1\n1 1 0 0\n",
"2\n4 0 1 1\n0 0 1 0\n",
"2\n4 0 0 1\n0 0 1 0\n",
"2\n4 0 0 1\n0 1 1 0\n",
"2\n1 2 0 1\n0 2 0 0\n",
"2\n0 2 0 1\n0 1 0 1\n",
"2\n9 1 1 1\n1 1 2 0\n",
"2\n2 2 1... |
1472_E. Correct Placement | Polycarp has invited n friends to celebrate the New Year. During the celebration, he decided to take a group photo of all his friends. Each friend can stand or lie on the side.
Each friend is characterized by two values h_i (their height) and w_i (their width). On the photo the i-th friend will occupy a rectangle h_i ... | {
"input": [],
"output": []
} | {
"input": [
"4\n3\n3 4\n5 4\n3 3\n3\n1 3\n2 2\n3 1\n4\n2 2\n3 1\n6 3\n5 4\n4\n2 2\n2 3\n1 1\n4 4\n"
],
"output": [
"\n-1 3 -1 \n-1 -1 -1 \n-1 -1 2 2 \n3 3 -1 3 \n"
]
} | {
"input": [
"4\n3\n3 4\n5 4\n3 3\n3\n1 3\n2 2\n3 1\n4\n2 2\n3 1\n6 5\n5 4\n4\n2 2\n2 3\n1 1\n4 4\n",
"4\n3\n6 4\n5 4\n3 3\n3\n1 3\n2 2\n3 0\n4\n2 2\n3 1\n6 5\n5 4\n4\n2 2\n2 3\n1 1\n4 4\n",
"4\n3\n3 4\n5 4\n3 3\n3\n1 3\n0 2\n3 0\n4\n2 2\n3 1\n6 5\n3 4\n4\n2 2\n2 3\n1 1\n4 4\n",
"4\n3\n3 4\n5 4\n3 3\n... |
factorial-again-1 | Kate has finally calmed down and decides to forgive Little Deepu, but she won't forgive him just like that. She agrees to forgive him on the grounds that he can solve a mathematical question for her.
She gives Deepu a large number N and a prime number P and asks him to calculate ((3*N)! / (3!^N) )%P.Your task is to he... | {
"input": [],
"output": []
} | {
"input": [
"2\n3 11\n2 11\n\nSAMPLE"
],
"output": [
"8\n9"
]
} | {
"input": [
"2\n3 11\n2 11\n\nSALPLE",
"2\n3 11\n2 2\n\nSALPLE",
"2\n3 13\n2 11\n\nSALPLE",
"2\n3 11\n2 7\n\nSAMPME",
"2\n4 13\n2 11\n\nSALPLE",
"2\n3 11\n2 13\n\nSAMPME",
"2\n0 11\n2 13\n\nSAMPME",
"2\n1 11\n2 11\n\nSAMPLE",
"2\n5 11\n2 11\n\nSALPLE",
"2\n1 11\n2 2\n\nSALPLE"... |
how-many-prime | This is a fact for almost all the students out there that Mathematics subject is a very fearful subject for them.
And no wonder this fact is also true for our friend Primo. But to challenge his fear he went to the Mathe-Matica Town for his summer vacations.
In Mathe-Matica town every person is assigned a Friend Score... | {
"input": [],
"output": []
} | {
"input": [
"3\n10\n100\n1000\n\nSAMPLE"
],
"output": [
"3 7\n47 53\n491 509"
]
} | {
"input": [
"3\n12\n100\n1000\n\nSAMPLE",
"3\n12\n100\n1100\n\nSAMPLE",
"3\n12\n110\n1100\n\nSAMPLE",
"3\n20\n110\n1100\n\nSAMPLE",
"3\n20\n111\n1100\n\nSAMPLE",
"3\n25\n111\n1100\n\nSAMPLE",
"3\n25\n110\n1100\n\nSANPLE",
"3\n36\n110\n1100\n\nSANPLE",
"3\n36\n100\n1100\n\nSANPLE",... |
nikhil-and-matrice-1 | Nikhil got to know about what is a matrice. He made several patterns using 1-d and 2-d matrices. One of which was his favorite pattern. Your task is to right a code for his favorite pattern.
NOTE :- To understand his favorite pattern see the sample output
Input:-
First line of code takes number of test cases 'N' as ... | {
"input": [],
"output": []
} | {
"input": [
"1\n3\n\nSAMPLE"
],
"output": [
"123\n894\n765"
]
} | {
"input": [
"1\n6\n\nSAMPLE",
"1\n8\n\nELQMSA",
"1\n9\n\nELQMSA",
"1\n2\n\nELQMSA",
"1\n3\n\nASMQLE",
"1\n1\n\nSAMQLE",
"1\n12\n\nELQMSA",
"1\n4\n\nASMQLE",
"1\n5\n\nDKLQSA",
"1\n10\n\nDKLRSA",
"1\n18\n\nASMQLE",
"1\n7\n\nDKLQSA",
"1\n17\n\nDKLRSA",
"1\n14\n\nA... |
shil-and-beautiful-matrix | During his interview, Shil came across a very difficult problem. The problem is as follows:
A matrix V consisting of N rows and M columns is called beautiful if and only if it satisfies the following two conditions:
1) Every cell of the matrix contains distinct natural number less or equal to N*M.
2) For any two... | {
"input": [],
"output": []
} | {
"input": [
"2 2\n\nSAMPLE"
],
"output": [
"4"
]
} | {
"input": [],
"output": []
} |
the-ghost-open | PandeyG, a brilliant tennis player, decided to start a tournament in his colony. Now, since PandeyG is overly optimistic and ambitious - he tries to lure in as many people as he can from his colony for them to participate in his very own knockout type tennis tournament. What he fails to realize that, to have a knockout... | {
"input": [],
"output": []
} | {
"input": [
"2\n7\n3\n\nSAMPLE"
],
"output": [
"6\n2\n"
]
} | {
"input": [
"2\n7\n2\n\nSAMPLE",
"2\n7\n4\n\nSAMPLE",
"2\n10\n4\n\nSAMPLE",
"2\n6\n4\n\nSAMPLE",
"2\n6\n5\n\nSAMPLE",
"2\n10\n5\n\nSAMPLE",
"2\n10\n1\n\nASMPLE",
"2\n12\n1\n\nELPMSA",
"2\n20\n1\n\nELPMSA",
"2\n9\n1\n\nDKPMSA",
"2\n5\n1\n\nDKPMSA",
"2\n9\n2\n\nDKPARM",
... |
p02659 AtCoder Beginner Contest 169 - Multiplication 3 | Compute A \times B, truncate its fractional part, and print the result as an integer.
Constraints
* 0 \leq A \leq 10^{15}
* 0 \leq B < 10
* A is an integer.
* B is a number with two digits after the decimal point.
Input
Input is given from Standard Input in the following format:
A B
Output
Print the answer as ... | {
"input": [],
"output": []
} | {
"input": [
"1000000000000000 9.99",
"1 0.01",
"198 1.10"
],
"output": [
"9990000000000000",
"0",
"217"
]
} | {
"input": [
"1000000000000001 9.99",
"2 0.01",
"74 1.10",
"1000000000000101 9.99",
"1000001000000000 9.99",
"1010000000000101 9.99",
"1010000000100101 9.99",
"1000000001000000 9.99",
"1000010000000001 9.99",
"1000010100000001 9.99",
"1000000100000000 9.99",
"10 1.10",
... |
p02788 AtCoder Beginner Contest 153 - Silver Fox vs Monster | Silver Fox is fighting with N monsters.
The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the health of H_i.
Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all mo... | {
"input": [],
"output": []
} | {
"input": [
"9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5",
"3 3 2\n1 2\n5 4\n9 2",
"3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000"
],
"output": [
"5",
"2",
"3000000000"
]
} | {
"input": [
"9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 0",
"3 3 2\n1 4\n5 4\n9 2",
"3 0 1\n77888184 1000000000\n100000000 1000000000\n200000000 1000000000",
"3 0 1\n86580931 1000000000\n100000000 1000001000\n200000000 1000000000",
"2 3 1\n1 1\n5 6\n9 2",
"2 0 1\n1 1\n5 6\n9 2",
"2 ... |
p02924 AtCoder Beginner Contest 139 - ModSum | For an integer N, we will choose a permutation \\{P_1, P_2, ..., P_N\\} of \\{1, 2, ..., N\\}.
Then, for each i=1,2,...,N, let M_i be the remainder when i is divided by P_i.
Find the maximum possible value of M_1 + M_2 + \cdots + M_N.
Constraints
* N is an integer satisfying 1 \leq N \leq 10^9.
Input
Input is giv... | {
"input": [],
"output": []
} | {
"input": [
"13",
"2",
"1"
],
"output": [
"78",
"1",
"0"
]
} | {
"input": [
"21",
"3",
"4",
"30",
"6",
"0",
"-1",
"8",
"-4",
"9",
"15",
"14",
"16",
"17",
"11",
"10",
"7",
"-17",
"25",
"-19",
"-12",
"29",
"-27",
"36",
"-23",
"-18",
"-25",
"-32",
"-51",
"-11",
... |
p03059 AtCoder Beginner Contest 125 - Biscuit Generator | A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation.
Find the total number of biscuits produced within T + 0.5 seconds after activation.
Constraints
* All values in input are integers.
* 1 \leq A, B, T \le... | {
"input": [],
"output": []
} | {
"input": [
"3 5 7",
"20 20 19",
"3 2 9"
],
"output": [
"10",
"0",
"6"
]
} | {
"input": [
"20 20 8",
"4 2 9",
"8 2 9",
"2 -2 6",
"2 -3 6",
"2 -3 10",
"2 -4 10",
"2 -8 10",
"2 -8 13",
"2 -7 13",
"2 -7 14",
"1 -7 14",
"1 -7 15",
"1 -7 3",
"38 1 -1",
"38 2 -1",
"1 -1 -1",
"3 5 11",
"3 2 13",
"3 -8 10",
"1 -8 13",... |
p03203 AtCoder Grand Contest 029 - Grid game | Takahashi and Aoki will play a game using a grid with H rows and W columns of square cells. There are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i). Here, we represent the cell at the i-th row and j-th column (1 \leq i \leq H, 1 \leq j \leq W) by (i,j). There is no obstacle at (1,1), and there is a piece ... | {
"input": [],
"output": []
} | {
"input": [
"3 3 1\n3 2",
"100000 100000 0",
"10 10 14\n4 3\n2 2\n7 3\n9 10\n7 7\n8 1\n10 10\n5 4\n3 4\n2 8\n6 4\n4 4\n5 8\n9 2"
],
"output": [
"2",
"100000",
"6"
]
} | {
"input": [
"3 6 1\n3 2",
"100001 100000 0",
"10 10 14\n4 3\n2 2\n7 3\n9 10\n7 9\n8 1\n10 10\n5 4\n3 4\n2 8\n6 4\n4 4\n5 8\n9 2",
"100101 100000 0",
"10 10 14\n4 3\n2 1\n7 3\n9 10\n7 9\n8 1\n10 10\n5 4\n3 4\n2 8\n6 4\n4 4\n5 8\n9 2",
"110101 100000 0",
"110111 100000 0",
"010101 11100... |
p03350 AtCoder Grand Contest 024 - Simple Subsequence Problem | You are given a set S of strings consisting of `0` and `1`, and an integer K.
Find the longest string that is a subsequence of K or more different strings in S. If there are multiple strings that satisfy this condition, find the lexicographically smallest such string.
Here, S is given in the format below:
* The data... | {
"input": [],
"output": []
} | {
"input": [
"4 6\n1\n01\n1011\n10111010\n1101110011111101",
"2 5\n0\n11\n1111",
"3 4\n1\n01\n1011\n01001110"
],
"output": [
"100",
"",
"10"
]
} | {
"input": [
"3 4\n2\n01\n1011\n01001110",
"4 6\n1\n01\n1111\n10111010\n1101110011111101",
"3 2\n1\n01\n1011\n01001110",
"3 0\n1\n3\n1111\n01000110",
"3 4\n2\n01\n1001\n01001110",
"4 1\n1\n01\n1101\n01011110\n1101110011011100",
"4 1\n1\n01\n1111\n00111110\n0101110011111101",
"3 3\n2\n0... |
p03510 Code Festival Team Relay (Parallel) - Capture | In a long narrow forest stretching east-west, there are N beasts. Below, we will call the point that is p meters from the west end Point p. The i-th beast from the west (1 ≤ i ≤ N) is at Point x_i, and can be sold for s_i yen (the currency of Japan) if captured.
You will choose two integers L and R (L ≤ R), and throw ... | {
"input": [],
"output": []
} | {
"input": [
"4\n1 100\n3 200\n999999999999999 150\n1000000000000000 150",
"5\n10 2\n40 5\n60 3\n70 4\n90 1",
"5\n10 20\n40 50\n60 30\n70 40\n90 10"
],
"output": [
"299",
"5",
"90"
]
} | {
"input": [
"4\n1 100\n3 200\n999999999999999 44\n1000000000000000 150",
"5\n10 20\n40 50\n60 35\n70 40\n90 10",
"4\n1 101\n3 200\n999999999999999 61\n1000000000000000 150",
"5\n19 28\n40 50\n60 35\n70 40\n90 10",
"4\n1 101\n5 200\n789952814361385 49\n1000000000000000 150",
"4\n1 101\n7 200\n... |
p03671 AtCoder Beginner Contest 066 - ringring | Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for each hand.
The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the m... | {
"input": [],
"output": []
} | {
"input": [
"10000 10000 10000",
"700 600 780"
],
"output": [
"20000",
"1300"
]
} | {
"input": [
"10000 10100 10000",
"55 600 780",
"10000 00100 10000",
"95 600 780",
"95 652 780",
"11000 10100 10000",
"11000 10110 10000",
"57 652 734",
"11000 10111 10000",
"88 652 734",
"11000 10111 10100",
"88 102 734",
"11000 10111 10101",
"11000 10111 11101... |
p03826 AtCoder Beginner Contest 052 - Two Rectangles | There are two rectangles. The lengths of the vertical sides of the first rectangle are A, and the lengths of the horizontal sides of the first rectangle are B. The lengths of the vertical sides of the second rectangle are C, and the lengths of the horizontal sides of the second rectangle are D.
Print the area of the r... | {
"input": [],
"output": []
} | {
"input": [
"100 600 200 300",
"3 5 2 7"
],
"output": [
"60000",
"15"
]
} | {
"input": [
"100 600 200 6",
"3 3 2 7",
"100 480 244 6",
"0 3 0 7",
"100 169 362 6",
"100 311 362 6",
"000 311 50 6",
"110 311 50 6",
"110 222 182 6",
"-1 1 -1 10",
"111 222 182 6",
"-2 1 -1 10",
"101 222 131 6",
"-2 2 1 10",
"001 222 109 9",
"000 222 1... |
p03993 CODE FESTIVAL 2016 qual A - Friendly Rabbits | There are N rabbits, numbered 1 through N.
The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i.
For a pair of rabbits i and j (i<j), we call the pair (i,j) a friendly pair if the following condition is met.
* Rabbit i likes rabbit j and rabbit j likes rabbit i.
Calculate ... | {
"input": [],
"output": []
} | {
"input": [
"3\n2 3 1",
"5\n5 5 5 5 1",
"4\n2 1 4 3"
],
"output": [
"0",
"1",
"2"
]
} | {
"input": [
"3\n3 3 1",
"5\n3 5 5 5 1",
"5\n5 4 5 2 1",
"5\n5 5 5 5 2",
"5\n5 5 5 1 1",
"4\n3 1 4 3",
"5\n5 3 5 1 1",
"4\n4 1 4 3",
"5\n5 3 5 2 1",
"5\n5 5 5 2 1",
"5\n5 5 5 1 2",
"4\n0 1 4 3",
"5\n4 3 5 2 1",
"5\n5 5 5 0 1",
"5\n3 5 5 0 1",
"5\n5 5 5 0... |
p00081 A Symmetric Point | Read a set of coordinates of three different points P1 (x1, y1), P2 (x2, y2), Q (xq, yq) on the plane, and line symmetry with point Q with the straight line passing through point P1 point P2 as the axis of symmetry. Create a program that outputs the point R (x, y) at the position of. Note that the point Q is not on its... | {
"input": [],
"output": []
} | {
"input": [
"1.0,0.0,-1.0,0.0,1.0,1.0\n1.0,0.0,0.0,-1.0,3.0,0.0\n0.0,1.0,0.0,-1.0,1.0,1.0"
],
"output": [
"1.000000 -1.000000\n1.000000 2.000000\n-1.000000 1.000000"
]
} | {
"input": [
"1.0,0.0,-1.0,0.0,1.0,1.0\n1.0,0.0,0.0,-1.0,0.0,0.3\n0.0,1.0,0.0,-1.0,1.0,1.0",
"1.0,0.0,-1.0,0.0,1.0,1.0\n1.0,0.0,0.0,-1.0,3.0,0.0\n1.0,1.0,0.0,-1.0,1.0,1.0",
"1.0,0.0,-1.0,0.0,1.0,2.0\n1.0,0.0,0.0,-1.0,3.0,0.0\n1.0,1.0,0.1,-1.0,1.0,1.0",
"0.0,0.1,-1.0,0.0,1.0,2.0\n1.0,0.0,0.0,-1.0,3.0,0... |
p00213 Subdivide The Land | Housing maker Yamada House has launched a new featured product, a land for sale in a green home town with a rich environment such as schools and hospitals. This lot is divided into multiple lots and you can buy as many as you like, but the shape of the land with the lots you buy must be rectangular (including squares).... | {
"input": [],
"output": []
} | {
"input": [
"5 4 6\n1 6\n2 4\n3 3\n4 4\n5 1\n6 2\n0 0 1 0 0\n0 0 0 2 0\n0 0 0 3 0\n0 4 5 0 6\n3 3 1\n1 9\n0 0 1\n0 0 0\n0 0 0\n4 4 4\n1 6\n2 2\n3 4\n4 4\n0 1 0 0\n0 0 0 2\n0 0 3 0\n0 4 0 0\n0 0 0"
],
"output": [
"1 1 1 2 2\n1 1 1 2 2\n4 4 3 3 3\n4 4 5 6 6\n1 1 1\n1 1 1\n1 1 1\nNA"
]
} | {
"input": [
"5 4 6\n1 6\n2 4\n3 3\n4 4\n5 1\n6 2\n0 0 1 0 0\n0 0 0 2 0\n0 0 0 3 0\n0 4 5 0 6\n3 3 1\n1 9\n0 0 1\n0 0 0\n0 0 0\n4 4 4\n1 6\n2 2\n3 4\n4 4\n0 1 1 0\n0 0 0 2\n0 0 3 0\n0 4 0 0\n0 0 0",
"5 4 6\n1 6\n2 4\n3 3\n4 4\n5 1\n6 2\n0 0 1 0 1\n0 0 0 2 0\n0 0 0 3 0\n0 4 5 0 6\n3 3 1\n1 9\n0 0 1\n0 0 0\n0 0... |
p00373 Aerial Photo | Hideyo has come by two aerial photos of the same scale and orientation. You can see various types of buildings, but some areas are hidden by clouds. Apparently, they are of the same area, and the area covered by the second photograph falls entirely within the first. However, because they were taken at different time po... | {
"input": [],
"output": []
} | {
"input": [
"5 5 3 3\nAF??z\nW?p88\n???Hk\npU?m?\nF???c\nF??\np?8\n?H?",
"6 5 4 2\naaaaaa\naaaaaa\naaaaaa\naaaaaa\naaaaaa\naaaa\naaaa"
],
"output": [
"4",
"12"
]
} | {
"input": [
"5 5 3 3\nAF??z\nW8p8?\n???Hk\npU?m?\nF???c\nF??\np?8\n?H?",
"6 5 4 2\naaaaaa\naaaaaa\naaaaaa\naaaaaa\naaaaab\naaaa\naaaa",
"5 5 3 3\nAF??z\np8W8?\n???Hk\npU?m?\nF???c\nF??\np?8\n?H?",
"6 5 4 2\naaaaaa\naaaaaa\naaaaaa\naaaaaa\nbaaaab\naaaa\naaaa",
"6 5 4 1\naaaaaa\naaaaaa\naaaaaa\naaa... |
p00590 Pair of Primes | We arrange the numbers between 1 and N (1 <= N <= 10000) in increasing order and decreasing order like this:
1 2 3 4 5 6 7 8 9 . . . N
N . . . 9 8 7 6 5 4 3 2 1
Two numbers faced each other form a pair. Your task is to compute the number of pairs P such that both numbers in the pairs are prime.
Input
Input cont... | {
"input": [],
"output": []
} | {
"input": [
"1\n4\n7\n51"
],
"output": [
"0\n2\n2\n6"
]
} | {
"input": [
"1\n8\n7\n51",
"1\n10\n7\n51",
"1\n10\n7\n65",
"1\n12\n7\n115",
"1\n12\n9\n115",
"1\n12\n9\n15",
"1\n26\n9\n15",
"1\n26\n11\n15",
"1\n26\n11\n20",
"1\n27\n11\n20",
"1\n26\n5\n20",
"1\n37\n5\n20",
"1\n37\n10\n20",
"1\n37\n20\n8",
"1\n44\n20\n8",
... |
p00727 Secrets in Shadows | Long long ago, there were several identical columns (or cylinders) built vertically in a big open space near Yokohama (Fig. F-1). In the daytime, the shadows of the columns were moving on the ground as the sun moves in the sky. Each column was very tall so that its shadow was very long. The top view of the shadows is s... | {
"input": [],
"output": []
} | {
"input": [
"3\n1 1\n3 1\n4 3\n4\n1 1\n2 3\n3 8\n1 9\n8\n1 1\n3 1\n6 1\n1 3\n5 3\n1 7\n3 5\n5 5\n8\n20 7\n1 27\n30 14\n9 6\n17 13\n4 2\n17 7\n8 9\n0"
],
"output": [
"2.553590050042226\n0.982793723247329\n1.570796326794896\n2.819842099193151\n1.325817663668032\n2.094395102393196\n2.777613697080149\n0.5880... | {
"input": [
"3\n1 1\n3 1\n4 3\n4\n1 1\n2 3\n3 8\n1 9\n8\n1 1\n3 1\n6 1\n1 4\n5 3\n1 7\n3 5\n5 5\n8\n20 7\n1 27\n30 14\n9 6\n17 13\n4 2\n17 7\n8 9\n0",
"3\n1 1\n3 1\n4 3\n4\n1 1\n2 3\n3 8\n1 9\n8\n1 1\n3 1\n6 1\n1 4\n5 3\n1 7\n3 5\n5 5\n8\n20 7\n1 27\n45 14\n9 6\n17 13\n4 2\n17 7\n8 9\n0",
"3\n1 1\n3 1\n4... |
p00867 Digits on the Floor | Taro attempts to tell digits to Hanako by putting straight bars on the floor. Taro wants to express each digit by making one of the forms shown in Figure 1.
Since Taro may not have bars of desired lengths, Taro cannot always make forms exactly as shown in Figure 1. Fortunately, Hanako can recognize a form as a digit i... | {
"input": [],
"output": []
} | {
"input": [
"9\n60 140 200 300\n300 105 330 135\n330 135 250 215\n240 205 250 215\n298 167 285 154\n30 40 30 90\n30 90 150 90\n150 90 150 20\n30 40 150 40\n8\n320 20 300 60\n320 20 380 50\n380 50 240 330\n10 50 40 20\n10 50 110 150\n110 150 180 80\n40 20 37 17\n37 17 27 27\n20\n72 222 132 182\n204 154 204 54\n51... | {
"input": [
"9\n60 140 200 300\n300 105 330 135\n330 135 250 215\n240 205 250 215\n298 167 285 154\n30 40 30 90\n30 90 150 90\n150 90 150 20\n30 40 150 70\n8\n320 20 300 60\n320 20 380 50\n380 50 240 330\n10 50 40 20\n10 50 110 150\n110 150 180 80\n40 20 37 17\n37 17 27 27\n20\n72 222 132 182\n204 154 204 54\n51... |
p00998 RMQ | Given n numbers a0, a1, ..., an-1 and q.
I want you to perform appropriate processing for q queries.
The query has the following three types of operations.
* Shift the value
Given a pair of l and r. (l <r) Circular shift the value from al to ar.
0 1 2 3 4 5 6 7 8 9
Is given the query l = 2, r = 5.
The shifted numb... | {
"input": [],
"output": []
} | {
"input": [
"10 3\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n1 5 7\n0 2 5\n1 5 7",
"10 10\n289383\n930886\n692777\n636915\n747793\n238335\n885386\n760492\n516649\n641421\n2 7 368690\n1 3 6\n0 2 6\n1 1 8\n0 2 9\n2 2 665123\n1 5 9\n0 2 8\n2 7 961393\n1 1 2"
],
"output": [
"5\n4",
"238335\n238335\n238335\n36869... | {
"input": [
"10 3\n0\n1\n2\n3\n4\n5\n6\n7\n8\n10\n1 5 7\n0 2 5\n1 5 7",
"10 10\n289383\n930886\n692777\n636915\n747793\n238335\n885386\n760492\n516649\n641421\n2 7 368690\n1 3 6\n0 2 6\n1 1 8\n0 0 9\n2 2 665123\n1 5 9\n0 2 8\n2 7 961393\n1 1 2",
"19 10\n289383\n930886\n692777\n636915\n747793\n238335\n885... |
p01130 Water Pipe Construction | In 21XX, humanity finally began a plan to relocate to Mars. Selected as the first group of immigrants to Mars, you are assigned to the Administrative Center of Mars to deal with various problems that occur on Mars. The biggest problem at the moment of the Central Bureau is securing an independent supply and demand cycl... | {
"input": [],
"output": []
} | {
"input": [
"4 5 1 3 4\n1 2 5\n2 3 5\n2 4 5\n1 3 8\n1 4 8\n0 0 0 0 0"
],
"output": [
"15"
]
} | {
"input": [
"4 5 1 3 4\n1 2 5\n2 3 9\n2 4 5\n1 3 8\n1 4 8\n0 0 0 0 0",
"4 5 1 3 4\n1 2 5\n2 3 9\n2 4 5\n1 3 3\n1 4 8\n0 0 0 0 0",
"6 5 1 3 4\n1 2 5\n4 3 5\n2 3 5\n1 3 8\n1 4 8\n0 0 0 0 0",
"4 5 1 3 4\n1 2 5\n2 3 5\n2 4 5\n1 3 8\n2 4 8\n0 0 0 0 0",
"4 5 1 3 4\n0 2 5\n2 3 9\n2 4 5\n1 2 3\n1 4 8\n0 ... |
p01269 Brave Princess Revisited | A brave princess in a poor country's tomboy is married to another country for a political marriage. However, a villain who is trying to kill the princess is releasing a thug on the way to his wife.
You have already decided on a safe route to safely deliver the princess to the other country, but with the wish of the pr... | {
"input": [],
"output": []
} | {
"input": [
"3 2 10\n1 2 8 6\n2 3 10 3\n3 2 10\n1 2 3 8\n2 3 7 7\n3 3 10\n1 3 17 6\n1 2 2 4\n2 3 9 13\n4 4 5\n1 3 9 3\n1 4 7 25\n2 3 8 2\n2 4 9 3\n0 0 0"
],
"output": [
"3\n0\n4\n8"
]
} | {
"input": [
"3 2 10\n1 2 8 6\n2 3 10 0\n3 2 10\n1 2 3 8\n2 3 7 7\n3 3 10\n1 3 17 6\n1 2 2 4\n2 3 9 13\n4 4 5\n1 3 9 3\n1 4 7 25\n2 3 8 2\n2 4 9 3\n0 0 0",
"3 2 10\n1 2 8 6\n2 3 10 3\n3 2 10\n1 2 3 8\n2 3 7 7\n3 3 10\n1 3 17 6\n1 2 2 4\n2 3 9 13\n4 4 5\n1 3 9 5\n1 4 7 25\n2 3 8 2\n2 4 9 3\n0 0 0",
"3 2 3\... |
p01439 Chinese Classics | Taro, a junior high school student, is working on his homework. Today's homework is to read Chinese classic texts.
As you know, Japanese language shares the (mostly) same Chinese characters but the order of words is a bit different. Therefore the notation called "returning marks" was invented in order to read Chinese ... | {
"input": [],
"output": []
} | {
"input": [
"6\nonetwo2\n-\nonetwo1\nonetwo2\n-\nonetwo1\n7\nv\ntopbottom2\nonetwo2\n-\nonetwo1\ntopbottom1\n-\n6\nbaz2\nfoo2\nbaz1v\nbar2\nfoo1\nbar1\n0"
],
"output": [
"2\n3\n1\n5\n6\n4\n4\n5\n3\n6\n2\n1\n7\n5\n2\n6\n4\n3\n1"
]
} | {
"input": [
"6\nonetwo2\n-\nonetwo1\nonetwo2\n-\nonetwo1\n7\nv\ntopbottom2\nonetwo2\n-\nonetwo1\ntopbottom1\n-\n6\nbaz2\nfoo2\nbaz1v\nbar1\nfoo1\nbar1\n0",
"6\nonetwo2\n-\nonetwo1\nonetwo1\n-\nonetwo1\n7\nv\ntopbottom2\nonetwo2\n-\nonetwo1\ntopbottom1\n-\n6\nbaz2\nfoo2\nbaz1v\nbar1\nfoo1\nbar1\n0",
"6\no... |
p01588 Round Table | You are the owner of a restaurant, and you are serving for N customers seating in a round table.
You will distribute M menus to them. Each customer receiving a menu will make the order of plates, and then pass the menu to the customer on the right unless he or she has not make the order. The customer i takes Li unit t... | {
"input": [],
"output": []
} | {
"input": [
""
],
"output": [
""
]
} | {
"input": [],
"output": []
} |
p01745 Cellular Automaton | Let w be a positive integer and p be a character string with a length of 22w + 1. (w, p) -A cellular automaton is as follows.
* An infinite number of cells that can take the state of 0 or 1 are lined up in one dimension.
* At time 0, Sunuke can choose any finite number of squares and set the state to 1. The remaining ... | {
"input": [],
"output": []
} | {
"input": [
"1\n11111111",
"1\n00011000"
],
"output": [
"no",
"00011101"
]
} | {
"input": [
"1\n11111011",
"1\n00001000",
"1\n00101110",
"1\n01010100",
"1\n01000100",
"1\n00010100",
"1\n11111010",
"1\n00001100",
"1\n10111011",
"1\n00001110",
"1\n01111011",
"1\n10001110",
"1\n01011011",
"1\n10101110",
"1\n01011111",
"1\n10100110",
... |
p01885 Escape from the Hell | Example
Input
3 9
6 3
5 2
3 1
2
2
2
Output
2 | {
"input": [],
"output": []
} | {
"input": [
"3 9\n6 3\n5 2\n3 1\n2\n2\n2"
],
"output": [
"2"
]
} | {
"input": [
"3 9\n6 3\n5 1\n3 1\n2\n2\n2",
"3 9\n6 3\n9 1\n3 1\n2\n2\n2",
"3 9\n4 3\n5 1\n3 0\n2\n0\n2",
"3 14\n1 3\n9 1\n3 1\n2\n2\n2",
"6 17\n8 2\n5 2\n3 0\n2\n0\n2",
"3 9\n6 3\n5 1\n3 0\n2\n2\n2",
"3 9\n6 3\n5 1\n3 0\n2\n2\n4",
"3 9\n6 3\n5 2\n3 1\n2\n0\n2",
"3 9\n6 3\n5 1\n3 0... |
p02022 Mercy | H: Mercy
Santa Claus found a group doing programming even though it was Christmas.
Santa Claus felt sorry for them, so he decided to give them a cake.
There are $ N $ types of cream, and the taste is $ A_1, A_2, A_3, \ dots, A_N $.
There are $ M $ types of sponges, and the taste is $ B_1, B_2, B_3, \ dots, B_M $.
... | {
"input": [],
"output": []
} | {
"input": [
"3 2\n3 1 5\n2 4"
],
"output": [
"54"
]
} | {
"input": [
"3 2\n3 1 5\n2 5",
"3 2\n2 1 5\n2 5",
"3 2\n2 1 3\n2 5",
"3 2\n2 2 3\n2 5",
"3 1\n2 4 3\n2 5",
"3 2\n2 4 3\n2 4",
"3 2\n1 4 3\n2 4",
"3 2\n1 4 3\n4 5",
"3 2\n0 4 3\n4 1",
"3 1\n0 4 3\n4 1",
"3 1\n0 0 3\n4 2",
"3 1\n0 1 3\n4 2",
"2 1\n0 1 3\n4 2",
"2... |
p02164 Satake likes straight | Problem
Satake doesn't like being bent.
For example, I don't like pencils, chopsticks, and bent-shaped houses, and I don't like taking actions such as turning right or left.
By the way, Satake who lives on the XY plane is $ N $ shops $ (X_ {1}, Y_ {1}), (X_ {2}, Y_ {2}), \ ldots, (X_ {N} , Y_ {N}) I was asked to shop... | {
"input": [],
"output": []
} | {
"input": [
"3\n1 0\n0 1\n-2 -1",
"2\n0 1\n0 -1"
],
"output": [
"386.565051",
"450.00000000"
]
} | {
"input": [
"3\n1 0\n0 1\n-2 -2",
"2\n0 1\n-1 -2",
"2\n0 1\n-1 -3",
"2\n0 1\n-1 -4",
"3\n1 1\n0 1\n-2 -1",
"2\n0 2\n0 -1",
"2\n1 1\n-1 -3",
"3\n1 0\n0 1\n-2 0",
"2\n1 0\n-1 -3",
"2\n0 2\n1 0",
"2\n1 0\n-4 -1",
"2\n2 0\n-2 -1",
"2\n1 0\n-1 -1",
"2\n0 2\n-1 2",
... |
p02305 Intersection | For given two circles $c1$ and $c2$, print
4
if they do not cross (there are 4 common tangent lines),
3
if they are circumscribed (there are 3 common tangent lines),
2
if they intersect (there are 2 common tangent lines),
1
if a circle is inscribed in another (there are 1 common tangent line),
0
if ... | {
"input": [],
"output": []
} | {
"input": [
"0 0 1\n1 0 2",
"1 2 1\n3 2 2",
"0 0 1\n0 0 2",
"1 2 1\n4 2 2",
"1 1 1\n6 2 2"
],
"output": [
"1",
"2",
"0",
"3",
"4"
]
} | {
"input": [
"0 0 0\n1 0 2",
"1 2 1\n3 4 2",
"1 2 0\n4 2 2",
"0 0 1\n0 1 2",
"0 0 0\n0 0 2",
"1 1 1\n9 2 2",
"0 1 0\n0 0 2",
"1 2 1\n5 4 2",
"-1 0 0\n0 0 2",
"1 2 0\n0 2 2",
"1 1 1\n15 2 2",
"-1 1 0\n0 0 2",
"-1 0 0\n-1 0 2",
"1 2 0\n1 2 2",
"1 1 0\n15 2 2",... |
p02452 Includes | For given two sequneces $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and $B = \\{b_0, b_1, ..., b_{m-1}\\}$, determine whether all elements of $B$ are included in $A$. Note that, elements of $A$ and $B$ are sorted by ascending order respectively.
Constraints
* $1 \leq n, m \leq 200,000$
* $-1,000,000,000 \leq a_0 < a_1 < ... <... | {
"input": [],
"output": []
} | {
"input": [
"4\n1 2 3 4\n2\n2 4",
"4\n1 2 3 4\n3\n1 2 5"
],
"output": [
"1",
"0"
]
} | {
"input": [
"4\n1 2 3 0\n2\n2 4",
"4\n1 2 4 1\n2\n1 4",
"4\n1 2 3 4\n3\n1 0 5",
"4\n1 2 3 0\n2\n1 4",
"4\n1 2 3 8\n3\n1 0 5",
"4\n1 2 3 1\n2\n1 4",
"4\n1 2 3 8\n3\n1 0 8",
"4\n1 2 3 8\n4\n1 0 8",
"4\n1 2 4 1\n2\n2 4",
"4\n1 2 3 8\n4\n0 0 8",
"4\n1 2 3 1\n2\n2 4",
"4\n1... |
arhn08 | Problem description.
Shyam has his computer science exam next week . He is solving one problem but he is not able to write the program
that for that . As a good programmer you thought that you will help so help him by writing a program that solves that problem .
The problem is that you have N boxes numbered from ... | {
"input": [],
"output": []
} | {
"input": [
"2"
],
"output": [
"3"
]
} | {
"input": [],
"output": []
} |
clco01 | Nikhil learnt two new commands pwd and cd on the first day of Operating Systems lab.
pwd - command displays the current working directory and,cd - changes the location of working directory.
If the cd parameter contains ".."(without quotes), that means to step one directory back.
The absolute path of directory is separa... | {
"input": [],
"output": []
} | {
"input": [
"1\n9\npwd\ncd /home/csed\npwd\ncd /lab/root/../dir\npwd\ncd /home\npwd\ncd lab\npwd"
],
"output": [
"/\n/home/csed/\n/lab/dir/\n/home/\n/home/lab/"
]
} | {
"input": [],
"output": []
} |
fctrl | The most important part of a GSM network is so called Base Transceiver Station (BTS). These transceivers form the areas called cells (this term gave the name to the cellular phone) and every phone connects to the BTS with the strongest signal (in a little simplified view). Of course, BTSes need some attention and techn... | {
"input": [],
"output": []
} | {
"input": [
"6\n3\n60\n100\n1024\n23456\n8735373"
],
"output": [
"0\n14\n24\n253\n5861\n2183837\n"
]
} | {
"input": [
"6\n3\n60\n100\n979\n23456\n8735373",
"6\n3\n60\n110\n979\n23456\n8735373",
"6\n3\n71\n110\n979\n23456\n8735373",
"6\n3\n71\n110\n979\n22394\n8735373",
"6\n3\n99\n110\n979\n22394\n8735373",
"6\n3\n99\n110\n835\n22394\n8735373",
"6\n3\n99\n110\n835\n31879\n8735373",
"6\n3\n... |
lebalons | The Little Elephant from the Zoo of Lviv is going to the Birthday Party of the Big Hippo tomorrow. Now he wants to prepare a gift for the Big Hippo.
He has N balloons, numbered from 1 to N. The i-th balloon has the color Ci and it costs Pi dollars. The gift for the Big Hippo will be any subset (chosen randomly, possi... | {
"input": [],
"output": []
} | {
"input": [
"2\n2 2\n1 4\n2 7\n2 1\n1 4\n2 7"
],
"output": [
"11.000000000\n7.333333333"
]
} | {
"input": [
"2\n2 2\n1 4\n2 7\n2 1\n1 4\n0 7",
"2\n2 2\n1 4\n2 7\n2 1\n1 3\n0 7",
"2\n2 0\n1 4\n2 7\n2 1\n1 4\n2 7",
"2\n2 2\n1 4\n2 0\n2 1\n1 4\n0 7",
"2\n2 1\n1 4\n2 7\n2 1\n1 4\n2 7",
"2\n2 1\n1 0\n2 7\n2 1\n1 4\n2 7",
"2\n2 2\n1 4\n2 7\n2 2\n1 4\n0 7",
"2\n2 2\n1 4\n2 7\n2 1\n1 2\... |
playfit | Who's interested in football?
Rayne Wooney has been one of the top players for his football club for the last few years. But unfortunately, he got injured during a game a few months back and has been out of play ever since.
He's got proper treatment and is eager to go out and play for his team again. Before doing that,... | {
"input": [],
"output": []
} | {
"input": [
"3\n6\n3 7 1 4 2 4\n5\n5 4 3 2 1\n5\n4 3 2 2 3"
],
"output": [
"4\nUNFIT\n1\n"
]
} | {
"input": [
"3\n6\n3 7 1 4 2 4\n5\n5 4 3 2 1\n5\n4 3 1 2 3",
"3\n6\n3 1 1 4 2 4\n5\n5 4 3 2 1\n5\n4 3 1 2 3",
"3\n6\n3 1 1 4 2 4\n5\n2 4 3 2 1\n5\n4 3 1 2 3",
"3\n6\n1 1 0 4 2 4\n5\n4 4 3 2 1\n5\n4 0 1 2 3",
"3\n6\n1 1 0 4 2 4\n5\n4 7 3 2 2\n5\n4 0 1 2 3",
"3\n6\n1 1 1 4 2 4\n5\n4 7 3 2 2\n5\... |
strsub | You are given a string S of length N consisting only of 0s and 1s. You are also given an integer K.
You have to answer Q queries. In the i^th query, two integers Li and Ri are given. Then you should print the number of substrings of S[L, R] which contain at most K 0s and at most K 1s where S[L, R] denotes the substring... | {
"input": [],
"output": []
} | {
"input": [
"1\n8 2 3\n01110000\n1 4\n2 4\n5 8"
],
"output": [
"8\n5\n7"
]
} | {
"input": [],
"output": []
} |
1307_A. Cow and Haybales | The USA Construction Operation (USACO) recently ordered Farmer John to arrange a row of n haybale piles on the farm. The i-th pile contains a_i haybales.
However, Farmer John has just left for vacation, leaving Bessie all on her own. Every day, Bessie the naughty cow can choose to move one haybale in any pile to an a... | {
"input": [],
"output": []
} | {
"input": [
"3\n4 5\n1 0 3 2\n2 2\n100 1\n1 8\n0\n"
],
"output": [
"3\n101\n0\n"
]
} | {
"input": [
"3\n4 5\n1 0 1 2\n2 2\n100 1\n1 8\n0\n",
"3\n4 5\n1 0 1 2\n2 2\n100 2\n1 8\n0\n",
"3\n4 5\n0 0 1 2\n2 2\n100 2\n1 7\n0\n",
"3\n4 5\n0 0 1 2\n2 2\n000 2\n1 7\n0\n",
"3\n4 5\n1 0 3 2\n2 2\n100 0\n1 8\n0\n",
"3\n4 5\n2 0 1 2\n2 2\n100 2\n1 8\n0\n",
"3\n4 1\n1 0 1 2\n2 2\n100 2\n1... |
1535_E. Gold Transfer | You are given a rooted tree. Each vertex contains a_i tons of gold, which costs c_i per one ton. Initially, the tree consists only a root numbered 0 with a_0 tons of gold and price c_0 per ton.
There are q queries. Each query has one of two types:
1. Add vertex i (where i is an index of query) as a son to some ver... | {
"input": [],
"output": []
} | {
"input": [
"5 5 2\n2 0 2\n1 0 3 4\n2 2 4\n1 0 1 3\n2 4 2\n"
],
"output": [
"\n2 4\n4 10\n1 3\n"
]
} | {
"input": [
"5 5 2\n2 0 2\n1 0 1 4\n2 2 4\n1 0 1 3\n2 4 2\n",
"5 10 2\n2 0 2\n1 0 3 4\n2 2 4\n1 0 1 3\n2 4 2\n",
"1 5 2\n2 0 2\n1 0 1 4\n2 2 4\n1 0 1 3\n2 4 2\n",
"1 5 4\n2 0 2\n1 0 1 4\n7 2 4\n1 0 1 3\n2 4 1\n",
"1 5 1\n2 0 2\n1 0 1 4\n2 2 4\n1 0 1 3\n2 4 1\n",
"1 5 2\n2 0 0\n0 -1 1 4\n7 2 4... |
162_H. Alternating case | You are given a string consisting of alphabet letters. Convert it to alternating case: the letters on odd positions should be in uppercase, and the letters on even positions should be lowercase. The letters are numbered staring from 1.
Input
The only line of input contains a string between 1 and 100 characters long. ... | {
"input": [],
"output": []
} | {
"input": [
"Codeforces\n",
"VKCup\n"
],
"output": [
"CoDeFoRcEs\n",
"VkCuP\n"
]
} | {
"input": [],
"output": []
} |
panda-and-chain-reaction | Panda has become a scientist recently. In his laboratory, there are infinite number of chambers where a chamber number K is connected to a chamber number K-1.
The numbering of chambers start from 0. Initially, X number of particles are present in the chamber number 0. The number of particles present in chamber K is ... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 3\n2 1\n\nSAMPLE"
],
"output": [
"3\n2\n"
]
} | {
"input": [
"2\n1 3\n2 1\n\nSAMPLD",
"2\n2 3\n2 1\n\nSAMPLD",
"2\n2 3\n2 0\n\nRAPMEL",
"2\n4 3\n2 0\n\nKEMPAR",
"2\n4 1\n0 0\n\nRAPMEK",
"2\n4 0\n0 0\n\nSAPMEK",
"2\n1 3\n4 1\n\nSAMPLD",
"2\n2 5\n2 1\n\nSAMPLD",
"2\n2 3\n0 1\n\nRAPMEL",
"2\n0 3\n2 0\n\nRAPMEK",
"2\n6 3\n2 ... |
robots | Oz and nakul have N robots, and they want to assign a distinct integer to each robot so that they can easily identify them. Also robots have already expressed their preferences to Oz and nakul. The k-th robot wants an integer between 1 and MAX[k], inclusive. Oz and nakul must obey the preferences of all their robots.
N... | {
"input": [],
"output": []
} | {
"input": [
"2\n1\n6\n2\n5 8\n\nSAMPLE"
],
"output": [
"6\n35\n"
]
} | {
"input": [
"2\n1\n6\n2\n10 8\n\nSAMPLE",
"2\n1\n6\n2\n10 5\n\nSAMPLE",
"2\n1\n6\n2\n5 8\n\nS@MPLE",
"2\n1\n6\n2\n10 3\n\nSAMPLE",
"2\n1\n6\n2\n10 6\n\nSAMPLD",
"2\n1\n9\n2\n10 3\n\nSAMPLE",
"2\n1\n4\n2\n10 5\n\nRAMPLE",
"2\n1\n6\n2\n12 5\n\nSAMPLE",
"2\n1\n6\n2\n10 7\n\nRAMPLE",
... |
p02585 AtCoder Beginner Contest 175 - Moving Piece | Takahashi will play a game using a piece on an array of squares numbered 1, 2, \cdots, N. Square i has an integer C_i written on it. Also, he is given a permutation of 1, 2, \cdots, N: P_1, P_2, \cdots, P_N.
Now, he will choose one square and place the piece on that square. Then, he will make the following move some n... | {
"input": [],
"output": []
} | {
"input": [
"10 58\n9 1 6 7 8 4 3 2 10 5\n695279662 988782657 -119067776 382975538 -151885171 -177220596 -169777795 37619092 389386780 980092719",
"3 3\n3 1 2\n-1000 -2000 -3000",
"5 2\n2 4 5 1 3\n3 4 -10 -8 8",
"2 3\n2 1\n10 -7"
],
"output": [
"29507023469",
"-1000",
"8",
"13"
... | {
"input": [
"10 58\n9 1 6 7 8 4 3 2 10 5\n695279662 988782657 -119067776 382975538 -151885171 -243968758 -169777795 37619092 389386780 980092719",
"10 58\n9 1 6 7 8 4 3 2 10 5\n1020768626 988782657 -119067776 382975538 -151885171 -177220596 -169777795 37619092 389386780 980092719",
"3 3\n3 1 2\n-1000 -20... |
p02716 AtCoder Beginner Contest 162 - Select Half | Given is an integer sequence A_1, ..., A_N of length N.
We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.
Find the maximum possible sum of the chosen elements.
Here \lfloor x \rfloor denotes the greatest integer not greater than x.
... | {
"input": [],
"output": []
} | {
"input": [
"27\n18 -28 18 28 -45 90 -45 23 -53 60 28 -74 -71 35 -26 -62 49 -77 57 24 -70 -93 69 -99 59 57 -49",
"5\n-1000 -100 -10 0 10",
"6\n1 2 3 4 5 6",
"10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000"
],
"output": [
"295"... | {
"input": [
"27\n18 -28 18 28 -45 90 -45 23 -53 60 28 -74 -71 35 -26 -62 49 -77 33 24 -70 -93 69 -99 59 57 -49",
"5\n-1156 -100 -10 0 10",
"6\n1 2 6 4 5 6",
"10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 0000000000 1000000000 1000000000 1000000000",
"27\n18 -28 18 28 -45 9... |
p02845 Sumitomo Mitsui Trust Bank Programming Contest 2019 - Colorful Hats 2 | N people are standing in a queue, numbered 1, 2, 3, ..., N from front to back. Each person wears a hat, which is red, blue, or green.
The person numbered i says:
* "In front of me, exactly A_i people are wearing hats with the same color as mine."
Assuming that all these statements are correct, find the number of p... | {
"input": [],
"output": []
} | {
"input": [
"54\n0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17",
"3\n0 0 0",
"6\n0 1 2 3 4 5"
],
"output": [
"115295190",
"6",
"3"
]
} | {
"input": [
"54\n0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 20 13 14 14 15 15 15 16 16 16 17 17 17",
"6\n0 1 2 0 3 4",
"6\n0 1 1 3 4 5",
"54\n0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 9 13 14 14 15 15... |
p02982 AtCoder Beginner Contest 133 - Good Distance | There are N points in a D-dimensional space.
The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).
The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.
How many pairs (i, j) (i < j) are there such ... | {
"input": [],
"output": []
} | {
"input": [
"3 4\n-3 7 8 2\n-12 1 10 2\n-2 8 9 3",
"3 2\n1 2\n5 5\n-2 8",
"5 1\n1\n2\n3\n4\n5"
],
"output": [
"2",
"1",
"10"
]
} | {
"input": [
"3 4\n-3 7 8 2\n-12 1 10 2\n-2 8 9 0",
"1 1\n1\n2\n3\n4\n5",
"5 1\n0\n2\n3\n4\n5",
"3 2\n1 8\n5 5\n-2 8",
"3 2\n1 4\n5 5\n-2 8",
"3 4\n-3 7 8 2\n-12 1 10 2\n-2 8 13 0",
"3 2\n2 4\n5 5\n-2 8",
"0 1\n1\n2\n3\n4\n5",
"3 4\n-3 7 8 2\n-18 1 10 2\n-2 8 13 0",
"3 2\n0 4\n... |
p03123 World Tour Finals 2019 - Distinct Boxes | Snuke has R red balls and B blue balls. He distributes them into K boxes, so that no box is empty and no two boxes are identical. Compute the maximum possible value of K.
Formally speaking, let's number the boxes 1 through K. If Box i contains r_i red balls and b_i blue balls, the following conditions must be satisfie... | {
"input": [],
"output": []
} | {
"input": [
"8 3"
],
"output": [
"5"
]
} | {
"input": [],
"output": []
} |
p03265 AtCoder Beginner Contest 108 - Ruined Square | There is a square in the xy-plane. The coordinates of its four vertices are (x_1,y_1),(x_2,y_2),(x_3,y_3) and (x_4,y_4) in counter-clockwise order. (Assume that the positive x-axis points right, and the positive y-axis points up.)
Takahashi remembers (x_1,y_1) and (x_2,y_2), but he has forgot (x_3,y_3) and (x_4,y_4).
... | {
"input": [],
"output": []
} | {
"input": [
"2 3 6 6",
"0 0 0 1",
"31 -41 -59 26"
],
"output": [
"3 10 -1 7",
"-1 1 -1 0",
"-126 -64 -36 -131"
]
} | {
"input": [
"2 1 6 6",
"0 0 -1 1",
"1 -41 -59 26",
"2 2 6 6",
"0 0 -1 2",
"1 -46 -59 26",
"2 2 6 2",
"0 -1 -1 2",
"1 -46 -59 12",
"2 2 6 1",
"0 -1 -2 2",
"1 -46 -103 12",
"3 2 6 2",
"0 -1 0 2",
"1 -46 0 12",
"6 2 6 2",
"0 -2 0 2",
"1 -46 1 12",
... |
p03424 AtCoder Beginner Contest 089 - Hina Arare | In Japan, people make offerings called hina arare, colorful crackers, on March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white and green, or contains arare in four colors: pink, white, green and yellow.
We have ... | {
"input": [],
"output": []
} | {
"input": [
"6\nG W Y P Y W",
"9\nG W W G P W P G G",
"8\nP Y W G Y W Y Y"
],
"output": [
"Four",
"Three",
"Four"
]
} | {
"input": [
"6\nG W Y Q Y W",
"6\nG X X O X X",
"6\nF W Y P Y W",
"6\nF W Y O Y W",
"6\nG W Y O Y W",
"6\nE W Y O Y W",
"8\nO Y W G Y W Y Y",
"6\nF W Y Q Y W",
"6\nE W Y P Y W",
"8\nO Y W F Y W Y Y",
"6\nE W Y N Y W",
"6\nD W Y N Y W",
"6\nG V Y P Y V",
"6\nF V... |
p03581 CODE FESTIVAL 2017 qual B - Popping Balls | A + B balls are arranged in a row. The leftmost A balls are colored red, and the rightmost B balls are colored blue.
You perform the following operation:
* First, you choose two integers s, t such that 1 \leq s, t \leq A + B.
* Then, you repeat the following step A + B times: In each step, you remove the first ball o... | {
"input": [],
"output": []
} | {
"input": [
"1987 1789",
"4 4",
"3 3",
"7 9"
],
"output": [
"456315553",
"67",
"20",
"7772"
]
} | {
"input": [
"1977 1789",
"1 4",
"0 3",
"7 2",
"1534 1789",
"1 3",
"13 2",
"69 1789",
"-1 4",
"1 5",
"42 1789",
"1 8",
"84 1789",
"164 1789",
"158 1789",
"100 1789",
"110 1789",
"010 1789",
"010 1966",
"010 26",
"010 20",
"011 20"... |
p03738 AtCoder Beginner Contest 059 - Comparison | You are given two positive integers A and B. Compare the magnitudes of these numbers.
Constraints
* 1 ≤ A, B ≤ 10^{100}
* Neither A nor B begins with a `0`.
Input
Input is given from Standard Input in the following format:
A
B
Output
Print `GREATER` if A>B, `LESS` if A<B and `EQUAL` if A=B.
Examples
Input
3... | {
"input": [],
"output": []
} | {
"input": [
"36\n24",
"9720246\n22516266",
"123456789012345678901234567890\n234567890123456789012345678901",
"850\n3777"
],
"output": [
"GREATER",
"LESS",
"LESS",
"LESS"
]
} | {
"input": [
"36\n16",
"9720246\n44989358",
"36\n36",
"123456789012345678901234567890\n179827845276187955292784642083",
"850\n4141",
"36\n2",
"9720246\n38650320",
"123456789012345678901234567890\n161824648859841611049963832583",
"850\n1340",
"36\n3",
"9720246\n51961997",
... |
p03900 CODE FESTIVAL 2016 Tournament Round 3 (Parallel) - Compression | Takahashi found an integer sequence (A_1,A_2,...,A_N) with N terms. Since it was too heavy to carry, he decided to compress it into a single integer.
The compression takes place in N-1 steps, each of which shorten the length of the sequence by 1. Let S be a string describing the steps, and the sequence on which the i-... | {
"input": [],
"output": []
} | {
"input": [
"5\n3 4 2 2 1\nMMmm",
"10\n1 8 7 6 8 5 2 2 6 1\nMmmmmMMMm",
"20\n12 7 16 8 7 19 8 19 20 11 7 13 20 3 4 11 19 11 15 5\nmMMmmmMMMMMMmMmmmMM",
"4\n1 2 3 4\nMmM"
],
"output": [
"2",
"5",
"11",
"3"
]
} | {
"input": [
"5\n3 8 2 2 1\nMMmm",
"10\n1 8 7 6 8 5 2 1 6 1\nMmmmmMMMm",
"20\n12 7 16 8 7 19 8 19 10 11 7 13 20 3 4 11 19 11 15 5\nmMMmmmMMMMMMmMmmmMM",
"4\n1 2 3 0\nMmM",
"10\n1 15 7 0 8 3 8 1 6 1\nMmmmmMMMm",
"10\n1 15 13 0 8 3 8 1 6 1\nMmmmmMMMm",
"10\n1 17 25 0 4 3 8 1 6 1\nMmmmmMMMm",... |
p00006 Reverse Sequence | Write a program which reverses a given string str.
Input
str (the size of str ≤ 20) is given in a line.
Output
Print the reversed str in a line.
Example
Input
w32nimda
Output
admin23w | {
"input": [],
"output": []
} | {
"input": [
"w32nimda"
],
"output": [
"admin23w"
]
} | {
"input": [
"w32njmda",
"admjn23w",
"acmjn23w",
"3cmjn2aw",
"3dmjn2aw",
"wa2njmd3",
"xa2njmd3",
"xa3njmd3",
"wa3njmd3",
"wa3njme3",
"wa3njme4",
"wa3nj4em",
"xa3nj4em",
"x`3nj4em",
"x`3nk4em",
"x`3mk4em",
"xa3mk4em",
"x3amk4em",
"me4kma3x",
... |
p00138 Track and Field Competition | The athletics competition 200M semi-final three races were held. Eight players (24 players in total) will participate in each group. A total of eight players, including the top two players in each group and the top two players from all the players in each group who are third or lower, will advance to the final.
Create... | {
"input": [],
"output": []
} | {
"input": [
"18 25.46\n16 26.23\n3 23.00\n10 24.79\n5 22.88\n11 23.87\n19 23.90\n1 25.11\n23 23.88\n4 23.46\n7 24.12\n12 22.91\n13 21.99\n14 22.86\n21 23.12\n9 24.09\n17 22.51\n22 23.49\n6 23.02\n20 22.23\n24 21.89\n15 24.14\n8 23.77\n2 23.42"
],
"output": [
"5 22.88\n3 23.00\n13 21.99\n14 22.86\n24 21.8... | {
"input": [
"18 25.46\n16 26.23\n3 23.00\n10 24.79\n5 22.88\n11 23.87\n19 23.90\n1 25.11\n23 23.88\n4 23.46\n7 24.12\n12 22.91\n13 21.99\n14 22.86\n21 23.12\n9 24.09\n17 22.51\n22 23.49\n6 23.02\n20 22.23\n8 21.89\n15 24.14\n8 23.77\n2 23.42",
"18 25.46\n16 26.23\n3 23.00\n10 24.79\n5 22.88\n11 23.87\n19 23.... |
p00271 Temperature Difference | Welcome to PC Koshien, players. Physical condition management is important to participate in the event. It is said that at the turn of the season when the temperature fluctuates greatly, it puts a strain on the body and it is easy to catch a cold. The day you should be careful about is the day when the difference betwe... | {
"input": [],
"output": []
} | {
"input": [
"30 19\n39 20\n19 18\n25 20\n22 21\n23 10\n10 -10"
],
"output": [
"11\n19\n1\n5\n1\n13\n20"
]
} | {
"input": [
"30 19\n39 20\n19 18\n4 20\n22 21\n23 10\n10 -10",
"30 19\n39 20\n19 18\n4 20\n22 21\n23 10\n15 -10",
"30 19\n39 1\n19 18\n4 20\n22 21\n23 10\n15 -10",
"30 19\n39 1\n19 18\n2 20\n22 21\n23 10\n15 -10",
"30 19\n39 1\n19 18\n2 20\n43 21\n23 10\n15 -10",
"30 31\n39 1\n19 18\n2 20\n43... |
p00459 Shuffle | problem
There are n cards with numbers from 1 to n. First, make a pile of cards by stacking them in order so that the top is the number 1 card, the second from the top is the number 2 card, ..., and the bottom is the number n card.
<image>
Sort the cards by performing the following operation called "shuffle (x, y)... | {
"input": [],
"output": []
} | {
"input": [
"9\n1\n3 7 4\n3 5\n12\n3\n3 8 5\n3 8\n2 5\n6 10\n0"
],
"output": [
"2\n3"
]
} | {
"input": [
"9\n1\n3 7 4\n4 5\n12\n3\n3 8 5\n3 8\n2 5\n6 10\n0",
"9\n1\n2 7 4\n4 5\n12\n3\n3 8 5\n3 8\n2 3\n6 10\n0",
"9\n1\n3 4 4\n3 5\n12\n3\n3 8 5\n3 8\n2 5\n9 10\n0",
"9\n1\n3 7 4\n4 5\n12\n3\n2 8 5\n3 8\n2 7\n6 10\n0",
"9\n1\n3 6 4\n3 5\n12\n3\n3 8 5\n3 8\n2 5\n9 10\n0",
"9\n1\n3 7 4\n4 ... |
p00649 Yanagi's Comic | Yanagi is a high school student, and she is called "Hime" by her boyfriend who is a ninja fanboy. She likes picture books very much, so she often writes picture books by herself. She always asks you to make her picture book as an assistant. Today, you got asked to help her with making a comic.
She sometimes reads her ... | {
"input": [],
"output": []
} | {
"input": [
"4\n0 0 100 60\n0 60 50 90\n50 60 100 90\n0 90 100 120\n6\n0 0 100 40\n0 40 50 70\n50 40 100 60\n50 60 100 80\n0 70 50 120\n50 80 100 120\n0"
],
"output": [
"1\n2\n3\n4\n\n1\n2\n4\n5\n3\n6"
]
} | {
"input": [
"4\n0 0 100 60\n0 60 50 90\n50 60 100 90\n0 90 100 120\n6\n0 0 100 40\n0 67 50 70\n50 40 100 60\n50 60 100 80\n0 70 50 120\n50 80 100 120\n0",
"4\n0 0 100 60\n0 60 50 90\n50 60 100 90\n0 90 100 120\n6\n0 0 100 58\n-1 67 50 70\n50 40 100 60\n50 60 100 80\n0 70 50 120\n50 80 100 120\n0",
"4\n0 ... |
p00793 Heavenly Jewels | There is a flat island whose shape is a perfect square. On this island, there are three habitants whose names are IC, PC, and ACM Every day, one jewel is dropped from the heaven. Just as the jewel touches the ground, IC, PC, and ACM leave their houses simultaneously, run with the same speed, and then a person who first... | {
"input": [],
"output": []
} | {
"input": [
"2000 2000 8000 8000 9000 9500\n2500 2500 7500 2500 2500 7500\n0 0 0 0 0 0"
],
"output": [
"1 0.50000\n2 0.25000"
]
} | {
"input": [
"2000 2252 8000 8000 9000 9500\n2500 2500 7500 2500 2500 7500\n0 0 0 0 0 0",
"2000 2000 8000 8000 9000 9500\n2500 2240 7500 2500 2500 7500\n0 0 0 0 0 0",
"2000 2000 8000 15891 9000 9500\n2500 2240 7500 2500 2500 7500\n0 0 0 0 0 0",
"2000 2000 8000 15891 9000 9500\n2500 2240 7500 2500 2500... |
p00925 Miscalculation | Example
Input
1+2*3+4
11
Output
M | {
"input": [],
"output": []
} | {
"input": [
"1+2*3+4\n11"
],
"output": [
"M"
]
} | {
"input": [
"1+2*3+4\n9",
"0+1*3+4\n7",
"4+3*0+4\n8",
"3*1+0*4\n12",
"1+2*3+4\n7",
"0+2*3+4\n7",
"1+2+3+4\n11",
"0+2*3+4\n9",
"1+2*3+4\n14",
"4+3+2+1\n11",
"0+1*3+4\n11",
"4+3+2+1\n2",
"4+3*1+0\n11",
"1+2+3+4\n2",
"0+3*1+4\n11",
"1*2+3+4\n2",
"0+3*1... |
p01058 Point in The Triangle | Problem
Select 3 grid points from the closed rectangular section surrounded by points (0,0), (n-1,0), (0, m-1), (n-1, m-1) and make a triangle. make.
At this time, the absolute difference between the number of triangles containing the point (x1, y1) but not the point (x2, y2) and the number of triangles containing the... | {
"input": [],
"output": []
} | {
"input": [
"2 2 0 0 0 1",
"3 2 1 0 0 0"
],
"output": [
"0",
"3"
]
} | {
"input": [
"2 2 1 0 0 1",
"3 2 1 0 2 1",
"3 3 1 0 2 0",
"3 6 1 0 2 0",
"4 2 1 0 0 1",
"3 3 1 1 2 1",
"3 9 1 0 2 0",
"3 3 1 1 2 2",
"2 11 2 0 2 -1",
"1 9 0 -1 6 0",
"2 13 2 -6 2 -2",
"1 6 2 0 0 -1",
"3 11 2 0 2 1",
"2 9 1 -1 6 0",
"2 13 2 -11 2 -2",
"1 ... |
p01190 Reading Brackets in English | Shun and his professor are studying Lisp and S-expressions. Shun is in Tokyo in order to make a presen- tation of their research. His professor cannot go with him because of another work today.
He was making final checks for his slides an hour ago. Then, unfortunately, he found some serious mistakes! He called his pro... | {
"input": [],
"output": []
} | {
"input": [
"4\na list of A, B, C and D\na list of A, a list of P and Q, B, a list of X, Y and Z and C\na list of A\na list of a list of A and B"
],
"output": [
"(A B C D)\n(A (P Q) B (X Y Z) C)\n(A)\nAMBIGUOUS"
]
} | {
"input": [
"4\na list of A, B, C and D\na list of A, a list of O and Q, B, a list of X, Y and Z and C\na list of A\na list of a list of A and B",
"4\na list of A, B, C and D\na list of B, a list of P and Q, B, a list of X, Y and Z and C\na list of A\na list of a list of A and B",
"4\na list of A, B, C a... |
p01328 Stray Cats | Many cats are kept at the pastry specialty store Stray Cats. The number of cats was so large that the staff at this store, Nozomi, had trouble feeding. Even if you put food in several places, the cats are greedy and will go to the nearest food, and many cats will concentrate in one food container. For rare reasons, you... | {
"input": [],
"output": []
} | {
"input": [
"3 3\n-1 1 1\n0 1 1\n1 1 1\n-3\n0\n3\n5 5\n7 3 5\n-9 2 7\n4 9 6\n10 5 9\n-9 7 9\n0\n-1\n-2\n-9\n-8\n0 0"
],
"output": [
"2\n20"
]
} | {
"input": [
"3 3\n-1 1 1\n0 1 1\n1 2 1\n-3\n0\n3\n5 5\n7 3 5\n-9 2 7\n4 9 6\n10 5 9\n-9 7 9\n0\n-1\n-2\n-9\n-8\n0 0",
"3 3\n-1 1 1\n0 1 1\n1 2 1\n-3\n0\n3\n5 5\n7 3 5\n-9 2 7\n4 9 3\n10 5 9\n-9 7 9\n0\n-1\n-2\n-9\n-8\n0 0",
"3 3\n-2 1 1\n0 1 0\n1 1 1\n-3\n0\n3\n5 5\n7 4 5\n-18 2 1\n4 9 6\n10 5 9\n-9 7 9\... |
p01495 SolveMe | Example
Input
3 1 0 1
Output
18 | {
"input": [],
"output": []
} | {
"input": [
"3 1 0 1"
],
"output": [
"18"
]
} | {
"input": [
"3 2 0 1",
"1 2 0 1",
"2 0 0 1",
"2 1 0 1",
"3 1 1 2",
"3 -1 0 2",
"3 -1 1 2",
"5 0 -1 2",
"4 0 1 3",
"7 0 -1 2",
"2 0 0 0",
"8 0 -1 2",
"6 2 -1 3",
"6 2 0 3",
"4 1 0 2",
"6 -1 1 2",
"6 2 1 3",
"7 -1 1 2",
"4 1 -1 -2",
"11 2 ... |
p01663 N and K | H --N and K
Consider a narrowly-sense monotonically increasing sequence of integers greater than or equal to 1 and N, in which no matter which two different numbers are taken from the elements of the sequence, the other does not divide one. Let L be the maximum length of such a sequence, and consider such a sequence (... | {
"input": [],
"output": []
} | {
"input": [
"5\n3 2\n5 2\n8 3\n10 1\n18 12"
],
"output": [
"3\n3\n5\n4\n-1"
]
} | {
"input": [
"5\n3 2\n4 2\n8 3\n10 1\n18 12",
"5\n3 2\n5 2\n8 3\n10 2\n18 12",
"5\n0 2\n7 2\n8 3\n10 1\n18 12",
"5\n0 2\n7 2\n8 3\n10 1\n18 7",
"5\n0 2\n7 2\n8 3\n4 1\n18 7",
"5\n3 2\n5 2\n1 3\n10 2\n14 12",
"5\n3 2\n4 2\n8 3\n1 1\n18 16",
"5\n3 2\n5 3\n1 3\n10 2\n14 12",
"5\n0 4\n... |
p01808 Kuru Kuru Door | Kuru Kuru Door
Round and round door
The ICPC (Intelligent Circular Perfect Cleaner), a fully automatic circular vacuum cleaner developed by ACM (Automatic Cleaning Machine) in 2011, has a function to automatically start during the day and clean dust in places where you have passed. In addition, this ICPC also has a f... | {
"input": [],
"output": []
} | {
"input": [
"3\n1 4\n-5 5\n5 -5\n10\n1 10\n-10 5\n5 -10\n5\n3 5\n-20 0\n20 0\n8\n1 9\n-14 58\n6 24\n2\n2 8\n-57 -113\n42 -31\n4\n1 4\n-4 -5\n4 5\n0"
],
"output": [
"17.5032106371\n41.3850388846\n-1\n102.0656847372\n178.1399151364\n19.5548716821"
]
} | {
"input": [
"3\n1 4\n-5 5\n5 -5\n10\n1 10\n-10 5\n5 -10\n5\n3 5\n-20 0\n20 0\n8\n1 9\n-14 58\n6 24\n2\n2 8\n-57 -113\n42 -31\n4\n1 4\n-4 -5\n4 0\n0",
"3\n1 4\n-5 5\n2 -5\n10\n1 10\n-10 5\n5 -10\n5\n3 5\n-20 0\n20 0\n8\n1 9\n-14 58\n6 24\n2\n2 8\n-57 -113\n42 -31\n4\n1 4\n-4 -5\n4 0\n0",
"3\n1 4\n-5 5\n2 ... |
p01943 Multiplication Is Interesting | F: Multiplication is fun --Multiplication Is Interesting -
story
Namba, a high school boy, is thinking of giving her a few lines on her birthday. She is a girl who loves multiplication, so Namba wants to give her a sequence that will allow her to enjoy multiplication as much as possible. However, when the calculation... | {
"input": [],
"output": []
} | {
"input": [
"6 2.01\n1.10\n1.44\n0.91\n2.00\n1.12\n1.55"
],
"output": [
"3"
]
} | {
"input": [
"6 2.01\n1.973291582506739\n1.44\n0.91\n2.00\n1.12\n1.55",
"6 2.01\n3.193972823107136\n1.44\n1.6011184015013515\n2.00\n1.4112240923770436\n1.7115339331404038",
"6 2.01\n1.10\n1.676594273939908\n0.91\n2.00\n1.12\n1.55",
"1 2.7392730443507527\n3.4955293017360702\n1.609483321839198\n2.465634... |
p02092 Red Black Balloons | E: Red Black Balloons
Story
Homura-chan's dream comes true. It means ICPC Asia regional contest 20xx will be held in Sapporo! Homura-chan has been working hard for the preparation. And finally, it's the previous day of the contest. Homura-chan started to stock balloons to be delivered to contestants who get accepted.... | {
"input": [],
"output": []
} | {
"input": [
"3 2\n6 5 4\n8 1\n7 1"
],
"output": [
"3"
]
} | {
"input": [
"3 2\n6 5 4\n8 1\n11 1",
"3 2\n6 5 4\n8 2\n11 1",
"3 0\n6 5 4\n8 1\n7 0",
"3 2\n7 5 3\n8 2\n12 0",
"0 2\n7 5 3\n8 2\n12 0",
"3 2\n6 5 7\n8 2\n11 1",
"3 2\n7 5 8\n8 2\n12 0",
"3 2\n6 5 4\n8 1\n7 0",
"3 2\n6 5 4\n7 1\n11 1",
"3 2\n6 5 4\n8 2\n12 1",
"3 2\n6 5 4\n... |
p02224 3 Player Co-op Game | This is a reactive problem.
Problem statement
There are $ 200 $ non-negative integers of $ 1000 $ bits, $ a_1, \ ldots, a_ {100}, b_1, \ ldots, b_ {100} $.
Alice confirms $ a_1, \ ldots, a_ {100} $ and leaves a note $ X $ for $ 3000 $ bits for Charlie.
Bob checks $ b_1, \ ldots, b_ {100} $ and leaves a note $ Y $ f... | {
"input": [],
"output": []
} | {
"input": [
""
],
"output": [
""
]
} | {
"input": [],
"output": []
} |
p02376 Maximum Flow | A flow network is a directed graph which has a $source$ and a $sink$. In a flow network, each edge $(u, v)$ has a capacity $c(u, v)$. Each edge receives a flow, but the amount of flow on the edge can not exceed the corresponding capacity. Find the maximum flow from the $source$ to the $sink$.
Constraints
* $2 \leq |V... | {
"input": [],
"output": []
} | {
"input": [
"4 5\n0 1 2\n0 2 1\n1 2 1\n1 3 1\n2 3 2"
],
"output": [
"3"
]
} | {
"input": [
"4 2\n0 1 2\n0 2 1\n1 2 1\n1 3 1\n2 3 2",
"3 2\n1 1 0\n0 2 1\n1 1 2\n1 3 1\n2 3 2",
"6 2\n0 1 2\n0 2 1\n1 2 1\n1 3 1\n2 3 2",
"6 2\n0 1 2\n0 2 1\n1 2 1\n1 3 1\n2 3 4",
"6 2\n0 1 2\n0 2 1\n1 2 1\n1 3 1\n2 3 5",
"6 2\n0 1 0\n0 2 1\n1 2 1\n1 3 1\n2 3 5",
"6 2\n1 1 0\n0 2 1\n1 2 1... |
amifib | The Head Chef has been playing with Fibonacci numbers for long . He has learnt several tricks related to Fibonacci numbers . Now he wants to test his chefs in the skills .
A fibonacci number is defined by the recurrence :
f(n) = f(n-1) + f(n-2) for n > 2 and f(1) = 0 and f(2) = 1 .
Given a number A , determine if... | {
"input": [],
"output": []
} | {
"input": [
"3\n3\n4\n5"
],
"output": [
"YES\nNO\nYES\n"
]
} | {
"input": [
"3\n3\n4\n3",
"3\n3\n6\n4",
"3\n3\n3\n4",
"3\n3\n3\n3",
"3\n6\n3\n6",
"3\n9\n15\n9",
"3\n6\n9\n3",
"3\n6\n5\n3",
"3\n3\n7\n3",
"3\n2\n7\n3",
"3\n3\n6\n5",
"3\n3\n6\n3",
"3\n2\n7\n5",
"3\n3\n3\n2",
"3\n3\n4\n4",
"3\n3\n5\n3",
"3\n2\n7\n6"... |
chefzot | Chef loves research! Now he is looking for subarray of maximal length with non-zero product.
Chef has an array A with N elements: A1, A2, ..., AN.
Subarray Aij of array A is elements from index i to index j: Ai, Ai+1, ..., Aj.
Product of subarray Aij is product of all its elements (from ith to jth).
Input
First li... | {
"input": [],
"output": []
} | {
"input": [
"1\n0",
"6\n1 0 2 3 0 4",
"3\n1 0 1"
],
"output": [
"0\n",
"2\n",
"1\n"
]
} | {
"input": [
"6\n1 0 2 3 0 6",
"3\n2 0 1",
"3\n1 1 1",
"3\n0 0 0",
"6\n1 0 2 5 0 6",
"3\n3 0 1",
"3\n1 0 2",
"6\n0 0 2 3 0 6",
"6\n1 0 2 0 0 6",
"3\n1 0 3",
"6\n-1 0 2 3 0 6",
"1\n1",
"3\n2 1 1",
"3\n2 0 2",
"3\n1 1 3",
"6\n0 0 2 0 0 6",
"6\n1 0 2 0 ... |
dumpling | Chef Shifu and Chef Po are participating in the Greatest Dumpling Fight of 2012.
Of course, Masterchef Oogway has formed the rules of the fight.
There is a long horizontal rope of infinite length with a center point P.
Initially both Chef Shifu and Chef Po will stand on the center P of the rope facing each other.
Don... | {
"input": [],
"output": []
} | {
"input": [
"3\n2 4 3 6 7\n1 2 4 5 1\n10 12 3 9 16"
],
"output": [
"3\n3\n5\n"
]
} | {
"input": [
"3\n2 4 3 11 7\n1 2 4 5 1\n10 12 3 9 16",
"3\n2 4 0 10 7\n1 4 4 5 1\n10 12 3 9 16",
"3\n2 4 0 10 0\n1 4 4 5 1\n10 12 3 5 16",
"3\n2 4 0 10 0\n0 4 4 5 1\n10 12 3 5 16",
"3\n2 4 0 10 0\n0 4 4 5 1\n1 12 3 5 16",
"3\n2 4 3 6 7\n1 2 4 5 1\n10 12 4 9 16",
"3\n2 4 3 18 7\n1 2 4 5 1\n... |
kgood | Chef Al Gorithm was reading a book about climate and oceans when he encountered the word “glaciological”. He thought it was quite curious, because it has the following interesting property: For every two letters in the word, if the first appears x times and the second appears y times, then |x - y| ≤ 1.
Chef Al was happ... | {
"input": [],
"output": []
} | {
"input": [
"4\nglaciological 1\nteammate 0\npossessions 3\ndefenselessness 3"
],
"output": [
"0\n0\n1\n2\n"
]
} | {
"input": [
"4\nglaciological 1\nteammate 0\npossessions 3\ndefenselessness 0",
"4\nglaciological 1\nteammate 0\npossessions 4\ndefenselessness 0",
"4\nglaciological 1\nteammate 1\npossessions 4\ndefensdlessness 0",
"4\nlacigoloicalg 2\nteammate 0\npossessions 0\ndefensdnessless 0",
"4\nlacigoloi... |
ojumps | This morning Chef wants to jump a little. In a few minutes he will arrive at the point 0. Then he will perform a lot of jumps in such a sequence: 1-jump, 2-jump, 3-jump, 1-jump, 2-jump, 3-jump, 1-jump, and so on.
1-jump means that if Chef is at the point x, he will jump to the point x+1.
2-jump means that if Chef is a... | {
"input": [],
"output": []
} | {
"input": [
"2",
"0",
"3",
"1",
"10",
"6",
"7"
],
"output": [
"no\n",
"yes\n",
"yes\n",
"yes\n",
"no\n",
"yes\n",
"yes\n"
]
} | {
"input": [
"4",
"-3",
"-1",
"-2",
"5",
"-4",
"8",
"12",
"-5",
"-6",
"-10",
"-8",
"-7",
"-9",
"9",
"-17",
"-11",
"22",
"-13",
"-14",
"-12",
"13",
"-23",
"11",
"16",
"-20",
"-22",
"-16",
"-31",
"-18... |
snon07 | Starting at the top left corner of an N*M grid and facing towards the right, you keep walking one square at a time in the direction you are facing. If you reach the boundary of the grid or if the next square you are about to visit has already been visited, you turn right. You stop when all the squares in the grid have ... | {
"input": [],
"output": []
} | {
"input": [
"4\n1 1\n2 2\n3 1\n3 3"
],
"output": [
"R\nL\nD\nR"
]
} | {
"input": [],
"output": []
} |
1302_H. Who needs suffix structures? | This is an unusual problem in an unusual contest, here is the announcement: [http://codeforces.com/blog/entry/73543](//codeforces.com/blog/entry/73543)
You run a string shop. During a day your customers want to buy strings of certain lengths and sometimes satisfying other properties.
You have a string of length n and... | {
"input": [],
"output": []
} | {
"input": [
"5 2\n1 2 3 1 2\n2 1 4\n3 1 3\n",
"9 3\n0 0 0 0 0 0 0 0 0\n9 1 1\n8 1 2\n1 1 9\n"
],
"output": [
"\nYes\nNo\n",
"\nYes\nYes\nYes\n"
]
} | {
"input": [],
"output": []
} |
1346_A. Color Revolution | Hmm, how long has it been since the last color revolution? 5 years?! It's totally the time to make a new one!
So the general idea is the following. Division 1 should have n_1 participants. Division 2 should have n_2 and be exactly k times bigger than division 1 (n_2 = k ⋅ n_1). Division 3 should have n_3 = k ⋅ n_2 par... | {
"input": [],
"output": []
} | {
"input": [
"4\n40 3\n1200 7\n320802005 400\n4 1\n"
],
"output": [
"\n1 3 9 27\n3 21 147 1029\n5 2000 800000 320000000\n1 1 1 1\n"
]
} | {
"input": [],
"output": []
} |
1430_B. Barrels | You have n barrels lined up in a row, numbered from left to right from one. Initially, the i-th barrel contains a_i liters of water.
You can pour water from one barrel to another. In one act of pouring, you can choose two different barrels x and y (the x-th barrel shouldn't be empty) and pour any possible amount of wa... | {
"input": [],
"output": []
} | {
"input": [
"2\n4 1\n5 5 5 5\n3 2\n0 0 0\n"
],
"output": [
"10\n0\n"
]
} | {
"input": [
"2\n4 2\n5 5 5 5\n3 2\n0 0 0\n",
"2\n4 2\n5 5 5 5\n3 2\n0 0 1\n",
"2\n4 3\n5 5 2 5\n3 2\n0 1 0\n",
"2\n4 3\n5 5 2 1\n3 2\n0 1 0\n",
"2\n4 3\n5 1 2 1\n3 2\n0 1 0\n",
"2\n4 2\n2 5 5 0\n3 2\n0 0 0\n",
"2\n4 3\n5 1 2 2\n3 2\n0 1 0\n",
"2\n4 3\n5 1 2 2\n3 2\n0 1 1\n",
"2\n4... |
1527_D. MEX Tree | You are given a tree with n nodes, numerated from 0 to n-1. For each k between 0 and n, inclusive, you have to count the number of unordered pairs (u,v), u ≠ v, such that the MEX of all the node labels in the shortest path from u to v (including end points) is k.
The MEX of a sequence of integers is the smallest non-n... | {
"input": [],
"output": []
} | {
"input": [
"2\n4\n0 1\n0 2\n2 3\n2\n1 0\n"
],
"output": [
"\n1 2 1 1 1 \n0 0 1 \n"
]
} | {
"input": [
"2\n4\n0 1\n1 2\n2 3\n2\n1 0\n",
"2\n4\n0 1\n1 2\n1 3\n2\n1 0\n",
"2\n4\n0 1\n1 2\n0 3\n2\n1 0\n",
"2\n4\n0 1\n0 2\n0 3\n2\n1 0\n",
"2\n4\n0 1\n1 3\n2 3\n2\n1 0\n",
"2\n4\n0 3\n1 2\n2 3\n2\n1 0\n",
"2\n4\n0 3\n1 2\n1 3\n2\n1 0\n",
"2\n4\n0 3\n1 3\n2 3\n2\n1 0\n",
"2\n4... |
178_E1. The Beaver's Problem - 2 | Offering the ABBYY Cup participants a problem written by the Smart Beaver is becoming a tradition. He proposed the following problem.
You are given a monochrome image, that is, an image that is composed of two colors (black and white). The image is given in raster form, that is, as a matrix of pixels' colors, and the ... | {
"input": [],
"output": []
} | {
"input": [],
"output": []
} | {
"input": [],
"output": []
} |
345_D. Chain Letter | A chain letter is a kind of a message which urges the recipient to forward it to as many contacts as possible, usually with some kind of mystic explanation. Of course, this is only a superstition, and you don't believe in it, but all your friends do. You know that today there will be one of these letters going around, ... | {
"input": [],
"output": []
} | {
"input": [
"4\n0111\n1011\n1101\n1110\n",
"4\n0110\n1010\n1100\n0000\n",
"4\n0101\n1001\n0001\n1110\n"
],
"output": [
"3\n",
"0\n",
"2\n"
]
} | {
"input": [],
"output": []
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.