name stringlengths 2 112 | description stringlengths 29 13k | private_tests dict | public_tests dict | generated_tests dict |
|---|---|---|---|---|
p01926 Game Balance | Game balance
You are creating an adventure game. The player of this game advances the adventure by operating the hero to defeat the enemy monsters and raising the level of the hero. The initial level of the hero is 1.
There are N types of enemy monsters in this game, and the strength of the i-th type enemy monster is... | {
"input": [],
"output": []
} | {
"input": [
"3 4\n1 5 9\n1 2\n1\n2 10\n1 1000000\n2 4\n1 10\n0 0"
],
"output": [
"3\n-1\n499996\n4"
]
} | {
"input": [
"3 4\n2 5 9\n1 2\n1\n2 10\n1 1000000\n2 4\n1 10\n0 0",
"3 8\n1 5 9\n1 2\n1\n2 10\n1 1000000\n2 4\n1 10\n0 0",
"3 8\n0 2 9\n1 2\n1\n2 10\n1 1000000\n2 4\n1 3\n0 0",
"3 4\n1 5 17\n1 2\n3\n2 10\n1 1000000\n2 4\n1 10\n0 0",
"3 8\n1 2 9\n1 2\n1\n2 10\n1 1000100\n2 4\n1 10\n0 0",
"3 4\n... |
p02064 Restore Shortest Path | E: Restoration of shortest path
story
Competition programmers solve the shortest path problem every day. BFS, Bellman Ford, Dijkstra, Worshall Floyd and many other algorithms are also known.
Meanwhile, you had a shortest path problem that you couldn't solve. It's a problem of solving the shortest path problem withou... | {
"input": [],
"output": []
} | {
"input": [
""
],
"output": [
""
]
} | {
"input": [],
"output": []
} |
p02206 Prize | Prize
Segtree entered a programming contest with a team of $ N $ and won a $ K $ yen prize! I'm trying to distribute this prize now.
Each $ N $ team member, including Segtree, is numbered from $ 1 $ to $ N $ in order of ability. Segtree is $ 1 $.
If the prize amount of $ i $'s teammate $ (i \ geq 2) $ is less than "... | {
"input": [],
"output": []
} | {
"input": [
"1 1"
],
"output": [
"1"
]
} | {
"input": [
"1 2",
"2 1",
"1 3",
"1 4",
"1 6",
"2 12",
"2 8",
"1 9",
"3 12",
"14 32",
"26 36",
"26 30",
"1 11",
"3 24",
"3 17",
"26 42",
"1 18",
"4 24",
"48 62",
"1 38",
"6 31",
"9 22",
"48 40",
"1 74",
"2 40",
"5... |
p02360 The Maximum Number of Overlaps | Given a set of $N$ axis-aligned rectangular seals, find the number of overlapped seals on the region which has the maximum number of overlapped seals.
Constraints
* $ 1 \leq N \leq 100000 $
* $ 0 \leq x1_i < x2_i \leq 1000 $
* $ 0 \leq y1_i < y2_i \leq 1000 $
* $ x1_i, y1_i, x2_i, y2_i$ are given in integers
Input
... | {
"input": [],
"output": []
} | {
"input": [
"2\n0 0 2 2\n2 0 4 2",
"3\n0 0 2 2\n0 0 2 2\n0 0 2 2",
"2\n0 0 3 2\n2 1 4 3"
],
"output": [
"1",
"3",
"2"
]
} | {
"input": [
"2\n0 0 2 2\n2 0 4 4",
"3\n0 0 1 2\n0 0 2 2\n0 0 2 2",
"2\n0 0 3 2\n2 1 4 2",
"2\n0 0 0 1\n2 2 4 2",
"2\n0 0 3 1\n2 1 4 3",
"2\n0 0 3 1\n2 1 4 2",
"2\n0 0 3 1\n2 1 4 4",
"2\n0 0 2 2\n2 0 2 2",
"3\n0 0 2 4\n0 0 2 2\n0 0 2 2",
"3\n0 0 1 2\n0 0 2 3\n0 0 2 2",
"2\n... |
chefa | Chef and Roma are playing a game. Rules of the game are quite simple.
Initially there are N piles of stones on the table.
In each turn, a player can choose one pile and remove it from the table.
Each player want to maximize the total number of stones removed by him.
Chef takes the first turn.
Please tell Chef the max... | {
"input": [],
"output": []
} | {
"input": [
"2\n3\n1 2 3\n3\n1 2 1"
],
"output": [
"4\n3\n"
]
} | {
"input": [
"2\n3\n1 2 3\n3\n1 2 2",
"2\n3\n1 2 3\n3\n0 2 1",
"2\n3\n1 0 3\n3\n0 2 1",
"2\n3\n1 0 2\n3\n0 2 1",
"2\n3\n1 1 2\n3\n0 4 1",
"2\n3\n1 1 4\n3\n0 4 1",
"2\n3\n1 1 4\n3\n0 3 1",
"2\n3\n1 1 5\n3\n0 3 1",
"2\n3\n1 1 5\n3\n0 2 1",
"2\n3\n1 1 5\n3\n2 2 2",
"2\n3\n1 1 ... |
devperf | There is a haunted town called HauntedLand. The structure of HauntedLand can be thought of as a grid of size n * m. There is a house in each cell of the grid. Some people have fled from their houses because they were haunted. '.' represents a haunted house whereas '*' represents a house in which people are living.
On... | {
"input": [],
"output": []
} | {
"input": [
"2\n2 2\n*.\n..\n3 4\n.*..\n***.\n.*.."
],
"output": [
"1\n2"
]
} | {
"input": [],
"output": []
} |
insm06 | Ronak’s class teacher gives him an NxN matrix.
Then, she gives him M numbers. Every number is an angle, the angle by which he has to rotate the matrix in clockwise direction. (The angles are multiples of 90.)
Help him with the task.
Input
First line consists of two numbers N and M.
The following N lines contain ... | {
"input": [],
"output": []
} | {
"input": [
"4 2\n1 2 3 4\n4 5 6 7\n6 8 4 3\n8 1 4 7\n90\n180"
],
"output": [
"8 6 4 1\n1 8 5 2\n4 4 6 3\n7 3 7 4\n\n7 4 1 8\n3 4 8 6\n7 6 5 4\n4 3 2 1"
]
} | {
"input": [],
"output": []
} |
newsch | Scheme? - Too loudly said. Just a new idea. Now Chef is expanding his business. He wants to make some new restaurants in the big city of Lviv. To make his business competitive he should interest customers. Now he knows how. But don't tell anyone - it is a secret plan. Chef knows four national Ukrainian dishes - salo, ... | {
"input": [],
"output": []
} | {
"input": [
"3\n2\n3\n5"
],
"output": [
"12\n24\n240\n"
]
} | {
"input": [
"3\n2\n3\n6",
"3\n2\n3\n3",
"3\n3\n3\n6",
"3\n2\n3\n2",
"3\n4\n3\n2",
"3\n4\n5\n2",
"3\n4\n5\n4",
"3\n2\n5\n4",
"3\n2\n5\n5",
"3\n2\n6\n5",
"3\n2\n8\n5",
"3\n2\n2\n5",
"3\n2\n6\n6",
"3\n2\n2\n3",
"3\n3\n5\n6",
"3\n2\n2\n2",
"3\n4\n6\n2",... |
sad | Our Chef is very happy that his son was selected for training in one of the finest culinary schools of the world.
So he and his wife decide to buy a gift for the kid as a token of appreciation.
Unfortunately, the Chef hasn't been doing good business lately, and is in no mood on splurging money.
On the other hand, the b... | {
"input": [],
"output": []
} | {
"input": [
"2 3\n9 8 8\n2 6 11",
"3 3\n9 8 11\n2 6 34\n5 9 11",
"2 2\n10 10\n10 10"
],
"output": [
"8\n",
"GUESS\n",
"10\n"
]
} | {
"input": [
"2 3\n1 8 8\n2 6 11",
"3 3\n9 8 11\n0 6 34\n5 9 11",
"2 2\n10 7\n10 10",
"2 3\n0 8 8\n3 6 11",
"2 2\n9 7\n10 8",
"2 3\n0 8 8\n1 6 11",
"2 2\n10 7\n10 0",
"3 3\n1 1 11\n0 6 34\n5 10 11",
"2 2\n10 9\n10 8",
"2 3\n0 8 8\n0 8 11",
"2 3\n1 2 12\n4 6 4",
"2 3\n24... |
ynoutput | The state space of the output of this problem (and as a matter of fact, all the problems in this Cook-Off) is - 2 to the power T -
where T is the number of test cases (so be extra careful!). Each test case consists of T lines consisting of "YES" or "NO".
If a test case accurately represents the output that you would pr... | {
"input": [],
"output": []
} | {
"input": [
"2\nNO\nNO\nNO\nYES"
],
"output": [
"NO\nYES"
]
} | {
"input": [
"2\nNO\nON\nNO\nYES",
"2\nNN\nNL\nON\nXES",
"2\nNO\nNN\nNO\nYES",
"2\nNN\nON\nNO\nYES",
"2\nNN\nOM\nNO\nYES",
"2\nNN\nOL\nNO\nYES",
"2\nNN\nMO\nNO\nYES",
"2\nNO\nMN\nNO\nYES",
"2\nNN\nNL\nNO\nYES",
"2\nNN\nMN\nNO\nYES",
"2\nNN\nMM\nNO\nYES",
"2\nNN\nNN\nNO\... |
fibofibo-3 | Pseudo-code to find the nth fibonacci number :
int fibo(int n)
{
if (n == 0)
{
write(0)
return 0
}
if (n == 1)
{
write(1)
return 1
}
return fibo(n - 1) + fibo(n - 2)
}
If we call fibo(3), the following happens:
fibo(3) calls fibo(2) and fibo(1) ---->the first call.
fibo(2) calls fibo(1) ---->the seco... | {
"input": [],
"output": []
} | {
"input": [
"2\n1\n2\n\nSAMPLE"
],
"output": [
"0 1\n1 1"
]
} | {
"input": [
"2\n1\n2\n\nELPMAS",
"2\n2\n2\n\nELPMAS",
"2\n1\n1\n\nSAMPLE",
"2\n2\n3\n\nSLBPLE",
"2\n1\n3\n\nSEMALP",
"2\n2\n1\n\nSLBPLE",
"2\n1\n5\n\nSEMALP",
"2\n4\n1\n\nSLBPLE",
"2\n4\n2\n\nSLNPEB",
"2\n6\n2\n\nSLNPEB",
"2\n1\n7\n\nSEM@QL",
"2\n1\n11\n\nSEM@QL",
... |
number-mania | Tod is very much focus about his English subject but now he is in trouble because he have to do his Math homework but also have to go for English classes so he asks you for help to solve his Math homework question.
You are given a Natural number(N) you have to print Factorial of the Prime number present in the (S) se... | {
"input": [],
"output": []
} | {
"input": [
"4\n\nSAMPLE"
],
"output": [
"2\n6\n"
]
} | {
"input": [
"4\n\nSALPLE",
"4\n\nSALPLD",
"4\n\nRALPLD",
"4\n\nDLPLAR",
"4\n\nELPLAR",
"4\n\nRALPLE",
"4\n\nR@LPLE",
"4\n\nR@LPLD",
"4\n\nR@LDLP",
"4\n\nQ@LDLP",
"4\n\nL@LDQP",
"4\n\nL@QDLP",
"4\n\nPLDQ@L",
"4\n\nL@QELP",
"4\n\nPLEQ@L",
"4\n\nOLEQ@L",
... |
question-3-21 | Hardy wants to test Ramanujam of his Mathematical skills. So he gives him a puzzle which is described below.
Puzzle:
There are 100 doors, numbered 1,2,....100 .Initially all doors are closed.
Now a person comes(lets call him the 1st person)he opens the first door and leaves.
Now a second guy comes and checks the stat... | {
"input": [],
"output": []
} | {
"input": [
"4 2\n2\n3\n\nSAMPLE"
],
"output": [
"1\n2\n"
]
} | {
"input": [
"5 2\n2\n3\n\nSAMPLE",
"5 1\n2\n3\n\nSAMPLE",
"4 2\n2\n2\n\nELPMBS",
"5 1\n3\n2\n\nEKPMAS",
"4 2\n1\n3\n\nSAMPLE",
"4 2\n2\n1\n\nELPMBS",
"7 2\n3\n3\n\nELPMAS",
"5 2\n2\n5\n\nSAMPLE",
"5 1\n0\n0\n\nEKPMAS",
"7 2\n3\n0\n\nELPMAS",
"5 2\n0\n2\n\nEKPAMS",
"5 2... |
p02534 ACL Beginner Contest - Repeat ACL | You are given an integer K. Print the string obtained by repeating the string `ACL` K times and concatenating them.
For example, if K = 3, print `ACLACLACL`.
Constraints
* 1 \leq K \leq 5
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
K
Output
Print the s... | {
"input": [],
"output": []
} | {
"input": [
"3"
],
"output": [
"ACLACLACL"
]
} | {
"input": [
"4",
"6",
"5",
"10",
"8",
"7",
"9",
"2",
"13",
"1",
"20",
"15",
"16",
"17",
"19",
"24",
"11",
"26",
"27",
"47",
"61",
"115",
"58",
"14",
"22",
"18",
"38",
"46",
"60",
"82",
"151",
... |
p02666 NOMURA Programming Competition 2020 - Urban Planning | There are N towns numbered 1, 2, \cdots, N.
Some roads are planned to be built so that each of them connects two distinct towns bidirectionally. Currently, there are no roads connecting towns.
In the planning of construction, each town chooses one town different from itself and requests the following: roads are built... | {
"input": [],
"output": []
} | {
"input": [
"4\n2 1 -1 3",
"2\n2 1",
"10\n2 6 9 -1 6 9 -1 -1 -1 -1"
],
"output": [
"8",
"1",
"527841"
]
} | {
"input": [
"4\n2 1 -1 2",
"2\n1 1",
"10\n2 6 9 -1 7 9 -1 -1 -1 -1",
"4\n2 2 -1 3",
"10\n2 9 5 -1 7 9 -1 -1 -1 -1",
"2\n1 2",
"4\n1 1 -1 4",
"4\n2 3 -1 4",
"10\n2 9 5 -1 6 9 -1 -1 -1 -1",
"4\n1 2 -1 4",
"10\n2 9 8 -1 7 9 -1 -1 -1 -1",
"10\n2 9 5 -1 3 9 -1 -1 -1 -1",
... |
p02795 Keyence Programming Contest 2020 - Painting | We have a grid with H rows and W columns, where all the squares are initially white.
You will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions:
* Choose one row, then paint all the squares in that row black.
* Choose one column, then paint all the s... | {
"input": [],
"output": []
} | {
"input": [
"3\n7\n10",
"2\n100\n200",
"14\n12\n112"
],
"output": [
"2",
"2",
"8"
]
} | {
"input": [
"3\n7\n15",
"2\n000\n200",
"14\n12\n47",
"2\n000\n217",
"3\n7\n45",
"14\n16\n2",
"3\n7\n76",
"2\n000\n4",
"3\n10\n43",
"14\n12\n183",
"2\n000\n311",
"2\n000\n17",
"3\n7\n54",
"3\n0\n76",
"3\n2\n43",
"2\n000\n406",
"2\n000\n12",
"3\n1... |
p02931 Japanese Student Championship 2019 Qualification - Card Collector | There are N cards placed on a grid with H rows and W columns of squares.
The i-th card has an integer A_i written on it, and it is placed on the square at the R_i-th row from the top and the C_i-th column from the left.
Multiple cards may be placed on the same square.
You will first pick up at most one card from eac... | {
"input": [],
"output": []
} | {
"input": [
"1 100000 100000\n1 1 1",
"13 5 6\n1 3 35902\n4 6 19698\n4 6 73389\n3 6 3031\n3 1 4771\n1 4 4784\n2 1 36357\n2 1 24830\n5 6 50219\n4 6 22645\n1 2 30739\n1 4 68417\n1 5 78537",
"6 2 2\n2 2 2\n1 1 8\n1 1 5\n1 2 9\n1 2 7\n2 1 4"
],
"output": [
"1",
"430590",
"28"
]
} | {
"input": [
"13 5 6\n1 3 35902\n4 6 19698\n4 6 73389\n3 6 3031\n3 1 4771\n1 4 4784\n2 1 36357\n2 1 24830\n5 6 50219\n4 6 22645\n0 2 30739\n1 4 68417\n1 5 78537",
"6 2 2\n2 2 2\n1 1 8\n1 1 5\n1 2 9\n1 2 2\n2 1 4",
"13 5 6\n1 3 35902\n4 6 19698\n4 6 73389\n3 6 3031\n3 1 4771\n1 4 4784\n2 1 36357\n2 1 24830... |
p03067 Tenka1 Programmer Beginner Contest 2019 - On the Way | There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
Constraints
* 0\leq A,B,C\leq 100
* A, B and C are distinct integers.
I... | {
"input": [],
"output": []
} | {
"input": [
"10 2 4",
"7 3 1",
"31 41 59",
"3 8 5"
],
"output": [
"Yes",
"No",
"No",
"Yes"
]
} | {
"input": [
"8 2 4",
"3 3 1",
"31 61 59",
"3 8 7",
"1 2 4",
"4 3 1",
"31 49 59",
"6 8 7",
"1 0 4",
"4 2 1",
"39 49 59",
"4 8 7",
"1 -1 4",
"39 49 10",
"4 4 7",
"1 -1 2",
"51 49 10",
"4 4 0",
"0 -1 2",
"51 49 0",
"0 -2 2",
"51 79 ... |
p03210 AtCoder Beginner Contest 114 - 753 | Shichi-Go-San (literally "Seven-Five-Three") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children.
Takahashi is now X years old. Will his growth be celebrated in Shichi-Go-San this time?
Constraints
* 1 ≤ X ≤ 9
* X is an integer.
Input
Input is given from... | {
"input": [],
"output": []
} | {
"input": [
"6",
"5"
],
"output": [
"NO",
"YES"
]
} | {
"input": [
"11",
"7",
"16",
"3",
"19",
"4",
"12",
"0",
"9",
"1",
"13",
"-1",
"8",
"-2",
"2",
"-3",
"-5",
"-6",
"-9",
"-12",
"-11",
"-4",
"14",
"-7",
"-20",
"22",
"10",
"15",
"-8",
"26",
"-10",... |
p03359 AtCoder Beginner Contest 096 - Day of Takahashi | In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called Takahashi when the month and the day are equal as numbers. For exam... | {
"input": [],
"output": []
} | {
"input": [
"11 30",
"2 1",
"5 5"
],
"output": [
"11",
"1",
"5"
]
} | {
"input": [
"1 30",
"9 5",
"4 0",
"6 5",
"2 50",
"8 5",
"0 50",
"11 5",
"16 3",
"10 -1",
"23 3",
"12 6",
"12 12",
"0 -3",
"-2 1",
"-3 0",
"-5 0",
"5 2",
"-4 1",
"-9 1",
"-16 1",
"-11 0",
"-14 0",
"-6 -3",
"-24 0",
... |
p03517 CODE FESTIVAL 2017 Elimination Tournament Round 2 (Parallel) - Colorful MST | Ringo has an undirected graph G with N vertices numbered 1,2,...,N and M edges numbered 1,2,...,M. Edge i connects Vertex a_{i} and b_{i} and has a length of w_i.
Now, he is in the middle of painting these N vertices in K colors numbered 1,2,...,K. Vertex i is already painted in Color c_i, except when c_i = 0, in whic... | {
"input": [],
"output": []
} | {
"input": [
"4 3 3\n1 0 1 2\n1 2 10\n2 3 20\n2 4 50",
"18 37 12\n5 0 4 10 8 7 2 10 6 0 9 12 12 11 11 11 0 1\n17 1 1\n11 16 7575\n11 15 9\n10 10 289938980\n5 10 17376\n18 4 1866625\n8 11 959154208\n18 13 200\n16 13 2\n2 7 982223\n12 12 9331\n13 12 8861390\n14 13 743\n2 10 162440\n2 4 981849\n7 9 1\n14 17 2800... | {
"input": [
"4 3 3\n1 0 1 2\n1 2 0\n2 3 20\n2 4 50",
"9 12 9\n1 2 3 4 5 6 7 8 9\n6 9 13\n8 9 6\n6 7 85\n9 5 545631016\n2 1 321545\n1 6 33562944\n7 3 84946329\n9 7 15926167\n4 7 53386480\n5 8 70476\n4 6 4549\n4 8 8",
"5 2 4\n0 0 0 0 0\n1 2 10\n2 2 10",
"18 37 12\n5 0 4 10 8 7 2 10 6 0 9 12 12 11 11 11... |
p03680 AtCoder Beginner Contest 065 - Trained? | Takahashi wants to gain muscle, and decides to work out at AtCoder Gym.
The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It ... | {
"input": [],
"output": []
} | {
"input": [
"3\n3\n1\n2",
"5\n3\n3\n4\n2\n4",
"4\n3\n4\n1\n2"
],
"output": [
"2",
"3",
"-1"
]
} | {
"input": [
"3\n3\n1\n3",
"5\n3\n3\n5\n2\n4",
"4\n4\n3\n1\n2",
"3\n2\n2\n1",
"5\n3\n0\n4\n2\n4",
"4\n3\n3\n1\n2",
"3\n3\n2\n3",
"4\n4\n3\n0\n2",
"4\n4\n4\n0\n2",
"4\n4\n7\n0\n2",
"3\n1\n2\n6",
"5\n1\n3\n5\n2\n4",
"4\n3\n3\n1\n3",
"3\n3\n2\n1",
"4\n4\n5\n0\n... |
p03835 AtCoder Beginner Contest 051 - Sum of Three Integers | You are given two integers K and S.
Three variable X, Y and Z takes integer values satisfying 0≤X,Y,Z≤K.
How many different assignments of values to X, Y and Z are there such that X + Y + Z = S?
Constraints
* 2≤K≤2500
* 0≤S≤3K
* K and S are integers.
Input
The input is given from Standard Input in the following for... | {
"input": [],
"output": []
} | {
"input": [
"2 2",
"5 15"
],
"output": [
"6",
"1"
]
} | {
"input": [
"3 2",
"5 7",
"3 3",
"4 7",
"3 4",
"1 7",
"2 5",
"4 0",
"6 7",
"17 4",
"5 5",
"5 9",
"2 3",
"6 9",
"12 9",
"7 9",
"11 12",
"82 7",
"10 6",
"21 10",
"24 13",
"12 8",
"12 13",
"7 13",
"13 12",
"4 6",
... |
p04000 AtCoder Beginner Contest 045 - Snuke's Coloring | We have a grid with H rows and W columns. At first, all cells were painted white.
Snuke painted N of these cells. The i-th ( 1 \leq i \leq N ) cell he painted is the cell at the a_i-th row and b_i-th column.
Compute the following:
* For each integer j ( 0 \leq j \leq 9 ), how many subrectangles of size 3×3 of the gr... | {
"input": [],
"output": []
} | {
"input": [
"1000000000 1000000000 0",
"4 5 8\n1 1\n1 4\n1 5\n2 3\n3 1\n3 2\n3 4\n4 4",
"10 10 20\n1 1\n1 4\n1 9\n2 5\n3 10\n4 2\n4 7\n5 9\n6 4\n6 6\n6 7\n7 1\n7 3\n7 7\n8 1\n8 5\n8 10\n9 2\n10 4\n10 9"
],
"output": [
"999999996000000004\n0\n0\n0\n0\n0\n0\n0\n0\n0",
"0\n0\n0\n2\n4\n0\n0\n0\n0... | {
"input": [
"1000000000 1000000001 0",
"4 5 8\n1 1\n1 4\n0 5\n2 3\n3 1\n3 2\n3 4\n4 4",
"10 10 20\n1 1\n1 4\n1 9\n2 5\n3 10\n4 2\n4 7\n5 9\n12 4\n6 6\n6 7\n7 1\n7 3\n7 7\n8 1\n8 5\n8 10\n9 2\n10 4\n10 9",
"4 5 8\n1 1\n1 6\n0 5\n2 3\n3 1\n3 2\n3 4\n4 4",
"10 10 20\n2 1\n1 4\n1 9\n2 5\n3 10\n4 2\n4... |
p00088 The Code A Doctor Loved | Dr .: Peter, I've finally done it.
Peter: What's wrong, Dr. David? Is it a silly invention again?
Dr .: This table, this table.
| Character | Sign
--- | ---
(Blank) | 101
'| 000000
, | 000011
-| 10010001
. | 010001
? | 000001
A | 100101
B | 10011010
| Character | Sign
--- | ---
C | 0101
D | 0001
E | 110
F | 01001
G |... | {
"input": [],
"output": []
} | {
"input": [
"PETER POTTER"
],
"output": [
"?D-C'KOPUA"
]
} | {
"input": [
"PETER POTTRE",
"RETEP POTTRE",
"RETEP PNTTRE",
"REETP PNTTRE",
"REETP PMTTRE",
"RETEP PMTTRE",
"RETEP PRTTME",
"RETEP TRTPME",
"EETRP TRTPME",
"EETRP TRTPNE",
"EETRP ENPTRT",
"PRTEE ENPTRT",
"PRTEE TRTPNE",
"PRTEE TRSPNE",
"EETRP TRSPNE",
"... |
p00220 Binary Digit A Doctor Loved | "What are your shoe sizes?"
Suddenly, the doctor asked me when I met him for the first time.
"It's 23.5"
"Oh, that's a really nice number. It's 2 to the 4th power plus 2 to the 2nd power, 2 to the 1st power, 2 to the 0th power, and 2 to the 1st power."
Then the doctor asked.
"You, how tall are you?"
"Yes, it's 158.... | {
"input": [],
"output": []
} | {
"input": [
"23.5\n158.1\n-1.0"
],
"output": [
"00010111.1000\nNA"
]
} | {
"input": [
"23.72975180461117\n158.1\n-1.0",
"23.5\n158.1\n-0.5246083014985048",
"23.72975180461117\n158.1\n-0.5449258499657357",
"24.206542817215936\n158.1\n-1.0",
"24.615346202775605\n158.1\n-1.0",
"23.72975180461117\n158.6852941341954\n-0.5449258499657357",
"25.190547978615548\n158.1\... |
p00382 Taxi | PCK Taxi in Aizu city, owned by PCK company, has adopted a unique billing system: the user can decide the taxi fare. Today as usual, many people are waiting in a queue at the taxi stand in front of the station.
In front of the station, there are $N$ parking spaces in row for PCK taxis, each with an index running from ... | {
"input": [],
"output": []
} | {
"input": [
"3\n3 8 10 1\n4 7 1 2 15\n3 11 8 19"
],
"output": [
"45"
]
} | {
"input": [
"3\n3 8 10 1\n4 7 1 4 15\n3 11 8 19",
"3\n3 8 10 0\n2 7 1 4 15\n3 11 8 19",
"3\n3 8 10 0\n4 7 2 4 4\n3 11 8 19",
"3\n3 2 10 1\n4 7 2 4 15\n3 11 13 19",
"3\n3 8 9 0\n2 7 1 4 15\n2 11 1 19",
"3\n3 8 5 1\n2 6 1 4 15\n3 11 8 15",
"3\n6 8 10 1\n4 7 0 1 15\n3 11 8 38",
"3\n3 8 1... |
p00598 Operations with Finite Sets | Let A, B, C, D, E be sets of integers and let U is a universal set that includes all sets under consideration. All elements in any set are different (no repetitions).
u - union of two sets, AuB = {x ∈ U : x ∈ A or x ∈ B} is the set of all elements which belong to A or B.
i - intersection of two sets, AiB = {x ∈ U : x... | {
"input": [],
"output": []
} | {
"input": [
"A 3\n1 3 -1\nB 4\n3 1 5 7\nD 1\n5\nR 0\ncAiBdD\nC 3\n1 2 3\nA 4\n2 10 8 3\nB 3\n2 4 8\nR 0\n(As(AiB))uC"
],
"output": [
"7\n1 2 3 10"
]
} | {
"input": [
"A 3\n1 3 -1\nB 4\n3 1 5 7\nD 1\n5\nR 0\ncAiBdD\nC 3\n1 2 3\nA 4\n2 9 8 3\nB 3\n2 4 8\nR 0\n(As(AiB))uC",
"A 3\n1 3 -1\nB 4\n3 1 5 7\nD 1\n5\nR 0\ncAiBdD\nC 3\n1 2 3\nA 4\n2 10 8 3\nB 3\n3 4 8\nR 0\n(As(AiB))uC",
"A 3\n1 2 -1\nB 4\n3 1 5 7\nD 1\n5\nR 0\ncAiBdD\nC 3\n1 2 3\nA 4\n2 9 8 3\nB 3\n... |
p00734 Equal Total Scores | Taro and Hanako have numbers of cards in their hands. Each of the cards has a score on it. Taro and Hanako wish to make the total scores of their cards equal by exchanging one card in one's hand with one card in the other's hand. Which of the cards should be exchanged with which?
Note that they have to exchange their ... | {
"input": [],
"output": []
} | {
"input": [
"2 2\n1\n5\n3\n7\n6 5\n3\n9\n5\n2\n3\n3\n12\n2\n7\n3\n5\n4 5\n10\n0\n3\n8\n1\n9\n6\n0\n6\n7 4\n1\n1\n2\n1\n2\n1\n4\n2\n3\n4\n3\n2 3\n1\n1\n2\n2\n2\n0 0"
],
"output": [
"1 3\n3 5\n-1\n2 2\n-1"
]
} | {
"input": [
"2 2\n1\n5\n4\n7\n6 5\n3\n9\n5\n2\n3\n3\n12\n2\n7\n3\n5\n4 5\n10\n0\n3\n8\n1\n9\n6\n0\n6\n7 4\n1\n1\n2\n1\n2\n1\n4\n2\n3\n4\n3\n2 3\n1\n1\n2\n2\n2\n0 0",
"2 2\n1\n5\n4\n7\n6 5\n3\n9\n5\n2\n3\n3\n12\n2\n7\n3\n5\n4 5\n10\n0\n3\n8\n1\n9\n6\n0\n6\n7 4\n1\n1\n2\n1\n2\n1\n4\n2\n3\n4\n6\n2 3\n1\n1\n2\n2... |
p00874 Cubist Artwork | International Center for Picassonian Cubism is a Spanish national museum of cubist artworks, dedicated to Pablo Picasso. The center held a competition for an artwork that will be displayed in front of the facade of the museum building. The artwork is a collection of cubes that are piled up on the ground and is intended... | {
"input": [],
"output": []
} | {
"input": [
"5 5\n1 2 3 4 5\n1 2 3 4 5\n5 5\n2 5 4 1 3\n4 1 5 3 2\n5 5\n1 2 3 4 5\n3 3 3 4 5\n3 3\n7 7 7\n7 7 7\n3 3\n4 4 4\n4 3 4\n4 3\n4 2 2 4\n4 2 1\n4 4\n2 8 8 8\n2 3 8 3\n10 10\n9 9 9 9 9 9 9 9 9 9\n9 9 9 9 9 9 9 9 9 9\n10 9\n20 1 20 20 20 20 20 18 20 20\n20 20 20 20 7 20 20 20 20\n0 0"
],
"output": [
... | {
"input": [
"5 5\n1 2 3 4 5\n1 2 1 4 5\n5 5\n2 5 4 1 3\n4 1 5 3 2\n5 5\n1 2 3 4 5\n3 3 3 4 5\n3 3\n7 7 7\n7 7 7\n3 3\n4 4 4\n4 3 4\n4 3\n4 2 2 4\n4 2 1\n4 4\n2 8 8 8\n2 3 8 3\n10 10\n9 9 9 9 9 9 9 9 9 9\n9 9 9 9 9 9 9 9 9 9\n10 9\n20 1 20 20 20 20 20 18 20 20\n20 20 20 20 7 20 20 20 20\n0 0",
"5 5\n1 2 3 4 5... |
p01005 The Humans Braving the Invaders | Problem
Today, the Earth has been attacked by the invaders from space, Invader, and the only survivors of humankind are us at the base. There is almost no force left to compete with them. But here we do not give up. Eradication of Invaders is the last resort for us humans to survive. I will explain the contents of the... | {
"input": [],
"output": []
} | {
"input": [
"18 10\n0\n4 1\n1 1\n4 1\n0\n1 1\n0\n2 2\n1 10\n0\n1 1\n0\n1 1\n0\n1 5\n3 4 0\n3 4 1\n0\n9 10\n4 1\n2 2\n3 5 5\n0\n4 1\n2 2\n3 5 5\n0\n2 1\n0 0"
],
"output": [
"distance 10\ndistance 9\nhit\ndamage 2\nbomb 1\nbomb 2\nend\ndistance -1\nmiss\nbomb 0\ndistance 10\nmiss\nbomb 1\nhit\nend"
]
} | {
"input": [
"18 10\n0\n4 1\n1 1\n4 1\n0\n1 1\n0\n2 2\n1 10\n0\n1 1\n0\n1 1\n0\n1 5\n3 4 1\n3 4 1\n0\n9 10\n4 1\n2 2\n3 5 5\n0\n4 1\n2 2\n3 5 5\n0\n2 1\n0 0",
"18 10\n0\n4 1\n1 1\n4 1\n0\n1 1\n0\n2 2\n1 10\n0\n1 1\n0\n1 1\n0\n1 5\n3 4 1\n3 4 1\n0\n9 10\n4 1\n2 2\n3 7 5\n0\n4 1\n4 2\n3 5 5\n0\n2 1\n0 0",
"... |
p01137 Space Coconut Grab | Space Coconut Crab
Space coconut crab
English text is not available in this practice contest.
Ken Marine Blue is a space hunter who travels through the entire galaxy in search of space coconut crabs. The space coconut crab is the largest crustacean in the universe, and it is said that the body length after growth is... | {
"input": [],
"output": []
} | {
"input": [
"1\n2\n4\n27\n300\n1250\n0"
],
"output": [
"1\n2\n2\n3\n18\n44"
]
} | {
"input": [
"1\n2\n4\n6\n300\n1250\n0",
"1\n2\n4\n2\n300\n1250\n0",
"1\n2\n4\n3\n300\n1250\n0",
"1\n2\n4\n3\n76\n1250\n0",
"1\n2\n4\n27\n557\n1250\n0",
"1\n2\n4\n6\n300\n1687\n0",
"1\n1\n4\n2\n300\n1250\n0",
"1\n2\n5\n3\n300\n1250\n0",
"1\n2\n3\n3\n76\n1250\n0",
"1\n2\n4\n27\n... |
p01276 Double Sorting | Here we describe a typical problem. There are n balls and n boxes. Each ball is labeled by a unique number from 1 to n. Initially each box contains one of these balls. We can swap two balls in adjacent boxes. We are to sort these balls in increasing order by swaps, i.e. move the ball labeled by 1 to the first box, labe... | {
"input": [],
"output": []
} | {
"input": [
"5\n5 5\n4 4\n3 3\n2 2\n1 1\n5\n1 5\n3 4\n2 5\n2 3\n1 4\n8\n8 3\n4 2\n6 4\n3 5\n5 8\n7 1\n2 6\n1 7\n0"
],
"output": [
"15\n9\n21"
]
} | {
"input": [
"5\n5 5\n4 4\n3 3\n2 2\n1 1\n0\n1 5\n3 4\n2 5\n2 3\n1 4\n8\n8 3\n4 2\n6 4\n3 5\n5 8\n7 1\n2 6\n1 7\n0",
"5\n5 5\n4 4\n3 3\n2 2\n1 1\n0\n1 5\n3 4\n2 5\n2 3\n1 5\n8\n8 3\n4 2\n6 4\n3 5\n5 8\n7 1\n2 6\n1 7\n0",
"5\n5 5\n4 4\n3 3\n2 2\n1 1\n0\n1 5\n3 4\n2 5\n0 3\n1 5\n8\n8 3\n4 2\n6 4\n3 5\n5 8\n... |
p01446 Blue Forest | John is playing a famous console game named 'Tales of Algorithmers.' Now he is facing the last dungeon called 'Blue Forest.' To find out the fastest path to run through the very complicated dungeon, he tried to draw up the dungeon map.
The dungeon consists of several floors. Each floor can be described as a connected ... | {
"input": [],
"output": []
} | {
"input": [
"2\n5\n0 0\n10 0\n20 0\n30 0\n30 10\n4\n1 2\n2 3\n3 4\n4 5\n2\n1 2 4\n3 2 2\n5\n-10 0\n0 0\n0 -10\n0 -20\n0 -30\n4\n1 2\n2 3\n3 4\n4 5\n1\n4 1 3\n1 1\n2 1\n4\n3\n4 3\n0 0\n5 0\n2\n1 2\n2 3\n0\n3\n0 0\n3 4\n0 5\n2\n1 2\n1 3\n1\n2 3 4\n4\n0 13\n0 0\n13 0\n13 13\n4\n1 2\n1 4\n2 3\n2 4\n0\n4\n5 12\n0 0\n... | {
"input": [
"2\n5\n0 0\n10 0\n20 0\n30 0\n30 10\n4\n1 2\n2 3\n3 4\n4 5\n2\n1 2 4\n3 2 2\n5\n-10 0\n0 0\n0 -10\n0 -20\n0 -30\n4\n1 2\n2 3\n3 4\n4 5\n1\n4 1 3\n1 1\n2 1\n4\n3\n4 3\n0 0\n5 0\n2\n1 2\n2 3\n0\n3\n0 0\n3 4\n0 5\n2\n1 2\n1 3\n1\n2 3 4\n4\n0 13\n0 0\n13 0\n13 13\n4\n1 2\n1 4\n2 3\n2 4\n0\n4\n5 12\n0 0\n... |
p01595 Laser Puzzle | Problem E: Laser Puzzle
An explorer John is now at a crisis! He is entrapped in a W times H rectangular room with a embrasure of laser beam. The embrasure is shooting a deadly dangerous laser beam so that he cannot cross or touch the laser beam. On the wall of this room, there are statues and a locked door. The door l... | {
"input": [],
"output": []
} | {
"input": [
"8 3\nL####\nS.../@.#\nD#",
"8 3\nL#####\nS...@.#\nD#",
"7 8\n##S####\n#.....#\nS.O...#\n#.*|..#\nL..*..#\n#.O*..D\n#.@...#\n#######",
"7 8\nS####\n.....#\nS.O...#\n.*|..#\nL..*..#\n.O*..D\n.@...#"
],
"output": [
"Yes",
"No",
"Yes",
"Yes"
]
} | {
"input": [
"8 5\nL####\nS.../@.#\nD#",
"7 8\n##S####\n#.....$\nS.O...#\n#.*|..#\nL..*..#\n#.O*..D\n#.@...#\n#######",
"8 3\nL#####\nS./.@.#\nD#",
"10 8\nS####\n.....#\nS.O...#\n.*|..#\nL..*..#\n.O*..D\n.@...#",
"8 5\nL####\n#.@/...S\nD#",
"3 3\nL#####\nS./.@.#\nD#",
"7 7\n##S####\n#........ |
p01752 Prowler | Mr. A and Mr. B live in an N × M rectangular grid area. Each square is either a road, a wall, or a house. Since this area is famous for the frequent occurrence of molestation damage due to the complicated and intricate roads, the boundary between this area and the outside is completely surrounded by walls and isolated.... | {
"input": [],
"output": []
} | {
"input": [
"4 4\n....\n.#.G\n...#\n^#..",
"3 3\n...\n.G.\n.>.",
"3 3\nG##\n.#.\n.",
"3 3\nG##\n.#.\n.>.",
"3 3\nG##\n.#.\n.<."
],
"output": [
"8",
"-1",
"4",
"6",
"4"
]
} | {
"input": [
"4 4\n....\n.#.G\n...#\n..#^",
"3 3\nG##\n.#-\n.>.",
"3 3\n##G\n.#-\n.>.",
"4 4\n....\n.#.G\n-..#\n^#..",
"3 3\n##G\n#..\n<..",
"4 4\n./..\n.#.G\n...\"\n..#^",
"4 4\n-...\nG.#.\n...#\n^#..",
"4 4\n....\nG.#.\n...#\n..\"^",
"3 3\n../\nG-.\n.>.",
"4 3\n...\n.G.\n.>."... |
p01892 SNS | Problem statement
AOR Ika-chan is in a bad mood lately. Apparently, I don't like the ratio of the number of followers to the number of followers of "Ikatta". Currently, AOR Ika-chan has $ A $ followers, $ B $ followers, and a ratio of $ A: B $.
Therefore, AOR Ika decided to increase or decrease the number of follower... | {
"input": [],
"output": []
} | {
"input": [
"19 30 3"
],
"output": [
"1"
]
} | {
"input": [
"19 28 3",
"19 51 3",
"19 51 1",
"30 51 1",
"30 33 1",
"30 7 1",
"37 7 1",
"19 30 2",
"32 51 1",
"35 7 1",
"32 86 1",
"35 1 1",
"7 26 3",
"35 2 1",
"19 2 2",
"7 42 3",
"35 0 1",
"19 1 2",
"7 64 3",
"7 4 3",
"27 0 6",
... |
p02029 Chisaki and Picnic | O: Chisaki and Picnic
Chisaki, a kindergarten student, decided to bring sweets for the excursion.
There are $ N $ of sweets, and the $ i $ th sweet is priced at $ A_i $ yen and tastes $ B_i $.
Chisaki has $ M $ friends, and the $ j $ th friend cries when she has $ D_j $ or more of sweets priced at $ C_j $ or more.
... | {
"input": [],
"output": []
} | {
"input": [
"3 1\n10 1\n20 2\n30 3\n20 2"
],
"output": [
"4"
]
} | {
"input": [
"3 1\n10 2\n20 2\n30 3\n20 2",
"3 1\n10 2\n20 4\n30 3\n20 2",
"3 1\n10 3\n20 4\n30 3\n20 2",
"3 1\n10 1\n20 3\n30 3\n20 2",
"0 1\n10 3\n20 4\n42 3\n20 2",
"3 1\n19 2\n20 0\n30 -1\n20 2",
"3 1\n10 0\n20 3\n30 3\n20 2",
"3 1\n10 3\n20 4\n42 3\n20 2",
"3 1\n4 2\n20 2\n30 ... |
p02171 Ukunichia Query | Problem
$ N $ people are lined up in a row from left to right. The string $ S $ is prevalent among them.
Each person is happy when the following conditions are met, and not happy when they are not.
* If you have been told more than $ | S | $ characters and the most recent $ | S | $ characters are arranged from oldes... | {
"input": [],
"output": []
} | {
"input": [
"abab\n5 5\n2 2 4\n1 1 5 abab\n2 3 5\n1 3 3 a\n2 1 5",
"uku\n1333 5\n2 232 423\n1 13 532 uku\n2 322 567\n1 3 33 ku\n2 1 333",
"aabb\n1879 20\n2 69 1585\n1 415 1680 aabb\n1 756 1628 abbabbaa\n1 849 1273 abba\n2 418 1172\n2 1063 1164\n2 203 623\n2 481 1209\n1 107 110 ababaaaab\n1 857 985 bbbbab... | {
"input": [
"abab\n5 1\n2 2 4\n1 1 5 abab\n2 3 5\n1 3 3 a\n2 1 5",
"uku\n1333 5\n2 232 423\n1 13 532 uku\n2 322 567\n1 3 33 ku\n2 1 373",
"uku\n1333 5\n2 232 423\n1 13 532 ulu\n2 322 567\n1 3 33 ku\n2 1 373",
"uuk\n1333 5\n2 232 423\n1 13 532 uku\n2 322 567\n1 3 33 ku\n2 1 333",
"uku\n1333 5\n2 2... |
p02312 Intersection of a Circle and a Polygon | Find the area of intersection between a circle $c$ and a polygon $g$. The center coordinate of the circle is ($0, 0$).
The polygon $g$ is represented by a sequence of points $p_1$, $p_2$,..., $p_n$ where line segments connecting $p_i$ and $p_{i+1}$ ($1 \leq i \leq n−1$) are sides of the polygon. The line segment conne... | {
"input": [],
"output": []
} | {
"input": [
"4 5\n0 0\n-3 -6\n1 -3\n5 -4",
"3 5\n1 1\n4 1\n5 5"
],
"output": [
"11.787686807576",
"4.639858417607"
]
} | {
"input": [
"4 5\n0 0\n-3 -5\n1 -3\n5 -4",
"3 5\n1 1\n4 1\n8 5",
"4 8\n0 0\n-3 -5\n1 -3\n5 -4",
"3 8\n1 1\n4 1\n8 5",
"4 8\n-1 0\n-3 -5\n1 -3\n5 -4",
"3 8\n1 1\n4 2\n8 5",
"4 8\n-1 0\n-3 -5\n1 -3\n5 -6",
"3 8\n1 1\n8 2\n8 5",
"4 8\n-1 0\n-3 -5\n1 -3\n10 -6",
"3 8\n2 1\n8 2\n8 ... |
p02460 Map: Delete | For a dictionary $M$ that stores elements formed by a pair of a string key and an integer value, perform a sequence of the following operations. Note that each key in $M$ must be unique.
* insert($key$, $x$): Insert an element formed by a pair of $key$ and $x$ to $M$.
* get($key$): Print the value with the specified $... | {
"input": [],
"output": []
} | {
"input": [
"8\n0 blue 4\n0 red 1\n0 white 5\n1 red\n1 blue\n2 red\n1 black\n1 red"
],
"output": [
"1\n4\n0\n0"
]
} | {
"input": [
"8\n0 blue 4\n0 red 1\n0 white 5\n1 red\n1 bmue\n2 red\n1 black\n1 red",
"8\n0 blue 4\n0 red 1\n0 white 5\n1 erd\n1 bmue\n2 red\n1 black\n1 red",
"8\n0 blue 4\n0 der 1\n0 white 10\n1 etd\n1 bmue\n2 der\n0 black\n1 des",
"8\n0 blue 4\n0 red 1\n0 white 5\n1 red\n2 blue\n2 red\n1 black\n1 re... |
ai04 | It's not the rivers that you might be thinking about. The question revolves around the concept of digital rivers.
A digital river is a sequence of numbers where the number
following n is n plus the sum of its digits.
FOR EXAMPLE
12345 is followed by 12360 since 1+2+3+4+5=15 and so
12345 + 15 gives 12360.
similarly ... | {
"input": [],
"output": []
} | {
"input": [
"86\n 12345\n 0"
],
"output": [
"Case #1\n first meets river 1 at 101\n \n Case #2\n first meets river 3 at 12423"
]
} | {
"input": [
"86\n 12444\n 0",
"86\n 5862\n 0",
"86\n 9079\n 0",
"86\n 7745\n 0",
"86\n 9113\n 0",
"86\n 9885\n 0",
"86\n 4733\n 0",
"86\n 18793\n 0",
"86\n 6477\n 0",
"86\n 18588\n 0",
"86\n 4494\n 0",
"86\n 36250\n 0",
"86\n 13644\n 0",
... |
chefstlt | Chef has found two very old sheets of paper, each of which originally contained a string of lowercase Latin letters. The strings on both the sheets have equal lengths. However, since the sheets are very old, some letters have become unreadable.
Chef would like to estimate the difference between these strings. Let's ass... | {
"input": [],
"output": []
} | {
"input": [
"3\na?c\n??b\n???a\n???a\n?abac\naba?w"
],
"output": [
"1 3\n0 3\n3 5\n"
]
} | {
"input": [
"3\na?c\n??b\n???a\n@??a\n?abac\naba?w",
"3\na?c\n??b\n?>?a\n@??a\n?bbbc\naba?w",
"3\nc?a\n??b\n@>?a\n@?@a\nbb?bc\naba?w",
"3\na?c\nb??\n@>>a\n@?@a\nbb?bc\nw?aba",
"3\na?c\nb??\nA>>a\n@?@a\nbb?bc\nw?aba",
"3\na?c\nb??\na>>A\n@?@a\nbb?bc\nw?aba",
"3\nb?c\nb>?\na=>B\n@?@a\nba?bb... |
dream | The Chef is sleeping now. He tries to cook new kind of meals in his dream.
These meals are arranged in a row and numbered from 1 to N consecutively. For each meal i (1<=i<=N) there
is given one integer f(i) which denotes the time needed to cook it. Initially, all meals are uncooked. Each assistant
of The Chef (the... | {
"input": [],
"output": []
} | {
"input": [
"5 3\n40 30 40 30 40"
],
"output": [
"3"
]
} | {
"input": [],
"output": []
} |
johny | Vlad enjoys listening to music. He lives in Sam's Town. A few days ago he had a birthday, so his parents gave him a gift: MP3-player! Vlad was the happiest man in the world! Now he can listen his favorite songs whenever he wants!
Vlad built up his own playlist. The playlist consists of N songs, each has a unique positi... | {
"input": [],
"output": []
} | {
"input": [
"3\n4\n1 3 4 2\n2\n5\n1 2 3 9 4\n5\n5\n1 2 3 9 4 \n1"
],
"output": [
"3\n4\n1\n"
]
} | {
"input": [
"3\n4\n1 3 4 2\n2\n5\n1 2 3 9 4\n5\n5\n1 2 3 9 4 \n2",
"3\n4\n1 3 7 2\n1\n5\n1 2 0 9 4\n5\n5\n1 2 3 9 4 \n2",
"3\n4\n1 3 4 2\n1\n5\n1 2 0 2 4\n5\n5\n1 2 3 9 4 \n2",
"3\n4\n1 3 4 2\n2\n5\n1 2 3 9 8\n5\n5\n1 2 3 9 4 \n1",
"3\n4\n1 3 4 2\n1\n5\n1 2 0 9 4\n5\n5\n1 2 3 1 4 \n2",
"3\n4\... |
numfact | Alice has learnt factorization recently. Bob doesn't think she has learnt it properly and hence he has decided to quiz her. Bob gives Alice a very large number and asks her to find out the number of factors of that number. To make it a little easier for her, he represents the number as a product of N numbers. Alice is ... | {
"input": [],
"output": []
} | {
"input": [
"3\n3\n3 5 7\n3\n2 4 6\n2\n5 5"
],
"output": [
"8\n10\n3\n"
]
} | {
"input": [
"3\n3\n3 5 7\n3\n2 4 3\n2\n5 5",
"3\n3\n3 3 7\n3\n2 4 3\n2\n5 5",
"3\n3\n3 5 7\n3\n2 4 3\n2\n5 2",
"3\n3\n3 5 7\n3\n2 4 6\n2\n8 5",
"3\n3\n4 3 7\n3\n2 4 3\n2\n5 5",
"3\n3\n3 7 7\n3\n2 4 6\n2\n8 5",
"3\n3\n3 5 7\n3\n2 4 6\n2\n7 5",
"3\n3\n3 3 7\n3\n4 4 3\n2\n5 5",
"3\n3... |
skyscr | Chef had constructed 2 buildings - one of height N and another of height M.
He was unhappy, and wanted both buildings to be of the same height.
In one move, he could either add a floor to a building, or remove a floor from a building.
Help him find the minimum number of moves to make the heights equal.
Input
First lin... | {
"input": [],
"output": []
} | {
"input": [
"1\n2 3"
],
"output": [
"1\n"
]
} | {
"input": [
"1\n2 1",
"1\n2 0",
"1\n3 0",
"1\n3 -1",
"1\n0 0",
"1\n4 -2",
"1\n4 -1",
"1\n2 -5",
"1\n0 -9",
"1\n-1 -9",
"1\n14 0",
"1\n-1 12",
"1\n0 12",
"1\n0 19",
"1\n-1 19",
"1\n-1 37",
"1\n0 37",
"1\n0 27",
"1\n0 35",
"1\n0 28",
"... |
1217_C. The Number Of Good Substrings | You are given a binary string s (recall that a string is binary if each character is either 0 or 1).
Let f(t) be the decimal representation of integer t written in binary form (possibly with leading zeroes). For example f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0 and f(000100) = 4.
The substring s_{... | {
"input": [],
"output": []
} | {
"input": [
"4\n0110\n0101\n00001000\n0001000\n"
],
"output": [
"4\n3\n4\n3\n"
]
} | {
"input": [
"4\n0110\n1101\n00001000\n0001000\n",
"4\n0110\n1101\n00001000\n0101000\n",
"4\n0110\n1101\n00000000\n0101000\n",
"4\n0110\n1100\n00000000\n0101000\n",
"4\n0110\n1100\n00000000\n0001000\n",
"4\n0110\n1101\n00000000\n0001000\n",
"4\n0110\n0001\n00000000\n0001000\n",
"4\n011... |
1302_B. DAG | 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 are given a directed acyclic graph G with n vertices and m edges. Denote by R(v) the set of all vertices u reachable from v by moving along the edges of G. Find ∑_... | {
"input": [],
"output": []
} | {
"input": [
"5 4\n1 2\n2 3\n3 4\n4 5\n",
"12 6\n1 2\n3 4\n5 6\n8 7\n10 9\n12 11\n",
"7 6\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7\n"
],
"output": [
"\n55\n",
"\n30\n",
"\n45\n"
]
} | {
"input": [],
"output": []
} |
1345_A. Puzzle Pieces | You are given a special jigsaw puzzle consisting of n⋅ m identical pieces. Every piece has three tabs and one blank, as pictured below.
<image>
The jigsaw puzzle is considered solved if the following conditions hold:
1. The pieces are arranged into a grid with n rows and m columns.
2. For any two pieces that sh... | {
"input": [],
"output": []
} | {
"input": [
"3\n1 3\n100000 100000\n2 2\n"
],
"output": [
"YES\nNO\nYES\n"
]
} | {
"input": [
"3\n1 5\n100000 100000\n2 2\n",
"3\n1 3\n100000 100000\n3 2\n",
"3\n2 3\n100000 100000\n3 2\n",
"3\n2 4\n100010 100100\n2 2\n",
"3\n1 6\n100000 100000\n3 2\n",
"3\n1 3\n100000 100100\n2 2\n",
"3\n1 6\n100000 100001\n3 2\n",
"3\n1 3\n100000 101100\n2 2\n",
"3\n1 2\n1000... |
1476_C. Longest Simple Cycle | You have n chains, the i-th chain consists of c_i vertices. Vertices in each chain are numbered independently from 1 to c_i along the chain. In other words, the i-th chain is the undirected graph with c_i vertices and (c_i - 1) edges connecting the j-th and the (j + 1)-th vertices for each 1 ≤ j < c_i.
Now you decided... | {
"input": [],
"output": []
} | {
"input": [
"3\n4\n3 4 3 3\n-1 1 2 2\n-1 2 2 3\n2\n5 6\n-1 5\n-1 1\n3\n3 5 2\n-1 1 1\n-1 3 5\n"
],
"output": [
"\n7\n11\n8\n"
]
} | {
"input": [
"3\n4\n3 4 3 3\n-1 1 2 2\n-1 2 2 3\n2\n5 6\n-1 5\n0 1\n3\n3 5 2\n-1 1 1\n-1 3 5\n",
"3\n4\n3 4 3 3\n-1 1 2 2\n-1 2 2 3\n2\n5 9\n-1 5\n0 1\n3\n3 5 2\n-1 1 1\n-1 3 5\n",
"3\n4\n3 4 3 4\n-1 1 2 2\n-1 2 2 3\n2\n5 9\n-1 5\n0 1\n3\n3 5 2\n-1 1 1\n-1 3 5\n",
"3\n4\n3 4 3 3\n-1 1 2 2\n-1 2 2 3\n2... |
1501_B. Napoleon Cake | This week Arkady wanted to cook some pancakes (to follow ancient traditions) and make a problem about that. But then he remembered that one can't make a problem about stacking pancakes without working at a specific IT company, so he decided to bake the Napoleon cake instead.
To bake a Napoleon cake, one has to bake n ... | {
"input": [],
"output": []
} | {
"input": [
"3\n6\n0 3 0 0 1 3\n10\n0 0 0 1 0 5 0 0 0 2\n3\n0 0 0\n"
],
"output": [
"\n1 1 0 1 1 1 \n0 1 1 1 1 1 0 0 1 1 \n0 0 0 \n"
]
} | {
"input": [
"3\n6\n0 3 0 0 1 3\n10\n0 0 0 1 0 5 0 0 0 4\n3\n0 0 0\n",
"3\n6\n0 3 0 0 1 3\n10\n1 0 0 1 0 5 0 0 0 4\n3\n0 0 0\n",
"3\n6\n0 3 0 0 1 3\n10\n0 0 0 1 0 5 0 0 0 3\n3\n0 0 0\n",
"3\n6\n0 3 1 0 1 3\n10\n1 0 0 1 0 5 0 0 0 4\n3\n0 0 0\n",
"3\n6\n0 3 1 0 1 3\n10\n1 0 0 1 0 5 0 0 0 4\n3\n1 0 0... |
530_I. Different variables | N variables X1, ..., XN can have positive integer values. You are given K constraints for these value that look like "the values of variables Xi1, Xi2, ..., XiM are different". Among all possible lists of values of these variables that satisfy these constraints select the ones which have minimum possible max(Xi). Outpu... | {
"input": [],
"output": []
} | {
"input": [
"2 1\n2 1 2\n",
"3 2\n2 1 2\n2 2 3\n"
],
"output": [
"1 2\n",
"1 2 1\n"
]
} | {
"input": [],
"output": []
} |
856_C. Eleventh Birthday | It is Borya's eleventh birthday, and he has got a great present: n cards with numbers. The i-th card has the number ai written on it. Borya wants to put his cards in a row to get one greater number. For example, if Borya has cards with numbers 1, 31, and 12, and he puts them in a row in this order, he would get a numbe... | {
"input": [],
"output": []
} | {
"input": [
"4\n2\n1 1\n3\n1 31 12\n3\n12345 67 84\n9\n1 2 3 4 5 6 7 8 9\n"
],
"output": [
"2\n2\n2\n31680\n"
]
} | {
"input": [
"4\n2\n1 1\n3\n1 31 12\n3\n12345 67 98\n9\n1 2 3 4 5 6 7 8 9\n",
"4\n2\n1 1\n3\n1 31 12\n3\n12345 67 98\n9\n1 2 3 4 4 6 7 8 9\n",
"4\n2\n1 1\n3\n1 31 12\n3\n21646 67 98\n9\n1 2 3 4 4 6 7 8 9\n",
"4\n2\n1 1\n3\n1 31 12\n3\n21646 67 98\n9\n1 2 3 4 4 6 7 8 6\n",
"4\n2\n1 1\n3\n1 31 12\n3... |
3-types | Russian translation
Let's consider some weird country with N cities and M bidirectional roads of 3 types. It's weird because of some unusual rules about using these roads: men can use roads of types 1 and 3 only and women can use roads of types 2 and 3 only. Please answer the following very interesting question: what ... | {
"input": [],
"output": []
} | {
"input": [
"5 7\n1 2 3\n2 3 3\n3 4 3\n5 3 2\n5 4 1\n5 2 2\n1 5 1\n\n\nSAMPLE"
],
"output": [
"2\n"
]
} | {
"input": [
"5 7\n1 2 3\n2 3 3\n3 4 3\n5 3 2\n5 4 1\n5 2 2\n1 5 2\n\n\nSAMPLE",
"5 7\n1 2 3\n2 3 3\n3 4 1\n5 3 2\n5 4 1\n5 2 2\n1 5 2\n\n\nSAMPLE",
"5 5\n1 2 3\n2 3 3\n3 4 3\n5 3 2\n5 4 1\n5 2 2\n1 5 1\n\n\nSAMPLE",
"5 7\n1 2 3\n2 3 3\n3 4 1\n5 3 2\n5 4 1\n5 2 4\n1 5 2\n\n\nSAMPLE",
"5 7\n1 2 5\n... |
count-strings-1 | This task is very simple.You are given two string A and B and you have to find how many times you can form string B from string A. You are only allow to delete some character from string A and Change postion of characters .You are not allow to use same index character of A two times in the same string to form string B.... | {
"input": [],
"output": []
} | {
"input": [
"1\naba \nab\n\nSAMPLE"
],
"output": [
"2"
]
} | {
"input": [],
"output": []
} |
interesting-prime | Taru and Chandu both are getting bored. So Taru thinks to play a game and he gives a number to Chandu and asks him to find the number of combinations formed by divisors in form of prime.
For example:-
For N = 36 divisor in form of prime are ( 2 , 2 , 3 , 3 )
Number of combinations formed by prime divisor of 36 a... | {
"input": [],
"output": []
} | {
"input": [
"1\n36\n\nSAMPLE"
],
"output": [
"8\n"
]
} | {
"input": [
"1\n36\n\nELPMAS",
"1\n38\n\nELPMBT",
"1\n61\n\nDKOMBU",
"1\n45\n\nELPMAT",
"1\n70\n\nDLPMBT",
"1\n72\n\nDKPMBU",
"1\n64\n\nDKOMBU",
"1\n168\n\nDLPLBT",
"1\n4\n\nDKBMPT",
"1\n48\n\nELPMBT",
"1\n16\n\nTBMPKD",
"1\n240\n\nDPLAMU",
"1\n36\n\nELPMAT",
"... |
maximum-resistance-5 | PIET's EC department students are working on a set of conductors to create a circuit with maximum resistance.
The simplest circuit consists of a single conductor (i.e., a single piece of wire). Each such circuit is labeled using the string "X".
Students are using two different ways to connect two simpler circuits int... | {
"input": [],
"output": []
} | {
"input": [
"3\nBXBXX\n8 2 3\nAAXXAXAXX\n1 1 2 8 10\nAXBXX\n8 2 3\n\nSAMPLE"
],
"output": [
"8\n22\n11"
]
} | {
"input": [],
"output": []
} |
range-sum-for-mapping-of-large-ranges-to-small-ranges | There are a total of n people in Prateek's class, numbered from 1 to n.
Every person has some field of interest for their projects.
There are a number people who have the same field of interest.
Now, you are given a number of pairs of the form (x,y).
This means that the students numbered x and y have interest in the ... | {
"input": [],
"output": []
} | {
"input": [
"1\n6 4\n1 2\n2 3\n4 5\n2 6\n\nSAMPLE"
],
"output": [
"6"
]
} | {
"input": [
"1\n6 4\n1 2\n2 3\n6 5\n2 6\n\nSAMPLE",
"1\n6 4\n1 2\n2 1\n6 5\n2 6\n\nSAMPLE",
"1\n11 4\n1 2\n2 1\n0 5\n2 6\n\nSAMPLE",
"1\n11 3\n1 2\n2 1\n0 4\n2 6\n\nSAMPLE",
"1\n6 4\n1 2\n4 3\n4 5\n2 6\n\nSAMPLE",
"1\n6 4\n1 2\n2 1\n2 5\n2 6\n\nSAMPLE",
"1\n11 4\n1 2\n2 1\n2 5\n2 6\n\nSAM... |
think-1 | Rajesh has been challenge by his friend to find the number which have properties like,
Here take no 12 such that
square of 12(12*12)=144
and 21 which is reverse of 12 have square(21*21)= 441 whose reverse is equal to 144
and now Rajesh is not getting any way how to solve the problem.So he makes a list of the number... | {
"input": [],
"output": []
} | {
"input": [
"2\n12\n11\n\nSAMPLE"
],
"output": [
"21\nNo\n"
]
} | {
"input": [
"2\n12\n4\n\nSAMPLE",
"2\n8\n4\n\nSAMPLE",
"2\n21\n0\n\nFLPMAR",
"2\n13\n0\n\nLERQL@",
"2\n17\n12\n\nLDRPM@",
"2\n1\n13\n\nJQREM@",
"2\n102\n1\n\nKRREM@",
"2\n113\n1\n\nKRREM@",
"2\n31\n0\n\nRAMPLD",
"2\n0\n21\n\n?FPSLL",
"2\n8\n4\n\nELPMAS",
"2\n6\n4\n\nEL... |
p02554 AtCoder Beginner Contest 178 - Ubiquity | How many integer sequences A_1,A_2,\ldots,A_N of length N satisfy all of the following conditions?
* 0 \leq A_i \leq 9
* There exists some i such that A_i=0 holds.
* There exists some i such that A_i=9 holds.
The answer can be very large, so output it modulo 10^9 + 7.
Constraints
* 1 \leq N \leq 10^6
* N is an in... | {
"input": [],
"output": []
} | {
"input": [
"869121",
"1",
"2"
],
"output": [
"2511445",
"0",
"2"
]
} | {
"input": [
"226564",
"0",
"3",
"241465",
"5",
"127499",
"10",
"99752",
"7",
"112403",
"25292",
"5344",
"6841",
"8450",
"15610",
"18734",
"19783",
"21762",
"6053",
"10667",
"15421",
"18759",
"20670",
"2282",
"1889",
... |
p02685 AtCoder Beginner Contest 167 - Colorful Blocks | There are N blocks arranged in a row. Let us paint these blocks.
We will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways.
Find the number of ways to paint the blocks under the following conditions:
* For each block, use one of the M colors... | {
"input": [],
"output": []
} | {
"input": [
"100 100 0",
"3 2 1",
"60522 114575 7559"
],
"output": [
"73074801",
"6",
"479519525"
]
} | {
"input": [
"100 110 0",
"6 2 1",
"119754 114575 7559",
"100 010 0",
"12 2 1",
"119754 114575 8988",
"100 010 -1",
"11 2 1",
"145188 114575 8988",
"11 3 1",
"145188 114575 3371",
"5 3 1",
"145188 114575 5625",
"5 3 2",
"145188 114575 6864",
"247804 1145... |
p02814 AtCoder Beginner Contest 150 - Semi Common Multiple | Given are a sequence A= {a_1,a_2,......a_N} of N positive even numbers, and an integer M.
Let a semi-common multiple of A be a positive integer X that satisfies the following condition for every k (1 \leq k \leq N):
* There exists a non-negative integer p such that X= a_k \times (p+0.5).
Find the number of semi-co... | {
"input": [],
"output": []
} | {
"input": [
"3 100\n14 22 40",
"2 50\n6 10",
"5 1000000000\n6 6 2 6 2"
],
"output": [
"0",
"2",
"166666667"
]
} | {
"input": [
"3 000\n14 22 40",
"2 46\n6 10",
"2 46\n10 10",
"2 12\n10 10",
"2 85\n6 10",
"3 101\n14 2 2",
"3 000\n14 16 40",
"3 010\n14 16 40",
"3 010\n14 16 4",
"3 110\n14 16 4",
"3 110\n14 22 4",
"3 010\n14 22 4",
"3 010\n14 25 4",
"3 011\n14 25 4",
"3 10... |
p02950 AtCoder Beginner Contest 137 - Polynomial Construction | Given are a prime number p and a sequence of p integers a_0, \ldots, a_{p-1} consisting of zeros and ones.
Find a polynomial of degree at most p-1, f(x) = b_{p-1} x^{p-1} + b_{p-2} x^{p-2} + \ldots + b_0, satisfying the following conditions:
* For each i (0 \leq i \leq p-1), b_i is an integer such that 0 \leq b_i \le... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 0",
"3\n0 0 0",
"5\n0 1 0 1 0"
],
"output": [
"1 1",
"0 0 0",
"0 2 0 1 3"
]
} | {
"input": [
"3\n0 0 1",
"2\n0 0",
"3\n0 1 0",
"3\n0 1 1",
"3\n1 1 0",
"5\n0 1 0 1 1",
"2\n0 1",
"5\n0 0 0 1 1",
"3\n1 1 1",
"5\n0 0 1 1 1",
"3\n1 0 1",
"5\n1 1 0 1 1",
"5\n1 1 0 1 0",
"2\n1 1",
"3\n1 0 0",
"5\n0 1 0 0 1",
"5\n1 0 0 1 1",
"5\n0 0... |
p03086 AtCoder Beginner Contest 122 - ATCoder | You are given a string S consisting of uppercase English letters. Find the length of the longest ACGT string that is a substring (see Notes) of S.
Here, a ACGT string is a string that contains no characters other than `A`, `C`, `G` and `T`.
Constraints
* S is a string of length between 1 and 10 (inclusive).
* Each c... | {
"input": [],
"output": []
} | {
"input": [
"SHINJUKU",
"ATCODER",
"HATAGAYA"
],
"output": [
"0",
"3",
"5"
]
} | {
"input": [
"SHINJUKV",
"ATCPDER",
"HATAGBYA",
"HASAGBYA",
"VKUJNIHT",
"HATAGCYA",
"VKUJNIHS",
"ATCPCER",
"ATCPBER",
"HASAGCYA",
"VUKJNIHT",
"REBPCTA",
"THINJKUV",
"RDBPCTA",
"AYCGATAH",
"JUKVNIHT",
"RTBPCDA",
"HATAHCYA",
"JUKVMIHT",
"RP... |
p03231 AtCoder Grand Contest 028 - Two Abbreviations | You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters.
A string X is called a good string when the following conditions are all met:
* Let L be the length of X. L is divisible by both N and M.
* Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 \times \... | {
"input": [],
"output": []
} | {
"input": [
"3 2\nacp\nae",
"6 3\nabcdef\nabc",
"15 9\ndnsusrayukuaiia\ndujrunuma"
],
"output": [
"6",
"-1",
"45"
]
} | {
"input": [
"3 2\nacq\nae",
"3 3\nabcdef\nabc",
"15 9\ndnsusrayukuaiia\nrujdunuma",
"3 4\nasiaukvyartuind\naumnudjus",
"15 9\ndnausrayukusiia\ndujrunuma",
"1 2\nacq\nae",
"4 1\nabq\nae",
"15 16\ndnausrayukusiia\ndujrunuma",
"1 1\n`br\n`e",
"5 4\naiiaukuyarsusod\namtntdjur",
... |
p03381 AtCoder Regular Contest 095 - Many Medians | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.
You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..... | {
"input": [],
"output": []
} | {
"input": [
"6\n5 5 4 4 3 3",
"4\n2 4 4 3",
"2\n1 2"
],
"output": [
"4\n4\n4\n4\n4\n4",
"4\n3\n3\n4",
"2\n1"
]
} | {
"input": [
"6\n1 5 4 4 3 3",
"4\n2 6 4 3",
"2\n1 3",
"6\n1 5 4 4 5 3",
"4\n2 6 4 6",
"2\n1 4",
"6\n1 5 4 6 5 3",
"4\n2 6 5 6",
"2\n2 4",
"4\n2 6 5 0",
"2\n3 4",
"4\n0 6 5 0",
"2\n4 4",
"6\n2 5 4 0 5 3",
"2\n4 7",
"6\n2 5 4 0 1 3",
"2\n4 13",
"6... |
p03546 AtCoder Beginner Contest 079 - Wall | Joisino the magical girl has decided to turn every single digit that exists on this world into 1.
Rewriting a digit i with j (0≤i,j≤9) costs c_{i,j} MP (Magic Points).
She is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and... | {
"input": [],
"output": []
} | {
"input": [
"2 4\n0 9 9 9 9 9 9 9 9 9\n9 0 9 9 9 9 9 9 9 9\n9 9 0 9 9 9 9 9 9 9\n9 9 9 0 9 9 9 9 9 9\n9 9 9 9 0 9 9 9 9 2\n9 9 9 9 9 0 9 9 9 9\n9 9 9 9 9 9 0 9 9 9\n9 9 9 9 9 9 9 0 9 9\n9 9 9 9 2 9 9 9 0 9\n9 2 9 9 9 9 9 9 9 0\n-1 -1 -1 -1\n8 1 1 8",
"3 5\n0 4 3 6 2 7 2 5 3 3\n4 0 5 3 7 5 3 7 2 7\n5 7 0 7 2 ... | {
"input": [
"2 4\n0 9 9 9 9 9 9 9 9 9\n9 0 9 9 9 9 9 9 9 9\n9 9 0 9 9 9 9 9 9 9\n9 9 9 0 2 9 9 9 9 9\n9 9 9 9 0 9 9 9 9 2\n9 9 9 9 9 0 9 9 9 9\n9 9 9 9 9 9 0 9 9 9\n9 9 9 9 9 9 9 0 9 9\n9 9 9 9 2 9 9 9 0 9\n9 2 9 9 9 9 9 9 9 0\n-1 -1 -1 -1\n8 1 1 8",
"3 5\n0 4 3 6 2 7 2 5 3 3\n4 0 5 3 7 5 3 7 2 7\n5 7 0 7 2 ... |
p03700 AtCoder Beginner Contest 063 - Widespread | You are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called health, and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below.
Fortunately, you are a skilled magician, capable of causing expl... | {
"input": [],
"output": []
} | {
"input": [
"5 2 1\n900000000\n900000000\n1000000000\n1000000000\n1000000000",
"4 5 3\n8\n7\n4\n2",
"2 10 4\n20\n20"
],
"output": [
"800000000",
"2",
"4"
]
} | {
"input": [
"5 2 1\n187174154\n900000000\n1000000000\n1000000000\n1000000000",
"4 5 3\n8\n7\n6\n2",
"2 10 4\n20\n37",
"5 2 1\n187174154\n900000000\n1000000000\n1000000000\n1100000000",
"2 17 4\n20\n37",
"5 2 1\n187174154\n900000000\n1000000000\n1000000001\n1100000000",
"5 2 1\n187174154\n... |
p03857 AtCoder Regular Contest 065 - Connectivity | There are N cities. There are also K roads and L railways, extending between the cities. The i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities. No two roads connect the same pair of cities. Similarly, no two railways connect the s... | {
"input": [],
"output": []
} | {
"input": [
"7 4 4\n1 2\n2 3\n2 5\n6 7\n3 5\n4 5\n3 4\n6 7",
"4 3 1\n1 2\n2 3\n3 4\n2 3",
"4 2 2\n1 2\n2 3\n1 4\n2 3"
],
"output": [
"1 1 2 1 2 2 2",
"1 2 2 1",
"1 2 2 1"
]
} | {
"input": [
"7 4 4\n1 2\n2 3\n2 7\n6 7\n3 5\n4 5\n3 4\n6 7",
"4 3 0\n1 2\n2 3\n3 4\n2 3",
"4 2 2\n2 2\n2 3\n1 4\n2 3",
"6 3 0\n-1 2\n2 3\n3 4\n2 3",
"14 4 4\n1 2\n2 3\n2 5\n6 7\n3 5\n4 5\n3 4\n6 7",
"7 4 4\n1 2\n2 3\n2 7\n6 7\n3 5\n4 5\n3 4\n6 2",
"6 3 1\n-1 2\n2 3\n3 4\n2 3",
"5 3 0\... |
p04022 AtCoder Grand Contest 003 - Anticube | Snuke got positive integers s_1,...,s_N from his mother, as a birthday present. There may be duplicate elements.
He will circle some of these N integers. Since he dislikes cubic numbers, he wants to ensure that if both s_i and s_j (i ≠ j) are circled, the product s_is_j is not cubic. For example, when s_1=1,s_2=1,s_3=... | {
"input": [],
"output": []
} | {
"input": [
"10\n1\n10\n100\n1000000007\n10000000000\n1000000009\n999999999\n999\n999\n999",
"6\n2\n4\n8\n16\n32\n64",
"8\n1\n2\n3\n4\n5\n6\n7\n8"
],
"output": [
"9",
"3",
"6"
]
} | {
"input": [
"10\n1\n11\n100\n1000000007\n10000000000\n1000000009\n999999999\n999\n999\n999",
"8\n1\n2\n4\n4\n5\n6\n7\n8",
"8\n1\n2\n6\n4\n5\n7\n7\n3",
"6\n2\n4\n8\n16\n32\n54",
"10\n1\n11\n100\n1000000007\n10000000100\n1000000009\n999999999\n1416\n999\n999",
"6\n2\n4\n16\n16\n45\n54",
"8\... |
p00106 Discounts of Buckwheat | Aizu is famous for its buckwheat. There are many people who make buckwheat noodles by themselves.
One day, you went shopping to buy buckwheat flour. You can visit three shops, A, B and C. The amount in a bag and its unit price for each shop is determined by the follows table. Note that it is discounted when you buy bu... | {
"input": [],
"output": []
} | {
"input": [
"500\n2200\n0"
],
"output": [
"850\n3390"
]
} | {
"input": [
"500\n1000\n0",
"500\n0000\n0",
"500\n1100\n0",
"500\n0000\n1",
"500\n0000\n2",
"500\n0000\n-1",
"500\n0000\n4",
"500\n0000\n8",
"500\n0000\n-2",
"500\n0000\n3",
"500\n0000\n14",
"500\n0000\n13",
"500\n0000\n19",
"500\n0000\n7",
"500\n0000\n-3",... |
p00240 Interest Rates | Interest rates are attached to the money deposited in banks, and the calculation method and interest rates vary from bank to bank. The combination of interest and principal is called principal and interest, but as a method of calculating principal and interest, there are "single interest" that calculates without incorp... | {
"input": [],
"output": []
} | {
"input": [
"2\n8\n1 5 2\n2 6 1\n2\n9\n1 5 2\n2 6 1\n0"
],
"output": [
"2\n1"
]
} | {
"input": [
"2\n8\n1 5 2\n2 6 1\n2\n9\n1 3 2\n2 6 1\n0",
"2\n8\n1 5 2\n3 6 1\n2\n7\n1 5 2\n2 6 1\n0",
"2\n8\n1 5 2\n2 6 1\n0\n9\n0 3 2\n2 6 1\n0",
"2\n14\n1 5 2\n3 6 1\n2\n7\n1 5 2\n2 6 1\n0",
"2\n8\n1 5 2\n2 6 1\n2\n7\n1 8 2\n2 6 1\n0",
"2\n14\n1 5 2\n3 6 1\n2\n7\n1 5 2\n1 6 1\n0",
"2\n8... |
p00412 Gas Station | Gas stations in the White Tiger service area have $ N $ lanes assigned numbers from $ 1 $ to $ N $. The first car in each lane can refuel.
Cars entering the gas station will choose the lane with the fewest cars in line and line up at the end of the line. If there are multiple such lanes, choose the one with the lowest... | {
"input": [],
"output": []
} | {
"input": [
"2 7\n1 999\n1 1000\n0 2\n1 1001\n1 1002\n0 1\n0 1"
],
"output": [
"1000\n999\n1002"
]
} | {
"input": [
"2 7\n1 999\n1 1000\n0 2\n1 1001\n1 1002\n0 1\n1 1",
"2 7\n1 999\n1 1000\n0 2\n1 1001\n1 1002\n0 2\n1 1",
"2 7\n1 999\n1 1000\n0 2\n1 1001\n1 1002\n1 2\n1 1",
"2 7\n1 999\n1 1000\n0 2\n1 1000\n1 1002\n0 1\n0 1",
"2 7\n1 999\n1 1001\n0 2\n1 1001\n1 1002\n1 2\n1 1",
"4 7\n1 999\n1 1... |
p00616 Cubes Without Holes | There is a cube which consists of n × n × n small cubes. Small cubes have marks on their surfaces. An example where n = 4 is shown in the following figure.
<image>
Then, as shown in the figure above (right), make a hole that penetrates horizontally or vertically from the marked surface to the opposite surface.
You... | {
"input": [],
"output": []
} | {
"input": [
"4 3\nxy 4 4\nxz 1 2\nyz 2 3\n4 5\nxy 1 1\nxy 3 3\nxz 3 3\nyz 2 1\nyz 3 3\n0 0"
],
"output": [
"52\n46"
]
} | {
"input": [
"4 3\nxy 4 4\nxz 1 2\nyz 2 3\n4 5\nxy 1 1\nxy 3 3\nxz 3 2\nyz 2 1\nyz 3 3\n0 0",
"4 3\nxy 4 4\nxz 1 2\nyz 2 3\n4 5\nxy 1 1\nxy 3 3\nxz 3 1\nyz 2 1\nyz 3 3\n0 0",
"4 3\nxy 4 3\nxz 1 2\nyz 2 3\n4 5\nxy 1 1\nwy 3 3\nxz 3 2\nyz 2 1\nyz 3 3\n0 0",
"5 3\nxy 4 3\nxz 1 2\nyz 2 3\n4 5\nxy 1 1\nxy ... |
p00760 Millennium | A wise king declared a new calendar. "Tomorrow shall be the first day of the calendar, that is, the day 1 of the month 1 of the year 1. Each year consists of 10 months, from month 1 through month 10, and starts from a big month. A common year shall start with a big month, followed by small months and big months one aft... | {
"input": [],
"output": []
} | {
"input": [
"8\n1 1 1\n344 3 1\n696 5 1\n182 9 5\n998 8 7\n344 2 19\n696 4 19\n999 10 20"
],
"output": [
"196470\n128976\n59710\n160715\n252\n128977\n59712\n1"
]
} | {
"input": [
"8\n1 1 1\n344 3 1\n696 5 1\n182 9 5\n998 5 7\n344 2 19\n696 4 19\n999 10 20",
"8\n1 1 1\n344 3 1\n696 5 1\n182 9 5\n998 5 7\n344 2 26\n696 4 19\n999 10 20",
"8\n1 1 1\n344 3 1\n696 4 1\n182 9 5\n998 8 7\n344 2 19\n696 4 19\n999 10 20",
"8\n1 1 1\n344 3 1\n696 5 1\n182 9 5\n998 5 7\n344 3... |
p00892 Intersection of Two Prisms | Suppose that P1 is an infinite-height prism whose axis is parallel to the z-axis, and P2 is also an infinite-height prism whose axis is parallel to the y-axis. P1 is defined by the polygon C1 which is the cross section of P1 and the xy-plane, and P2 is also defined by the polygon C2 which is the cross section of P2 and... | {
"input": [],
"output": []
} | {
"input": [
"4 3\n7 2\n3 3\n0 2\n3 1\n4 2\n0 1\n8 1\n4 4\n30 2\n30 12\n2 12\n2 2\n15 2\n30 8\n13 14\n2 8\n8 5\n13 5\n21 7\n21 9\n18 15\n11 15\n6 10\n6 8\n8 5\n10 12\n5 9\n15 6\n20 10\n18 12\n3 3\n5 5\n10 3\n10 10\n20 8\n10 15\n10 8\n4 4\n-98 99\n-99 -99\n99 -98\n99 97\n-99 99\n-98 -98\n99 -99\n96 99\n0 0"
],
... | {
"input": [
"4 3\n7 2\n3 3\n0 2\n3 1\n4 2\n0 1\n8 1\n4 4\n30 2\n30 12\n2 12\n2 2\n15 2\n30 8\n13 14\n2 8\n8 5\n13 5\n21 7\n21 9\n18 15\n11 15\n6 10\n6 8\n8 5\n10 12\n5 9\n15 6\n20 10\n18 12\n3 3\n5 5\n10 3\n10 10\n20 8\n10 15\n10 8\n4 4\n-98 99\n-99 -104\n99 -98\n99 97\n-99 99\n-98 -98\n99 -99\n96 99\n0 0",
... |
p01024 Sum of Last Digits | Problem
Given the three integers n, m, k
n1% 10 + n1 + m% 10 + n1 + 2m% 10 + ... + n1 + (k-1) m% 10
Calculate. a% b represents the remainder when a is divided by b.
Constraints
Input meets the following conditions
* 0 ≤ n ≤ 1018
* 0 ≤ m ≤ 109
* 1 ≤ k ≤ 109
Input
n m k
One line is given n, m, k.
Output
Prin... | {
"input": [],
"output": []
} | {
"input": [
"1 1 9",
"100 7 12",
"6 11 11",
"2 1 3",
"123 123 3"
],
"output": [
"9",
"0",
"66",
"14",
"11"
]
} | {
"input": [
"1 1 4",
"100 10 12",
"6 11 5",
"3 1 3",
"132 123 3",
"1 1 3",
"132 123 6",
"1 2 5",
"132 123 7",
"101 0 12",
"1 0 6",
"101 0 1",
"8 1 3",
"6 1 3",
"132 62 7",
"132 62 2",
"11 0 2",
"1 7 17",
"347 42 1",
"1 1 34",
"1 1 48... |
p01156 Hyper Rock-Scissors-Paper | Rock-Scissors-Paper is a game played with hands and often used for random choice of a person for some purpose. Today, we have got an extended version, namely, Hyper Rock-Scissors-Paper (or Hyper RSP for short).
In a game of Hyper RSP, the players simultaneously presents their hands forming any one of the following 15 ... | {
"input": [],
"output": []
} | {
"input": [
"8\nLightning\nGun\nPaper\nSponge\nWater\nDragon\nDevil\nAir\n3\nRock\nScissors\nPaper\n0"
],
"output": [
"Sponge\nDraw"
]
} | {
"input": [
"8\nLightning\nGun\nPaper\nSponge\nWater\nDragon\nDevil\nAir\n0\nRock\nScsisors\nPaper\n0",
"8\nLightning\nGun\nPaper\nSponge\nWater\nDragon\nDevil\nAir\n0\nRock\nScsisors\nPapes\n0",
"8\nLightning\nGun\nPaper\nSponge\nWater\nDragon\nDevil\nAir\n0\nkcoR\nScsisors\nPaper\n0",
"8\nLightning... |
p01295 Champernowne Constant | Champernown constant is an irrational number represented in decimal by "0." followed by concatenation of all positive integers in the increasing order. The first few digits of this constant are: 0.123456789101112...
Your task is to write a program that outputs the K digits of Chapnernown constant starting at the N-th ... | {
"input": [],
"output": []
} | {
"input": [
"4 5\n6 7\n0 0"
],
"output": [
"45678\n6789101"
]
} | {
"input": [
"3 5\n6 7\n0 0",
"4 5\n1 7\n0 0",
"4 5\n1 13\n0 0",
"2 5\n1 13\n0 0",
"8 5\n6 7\n0 0",
"3 5\n6 5\n0 0",
"2 5\n1 0\n0 0",
"8 5\n6 14\n0 0",
"2 5\n0 0\n0 0",
"8 8\n6 14\n0 0",
"4 5\n0 0\n0 0",
"4 1\n0 0\n0 0",
"4 2\n0 0\n0 -1",
"8 5\n1 7\n0 0",
"4... |
p01464 Sunny Graph | The Sun is a great heavenly body. The Sun is worshiped by various religions. Bob loves the Sun and loves any object that is similar to the Sun. He noticed that he can find the shape of the Sun in certain graphs. He calls such graphs "Sunny".
We define the property "Sunny" mathematically. A graph G=(V,E) with a vertex ... | {
"input": [],
"output": []
} | {
"input": [
"5 5\n1 2\n2 3\n3 4\n4 5\n1 3",
"5 5\n1 2\n2 3\n3 4\n4 5\n1 4"
],
"output": [
"Yes",
"No"
]
} | {
"input": [
"5 5\n1 3\n2 3\n3 4\n4 5\n1 4",
"5 5\n1 3\n2 3\n3 4\n4 5\n1 2",
"5 5\n1 2\n4 3\n3 4\n4 5\n1 3",
"7 5\n1 2\n2 3\n3 4\n4 5\n1 4",
"5 5\n1 2\n4 3\n3 4\n4 5\n1 2",
"7 5\n1 2\n2 3\n3 1\n4 5\n1 4",
"5 5\n1 2\n2 3\n2 4\n4 5\n1 4",
"5 5\n1 3\n2 3\n1 4\n4 5\n1 4",
"7 5\n1 2\n2 ... |
p01624 Ononokomachi's Edit War | Dr. Akita, who lives in the neighborhood, is a historical researcher in the field and recently discovered a new ancient document about Ono no Komachi.
It is widely known that Ono no Komachi has given General Fukakusa, who wants to be dating, on condition that he keeps going for 100 nights, but he claims that this disc... | {
"input": [],
"output": []
} | {
"input": [
"1 1\n2 2\n3 1+2*3-4\n3 1|2^3&4\n3 (1+2)*3\n3 1-1-1-1\n0 #"
],
"output": [
"91\n2\n273\n93\n279\n88"
]
} | {
"input": [
"1 1\n2 2\n6 1+2*3-4\n3 1|2^3&4\n3 (1+2)*3\n3 1-1-1-1\n0 #",
"1 1\n2 2\n6 1+2*3-4\n3 1|2^3&4\n4 (1+2)*3\n3 1-1-1-1\n0 #",
"1 1\n2 2\n1 1+2*3-4\n3 1|2^3&4\n4 (1+2)*3\n3 1-1-1-1\n0 #",
"1 1\n2 2\n1 1+2-3*4\n3 1|2^3&4\n4 (1+2)*3\n3 1-1-1-1\n0 #",
"1 1\n2 2\n1 1+2*3-3\n3 1|2^3&4\n4 (1+2)*... |
p01776 Do You Divide It? | E: Do You Divide It? / Do you want to chop it up?
story
Mr. T has been terribly troubled by the problem of plane figures in programming contests he has participated in in the past, and has had a strong grudge against plane figures ever since.
Above all, I have mixed feelings about polygons drawn on a two-dimensional... | {
"input": [],
"output": []
} | {
"input": [
"6\n0 0\n-1 -2\n3 -2\n2 0\n3 2\n-1 2"
],
"output": [
"6.000000000"
]
} | {
"input": [
"6\n1 0\n-1 -2\n3 -2\n2 0\n3 2\n-1 2",
"6\n1 0\n0 -2\n3 -2\n2 0\n3 2\n-1 2",
"6\n1 0\n0 -1\n3 -2\n2 0\n3 2\n-1 2",
"6\n1 0\n1 -1\n3 -2\n2 0\n3 2\n-1 2",
"6\n1 0\n1 -1\n3 -3\n2 0\n3 2\n-1 2",
"6\n1 0\n1 -1\n3 -3\n2 -1\n3 2\n-1 2",
"6\n1 0\n1 -1\n3 -1\n2 -1\n3 2\n-1 2",
"6\n... |
p01910 Card Game | problem
Play the card-based game $ Q $ times. The cards are numbered $ 1 \ cdots N $, and each numbered card is large enough to play the game. In the $ i $ game, two cards are first dealt as a hand. The numbers on each card are $ x_i $ and $ y_i $. Cards can be exchanged according to the rules. The $ j $ th $ (1 \ le ... | {
"input": [],
"output": []
} | {
"input": [
"4 4 2 2\n1 2 1\n2 3 1\n3 4 5\n4 1 7\n1 4 5\n2 4 3"
],
"output": [
"7"
]
} | {
"input": [
"4 2 2 2\n1 2 1\n2 3 1\n3 4 5\n4 1 7\n1 4 5\n2 4 3",
"4 2 2 2\n1 2 1\n2 3 1\n3 4 5\n4 1 13\n1 4 5\n2 4 3",
"4 2 2 2\n2 2 1\n2 3 1\n3 4 5\n4 1 13\n0 4 5\n2 4 3",
"4 4 2 4\n1 2 1\n2 3 1\n3 4 5\n4 1 7\n1 4 5\n2 4 3",
"4 2 2 2\n1 2 1\n2 3 1\n4 4 5\n4 1 13\n2 4 10\n2 4 3",
"4 1 2 2\n1 ... |
p02049 The Genome Database of All Space Life Returns | Extraterrestrial Life Genome Database Returns
In 2301 AD, the Department of Life Sciences of the Federal Republic of Space was studying the genome sequences of space organisms. As a result of recent research, it has become clear that the number of times a specific pattern appears in the genome sequence has a great inf... | {
"input": [],
"output": []
} | {
"input": [
"MI2(2SI)2PI\nISSI\n100(100(JAG))\nJAG\n1000000000000000000A\nAAAAA\n#"
],
"output": [
"2\n10000\n999999999999999996"
]
} | {
"input": [
"MI2(2SI)2PI\nISSI\n100(100(KAG))\nJAG\n1000000000000000000A\nAAAAA\n#",
"MI2(2SI)2PI\nISSI\n100(100(KAG))\nJBG\n1000000001000000000A\nAAAAA\n#",
"MI2(2SI)2PI\nSISI\n100(100(KAG))\nJBG\n1000000001000000000A\nAAAAA\n#",
"MH2(2SI)2PI\nISSI\n100(100(KAG))\nJBG\n1000000001000000000A\nAAAAA\n#... |
p02191 Range Count Query | Range Count Query
Given the sequence a_1, a_2, .., a_N.
In the query, answer the number of terms whose value is l or more and r or less.
input
N Q
a_1 a_2 ... a_N
l_1 r_1
l_2 r_2
::
l_q r_q
output
ans_1
ans_2
::
ans_q
On line i, output the answer to the i-th query, that is, the number of j such as l_i \ leq ... | {
"input": [],
"output": []
} | {
"input": [
"6 3\n8 6 9 1 2 1\n2 8\n1 7\n3 5"
],
"output": [
"3\n4\n0"
]
} | {
"input": [
"6 3\n8 6 15 1 2 1\n2 8\n1 7\n3 5",
"6 3\n8 6 15 1 1 1\n2 8\n1 7\n3 5",
"6 3\n8 6 12 3 1 1\n2 7\n1 7\n3 4",
"6 3\n4 6 12 3 1 1\n2 7\n1 7\n3 4",
"6 3\n4 6 1 3 1 1\n2 7\n1 7\n3 4",
"6 3\n4 6 1 0 1 1\n2 7\n1 7\n3 4",
"6 3\n4 6 1 0 2 1\n2 7\n1 7\n3 4",
"6 1\n3 11 1 0 2 1\n2 7\... |
p02345 Range Minimum Query (RMQ) | Write a program which manipulates a sequence A = {a0, a1, . . . , an-1} with the following operations:
* find(s, t): report the minimum element in as, as+1, . . . ,at.
* update(i, x): change ai to x.
Note that the initial values of ai (i = 0, 1, . . . , n−1) are 231-1.
Constraints
* 1 ≤ n ≤ 100000
* 1 ≤ q ≤ 10000... | {
"input": [],
"output": []
} | {
"input": [
"3 5\n0 0 1\n0 1 2\n0 2 3\n1 0 2\n1 1 2",
"1 3\n1 0 0\n0 0 5\n1 0 0"
],
"output": [
"1\n2",
"2147483647\n5"
]
} | {
"input": [
"1 3\n1 -1 0\n0 0 5\n1 0 0",
"3 5\n0 0 1\n0 1 2\n0 2 3\n1 0 2\n1 1 4",
"1 3\n1 -1 0\n0 0 9\n1 0 0",
"3 5\n0 0 1\n0 2 2\n0 2 3\n1 0 2\n1 1 2",
"1 3\n1 -1 0\n0 0 5\n0 0 0",
"1 3\n1 -1 0\n0 0 15\n1 0 0",
"3 5\n0 0 1\n0 2 2\n0 2 3\n1 0 2\n0 1 2",
"3 5\n0 0 1\n0 0 2\n0 2 6\n1 0... |
bytesa | Amy is a bright kid. She recently learnt the numbers from 0 to 9, and spends all her time these days, trying to write larger numbers. One day she wrote a number on a paper, and turned it upside down. It surprised and amazed her that the writing on the paper still made sense.
So, now she has created a game for herself, ... | {
"input": [],
"output": []
} | {
"input": [
"2\n1968086\n12345678"
],
"output": [
"YES\n9808961\nNO"
]
} | {
"input": [
"2\n1968086\n8980865",
"2\n323585\n8980865",
"2\n152971\n11089119",
"2\n85373\n6180",
"2\n77737\n8",
"2\n449\n18",
"2\n449\n0",
"2\n449\n1",
"2\n111\n4",
"2\n80\n14",
"2\n91966\n94",
"2\n1109\n3",
"2\n011\n4",
"2\n181\n4",
"2\n414\n6",
"2\n1... |
coolguys | Given an integer N. Integers A and B are chosen randomly in the range [1..N]. Calculate the probability that the Greatest Common Divisor(GCD) of A and B equals to B.
Input
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows. Each test case consis... | {
"input": [],
"output": []
} | {
"input": [
"3\n1\n2\n3"
],
"output": [
"1/1\n3/4\n5/9"
]
} | {
"input": [],
"output": []
} |
givcandy | Alvin and Berto have gotten tired of eating chocolates, so now they have decided to eat candies instead.
Alvin has A apple candies, and Berto has B banana candies. (I know, they have weird tastes.) Alvin and Berto always wants the split of candies to be as fair as possible. The problem is, Alvin only wants apple candie... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 5 10 3\n1 2 2 2"
],
"output": [
"0\n1\n"
]
} | {
"input": [
"2\n1 9 10 3\n1 2 2 2",
"2\n1 3 2 3\n1 2 2 7",
"2\n2 3 0 3\n0 4 4 3",
"2\n1 3 0 5\n2 2 2 4",
"2\n1 3 0 3\n-2 2 6 3",
"2\n0 5 0 7\n0 3 0 2",
"2\n0 17 0 3\n0 2 4 4",
"2\n1 3 4 3\n0 2 0 7",
"2\n0 3 0 6\n-2 2 7 3",
"2\n0 17 0 5\n0 2 4 4",
"2\n1 4 8 16\n0 4 3 3",
... |
marbles | Rohit dreams he is in a shop with an infinite amount of marbles. He is allowed to select n marbles. There are marbles of k different colors. From each color there are also infinitely many marbles. Rohit wants to have at least one marble of each color, but still there are a lot of possibilities for his selection. In his... | {
"input": [],
"output": []
} | {
"input": [
"2\n10 10\n30 7"
],
"output": [
"1\n475020\n"
]
} | {
"input": [
"2\n10 10\n30 1",
"2\n10 10\n30 2",
"2\n10 2\n30 2",
"2\n5 2\n30 2",
"2\n5 2\n30 1",
"2\n10 10\n48 7",
"2\n10 3\n30 2",
"2\n5 2\n49 2",
"2\n8 2\n30 1",
"2\n5 3\n29 1",
"2\n10 10\n19 7",
"2\n10 3\n59 2",
"2\n10 2\n49 2",
"2\n10 10\n13 7",
"2\n10 ... |
quad | A Quad is a data container that consists of 4 bits, represented by a hexadecimal number. It has 2 halves - the upper half and the lower half.
Consider a binary number with digits B1,B2,B3,B4 where B1 is the most significant digit and B4 is the least significant digit. The upper half consists of bits B1 and B2, and the ... | {
"input": [],
"output": []
} | {
"input": [
"2\n11",
"2\n1A"
],
"output": [
"0101",
"1000"
]
} | {
"input": [
"2\n2A",
"2\nA2",
"2\nB2",
"2\n3A",
"2\nA3",
"2\nA1",
"2\n4A",
"2\n2B",
"2\n13",
"2\n1B",
"2\nB1",
"2\nB0",
"2\n3C",
"2\nC2",
"2\n22",
"2\n2C",
"2\n15",
"2\nA4",
"2\n3B",
"2\n5A",
"2\n18",
"2\n4B",
"2\n19",
"2... |
tnmalg04 | While evaluating a expression of N distinct factors i.e (A1 * A2 * ..... * An) , Chef wanted to know in how may ways this expression can be evaluated by parenthesizing two factors at a time.
Input
The first line of the input contains an integer T denoting the number of test cases, for each test case enter the string ... | {
"input": [],
"output": []
} | {
"input": [
"2\nghjk\nab"
],
"output": [
"5\n1"
]
} | {
"input": [
"2\nghjk\nba",
"2\nhgjk\nba",
"2\nhgjk\nca",
"2\nhgik\nca",
"2\nhgik\nac",
"2\nhhik\nac",
"2\nhhik\nbc",
"2\nhhik\nca",
"2\nhiik\nca",
"2\nhiik\nac",
"2\nhiki\nac",
"2\nikih\nac",
"2\nikih\nca",
"2\nikig\nca",
"2\nilig\nca",
"2\nilig\nac",
... |
1250_I. Show Must Go On | The director of the famous dance show plans a tour. It is already decided that the tour will consist of up to m concerts.
There are n dancers in the troupe. Each dancer is characterized by her awkwardness: the awkwardness of the i-th dancer is equal to a_i.
The director likes diversity. For this reason, each concert ... | {
"input": [],
"output": []
} | {
"input": [
"3\n7 13 10\n3 1 5 1 8 2 13\n2 10 1\n12 12\n3 32 100000\n2 1 5\n"
],
"output": [
"\n10\n5 12\n4 7\n4 9\n4 10\n4 11\n4 11\n4 12\n4 13\n3 4\n3 5\n2 4 1 \n0\n7\n3 8\n2 3\n2 6\n2 7\n1 1\n1 2\n1 5\n3 \n"
]
} | {
"input": [],
"output": []
} |
1467_D. Sum of Paths | There are n cells, numbered 1,2,..., n from left to right. You have to place a robot at any cell initially. The robot must make exactly k moves.
In one move, the robot must move one cell to the left or right, provided that it doesn't move out of bounds. In other words, if the robot was in the cell i, it must move to e... | {
"input": [],
"output": []
} | {
"input": [
"4 40 6\n92 21 82 46\n3 56\n1 72\n4 28\n1 97\n2 49\n2 88\n",
"5 2 5\n3 5 1 4 2\n1 9\n2 4\n3 6\n4 6\n5 2\n",
"5 1 5\n3 5 1 4 2\n1 9\n2 4\n3 6\n4 6\n5 2\n"
],
"output": [
"\n239185261\n666314041\n50729936\n516818968\n766409450\n756910476\n",
"\n157\n147\n207\n227\n227\n",
"\n62\... | {
"input": [
"4 40 6\n92 21 82 46\n3 56\n1 72\n4 28\n1 97\n3 49\n2 88\n",
"5 1 5\n3 5 1 4 2\n1 9\n2 4\n3 6\n4 7\n5 2\n",
"4 40 6\n92 21 82 40\n3 56\n1 72\n4 28\n1 97\n3 49\n2 88\n",
"5 1 5\n3 5 1 4 2\n1 9\n2 4\n3 6\n5 7\n5 2\n",
"4 40 6\n92 17 82 40\n3 56\n1 72\n4 28\n1 97\n3 49\n2 88\n",
"4 4... |
arjit-and-printing-press | Arjit has his own printing press, Bainik Dhaskar (BD). He feels that words on their own simply aren't beautiful enough. So, he wishes to make a Super Manuscript (SM) machine. Now what does this machine do?
The SM machine aims to make words as beautiful as they can be by making a word as lexicographically small as possi... | {
"input": [],
"output": []
} | {
"input": [
"3\nbbbb\naaa\nzxewya\nabcd\nac\nzzzb\n\nSAMPLE"
],
"output": [
"aaab\nabcdya\nab\n"
]
} | {
"input": [
"3\nbbbb\naaa\nzxewya\nabcd\nca\nzzzb\n\nSAMPLE",
"3\nbbbb\naaa\nzxewya\ncbad\nca\nzzza\n\nSAMPLE",
"3\nbbbb\naaa\nzxewya\ncabe\nac\nzzza\n\nSAMPLE",
"3\nbbbb\naaa\nzxewya\nbbcd\nca\nzzzb\n\nSAMPLE",
"3\nbbbb\naaa\nzxewya\ncbad\ncb\nzzzb\n\nSAMPLE",
"3\nbbbb\naaa\nzxewya\ndbad\nca... |
little-jhool-and-his-addiction-2-4 | Little Jhool is an addict. No, unlike the usual drug addicts, he's an addict of the good kind: the shopping addict. Some of his friends also call him a shopaholic, though he tries his level best to deny the title given to him by his friends. Now, he has some favorite websites as we already have seen in another question... | {
"input": [],
"output": []
} | {
"input": [
"3\n2 1\n4 2\n6 4\n1 6 6 7 1 8\n4 0\n2 6 4 3\n\nSAMPLE"
],
"output": [
"0\nChick magnet Jhool!\n4\nLucky chap!\n1\nNo more girlfriends!\n"
]
} | {
"input": [
"3\n2 1\n4 2\n6 4\n1 6 6 7 1 8\n4 0\n2 6 4 5\n\nSAMPLE",
"3\n2 1\n4 2\n6 4\n1 6 6 7 1 8\n4 1\n2 6 4 5\n\nSAMPLE",
"3\n2 1\n4 2\n6 4\n1 6 6 7 1 8\n4 1\n2 3 4 5\n\nSAMPLE",
"3\n2 1\n4 2\n6 4\n1 6 6 7 1 8\n4 0\n2 6 4 6\n\nSAMPLE",
"3\n2 1\n4 2\n6 4\n1 6 6 7 2 8\n4 1\n2 6 4 5\n\nSAMPLE",
... |
samu-and-her-birthday-party-1 | Samu's Birthday is near so she had started planning a party for all of her friends. Being a kind and caring girl she calls each of her friend and asks for his/her favorite dish.Now each friend has own liking/disliking for different dishes.
A friend can only like or dislike a dish it means if we are having three dishe... | {
"input": [],
"output": []
} | {
"input": [
"1\n2 2\n10 \n01\n\nSAMPLE"
],
"output": [
"2\n"
]
} | {
"input": [
"1\n2 2\n10 \n01\n\nELPMAS",
"1\n1 2\n10 \n01\n\nTAMPME",
"1\n2 2\n10 \n01\n\nELQMAS",
"1\n2 2\n10 \n01\n\nTAMPLE",
"1\n2 2\n10 \n01\n\nELAMPS",
"1\n2 2\n10 \n01\n\nTAMPME",
"1\n2 2\n10 \n01\n\nELBMPS",
"1\n2 2\n10 \n01\n\nT@MPME",
"1\n2 2\n10 \n01\n\nT@NPME",
"1\n... |
weird-stairs | Somewhere in Andromeda, (yeah our neighbor galaxy!) Mystery Land, is having some signs of life. We just have found stairs there. But with different heights of each step.
Pictorially the stairs are like this:
The width of each step is same W, but for each stair numbered 'i', the total height of block of with W used f... | {
"input": [],
"output": []
} | {
"input": [
"4\n2 2\n1 1\n2 2\n2 2\n2 2\n1 2\n2 2\n2 1\n\nSAMPLE"
],
"output": [
"8\n6\n7\n8\n"
]
} | {
"input": [
"4\n1 2\n1 1\n2 2\n2 2\n2 2\n1 2\n2 2\n2 1\n\nSAMPLE",
"4\n3 2\n1 1\n2 2\n2 2\n2 2\n1 2\n2 2\n2 1\n\nSAMPLE",
"4\n1 2\n1 1\n4 2\n2 2\n2 2\n1 2\n2 2\n0 1\n\nTAMPLE",
"4\n2 2\n1 1\n2 2\n2 2\n2 2\n1 1\n2 2\n2 1\n\nSAMPLE",
"4\n2 2\n1 2\n2 2\n2 2\n2 2\n1 1\n2 2\n2 1\n\nSAMPLE",
"4\n2 ... |
p02620 Introduction to Heuristics Contest - Incremental Scoring | You will be given a contest schedule for D days and M queries of schedule modification. In the i-th query, given integers d_i and q_i, change the type of contest to be held on day d_i to q_i, and then output the final satisfaction at the end of day D on the updated schedule. Note that we do not revert each query. That ... | {
"input": [],
"output": []
} | {
"input": [
"5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770... | {
"input": [
"5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.