name stringlengths 2 112 | description stringlengths 29 13k | private_tests dict | public_tests dict | generated_tests dict |
|---|---|---|---|---|
omwg | Leha is playing a very interesting game. The game will be played on a rectangular grid consisting of N rows and M columns. Initially all the cells of the grid are uncolored.
Leha's initial score is zero. At each turn, he chooses some cell that is yet not colored, and colors that cell. The score obtained in this step w... | {
"input": [],
"output": []
} | {
"input": [
"1\n2 2"
],
"output": [
"4\n"
]
} | {
"input": [
"1\n3 2",
"1\n6 2",
"1\n3 3",
"1\n3 6",
"1\n6 6",
"1\n0 6",
"1\n-1 6",
"1\n0 5",
"1\n0 3",
"1\n0 0",
"1\n0 -1",
"1\n0 -2",
"1\n1 -1",
"1\n1 0",
"1\n-1 -1",
"1\n-1 3",
"1\n4 1",
"1\n5 -1",
"1\n5 -2",
"1\n5 -3",
"1\n2 -3",
... |
spalnum | A number is called palindromic if its decimal representation is a palindrome. You are given a range, described by a pair of integers L and R. Find the sum of all palindromic numbers lying in the range [L, R], inclusive of both the extrema.
Input
The first line of the input contains an integer T denoting the number of ... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 10\n123 150"
],
"output": [
"45\n272\n"
]
} | {
"input": [
"2\n2 10\n123 150",
"2\n2 10\n123 42",
"2\n2 2\n101 87",
"2\n2 2\n101 128",
"2\n2 2\n000 40",
"2\n0 2\n000 40",
"2\n0 2\n010 40",
"2\n0 0\n010 40",
"2\n0 1\n010 40",
"2\n0 1\n110 40",
"2\n0 2\n110 40",
"2\n0 4\n110 40",
"2\n1 4\n010 40",
"2\n1 4\n01... |
1302_I. Deja vu | 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.
Today your first customer asked y... | {
"input": [],
"output": []
} | {
"input": [
"5 2\n01101\n",
"10 3\n1110001011\n"
],
"output": [
"\n3\n",
"\n8\n"
]
} | {
"input": [],
"output": []
} |
1346_B. Boot Camp | Berland State University (BSU) is conducting a programming boot camp. The boot camp will last for n days, and the BSU lecturers are planning to give some number of lectures during these days.
Some days of the boot camp are already planned as excursion days, and no lectures should be held during these days. To make sur... | {
"input": [],
"output": []
} | {
"input": [
"4\n4 5 7\n1011\n4 4 10\n0101\n5 3 4\n11011\n6 4 6\n011101\n"
],
"output": [
"\n12\n8\n8\n14\n"
]
} | {
"input": [],
"output": []
} |
1367_F2. Flying Sort (Hard Version) | This is a hard version of the problem. In this version, the given array can contain equal elements and the constraints on n are greater than in the easy version of the problem.
You are given an array a of n integers (the given array can contain equal elements). You can perform the following operations on array element... | {
"input": [],
"output": []
} | {
"input": [
"9\n5\n4 7 2 2 9\n5\n3 5 8 1 7\n5\n1 2 2 4 5\n2\n0 1\n3\n0 1 0\n4\n0 1 0 0\n4\n0 1 0 1\n4\n0 1 0 2\n20\n16 15 1 10 0 14 0 10 3 9 2 5 4 5 17 9 10 20 0 9\n"
],
"output": [
"2\n2\n0\n0\n1\n1\n1\n1\n16\n"
]
} | {
"input": [
"9\n5\n4 7 2 2 9\n5\n3 5 8 1 7\n5\n1 2 2 4 0\n2\n0 1\n3\n0 1 0\n4\n0 1 0 0\n4\n0 1 0 1\n4\n0 1 0 2\n20\n16 15 1 10 0 14 0 10 3 9 2 5 4 5 17 9 10 20 0 9\n",
"9\n5\n4 7 2 2 9\n5\n1 5 8 1 7\n5\n1 2 2 4 5\n2\n0 1\n3\n0 1 0\n4\n0 1 0 0\n4\n0 1 0 1\n4\n0 1 0 2\n20\n16 15 1 10 0 14 0 10 3 9 2 5 4 5 17 9... |
1453_E. Dog Snacks | Gildong is playing with his dog, Badugi. They're at a park that has n intersections and n-1 bidirectional roads, each 1 meter in length and connecting two intersections with each other. The intersections are numbered from 1 to n, and for every a and b (1 ≤ a, b ≤ n), it is possible to get to the b-th intersection from ... | {
"input": [],
"output": []
} | {
"input": [
"3\n3\n1 2\n1 3\n4\n1 2\n2 3\n3 4\n8\n1 2\n2 3\n3 4\n1 5\n5 6\n6 7\n5 8\n"
],
"output": [
"\n2\n3\n3\n"
]
} | {
"input": [
"3\n3\n1 2\n2 3\n4\n1 2\n2 3\n3 4\n8\n1 2\n2 3\n3 4\n1 5\n5 6\n6 7\n5 8\n",
"3\n3\n1 2\n2 3\n4\n1 2\n2 3\n3 4\n8\n1 2\n2 3\n3 4\n1 7\n5 6\n6 7\n5 8\n",
"3\n3\n1 2\n2 3\n4\n1 4\n2 4\n3 4\n8\n1 3\n2 3\n3 4\n1 5\n2 6\n6 7\n3 8\n",
"3\n3\n1 2\n1 3\n4\n1 2\n1 3\n3 4\n8\n1 2\n2 3\n3 4\n1 5\n2 6... |
178_E2. 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": []
} |
320_E. Kalila and Dimna in the Logging Industry | Kalila and Dimna are two jackals living in a huge jungle. One day they decided to join a logging factory in order to make money.
The manager of logging factory wants them to go to the jungle and cut n trees with heights a1, a2, ..., an. They bought a chain saw from a shop. Each time they use the chain saw on the tree... | {
"input": [],
"output": []
} | {
"input": [
"5\n1 2 3 4 5\n5 4 3 2 0\n",
"6\n1 2 3 10 20 30\n6 5 4 3 2 0\n"
],
"output": [
"25\n",
"138\n"
]
} | {
"input": [
"6\n1 2 5 10 20 30\n6 5 4 3 2 0\n",
"6\n1 2 3 10 14 30\n6 5 4 3 2 0\n",
"5\n1 2 3 4 7\n5 4 3 2 0\n",
"5\n1 2 3 4 10\n5 4 3 2 0\n",
"5\n1 2 3 4 18\n5 4 3 2 0\n",
"6\n1 2 3 10 12 30\n6 5 4 3 2 0\n",
"5\n1 2 3 4 7\n5 4 3 1 0\n",
"5\n1 2 3 4 10\n9 4 3 2 0\n",
"6\n1 2 3 10 ... |
345_E. Black Cat Rush | Today you go out of your house and immediately notice that something is weird. Around your door there is a swarm of black cats — all tense paws and twitching tails. As you do your first step, they all dart off and start running towards you. It looks like they want to thwart you!
You are moving in a straight line from ... | {
"input": [],
"output": []
} | {
"input": [
"1 1 5 4\n0 3\n4 -4\n7 0\n-2 -2\n",
"10 5 3 4\n7 5\n5 2\n10 -7\n15 0\n"
],
"output": [
"3\n",
"3\n"
]
} | {
"input": [],
"output": []
} |
838_A. Binary Blocks | You are given an image, that can be represented with a 2-d n by m grid of pixels. Each pixel of the image is either on or off, denoted by the characters "0" or "1", respectively. You would like to compress this image. You want to choose an integer k > 1 and split the image into k by k blocks. If n and m are not divisib... | {
"input": [],
"output": []
} | {
"input": [
"3 5\n00100\n10110\n11001\n"
],
"output": [
"5"
]
} | {
"input": [
"3 5\n00100\n00110\n11001\n",
"3 5\n00100\n00110\n11011\n",
"3 5\n00100\n00110\n01001\n",
"3 5\n00100\n00110\n11111\n",
"3 5\n00110\n00110\n01001\n",
"3 5\n00000\n00110\n11111\n",
"3 5\n00110\n00110\n01000\n",
"3 5\n00000\n10111\n11011\n",
"3 5\n00100\n10110\n10001\n",... |
first-7 | Daenerys Targaryen has set her eyes on The kingdom of Dorne. Dornishmen, known for their strong sense of national identity, have refused to surrender to the whims of Daenerys. Fearing the imminent attack on their kingdom and knowing their strength as Spearmen, they have devised a battle plan which they think will give ... | {
"input": [],
"output": []
} | {
"input": [
"2\n1\n2\n\nSAMPLE"
],
"output": [
"1.000000\n4.000000"
]
} | {
"input": [
"2\n2\n2\n\nSAMPLE",
"2\n4\n2\n\nSAMPLE",
"2\n4\n1\n\nSALPLE",
"2\n7\n1\n\nSALPLE",
"2\n6\n1\n\nSALPLE",
"2\n5\n1\n\nTALPLE",
"2\n10\n1\n\nTALLPD",
"2\n3\n1\n\nTALLPD",
"2\n1\n2\n\nSAMPKE",
"2\n6\n2\n\nSAMPLE",
"2\n13\n1\n\nSALPLE",
"2\n1\n1\n\nTALPLE",
... |
ozs-lucky-strings-3 | Today Oz wants to play with Lucky strings. A string S is called Lucky string if there exists a non-negative integer m such that S is composed of m consecutive 'R' characters followed by m consecutive 'K' characters. Empty string is also a Lucky string i.e for m=0
Now Oz has a string STR. Each character of STR is either... | {
"input": [],
"output": []
} | {
"input": [
"2\nKRKRKKR\nKKKRRR\n\nSAMPLE"
],
"output": [
"4\n0\n"
]
} | {
"input": [
"2\nKRKRKKR\nKKKRRR\n\nSAMPLD",
"2\nRRKRKKK\nKKKRRR\n\nSAMPLD",
"2\nKRKRKKR\nRRRKKK\n\nSAMPLD",
"2\nRRKRKKK\nRRRKKK\n\nSAMPLD",
"2\nKKKRRKR\nKKKRRR\n\nSMAPLD",
"2\nRKRRKKK\nKKRKRR\n\nDLPAMS",
"2\nKKKRRKR\nRRRKKK\n\nDLPMAR",
"2\nKKKRRKR\nRKKRKR\n\nDLPMAS",
"2\nKKRRKRK\n... |
p02561 AtCoder Library Practice Contest - Maxflow | You are given a grid of N rows and M columns. The square at the i-th row and j-th column will be denoted as (i,j). Some of the squares contain an object. All the remaining squares are empty. The state of the grid is represented by strings S_1,S_2,\cdots,S_N. The square (i,j) contains an object if S_{i,j}= `#` and is em... | {
"input": [],
"output": []
} | {
"input": [
"3 3\n#..\n..#\n...",
"3 3\n..\n..#\n..."
],
"output": [
"3\n#><\nvv#\n^^.",
"3\n><\nvv#\n^^."
]
} | {
"input": [
"4 3\n#..\n..#\n...",
"3 5\n..\n..#\n...",
"4 3\n#..\n.#.\n...",
"4 3\n#..\n.#.\n../",
"3 1\n#..\n..#\n...",
"3 1\n..#\n..#\n...",
"3 1\n..$\n..#\n...",
"6 13\n..\n..#\n...",
"6 13\n..\n..#\n../",
"6 3\n#..\n..#\n...",
"6 3\n#..\n.#.\n...",
"1 1\n..#\n..#\n... |
p02692 AtCoder Beginner Contest 166 - Three Variables Game | There is a game that involves three variables, denoted A, B, and C.
As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by a string s_i. If s_i is `AB`, you must add 1 to A or B then subtract 1 from the other; if s_i is `AC`, you must add 1 to A or ... | {
"input": [],
"output": []
} | {
"input": [
"2 1 3 0\nAB\nAC",
"1 0 9 0\nAC",
"8 6 9 1\nAC\nBC\nAB\nBC\nAC\nBC\nAB\nAB",
"3 1 0 0\nAB\nBC\nAB"
],
"output": [
"Yes\nA\nC",
"No",
"Yes\nC\nB\nB\nC\nC\nB\nA\nA",
"No"
]
} | {
"input": [
"2 1 3 1\nAB\nAC",
"8 6 9 1\nBC\nBC\nAB\nBC\nAC\nBC\nAB\nAB",
"3 1 0 -1\nAB\nBC\nAB",
"8 6 16 1\nAC\nBC\nAB\nBC\nAC\nBC\nAB\nAB",
"2 0 3 2\nAB\nAC",
"1 0 8 1\nAC",
"8 9 16 1\nAC\nBC\nAB\nBC\nAC\nBC\nAC\nAB",
"1 0 6 1\nBC",
"2 2 3 0\nAB\nAB",
"2 3 2 0\nAB\nAC",
... |
p02821 AtCoder Beginner Contest 149 - Handshake | Takahashi has come to a party as a special guest. There are N ordinary guests at the party. The i-th ordinary guest has a power of A_i.
Takahashi has decided to perform M handshakes to increase the happiness of the party (let the current happiness be 0). A handshake will be performed as follows:
* Takahashi chooses o... | {
"input": [],
"output": []
} | {
"input": [
"5 3\n10 14 19 34 33",
"9 14\n1 3 5 110 24 21 34 5 3",
"9 73\n67597 52981 5828 66249 75177 64141 40773 79105 16076"
],
"output": [
"202",
"1837",
"8128170"
]
} | {
"input": [
"5 3\n10 4 19 34 33",
"9 14\n1 3 5 110 24 21 34 2 3",
"9 73\n67597 52981 5828 18 75177 64141 40773 79105 16076",
"5 1\n10 4 19 34 33",
"9 14\n1 3 5 111 24 21 34 2 3",
"9 73\n67597 52981 5828 18 116472 64141 40773 79105 16076",
"9 14\n1 3 3 111 24 21 34 2 3",
"9 14\n3 3 3 1... |
p02957 AtCoder Beginner Contest 135 - Harmony | We have two distinct integers A and B.
Print the integer K such that |A - K| = |B - K|.
If such an integer does not exist, print `IMPOSSIBLE` instead.
Constraints
* All values in input are integers.
* 0 \leq A,\ B \leq 10^9
* A and B are distinct.
Input
Input is given from Standard Input in the following format:
... | {
"input": [],
"output": []
} | {
"input": [
"998244353 99824435",
"0 3",
"2 16"
],
"output": [
"549034394",
"IMPOSSIBLE",
"9"
]
} | {
"input": [
"899758294 99824435",
"0 4",
"1349313191 99824435",
"0 2",
"1 7",
"1349313191 6197513",
"1 13",
"2563528379 6197513",
"2563528379 9221341",
"2563528379 13118121",
"-2 2",
"6 4",
"707160285 9274641",
"819805567 9274641",
"-2 8",
"819805567 65... |
p03093 AtCoder Grand Contest 032 - Modulo Pairing | Let M be a positive integer.
You are given 2 N integers a_1, a_2, \ldots, a_{2 N}, where 0 \leq a_i < M for each i.
Consider dividing the 2 N integers into N pairs. Here, each integer must belong to exactly one pair.
We define the ugliness of a pair (x, y) as (x + y) \mod M. Let Z be the largest ugliness of the N pa... | {
"input": [],
"output": []
} | {
"input": [
"3 10\n0 2 3 4 5 9",
"2 10\n1 9 1 9"
],
"output": [
"5",
"0"
]
} | {
"input": [
"3 10\n-1 2 3 4 5 9",
"3 10\n-1 2 3 1 5 9",
"2 16\n1 9 1 9",
"0 10\n-1 2 3 1 5 9",
"3 10\n-1 2 3 4 3 5",
"1 2\n0 1 2 4 3 6",
"3 10\n-1 2 3 1 5 8",
"3 10\n-1 4 3 4 5 5",
"3 11\n-1 7 5 4 5 5",
"3 11\n-2 3 3 4 5 5",
"2 16\n1 5 1 9",
"2 31\n-1 4 4 12 0 6",
... |
p03239 AtCoder Beginner Contest 112 - Time Limit Exceeded | When Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC.
You, the smartwatch, has found N routes to his home.
If Mr. X uses the i-th of these routes, he will get home in time t_i at cost c_i.
Find the smallest cost of a route that takes not l... | {
"input": [],
"output": []
} | {
"input": [
"4 3\n1 1000\n2 4\n3 1000\n4 500",
"5 9\n25 8\n5 9\n4 10\n1000 1000\n6 1",
"3 70\n7 60\n1 80\n4 50"
],
"output": [
"TLE",
"5",
"4"
]
} | {
"input": [
"4 3\n1 1000\n2 4\n3 1010\n4 500",
"5 9\n25 8\n5 9\n4 10\n0000 1000\n6 1",
"3 70\n7 94\n1 80\n4 50",
"4 3\n1 1000\n2 1\n3 1010\n4 500",
"5 9\n3 8\n5 9\n4 10\n0100 1000\n6 1",
"3 70\n7 94\n2 80\n7 50",
"3 36\n7 94\n1 2\n7 20",
"2 1\n0 0110\n0 1\n-1 0011\n0 -2",
"4 -1\n-... |
p03392 AtCoder Regular Contest 094 - Normalization | You are given a string S consisting of `a`,`b` and `c`. Find the number of strings that can be possibly obtained by repeatedly performing the following operation zero or more times, modulo 998244353:
* Choose an integer i such that 1\leq i\leq |S|-1 and the i-th and (i+1)-th characters in S are different. Replace each... | {
"input": [],
"output": []
} | {
"input": [
"babacabac",
"abbac",
"abc",
"ababacbcacbacacbcbbcbbacbaccacbacbacba"
],
"output": [
"6310",
"65",
"3",
"148010497"
]
} | {
"input": [
"babacaabc",
"bbaac",
"bac",
"ababacbcacbacacbcbbcbbbcbaccacbacbacba",
"cac",
"bdabdaaab",
"babababac",
"abcba",
"cbaacabab",
"bbbac",
"cab",
"abcabcabcaccabcbbbcbbcbcacabcacbcababa",
"cbabcaaab",
"bbcac",
"abcabcabcaccabcbbacbbcbcacabcacbcababa... |
p03555 AtCoder Beginner Contest 077 - Rotation | You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}.
Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
Constraints
* C_{i,j}(1 \leq i \leq 2, 1 \leq... | {
"input": [],
"output": []
} | {
"input": [
"tab\nbet",
"eye\neel",
"pot\ntop"
],
"output": [
"NO",
"NO",
"YES"
]
} | {
"input": [
"tbb\nbet",
"spp\npps",
"eye\nele",
"pos\ntop",
"btb\nbet",
"eey\nele",
"pos\npot",
"btb\nteb",
"efy\nele",
"qos\npot",
"atb\nbet",
"yfe\nele",
"qot\npot",
"atb\nbes",
"yfe\nfle",
"toq\npot",
"`tb\nbes",
"yef\nfle",
"toq\ntop",
... |
p03710 AtCoder Grand Contest 015 - Kenus the Ancient Greek | Kenus, the organizer of International Euclidean Olympiad, is seeking a pair of two integers that requires many steps to find its greatest common divisor using the Euclidean algorithm.
You are given Q queries. The i-th query is represented as a pair of two integers X_i and Y_i, and asks you the following: among all pai... | {
"input": [],
"output": []
} | {
"input": [
"10\n1 1\n2 2\n5 1000000000000000000\n7 3\n1 334334334334334334\n23847657 23458792534\n111111111 111111111\n7 7\n4 19\n9 10",
"3\n4 4\n6 10\n12 11"
],
"output": [
"1 1\n1 4\n4 600000013\n3 1\n1 993994017\n35 37447\n38 2\n3 6\n3 9\n4 2",
"2 4\n4 1\n4 7"
]
} | {
"input": [
"10\n1 1\n2 2\n5 1000000000000000000\n7 3\n1 334334334334334334\n23847657 23458792534\n111111111 011111111\n7 7\n4 19\n9 10",
"3\n4 4\n6 18\n12 11",
"10\n2 1\n2 2\n5 1000000000000000000\n7 3\n1 334334334334334334\n23847657 23458792534\n111111111 011111111\n7 7\n4 19\n9 10",
"3\n4 4\n6 18\... |
p03866 AtCoder Regular Contest 064 - Cosmic Rays | On the xy-plane, Snuke is going to travel from the point (x_s, y_s) to the point (x_t, y_t). He can move in arbitrary directions with speed 1. Here, we will consider him as a point without size.
There are N circular barriers deployed on the plane. The center and the radius of the i-th barrier are (x_i, y_i) and r_i, r... | {
"input": [],
"output": []
} | {
"input": [
"-2 0 2 0\n2\n-1 0 2\n1 0 2",
"4 -2 -2 4\n3\n0 0 2\n4 0 1\n0 4 1",
"-2 -2 2 2\n1\n0 0 1"
],
"output": [
"0.0000000000",
"4.0000000000",
"3.6568542495"
]
} | {
"input": [
"-2 0 2 0\n2\n-1 0 0\n1 0 2",
"4 -2 -2 4\n3\n0 0 2\n4 -1 1\n0 4 1",
"-2 -2 2 4\n1\n0 0 1",
"-2 1 2 0\n2\n-1 0 0\n1 0 2",
"-2 -2 2 4\n0\n0 0 1",
"-2 1 2 0\n1\n-1 0 0\n1 0 2",
"4 -2 -2 4\n1\n0 1 2\n4 0 1\n0 4 1",
"-3 -2 2 4\n0\n0 0 1",
"4 -2 -2 7\n1\n0 1 2\n4 0 1\n0 4 1"... |
p04030 AtCoder Beginner Contest 043 - Unhappy Hacking (ABC Edit) | Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key.
To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this stri... | {
"input": [],
"output": []
} | {
"input": [
"01B0",
"0BB1"
],
"output": [
"00",
"1"
]
} | {
"input": [
"01B1",
"BB11",
"B01B",
"02B0",
"/BB1",
"1B10",
"B010",
"B110",
"B011",
"B101",
"B111",
"B100",
"B001",
"B000",
"1B-0",
"0B.0",
"B00.",
"B.00",
"B0.0",
"BB01",
"B00B",
"011B",
"CB01",
"BB00",
"010B",
"... |
p00114 Electro-Fly | A calculator scholar has discovered a strange life form called an electronic fly that lives in electronic space. While observing the behavior of the electronic flies, the electronic flies at the (x, y, z) point in this space then move to (x', y', z') indicated by the following rules. I found out.
<image>
However, a1... | {
"input": [],
"output": []
} | {
"input": [
"2 5 3 7 6 13\n517 1024 746 6561 4303 3125\n0 0 0 0 0 0"
],
"output": [
"12\n116640000"
]
} | {
"input": [
"2 5 5 7 6 13\n517 1024 746 6561 4303 3125\n0 0 0 0 0 0",
"2 5 5 7 6 13\n517 1334 746 6561 4303 3125\n0 0 0 0 0 0",
"2 5 5 7 6 13\n517 1024 746 11315 4303 3125\n0 0 0 0 0 0",
"2 5 5 7 6 13\n913 1334 1228 6561 4303 3125\n0 0 0 0 0 0",
"2 5 5 7 6 13\n517 1024 746 14921 4303 3125\n0 0 0 ... |
p00247 Ice Maze | There is a rectangular maze with square squares lined up vertically and horizontally. In this maze, while moving to the adjacent squares in the north, south, east and west, the starting square S departs and the goal square G is aimed at. There are three types of trout: plain, mountain, and ice. S and G are located in t... | {
"input": [],
"output": []
} | {
"input": [
"5 5\n.X.S.\n.X#..\n.XX##\n.#XG.\n..X..\n7 3\nSXX.XXG\nX.#.#X.\nXXX.XX#\n4 4\nS...\nX.X.\nGX..\n...X\n10 10\n..XXXXX.XX\n.X.#.#X.XX\nSX.#X.X..X\n#X.##.X.XX\n..XXXX#.XX\n##.##.##XX\n....X.XX#X\n.##X..#X#X\n....XX#..X\n...#XXG..X\n0 0"
],
"output": [
"11\n10\n10\n33"
]
} | {
"input": [
"5 5\n.X.S.\n.X#..\n.XX##\n.#XG.\n..X..\n7 3\nSXX.XXG\nX.#.#X.\nXXX.XX#\n4 4\nS...\nX.X.\nGX..\n...X\n10 10\n..XXXXX.XX\n.X.#.#X.XX\nSX.#X.X..X\n#X.##.X.XX\n..XXXX#.XX\n##.##.##XX\n....X.YX#X\n.##X..#X#X\n....XX#..X\n...#XXG..X\n0 0",
"5 5\n.X.S.\n.X#..\n##XX.\n.#XG.\n..X..\n7 3\nSXX.XXG\nX.#.#X.... |
p00428 Questionnaire | I have a plan to go on a school trip at a school. I conducted a questionnaire survey for that purpose. Students have student numbers from 1 to n, and the locations of travel candidates are represented by numbers from 1 to m, and where they want to go ○ , Mark the places you don't want to go with a cross and submit.
At... | {
"input": [],
"output": []
} | {
"input": [
"4 6\n1 0 1 0 1 1\n1 1 0 1 0 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n4 6\n1 0 1 0 1 1\n1 1 0 1 0 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n0 0"
],
"output": [
"1 3 2 5 4 6\n1 3 2 5 4 6"
]
} | {
"input": [
"4 6\n1 0 1 0 1 1\n1 2 0 1 0 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n4 6\n1 0 1 0 1 1\n1 1 0 1 0 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n0 0",
"4 6\n1 0 1 0 1 1\n1 2 0 1 0 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n4 6\n1 0 1 0 1 1\n2 1 0 1 1 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n0 0",
"4 6\n1 0 1 0 1 1\n1 1 0 1 0 0\n1 1 1 0 0 0\n1 0 1 ... |
p00624 Dr. Nakamura's Lab. | Dr. Nakamura is a great inventor, and he is still working on a new invention that ordinary people cannot think of. Now he is inventing a new security system and container.
The security system is a panel that identifies the person who rides on it and stuns it by passing an electric current if it is an uninvited guest. ... | {
"input": [],
"output": []
} | {
"input": [
"5 5\n#####\n##@##\n#wc.#\n#Ew.#\n#####\n5 5\n#####\n##@.#\n#wc.#\n#E#.#\n#####\n3 6\n######\n#@.wE#\n######\n0 0",
"5 5\n\n@##\nwc.#\nEw.#\n\n5 5\n\n@.#\nwc.#\nE#.#\n\n3 6\n\n@.wE#\n\n0 0"
],
"output": [
"3\n5\n-1",
"3\n5\n-1"
]
} | {
"input": [
"5 5\n\n@##\nwc.#\nEw.#\n\n5 5\n\n@.#\nwc.#\nE#.#\n\n3 6\n\n@.wE#\n\n1 0",
"5 5\n#####\n##@##\n#wc.#\n#Ew.#\n#####\n5 5\n#####\n#.@##\n#wc.#\n#E#.#\n#####\n3 6\n######\n#@.wE#\n######\n0 0",
"5 5\n\n@##\nwc.#\nEw.#\n\n5 5\n\n@.#\nwc.#\nE#.#\n\n3 11\n\n@.wE#\n\n1 0",
"5 5\n\n@##\nwc.#\nEw.... |
p00768 ICPC Ranking | ICPC Ranking
Your mission in this problem is to write a program which, given the submission log of an ICPC (International Collegiate Programming Contest), determines team rankings.
The log is a sequence of records of program submission in the order of submission. A record has four fields: elapsed time, team number, p... | {
"input": [],
"output": []
} | {
"input": [
"300 10 8 5\n50 5 2 1\n70 5 2 0\n75 1 1 0\n100 3 1 0\n150 3 2 0\n240 5 5 7\n50 1 1 0\n60 2 2 0\n70 2 3 0\n90 1 3 0\n120 3 5 0\n140 4 1 0\n150 2 4 1\n180 3 5 4\n15 2 2 1\n20 2 2 1\n25 2 2 0\n60 1 1 0\n120 5 5 4\n15 5 4 1\n20 5 4 0\n40 1 1 0\n40 2 2 0\n120 2 3 4\n30 1 1 0\n40 2 1 0\n50 2 2 0\n60 1 2 0\... | {
"input": [
"300 10 8 5\n50 5 2 1\n70 5 2 0\n75 1 1 0\n100 3 1 0\n150 2 2 0\n240 5 5 7\n50 1 1 0\n60 2 2 0\n70 2 3 0\n90 1 3 0\n120 3 5 0\n140 4 1 0\n150 2 4 1\n180 3 5 4\n15 2 2 1\n20 2 2 1\n25 2 2 0\n60 1 1 0\n120 5 5 4\n15 5 4 1\n20 5 4 0\n40 1 1 0\n40 2 2 0\n120 2 3 4\n30 1 1 0\n40 2 1 0\n50 2 2 0\n60 1 2 0\... |
p00899 City Merger | Recent improvements in information and communication technology have made it possible to provide municipal service to a wider area more quickly and with less costs. Stimulated by this, and probably for saving their not sufficient funds, mayors of many cities started to discuss on mergers of their cities.
There are, of... | {
"input": [],
"output": []
} | {
"input": [
"3\nFUKUOKA\nOKAYAMA\nYAMAGUCHI\n3\nFUKUOKA\nFUKUYAMA\nOKAYAMA\n2\nABCDE\nEDCBA\n4\nGA\nDEFG\nCDDE\nABCD\n2\nABCDE\nC\n14\nAAAAA\nBBBBB\nCCCCC\nDDDDD\nEEEEE\nFFFFF\nGGGGG\nHHHHH\nIIIII\nJJJJJ\nKKKKK\nLLLLL\nMMMMM\nNNNNN\n0",
"3"
],
"output": [
"16\n19\n9\n9\n5\n70",
"16"
]
} | {
"input": [
"3\nFUKUOKA\nOKAYAMA\nYAMAGUCHI\n3\nFUKUOKA\nFUKUYAMA\nOKAYAMA\n2\nABCDE\nEDCBA\n4\nGA\nDEFG\nCDDE\nABCD\n2\nABCDE\nC\n14\nAAAAA\nBBBBB\nCCCCC\nDDDDD\nEEEED\nFFFFF\nGGGGG\nHHHHH\nIIIII\nJJJJJ\nKKKKK\nLLLLL\nMMMMM\nNNNNN\n0",
"2",
"3\nFUKUOKA\nOKAYAMA\nYAMAGUCHI\n3\nFUKUOKB\nFUKUYAMA\nOKAYAMA\... |
p01032 Rooted Tree Game | Problem
Multiple rooted trees are given as the initial state. Alice and Bob, on the other hand, play the game. The game is played alternately by two players, with Alice on the play and Bob on the play. The player whose turn has turned takes the following actions.
1. Select one root (vertex that has no parent). Let th... | {
"input": [],
"output": []
} | {
"input": [
"6 3\n4\n4\n5",
"6 4\n2\n5\n4\n5"
],
"output": [
"Alice",
"Bob"
]
} | {
"input": [
"6 3\n4\n7\n5",
"6 4\n2\n8\n4\n8",
"6 4\n2\n8\n4\n5",
"6 4\n2\n8\n8\n8",
"6 3\n4\n5\n5",
"8 4\n2\n5\n4\n5",
"6 4\n2\n8\n1\n8",
"2 4\n2\n8\n8\n8",
"10 3\n4\n5\n5",
"9 4\n2\n5\n4\n5",
"6 4\n3\n8\n1\n8",
"2 4\n2\n8\n15\n8",
"10 3\n4\n9\n5",
"9 4\n2\n5\... |
p01164 Sort the Panels | There was an explorer Henry Nelson traveling all over the world. One day he reached an ancient building. He decided to enter this building for his interest, but its entrance seemed to be locked by a strange security system.
There were some black and white panels placed on a line at equal intervals in front of the entr... | {
"input": [],
"output": []
} | {
"input": [
"4\nWBWB\nBWBW\n8\nWWWWBWBB\nWWBBWBWW\n0"
],
"output": [
"3\n9"
]
} | {
"input": [
"4\nWBWB\nBWBW\n8\nWWWWBWBB\nBWBBWWWW\n0",
"4\nBWBW\nBWBW\n8\nWWWWBWBB\nWWBBWBWW\n0",
"4\nBBWW\nBWBW\n8\nWWWWBWBB\nWWBBWBWW\n0",
"4\nBBWW\nWBWB\n8\nWWWWBWBB\nWWBBWBWW\n0",
"4\nWBWB\nBWBW\n13\nWWWWBWBB\nWBBBWWWW\n0",
"4\nWBWB\nBWBW\n8\nBBWBWWWW\nWWBBWBWW\n0",
"4\nWBWB\nBWBW\n8\... |
p01302 Cave Explorer | Mike Smith is a man exploring caves all over the world.
One day, he faced a scaring creature blocking his way. He got scared, but in short time he took his knife and then slashed it to attempt to kill it. Then they were split into parts, which soon died out but the largest one. He slashed the creature a couple of time... | {
"input": [],
"output": []
} | {
"input": [
"5\n0 1\n0 0\n5 0\n1 1\n5 2\n0 2\n7\n9999 9998\n0 0\n2 0\n3 1\n1 1\n10000 9999\n2 2\n0 2\n0"
],
"output": [
"2.00\n2.2500000"
]
} | {
"input": [
"5\n0 2\n0 0\n5 0\n1 1\n5 2\n0 2\n7\n9999 9998\n0 0\n2 0\n3 1\n1 1\n10000 9999\n2 2\n0 2\n0",
"5\n0 1\n0 0\n5 0\n1 1\n5 2\n0 2\n7\n9999 9998\n0 0\n2 0\n3 2\n1 1\n10000 9999\n2 2\n0 2\n0",
"5\n0 2\n0 0\n5 0\n1 1\n5 2\n0 2\n7\n9999 9998\n0 1\n2 0\n3 1\n1 1\n10000 9999\n2 2\n0 2\n0",
"5\n0 1... |
p01471 Fractional Knapsack | Problem statement
Real variables $ x_1, x_2, ..., x_N $ satisfy the following conditions.
1. $ 0 \ leq x_i \ leq 1 $ ($ 1 \ leq i \ leq N $)
2. $ w_1x_1 + w_2x_2 + ... + w_Nx_N \ leq W $
At this time, find the maximum value that $ v_1x_1 + v_2x_2 + ... + v_Nx_N $ can take. It is known that such a maximum actually ... | {
"input": [],
"output": []
} | {
"input": [
"1 1\n3 1",
"2 1\n-1 -3\n3 10",
"2 3\n3 3\n1 2"
],
"output": [
"0.333333",
"3.666667",
"4.000000"
]
} | {
"input": [
"0 1\n3 1",
"2 2\n-1 -3\n3 10",
"2 3\n4 3\n1 2",
"2 3\n4 2\n1 2",
"2 3\n1 2\n1 2",
"2 3\n1 2\n2 3",
"1 3\n1 2\n2 3",
"1 31\n0 8\n1 6",
"1 1\n3 2",
"2 1\n-1 0\n3 10",
"1 0\n-1 1\n3 8",
"1 31\n0 9\n1 6",
"2 1\n-2 0\n3 10",
"2 2\n-1 -2\n3 13",
"2 3... |
p01631 English | Problem Statement
Mr. Takatsuki, who is planning to participate in the Aizu training camp, is enthusiastic about studying and has been studying English recently. She tries to learn as many English words as possible by playing the following games on her mobile phone. The mobile phone she has is a touch panel type that ... | {
"input": [],
"output": []
} | {
"input": [
"6\nAIZU 10\nLINER 6\nLINE 4\nALL 2\nAS 1\nCIEL 10\nASLA\nCILI\nIRZN\nELEU\n21"
],
"output": [
"40"
]
} | {
"input": [
"6\nAIZU 10\nLINER 6\nLINE 4\nALL 2\nAS 1\nCIEL 10\nASLA\nCILI\nIRZN\nUELE\n21",
"6\nAIZU 10\nLINER 6\nLHNE 4\nALL 2\nAS 1\nCIEL 10\nASLA\nCILI\nIRZN\nUELE\n21",
"6\nAIZU 10\nLINER 6\nLHNE 3\nALL 2\nAS 1\nCIEL 10\nBSLA\nCILI\nIRZN\nUELE\n21",
"6\nUZI@ 4\nLINER 12\nLGNE 9\nALL 2\nAS 1\nCIE... |
p01783 LR | Example
Input
R?????,2?)
Output
29 | {
"input": [],
"output": []
} | {
"input": [
"R?????,2?)"
],
"output": [
"29"
]
} | {
"input": [
")?2,?????R",
")?2,???@?R",
"S?????,2?)",
")?2??,???R",
")@2,?????R",
"S???,??2?)",
")?2??-???R",
")@3,?????R",
")?2??,???S",
")?2??-???Q",
")@3,???@?R",
")?2??,??>S",
")?2??-???P",
")@3,??@@?R",
")?2??,?>>S",
"P???-??2?)",
"(@3,??@@?R",... |
p01918 Imagawayaki Man | C: Imagawayaki Man-Imagawayaki Man-
story
Imagawayaki Man is a hero of justice. The face is Imagawayaki with a diameter of 1 meter (mainly a food made by filling a dough made of wheat flour with a generous amount of bean paste, and it looks round and delicious. In Hokkaido, it is simply called "yaki". In addition to ... | {
"input": [],
"output": []
} | {
"input": [
""
],
"output": [
""
]
} | {
"input": [],
"output": []
} |
p02056 Jam | E: Jam
problem
There are N cities in a country, numbered 1, \ 2, \ ..., \ N. These cities are connected in both directions by M roads, and the i-th road allows you to travel between the cities u_i and v_i in time t_i. Also, any two cities can be reached by using several roads.
Bread is sold in each town, and the del... | {
"input": [],
"output": []
} | {
"input": [
"4 4 3\n3 6 1 6\n1 1 2 3\n6 1 5 5\n1 2 1\n2 3 1\n1 3 1\n1 4 1"
],
"output": [
"10\n8\n9"
]
} | {
"input": [
"4 4 3\n3 6 1 1\n1 1 2 3\n6 1 5 5\n1 2 1\n2 3 1\n1 3 1\n1 4 1",
"4 4 3\n3 6 1 1\n1 1 2 3\n6 0 5 5\n1 2 1\n2 2 1\n1 3 1\n1 4 1",
"4 4 3\n3 6 1 1\n1 1 2 3\n6 1 5 5\n1 2 1\n2 4 1\n1 3 1\n1 4 1",
"4 4 3\n3 6 1 1\n1 1 2 3\n5 0 5 5\n1 2 1\n2 3 1\n1 3 1\n1 4 1",
"4 4 3\n3 6 1 1\n1 1 2 3\n8 0... |
p02198 Oranges on Cans | Oranges on Cans
square1001 You put a $ N $ can of aluminum on the table.
E869120 You put $ M $ of oranges on each aluminum can on the table.
How many oranges are on the aluminum can?
input
Input is given from standard input in the following format.
$ N $ $ M $
output
Output the number of oranges on the alumin... | {
"input": [],
"output": []
} | {
"input": [
"3 4"
],
"output": [
"12"
]
} | {
"input": [
"3 0",
"2 1",
"2 2",
"3 2",
"6 2",
"9 2",
"13 2",
"13 3",
"2 5",
"4 5",
"4 9",
"3 9",
"3 10",
"3 11",
"3 5",
"3 8",
"1 8",
"1 3",
"1 -1",
"2 -1",
"3 -1",
"1 -6",
"1 1",
"-2 2",
"-4 2",
"-4 4",
"-3 ... |
p02352 RMQ and RAQ | Write a program which manipulates a sequence $A$ = {$a_0, a_1, ..., a_{n-1}$} with the following operations:
* $add(s, t, x)$ : add $x$ to $a_s, a_{s+1}, ..., a_t$.
* $find(s, t)$ : report the minimum value in $a_s, a_{s+1}, ..., a_t$.
Note that the initial values of $a_i ( i = 0, 1, ..., n-1 )$ are 0.
Constraints... | {
"input": [],
"output": []
} | {
"input": [
"6 7\n0 1 3 1\n0 2 4 -2\n1 0 5\n1 0 1\n0 3 5 3\n1 3 4\n1 0 5"
],
"output": [
"-2\n0\n1\n-1"
]
} | {
"input": [
"6 7\n0 1 3 1\n0 2 4 -2\n1 0 5\n1 0 1\n0 1 5 3\n1 3 4\n1 0 5",
"6 7\n0 0 3 1\n0 2 4 -2\n1 0 5\n1 0 1\n0 3 5 3\n1 3 4\n1 0 5",
"6 7\n0 1 3 1\n0 2 4 0\n1 0 5\n1 0 1\n0 3 5 3\n1 3 4\n1 0 5",
"6 7\n0 0 6 1\n0 2 4 -2\n1 0 5\n1 0 1\n0 3 5 3\n1 3 4\n1 0 5",
"6 11\n0 0 6 1\n0 2 4 -2\n1 0 5\n1... |
ashigift | Suraj, the Chief Prankster is back in action now and this time he has stolen the valentine's day gift given by Ashi (the love of Chef) to the Chef and ran away with it to Byteland.
Byteland is a not a regular place like Chef's town. The safest way from Chef's town to Byteland is through the path of tasty dishes. The pa... | {
"input": [],
"output": []
} | {
"input": [
"3\n10\n2 1 3 8 1\n0\n10\n2 1 3 8 5\n0\n10\n2 2 3 8 5\n3 1 2 1 4 3 2 9 1 1"
],
"output": [
"5\n9\n6"
]
} | {
"input": [
"3\n10\n2 1 3 8 1\n0\n10\n2 1 3 8 5\n0\n10\n2 2 3 8 3\n3 1 2 1 4 3 2 9 1 1",
"3\n10\n2 1 3 8 1\n0\n10\n2 1 3 8 5\n0\n10\n2 2 1 8 5\n3 1 2 1 4 3 2 9 1 1",
"3\n10\n2 1 3 8 1\n0\n10\n2 1 3 8 5\n0\n10\n2 2 3 2 3\n3 1 2 1 4 3 2 9 1 1",
"3\n10\n2 1 3 8 1\n0\n10\n2 1 3 8 5\n0\n10\n2 0 3 2 6\n3 1... |
cleanup | After a long and successful day of preparing food for the banquet, it is time to clean up. There is a list of n jobs to do before the kitchen can be closed for the night. These jobs are indexed from 1 to n.
Most of the cooks have already left and only the Chef and his assistant are left to clean up. Thankfully, some ... | {
"input": [],
"output": []
} | {
"input": [
"3\n6 3\n2 4 1\n3 2\n3 2\n8 2\n3 8"
],
"output": [
"3 6 \n5 \n1 \n\n1 4 6 \n2 5 7 \n"
]
} | {
"input": [
"3\n4 3\n2 4 1\n3 2\n3 2\n8 2\n3 8",
"3\n4 3\n2 4 1\n3 2\n3 2\n8 2\n1 8",
"3\n6 3\n2 4 1\n3 2\n3 1\n8 2\n3 8",
"3\n4 3\n2 4 1\n3 2\n3 2\n12 2\n1 8",
"3\n6 3\n2 4 1\n3 2\n3 1\n8 2\n5 8",
"3\n6 3\n2 4 1\n3 2\n3 1\n8 2\n7 8",
"3\n6 3\n2 4 1\n6 2\n3 2\n8 2\n3 8",
"3\n4 3\n3 4 ... |
flow002 | Write a program to find the remainder when two given numbers are divided.
Input
The first line contains an integer T, total number of test cases. Then follow T lines, each line contains two Integers A and B.
Output
Find remainder when A is divided by B.
Constraints
1 ≤ T ≤ 1000
1 ≤ A,B ≤ 10000
Example
Input
3... | {
"input": [],
"output": []
} | {
"input": [
"3 \n1 2\n100 200\n10 40"
],
"output": [
"1\n100\n10\n"
]
} | {
"input": [
"3 \n0 2\n100 200\n10 40",
"3 \n1 2\n000 200\n10 40",
"3 \n0 2\n100 200\n1 40",
"3 \n1 2\n000 200\n15 67",
"3 \n0 2\n100 79\n1 40",
"3 \n1 4\n001 200\n15 67",
"3 \n0 2\n100 75\n1 40",
"3 \n1 4\n001 200\n15 14",
"3 \n0 2\n000 75\n1 40",
"3 \n1 4\n000 337\n15 14",
... |
lecards | Little Elephant from the Zoo of Lviv likes cards. He has N cards, each of which has one of 1000 colors. The colors are numbered from 1 to 1000.
Little Elephant and Big Hippo are playing the following game. At first Little Elephant takes some subset of cards, and Big Hippo takes the rest of them. Here, Little Elephant c... | {
"input": [],
"output": []
} | {
"input": [
"2\n3\n1 2 3\n4\n1 1 3 2"
],
"output": [
"4\n5"
]
} | {
"input": [
"2\n3\n1 2 3\n4\n2 1 3 2",
"2\n3\n1 2 1\n7\n2 1 3 2",
"2\n3\n1 2 2\n1\n1 0 3 3",
"2\n5\n1 2 3\n4\n2 1 3 2",
"2\n2\n1 2 1\n7\n1 1 3 2",
"2\n3\n1 2 1\n8\n1 1 3 3",
"2\n5\n2 2 2\n7\n1 1 3 3",
"2\n4\n1 2 2\n7\n1 0 3 3",
"2\n5\n1 2 2\n1\n1 0 3 6",
"2\n5\n1 2 3\n8\n2 1 3... |
polydifr | In this problem, you will be given a polynomial, you have to print what it becomes after differentiation.
Following are the rules for differentiation:
For a polynomial f(x), its differentiation is defined as f'(x).
If a is a constant, then differentiation of af(x) is af'(x).
If f(x) = h(x) + g(x) , then f'(x) = h'(x... | {
"input": [],
"output": []
} | {
"input": [
"2\n1\n1 2\n3\n1 3\n1 1\n1 0"
],
"output": [
"2x^1\n3x^2 + 1"
]
} | {
"input": [
"2\n1\n1 2\n3\n1 3\n1 1\n2 0",
"2\n1\n1 4\n3\n1 3\n1 1\n2 0",
"2\n1\n1 4\n1\n1 3\n1 1\n3 0",
"2\n1\n1 2\n3\n1 6\n1 1\n2 0",
"2\n1\n1 4\n3\n1 3\n1 1\n2 1",
"2\n1\n1 4\n3\n1 3\n1 2\n3 0",
"2\n1\n1 4\n1\n1 6\n1 1\n6 0",
"2\n1\n1 2\n3\n1 3\n1 1\n1 -1",
"2\n1\n1 0\n3\n1 3\n... |
subgcd | Given an array A1,A2...AN, you have to print the size of the largest contiguous subarray such that
GCD of all integers in that subarray is 1.
Formally, For a subarray Ai,Ai+1...Aj where 1 ≤ i < j ≤ N to be valid: GCD(Ai,Ai+1...Aj) should be 1. You have to print the size of the largest valid subarray.
If no valid subarr... | {
"input": [],
"output": []
} | {
"input": [
"2\n2\n7 2\n3\n2 2 4"
],
"output": [
"2\n-1\n"
]
} | {
"input": [
"2\n2\n7 2\n3\n3 2 4",
"2\n2\n7 2\n3\n6 2 4",
"2\n2\n6 2\n3\n2 2 4",
"2\n2\n6 2\n3\n2 3 4",
"2\n2\n7 2\n2\n6 2 4",
"2\n2\n7 1\n2\n6 2 4",
"2\n2\n7 4\n3\n6 2 4",
"2\n2\n7 2\n1\n6 2 4",
"2\n1\n6 2\n3\n2 3 4",
"2\n1\n6 2\n3\n2 4 4",
"2\n1\n6 2\n1\n2 4 4",
"2\n... |
100_D. World of Mouth | There are a lot of rumors in the media these days. One day Aida decided to find out how rumors are made.
She asked n of her friends to help her. They all formed a circle and Aida told the person to her right a piece of news which was just a simple string. Then each person told the string to the person on his/her right... | {
"input": [],
"output": []
} | {
"input": [
"100\nCodeforces\nMMIODPC\n",
"5\nMMIOD\nCF\n"
],
"output": [
"Yes\n",
"No\n"
]
} | {
"input": [],
"output": []
} |
1221_C. Perfect Team | You may have already known that a standard ICPC team consists of exactly three members. The perfect team however has more restrictions. A student can have some specialization: coder or mathematician. She/he can have no specialization, but can't have both at the same time.
So the team is considered perfect if it includ... | {
"input": [],
"output": []
} | {
"input": [
"6\n1 1 1\n3 6 0\n0 0 0\n0 1 1\n10 1 10\n4 4 1\n"
],
"output": [
"1\n3\n0\n0\n1\n3\n"
]
} | {
"input": [
"6\n1 1 1\n3 6 0\n0 0 0\n1 1 1\n10 1 10\n4 4 1\n",
"6\n1 1 1\n3 6 0\n0 1 0\n0 1 1\n10 1 10\n4 4 1\n",
"6\n0 1 1\n3 6 0\n0 0 0\n1 1 1\n10 1 10\n4 4 1\n",
"6\n0 1 1\n3 6 0\n0 0 0\n1 0 1\n10 1 10\n4 4 1\n",
"6\n1 0 1\n3 2 0\n1 1 0\n0 1 1\n10 1 10\n4 4 1\n",
"6\n1 0 1\n3 2 0\n1 1 0\n0... |
1331_B. Limericks | There was once young lass called Mary,
Whose jokes were occasionally scary.
On this April's Fool
Fixed limerick rules
Allowed her to trip the unwary.
Can she fill all the lines
To work at all times?
On juggling the words
Right around two-thirds
Sh... | {
"input": [],
"output": []
} | {
"input": [
"391\n",
"57\n",
"35\n"
],
"output": [
"1723",
"319",
"57"
]
} | {
"input": [
"4\n",
"58\n",
"14\n",
"502\n",
"10\n",
"202\n",
"85\n",
"39\n",
"22\n",
"9\n",
"21\n",
"25\n",
"15\n",
"6\n",
"158\n",
"122\n",
"446\n",
"33\n",
"949\n",
"94\n",
"49\n",
"718\n",
"74\n",
"26\n",
"46\n",
... |
1418_D. Trash Problem | Vova decided to clean his room. The room can be represented as the coordinate axis OX. There are n piles of trash in the room, coordinate of the i-th pile is the integer p_i. All piles have different coordinates.
Let's define a total cleanup as the following process. The goal of this process is to collect all the pile... | {
"input": [],
"output": []
} | {
"input": [
"5 8\n5 1 2 4 3\n0 1\n0 2\n0 3\n0 4\n0 5\n1 1000000000\n1 1\n1 500000000\n",
"5 6\n1 2 6 8 10\n1 4\n1 9\n0 6\n0 10\n1 100\n1 50\n"
],
"output": [
"3\n2\n1\n0\n0\n0\n0\n0\n499999999\n",
"5\n7\n7\n5\n4\n8\n49\n"
]
} | {
"input": [
"5 6\n1 2 6 8 10\n1 4\n1 9\n0 6\n0 10\n1 100\n1 5\n",
"5 6\n1 2 6 5 10\n1 4\n1 9\n0 6\n0 10\n1 100\n1 50\n",
"5 4\n5 1 2 4 3\n0 1\n0 2\n0 3\n0 4\n0 5\n1 1000000000\n1 1\n1 500000000\n",
"5 1\n5 1 2 4 3\n0 1\n0 2\n0 3\n0 4\n0 5\n1 1000000000\n1 1\n0 500000000\n",
"5 6\n1 2 6 5 10\n1 4\... |
1536_D. Omkar and Medians | Uh oh! Ray lost his array yet again! However, Omkar might be able to help because he thinks he has found the OmkArray of Ray's array. The OmkArray of an array a with elements a_1, a_2, …, a_{2k-1}, is the array b with elements b_1, b_2, …, b_{k} such that b_i is equal to the median of a_1, a_2, …, a_{2i-1} for all i. O... | {
"input": [],
"output": []
} | {
"input": [
"5\n8\n-8 2 -6 -5 -4 3 3 2\n7\n1 1 3 1 0 -2 -1\n7\n6 12 8 6 2 6 10\n6\n5 1 2 3 6 7\n5\n1 3 4 3 0\n",
"5\n4\n6 2 1 3\n1\n4\n5\n4 -8 5 6 -7\n2\n3 3\n4\n2 1 2 3\n"
],
"output": [
"\nNO\nYES\nNO\nNO\nNO\n",
"\nNO\nYES\nNO\nYES\nYES\n"
]
} | {
"input": [
"5\n8\n-8 2 -6 -5 -4 3 3 2\n7\n1 1 4 1 0 -2 -1\n7\n6 12 8 6 2 6 10\n6\n5 1 2 3 6 7\n5\n1 3 4 3 0\n",
"5\n4\n6 2 2 3\n1\n4\n5\n4 -8 5 6 -7\n2\n3 3\n4\n2 1 2 3\n",
"5\n8\n-8 2 -6 -5 -4 3 3 2\n7\n1 1 4 1 0 -2 -1\n7\n6 12 8 6 2 6 4\n6\n5 1 2 2 6 7\n5\n1 2 4 3 0\n",
"5\n4\n6 2 2 10\n1\n7\n10\n... |
683_A. The Check of the Point | On the coordinate plane there is a square with sides parallel to the coordinate axes. The length of the square side is equal to a. The lower left corner of the square coincides with the point (0, 0) (the point of the origin). The upper right corner of the square has positive coordinates.
You are given a point with coo... | {
"input": [],
"output": []
} | {
"input": [
"2 1 1\n",
"4 4 4\n",
"10 5 -4\n"
],
"output": [
"0\n",
"1\n",
"2\n"
]
} | {
"input": [],
"output": []
} |
bytelandian-encoding | In Byteland,people don't use standard e-mail services like gmail,yahoo-mail etc.Instead they have their own e-mail service know as Bytemail.In Bytemail, encryption of e-mails is done using a special algorithm known as Bytecryption algorithm.It works as follows:
1)All the text is converted into lower-case alphabets onl... | {
"input": [],
"output": []
} | {
"input": [
"2\naaaaaaaa\nadappadsdsdas\n\nSAMPLE"
],
"output": [
"aaaaaaaa\ndasdppsadadas\n"
]
} | {
"input": [
"2\naaaaaaaa\nadappadsdsdas\n\nELPMAS",
"2\naaaaabaa\nadappadsdsdas\n\nELAMPT",
"2\naaaa`baa\nadappadsdsdas\n\nELAMTP",
"2\naaaa`caa\nadappadsdsdas\n\nOTMALE",
"2\naac`aaaa\nadaqpadsdsdas\n\nOTM@LE",
"2\naac``aaa\nadaqpadsdsdas\n\nOTM@LE",
"2\naac```aa\nadaqpadsdsdas\n\nOTM@LE... |
game-of-riches | There is a special game played in remote part of Rajasthan, where all people assemble with their all wealth and try to earn more wealth on the account of their current wealth.
Suppose you are also a part of this game.
The game is like, there are N people playing the game where everyone has its wealth. You are given w... | {
"input": [],
"output": []
} | {
"input": [
"3\n12 11\n1640 3997 4133 4282 3130 3938 4628 1138 4474 4534 2218 1293 \n1 1\n2491 \n15 6\n1242 3342 4797 4252 811 4955 76 4298 3753 1104 168 17 2364 1207 4764\n\nSAMPLE"
],
"output": [
"0\n0\n1\n"
]
} | {
"input": [
"3\n12 11\n1640 3997 4133 5404 3130 3938 4628 1138 4474 4534 2218 1293 \n1 1\n2491 \n15 6\n1242 3342 4797 4252 811 4955 76 4298 3753 1104 168 17 2364 1207 4764\n\nSAMPLE",
"3\n12 11\n1640 3997 4133 16600 4540 1074 4628 1138 4474 4534 402 1293 \n1 2\n2491 \n15 2\n1242 3342 5972 4252 811 4955 76 42... |
modified-power-set | As we all know that power sets of any set are formed by taking i elements (where i is from 1 to n) and then random shuffling them like this power set of {1,2,3} are {EMPTY SET},{1},{2},{3},{1,2}{1,3}{2,3}{1,2,3} .
Now we have a MODIfied POWER SET which contains only those subsets which have consecutive elements from s... | {
"input": [],
"output": []
} | {
"input": [
"2\nabcde\nabc\n\nSAMPLE"
],
"output": [
"15\n6\n"
]
} | {
"input": [
"2\nabcde\nabc\n\nSAMPEL",
"2\nabcdf\nacc\n\nASMPEL",
"2\nfdcca\n`dc\n\nASLPLD",
"2\nfdcca\n`dd\n\nASLQLD",
"2\ncafcc\ngaf\n\nUKJ@BQ",
"2\nea_ea\ngee\n\n@UEKJU",
"2\nabcde\nabc\n\nASMPEL",
"2\nabcdf\nabc\n\nASMPEL",
"2\nabcdf\nabc\n\nLEPMSA",
"2\nfdcba\nacc\n\nASMP... |
round-it | To round an integer a, it is customary to round to some multiple of a power of 10, and you will round it accordingly. This time, rules have changed. Given an int n and an int b, round n to the nearest value which is a multiple of b.
If n is exactly halfway between two multiples of b, print the larger value.
INPUT
Fi... | {
"input": [],
"output": []
} | {
"input": [
"2\n5 10\n100 3\n\nSAMPLE"
],
"output": [
"10\n99\n"
]
} | {
"input": [
"2\n5 10\n101 3\n\nSAMPLE",
"2\n5 10\n111 3\n\nSAMPLE",
"2\n5 10\n110 6\n\nSAMPLE",
"2\n5 10\n100 9\n\nSAMPLE",
"2\n5 10\n110 2\n\nSAMPLD",
"2\n5 10\n100 1\n\nSAMPLE",
"2\n5 10\n101 1\n\nMASPLE",
"2\n5 4\n110 2\n\nSAMPLD",
"2\n5 1\n111 3\n\nSEMPLA",
"2\n5 10\n001 1... |
unusual-blocks-6 | Admin is provided with infinite supply of Unusual blocks and now he has being assigned the task to fill the rectangular floor(completely) of Area A with one of these Unusual blocks.
The Property of Unusual Blocks being :-
Property 1 :- Both of it's dimensions are integers
Property 2 :- When both of it's dimension... | {
"input": [],
"output": []
} | {
"input": [
"1\n4\n\nSAMPLE"
],
"output": [
"2"
]
} | {
"input": [
"1\n7\n\nSAMPLE",
"1\n10\n\nRAMONE",
"1\n30\n\nDNOQAM",
"1\n72\n\nM@RMND",
"1\n390\n\nDNLQ@M",
"1\n990\n\n?LQLND",
"1\n828\n\n=LQMOD",
"1\n7\n\nSANPLE",
"1\n13\n\nSANPLE",
"1\n13\n\nRANPLE",
"1\n13\n\nRALPNE",
"1\n5\n\nRALPNE",
"1\n7\n\nRALPNE",
"1\... |
p02590 AtCoder Grand Contest 047 - Product Modulo | Let’s take a prime P = 200\,003. You are given N integers A_1, A_2, \ldots, A_N. Find the sum of ((A_i \cdot A_j) \bmod P) over all N \cdot (N-1) / 2 unordered pairs of elements (i < j).
Please note that the sum isn't computed modulo P.
Constraints
* 2 \leq N \leq 200\,000
* 0 \leq A_i < P = 200\,003
* All values in... | {
"input": [],
"output": []
} | {
"input": [
"4\n2019 0 2020 200002",
"5\n1 1 2 2 100000"
],
"output": [
"474287",
"600013"
]
} | {
"input": [
"4\n1234 0 2020 200002",
"5\n1 1 2 3 100000",
"4\n1234 0 3282 200002",
"5\n1 1 2 3 101000",
"5\n1 1 2 3 001000",
"5\n1 1 1 3 001000",
"5\n1 1 0 3 001000",
"5\n0 1 0 3 001000",
"5\n0 2 0 3 001000",
"5\n0 1 0 3 001100",
"5\n0 0 0 3 001100",
"4\n2019 1 2020 20... |
p02721 AtCoder Beginner Contest 161 - Yutori | Takahashi has decided to work on K days of his choice from the N days starting with tomorrow.
You are given an integer C and a string S. Takahashi will choose his workdays as follows:
* After working for a day, he will refrain from working on the subsequent C days.
* If the i-th character of S is `x`, he will not wor... | {
"input": [],
"output": []
} | {
"input": [
"5 2 3\nooxoo",
"11 3 2\nooxxxoxxxoo",
"16 4 3\nooxxoxoxxxoxoxxo"
],
"output": [
"1\n5",
"6",
"11\n16"
]
} | {
"input": [
"11 3 1\nooxxxoxxxoo",
"11 3 1\nooxxxooxxox",
"11 3 1\nxoxxooxxxoo",
"16 4 3\nooxxoxoxxyoxoxxo",
"16 4 3\noxxoxoxxxoxoxxoo",
"11 3 1\nxxxxoooxxoo",
"16 4 3\nooxxoxoxxyoxxxoo",
"11 3 1\nxoxwnoxxxoo",
"11 3 1\nooxxxonwxox",
"11 3 1\nxoxvopxxyoo",
"16 4 3\noxxoxox... |
p02851 AtCoder Beginner Contest 146 - Rem of Sum is Num | Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.
Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from... | {
"input": [],
"output": []
} | {
"input": [
"5 4\n1 4 2 3 5",
"10 7\n14 15 92 65 35 89 79 32 38 46",
"8 4\n4 2 4 2 4 2 4 2"
],
"output": [
"4",
"8",
"7"
]
} | {
"input": [
"5 1\n1 4 2 3 5",
"10 7\n14 15 101 65 35 89 79 32 38 46",
"10 8\n14 26 111 65 35 89 95 32 38 46",
"10 3\n14 26 111 65 35 89 95 32 38 46",
"5 8\n1 4 2 3 5",
"10 7\n18 15 92 65 35 89 79 32 38 46",
"10 3\n14 26 111 65 35 89 184 32 38 46",
"10 2\n40 2 100 26 22 15 2 19 8 46",
... |
p02988 AtCoder Beginner Contest 132 - Ordinary Number | We have a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n}.
Print the number of elements p_i (1 < i < n) that satisfy the following condition:
* p_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.
Constraints
* All values in input are integers.
* 3 \leq n \leq 20
* p... | {
"input": [],
"output": []
} | {
"input": [
"9\n9 6 3 2 5 8 7 4 1",
"5\n1 3 5 4 2"
],
"output": [
"5",
"2"
]
} | {
"input": [
"9\n9 6 3 2 5 14 7 4 1",
"5\n2 3 5 4 2",
"9\n14 17 3 4 5 25 7 4 0",
"5\n2 1 5 4 2",
"9\n14 12 3 2 9 14 1 4 0",
"5\n2 6 4 8 3",
"9\n14 6 3 2 5 14 7 4 1",
"9\n14 6 3 2 5 14 7 4 0",
"9\n14 12 3 2 5 14 7 4 0",
"9\n14 12 3 2 5 14 7 4 -1",
"9\n14 12 3 2 5 25 7 4 -1",... |
p03129 Yahoo Programming Contest 2019 - Anti-Adjacency | Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
Constraints
* 1\leq N,K\leq 100
* N and K are integers.
Input
Input is given from Standard Input in the following format:
N K
Output
If we can choose K integers as above, print `YES`; otherwise, prin... | {
"input": [],
"output": []
} | {
"input": [
"10 90",
"31 10",
"3 2",
"5 5"
],
"output": [
"NO",
"YES",
"YES",
"NO"
]
} | {
"input": [
"10 131",
"43 10",
"5 2",
"5 8",
"10 178",
"43 19",
"2 2",
"5 1",
"10 43",
"51 19",
"6 2",
"10 69",
"51 27",
"10 2",
"10 81",
"77 27",
"9 2",
"10 105",
"135 27",
"9 4",
"2 105",
"135 47",
"9 1",
"2 65",
"1... |
p03272 AtCoder Beginner Contest 107 - Train | There is an N-car train.
You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
Constraints
* 1 \leq N \leq 100
* 1 \leq i \leq N
Input
Input is given from Standard Input in the following format:
N i
O... | {
"input": [],
"output": []
} | {
"input": [
"1 1",
"4 2",
"15 11"
],
"output": [
"1",
"3",
"5"
]
} | {
"input": [
"2 1",
"2 2",
"15 9",
"4 1",
"2 0",
"14 9",
"12 1",
"14 7",
"9 1",
"28 7",
"52 7",
"-1 0",
"17 7",
"11 7",
"-1 1",
"-4 -1",
"-4 0",
"-4 1",
"-7 0",
"-7 1",
"-8 1",
"-5 1",
"-12 1",
"-8 2",
"-10 2",
"-1... |
p03429 AtCoder Grand Contest 021 - Tiling | Takahashi has an N \times M grid, with N horizontal rows and M vertical columns. Determine if we can place A 1 \times 2 tiles (1 vertical, 2 horizontal) and B 2 \times 1 tiles (2 vertical, 1 horizontal) satisfying the following conditions, and construct one arrangement of the tiles if it is possible:
* All the tiles m... | {
"input": [],
"output": []
} | {
"input": [
"4 5 5 3",
"3 4 4 2",
"7 9 20 20"
],
"output": [
"YES\n<>..^\n^.<>v\nv<>.^\n<><>v",
"YES\n<><>\n^<>^\nv<>v",
"NO"
]
} | {
"input": [
"8 5 5 3",
"3 5 4 2",
"7 9 20 32",
"15 5 5 3",
"3 9 4 2",
"15 5 5 5",
"3 9 4 3",
"15 5 8 5",
"5 9 4 3",
"15 5 8 3",
"5 9 7 3",
"15 6 8 3",
"10 9 7 3",
"15 11 8 3",
"10 6 7 3",
"15 3 8 3",
"13 6 7 3",
"12 3 12 6",
"13 6 13 3",
... |
p03587 Tenka1 Programmer Beginner Contest - Accepted...? | Snuke prepared 6 problems for a upcoming programming contest. For each of those problems, Rng judged whether it can be used in the contest or not.
You are given a string S of length 6. If the i-th character of s is `1`, it means that the i-th problem prepared by Snuke is accepted to be used; `0` means that the problem... | {
"input": [],
"output": []
} | {
"input": [
"001001",
"000000",
"111100"
],
"output": [
"2",
"0",
"4"
]
} | {
"input": [
"001011",
"100000",
"011011",
"100100",
"111011",
"111111",
"101100",
"110100",
"010011",
"100110",
"110000",
"000011",
"100001",
"001100",
"100011",
"110011",
"001101",
"100010",
"011101",
"101010",
"111001",
"011001... |
p03745 AtCoder Grand Contest 013 - Sorted Arrays | You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
Constraints
* 1 \leq N \leq 10^5
* 1 \leq A_i \leq 10^9
* Each A_i ... | {
"input": [],
"output": []
} | {
"input": [
"6\n1 2 3 2 2 1",
"9\n1 2 1 2 1 2 1 2 1",
"7\n1 2 3 2 1 999999999 1000000000"
],
"output": [
"2",
"5",
"3"
]
} | {
"input": [
"6\n1 2 3 2 0 1",
"9\n1 2 1 2 2 2 1 2 1",
"6\n1 2 3 2 0 0",
"9\n0 1 0 -1 2 7 2 -1 0",
"7\n1 2 3 2 1 999999999 1000000100",
"9\n1 2 1 2 2 2 2 2 1",
"7\n1 4 3 2 1 999999999 1000000100",
"6\n0 2 3 2 0 0",
"9\n1 2 0 2 2 2 2 2 1",
"7\n1 4 3 4 1 999999999 1000000100",
... |
p03907 CODE FESTIVAL 2016 Exhibition(Parallel) - Distance Pairs | There is an undirected connected graph with N vertices numbered 1 through N. The lengths of all edges in this graph are 1. It is known that for each i (1≦i≦N), the distance between vertex 1 and vertex i is A_i, and the distance between vertex 2 and vertex i is B_i. Determine whether there exists such a graph. If it exi... | {
"input": [],
"output": []
} | {
"input": [
"3\n0 1\n1 0\n2 2",
"4\n0 1\n1 0\n1 1\n2 1"
],
"output": [
"-1",
"4"
]
} | {
"input": [
"4\n1 1\n1 0\n1 1\n2 1",
"4\n0 1\n1 0\n2 1\n2 1",
"4\n2 1\n1 0\n1 1\n2 1",
"4\n1 1\n1 1\n1 1\n2 1",
"4\n1 2\n1 0\n1 1\n2 1",
"4\n1 2\n1 0\n1 1\n0 1",
"4\n1 2\n1 0\n0 1\n0 1",
"4\n1 2\n1 1\n0 1\n0 1",
"4\n1 2\n1 2\n0 1\n0 1",
"4\n1 2\n1 2\n0 1\n-1 1",
"4\n1 2\n2... |
p00011 Drawing Lots | Let's play Amidakuji.
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
<image>
In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first... | {
"input": [],
"output": []
} | {
"input": [
"5\n4\n2,4\n3,5\n1,2\n3,4"
],
"output": [
"4\n1\n2\n5\n3"
]
} | {
"input": [
"5\n4\n2,4\n3,5\n2,1\n3,4",
"5\n4\n2,4\n4,5\n2,1\n3,4",
"5\n1\n2,4\n4,5\n2,1\n3,4",
"5\n0\n2,4\n4,5\n1,2\n4-3",
"5\n1\n1,4\n5,4\n21,\n,34",
"5\n4\n2,4\n3,5\n1,2\n2,4",
"5\n2\n2,4\n4,5\n2,1\n3,4",
"5\n1\n5,1\n,54\n22-\n,44",
"5\n2\n2,4\n3,5\n2,1\n3,4",
"5\n2\n1,4\n5... |
p00143 Altair and Vega | Zhinü was a child of the Emperor, but he was weaving the machine even if he opened it at the request of his father.
It was a pleasure of the Emperor to wear clothes made of a splendid cloth called Unnishiki woven by Zhinü. Unnishiki has a short lifespan and deteriorates quickly, but there was no problem because the ha... | {
"input": [],
"output": []
} | {
"input": [
"5\n2 5 9 2 8 9 2 11 6 5\n2 5 9 2 8 9 2 11 12 6\n2 5 9 2 8 9 2 11 11 9\n14 1 25 7 17 12 17 9 20 5\n14 1 25 7 17 12 22 13 20 5"
],
"output": [
"OK\nNG\nNG\nNG\nOK"
]
} | {
"input": [
"5\n3 5 9 2 8 9 2 11 6 5\n2 5 9 2 8 9 2 11 12 6\n2 5 9 2 8 9 2 11 11 9\n14 1 25 7 17 12 17 9 20 5\n14 1 25 7 17 12 22 13 20 5",
"5\n3 5 9 2 8 9 0 11 6 5\n3 5 9 2 8 9 2 11 12 6\n2 5 9 4 8 9 2 11 11 9\n14 1 25 7 17 12 24 9 20 5\n14 1 25 7 17 12 22 13 20 5",
"5\n3 5 9 2 8 9 0 11 6 5\n3 5 9 2 8 9... |
p00276 Formation | At Akabe High School, which is a programmer training school, the roles of competition programmers in team battles are divided into the following three types.
C: | Coder | I am familiar with the language and code.
--- | --- | ---
A: | Algorithm | I am good at logical thinking and think about algorithms.
N: | Navigator |... | {
"input": [],
"output": []
} | {
"input": [
"4\n3 0 0\n1 1 1\n9 4 1\n0 1 2"
],
"output": [
"1\n1\n4\n0"
]
} | {
"input": [
"4\n3 0 0\n1 1 1\n9 4 2\n0 1 2",
"4\n2 0 0\n1 1 1\n9 4 2\n0 1 2",
"4\n3 0 1\n1 1 1\n9 4 1\n0 1 2",
"4\n3 0 0\n1 2 1\n0 4 2\n0 1 2",
"4\n0 0 0\n1 2 1\n0 4 2\n0 1 3",
"4\n2 1 0\n2 2 2\n9 8 2\n0 1 3",
"4\n0 1 2\n3 0 2\n9 19 0\n0 2 3",
"4\n0 1 2\n3 0 2\n9 0 0\n0 2 3",
"4\n... |
p00464 Walk | problem
One day, Taro, who lives in JOI town, decided to take a walk as a daily routine to improve his health. In JOI town, where Taro lives, he runs in the east-west direction as shown in the figure (H + 1). The road and the north-south direction (W + 1) run through the road in a grid pattern. Taro's house is at the ... | {
"input": [],
"output": []
} | {
"input": [
"3 4 3\n1 0 1 1\n0 1 0 0\n1 0 1 0\n0 0 0"
],
"output": [
"1 5"
]
} | {
"input": [
"3 4 3\n1 0 1 1\n0 1 0 0\n1 0 1 1\n0 0 0",
"3 4 6\n1 0 1 1\n0 1 0 0\n1 0 1 1\n0 0 0",
"3 4 8\n1 0 1 1\n0 1 0 0\n1 0 1 1\n0 0 0",
"3 4 8\n1 0 1 1\n0 0 0 0\n1 0 1 1\n0 0 0",
"3 4 4\n1 0 1 1\n0 1 0 0\n1 0 1 1\n0 0 0",
"3 4 9\n1 0 1 1\n0 1 0 0\n1 0 1 1\n0 0 0",
"3 4 1\n1 0 1 1\n0 ... |
p00654 Squid Multiplication | Problem H: Squid Multiplication
Squid Eiko loves mathematics. Especially she loves to think about integer. One day, Eiko found a math problem from a website.
"A sequence b ={ai + aj | i < j } is generated from a sequence a ={a0 , ... , an | ai is even if i is 0, otherwise ai is odd}. Given the sequence b , find the s... | {
"input": [],
"output": []
} | {
"input": [
"3\n6 10 14 15 21 35\n2\n30 42 35\n0"
],
"output": [
"2\n3 5 7\n6\n5 7"
]
} | {
"input": [
"3\n6 10 14 15 27 35\n2\n30 42 35\n0",
"3\n6 10 14 15 27 35\n0\n30 42 35\n0",
"3\n6 10 22 15 27 35\n0\n3 56 35\n-1",
"3\n6 10 26 15 27 35\n2\n30 42 35\n0",
"3\n6 10 24 15 27 35\n0\n30 42 8\n0",
"3\n6 10 28 15 31 35\n2\n30 42 35\n0",
"3\n6 10 26 15 27 35\n0\n30 42 10\n0",
"... |
p00799 Pump up Batteries | Bill is a boss of security guards. He has pride in that his men put on wearable computers on their duty. At the same time, it is his headache that capacities of commercially available batteries are far too small to support those computers all day long. His men come back to the office to charge up their batteries and sp... | {
"input": [],
"output": []
} | {
"input": [
"3 25\n3 1 2 1 4 1 0\n1 1 0\n2 1 3 2 0\n\n4 1000\n80 20 80 20 80 20 80 20 0\n80\n20\n0\n80 20 90\n10 80\n20\n0\n90 10\n0\n\n0 0"
],
"output": [
"10\n110"
]
} | {
"input": [
"3 25\n3 1 2 1 4 1 0\n1 1 0\n2 1 3 2 0\n\n4 1000\n80 20 80 20 80 20 80 20 0\n80\n20\n0\n80 20 90\n10 80\n20\n0\n90 9\n0\n\n0 0",
"3 25\n3 1 2 1 4 1 0\n1 1 0\n2 1 3 2 0\n\n4 1000\n80 20 80 40 80 20 80 20 0\n80\n20\n0\n80 20 90\n10 80\n20\n0\n90 9\n0\n\n0 0",
"3 25\n3 1 2 1 4 1 0\n1 1 0\n2 1 3 ... |
p00930 Flipping Parentheses | Example
Input
6 3
((()))
4
3
1
Output
2
2
1 | {
"input": [],
"output": []
} | {
"input": [
"6 3\n((()))\n4\n3\n1"
],
"output": [
"2\n2\n1"
]
} | {
"input": [
"6 2\n((()))\n4\n3\n1",
"6 3\n(((())\n4\n3\n1",
"6 3\n(((())\n4\n3\n2",
"4 3\n(((())\n4\n3\n4",
"6 3\n((()))\n4\n3\n2",
"4 1\n(((())\n4\n3\n2",
"4 3\n(((())\n4\n2\n4",
"6 3\n((()))\n4\n5\n2",
"6 3\n((()))\n4\n5\n4",
"6 2\n((()))\n1\n3\n1",
"4 3\n(((())\n4\n4\n2... |
p01063 Rubik Dungeon | Problem
You've come to an n x n x n cubic Rubik's Cube dungeon.
You are currently in the room (x1, y1, z1).
The target treasure is in the room (x2, y2, z2).
You can move to adjacent rooms in front, back, left, right, up and down in unit time.
<image>
Each room has 6 buttons, and by pressing each button, you can per... | {
"input": [],
"output": []
} | {
"input": [
"3\n0 0 0\n0 0 2",
"3\n0 0 0\n1 2 2"
],
"output": [
"2",
"3"
]
} | {
"input": [
"3\n0 0 0\n0 0 0",
"3\n0 0 1\n1 2 2",
"3\n0 0 0\n1 0 0",
"3\n0 0 -1\n1 0 0",
"3\n1 0 1\n1 2 -1",
"3\n0 1 2\n4 2 -1",
"3\n2 1 0\n2 5 2",
"3\n2 1 0\n2 7 2",
"3\n1 1 1\n5 6 1",
"3\n2 1 0\n2 8 2",
"3\n1 1 1\n5 4 4",
"3\n1 1 0\n5 7 -1",
"3\n2 1 1\n2 12 2",
... |
p01196 The Phantom | Mr. Hoge is in trouble. He just bought a new mansion, but it’s haunted by a phantom. He asked a famous conjurer Dr. Huga to get rid of the phantom. Dr. Huga went to see the mansion, and found that the phantom is scared by its own mirror images. Dr. Huga set two flat mirrors in order to get rid of the phantom.
As you m... | {
"input": [],
"output": []
} | {
"input": [
"4 4\n3 3 5 3\n3 5 5 6\n4 4\n3 3 5 3\n3 5 5 5\n0 0"
],
"output": [
"4\nTOO MANY"
]
} | {
"input": [
"4 4\n3 3 5 3\n3 5 5 6\n4 4\n3 3 5 3\n3 5 8 5\n0 0",
"4 4\n3 6 5 3\n3 5 5 6\n4 4\n3 3 5 3\n3 5 8 5\n0 0",
"4 4\n3 6 5 3\n3 5 5 6\n4 2\n3 3 5 3\n3 5 8 5\n0 0",
"4 5\n3 6 5 3\n3 5 5 6\n4 2\n5 3 5 3\n3 5 8 5\n0 0",
"4 4\n3 3 5 3\n3 9 5 6\n4 4\n3 3 5 3\n3 5 5 5\n0 0",
"4 5\n3 6 2 3\n3... |
p01333 Summer of KMC | Description
KMC sells CDs every year at a coterie spot sale called Comic Market. F was supposed to sell CDs at the comic market, but due to the popularity of F, the KMC sales floor was flooded with people, and the calculation of change could not keep up. So F decided to write a program that would output the change as ... | {
"input": [],
"output": []
} | {
"input": [
"500 1000\n100 10000\n400 700\n600 5000\n10000 10000\n0 0"
],
"output": [
"0 1 0\n4 1 9\n3 0 0\n4 0 4\n0 0 0"
]
} | {
"input": [
"500 1001\n100 10000\n400 700\n600 5000\n10000 10000\n0 0",
"500 1001\n100 10100\n400 700\n600 5000\n10000 10000\n0 0",
"500 1001\n100 10100\n400 700\n429 5000\n10000 10000\n0 0",
"500 1001\n100 10100\n400 700\n429 5000\n10000 11001\n0 0",
"500 1001\n100 10100\n454 700\n429 5000\n1000... |
p01500 Rabbit Jumping | Example
Input
6 3 1.0
1 2 3
4 5 6
0 0
1 0
2 0
0 1
1 1
2 1
Output
3 | {
"input": [],
"output": []
} | {
"input": [
"6 3 1.0\n1 2 3\n4 5 6\n0 0\n1 0\n2 0\n0 1\n1 1\n2 1"
],
"output": [
"3"
]
} | {
"input": [],
"output": []
} |
p01671 Minimum Spanning Tree | E - Minimum Spanning Tree
Problem Statement
You are given an undirected weighted graph G with n nodes and m edges. Each edge is numbered from 1 to m.
Let G_i be an graph that is made by erasing i-th edge from G. Your task is to compute the cost of minimum spanning tree in G_i for each i.
Input
The dataset is forma... | {
"input": [],
"output": []
} | {
"input": [
"4 6\n1 2 2\n1 3 6\n1 4 3\n2 3 1\n2 4 4\n3 4 5"
],
"output": [
"8\n6\n7\n10\n6\n6"
]
} | {
"input": [
"4 6\n1 2 2\n1 3 6\n1 4 3\n2 3 1\n2 4 3\n3 4 5",
"4 6\n1 2 2\n1 3 6\n1 4 3\n2 3 1\n2 4 3\n3 4 9",
"4 6\n1 2 2\n1 3 6\n1 4 3\n2 3 2\n2 4 3\n3 4 9",
"4 6\n1 2 2\n1 3 6\n1 4 3\n2 3 1\n2 4 3\n3 4 1",
"4 6\n1 2 3\n1 3 6\n1 4 3\n2 3 1\n2 4 3\n3 4 5",
"4 6\n1 2 2\n1 3 10\n1 4 3\n2 3 1\n2... |
p01813 An Equation in a Mine | Tunnel formula
One day while exploring an abandoned mine, you found a long formula S written in the mine. If you like large numbers, you decide to take out the choke and add `(` or `)` so that the result of the formula calculation is as large as possible. If it has to be a mathematical formula even after adding it, ho... | {
"input": [],
"output": []
} | {
"input": [
"1-(2+3-4+5)"
],
"output": [
"5"
]
} | {
"input": [
"0-(2+3-4+5)",
"0-(2+3-3+5)",
"2-(2+3-4+5)",
"1-(3+2-4+5)",
"2-(2-3+4+5)",
"0-(3+4-4+5)",
"3+(2-4-4+5)",
"2-(2+2-4+5)",
"2+(2-4-4+5)",
"2-(2+2-5+5)",
"2-(2-3+4+6)",
"3+(2-4-4+6)",
"4-(2+5-0+2)",
"2-(2-3+4+7)",
"0-(4+5-1+6)",
"0-(4+5-1+5)",
... |
p01948 Janken Master | You are supposed to play the rock-paper-scissors game. There are $N$ players including you.
This game consists of multiple rounds. While the rounds go, the number of remaining players decreases. In each round, each remaining player will select an arbitrary shape independently. People who show rocks win if all of the o... | {
"input": [],
"output": []
} | {
"input": [
"2\n2\n1 40 40 20",
"4\n4\n1 34 33 33\n2 33 34 33\n3 33 33 34",
"2\n1\n2 50 50 0",
"3\n2\n1 50 0 50\n3 0 0 100",
"3\n2\n3 40 40 20\n1 30 10 60"
],
"output": [
"0.8",
"0.6591870816",
"0.5",
"1",
"0.27"
]
} | {
"input": [
"2\n2\n0 40 40 20",
"2\n1\n2 50 50 1",
"3\n2\n3 40 40 8\n1 30 10 60",
"2\n1\n2 94 50 1",
"3\n2\n1 50 0 50\n3 0 0 000",
"3\n4\n3 40 40 20\n1 30 10 60",
"2\n1\n2 82 50 1",
"3\n2\n3 40 64 8\n1 30 10 60",
"2\n1\n2 115 38 1",
"3\n2\n3 40 40 20\n0 30 10 60",
"2\n1\n2... |
p02097 Horizontal-Vertical Permutation | J: Horizontal-Vertical Permutation
Problem Statement
You are given a positive integer N. Your task is to determine if there exists a square matrix A whose dimension is N that satisfies the following conditions and provide an example of such matrices if it exists. A_{i, j} denotes the element of matrix A at the i-th r... | {
"input": [],
"output": []
} | {
"input": [
"4"
],
"output": [
"Yes\n2 6 3 7\n4 5 2 1\n1 7 5 6\n5 3 4 2"
]
} | {
"input": [
"3",
"2",
"0",
"1",
"10",
"30",
"22",
"6",
"12",
"24",
"32",
"8",
"14",
"16",
"26",
"18",
"28",
"34",
"38",
"64",
"136",
"50",
"68",
"110",
"100",
"20",
"52",
"42",
"36",
"44",
"48"... |
p02235 Longest Common Subsequence | For given two sequences $X$ and $Y$, a sequence $Z$ is a common subsequence of $X$ and $Y$ if $Z$ is a subsequence of both $X$ and $Y$. For example, if $X = \\{a,b,c,b,d,a,b\\}$ and $Y = \\{b,d,c,a,b,a\\}$, the sequence $\\{b,c,a\\}$ is a common subsequence of both $X$ and $Y$. On the other hand, the sequence $\\{b,c,a... | {
"input": [],
"output": []
} | {
"input": [
"3\nabcbdab\nbdcaba\nabc\nabc\nabc\nbc"
],
"output": [
"4\n3\n2"
]
} | {
"input": [
"3\nabcbdab\nbdcaba\nabc\nabc\nacb\nbc",
"3\nabcbdab\nbdcaba\nabc\nabc\nbcb\nbc",
"3\nabcbdab\nbdcaba\n`bc\nabc\nbcb\nbc",
"3\nbadbcba\nbdcaba\n`bc\nabc\nbcb\nbc",
"3\nbadbdba\nbdcaba\n`bc\nabc\nbcb\ncc",
"3\nbadbdba\nbdcaba\n`bc\nabd\nbcb\ncc",
"3\nbadbdba\nabacdb\n_cb\ndba\n... |
p02381 Standard Deviation | You have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn.
The variance α2 is defined by
α2 = (∑ni=1(si - m)2)/n
where m is an average of si. The standard deviation of the scores is the square root of their variance.
Constraints
* n ≤ 1000
* 0 ≤ si ≤ 100
Inpu... | {
"input": [],
"output": []
} | {
"input": [
"5\n70 80 100 90 20\n3\n80 80 80\n0"
],
"output": [
"27.85677655\n0.00000000"
]
} | {
"input": [
"5\n70 80 100 107 20\n3\n80 80 80\n0",
"5\n70 80 100 107 20\n0\n80 80 80\n0",
"5\n70 80 101 107 20\n0\n80 80 80\n0",
"5\n70 80 101 123 20\n0\n80 80 80\n0",
"5\n70 80 111 123 20\n0\n80 80 80\n0",
"5\n70 80 100 90 20\n3\n74 80 80\n0",
"5\n70 80 100 99 20\n3\n80 80 80\n0",
"5... |
amr15d | Bhallaladeva was an evil king who ruled the kingdom of Maahishmati. He wanted to erect a 100ft golden statue of himself and he looted gold from several places for this. He even looted his own people, by using the following unfair strategy:
There are N houses in Maahishmati, and the i^th house has Ai gold plates. Each g... | {
"input": [],
"output": []
} | {
"input": [
"4\n3 2 1 4\n2\n0\n2"
],
"output": [
"10\n3"
]
} | {
"input": [
"4\n3 2 1 0\n2\n0\n2",
"4\n3 2 1 0\n2\n1\n2",
"4\n3 2 1 0\n1\n1\n2",
"4\n5 2 1 0\n2\n1\n3",
"4\n5 0 1 0\n2\n1\n3",
"4\n3 0 1 -1\n2\n1\n3",
"4\n3 -1 1 -1\n2\n1\n3",
"4\n1 2 1 4\n2\n0\n2",
"4\n3 2 0 0\n2\n0\n2",
"4\n5 2 2 0\n2\n1\n3",
"4\n2 2 1 4\n2\n0\n2",
"... |
chgift1 | Chef likes cooking. But more than that, he likes to give gifts. And now he wants to give his girlfriend an unforgettable gift. But unfortunately he forgot the password to the safe where the money he saved for the gift is kept.
But he knows how to hack the safe. To do this, you need to correctly answer questions asked ... | {
"input": [],
"output": []
} | {
"input": [
"2\n3\n1 2 3\n1\n9"
],
"output": [
"-4\n9"
]
} | {
"input": [
"2\n3\n2 2 3\n1\n9",
"2\n3\n2 1 3\n1\n9",
"2\n3\n3 1 3\n1\n9",
"2\n3\n3 4 3\n1\n9",
"2\n3\n1 2 6\n1\n9",
"2\n3\n3 1 3\n1\n6",
"2\n3\n3 2 3\n1\n13",
"2\n3\n3 4 3\n1\n4",
"2\n3\n0 2 6\n1\n9",
"2\n3\n2 1 3\n0\n11",
"2\n3\n3 2 4\n1\n13",
"2\n3\n4 1 3\n0\n11",
... |
encode01 | Arunava has learnt to find the sum of first N natural numbers using the expression N(N+1)/2.But now Kartik Sir has asked him to find the sum of floor(N/2) for first N natural numbers where floor(X) is the greatest integer less than or equal to a given real number X.Arunava has not memorized any formula for this. So can... | {
"input": [],
"output": []
} | {
"input": [
"5\n1\n2\n3\n4\n5"
],
"output": [
"0\n1\n2\n4\n6\n"
]
} | {
"input": [
"5\n1\n4\n3\n4\n5",
"5\n1\n4\n3\n8\n5",
"5\n1\n2\n3\n4\n9",
"5\n1\n2\n2\n4\n9",
"5\n2\n2\n2\n4\n9",
"5\n2\n1\n2\n4\n9",
"5\n2\n1\n2\n6\n9",
"5\n2\n2\n2\n6\n9",
"5\n2\n3\n2\n6\n9",
"5\n1\n3\n2\n6\n9",
"5\n1\n5\n2\n6\n9",
"5\n1\n5\n2\n7\n9",
"5\n1\n9\n2\n... |
kjcc01 | Chef wants you to write a calculator program for carrying out some simple mathematical operations. Chef calls the program Calculator Plus Plus.
Input
First line contains an operation in the form : a operator b
Output
Output in a single line the result of the mathematical operation. Print "Invalid Operator" if inp... | {
"input": [],
"output": []
} | {
"input": [
"1 % 1",
"10 + 30"
],
"output": [
"Invalid Operator\n",
"40\n"
]
} | {
"input": [
"2 % 1",
"10 + 18",
"16 + 18",
"16 + 29",
"23 + 29",
"23 * 29",
"22 * 29",
"22 * 5",
"22 * 8",
"0 * 3",
"0 + 3",
"-1 * 3",
"-1 * 4",
"-1 * 6",
"-1 * 2",
"-1 + 3",
"-1 * 5",
"1 * 5",
"-1 * 30",
"-1 * 9",
"-1 * 32",
"-1... |
opc1604 | Raavan abducted sita in the past, at that time when Ram went to save her wife , he was posed a question by Raavan in binomial theorem :
given N Ram has to find the number of odd coefficients in the expansion of (1+x)^n . As the number given by Raavan was huge, Ram was unable to calculate at that time , so he was force... | {
"input": [],
"output": []
} | {
"input": [
"3"
],
"output": [
"4"
]
} | {
"input": [],
"output": []
} |
spoon | Chef recently saw the movie Matrix. He loved the movie overall but he didn't agree with some things in it. Particularly he didn't agree with the bald boy when he declared - There is no spoon. Being a chef, he understands the importance of the spoon and realizes that the universe can't survive without it. Furthermore, h... | {
"input": [],
"output": []
} | {
"input": [
"3\n3 6\nabDefb\nbSpoon\nNIKHil\n6 6\naaaaaa\nssssss\nxuisdP\noooooo\nioowoo\nbdylan\n6 5\nbdfhj\ncacac\nopqrs\nddddd\nindia\nyucky"
],
"output": [
"There is a spoon!\nThere is a spoon!\nThere is indeed no spoon!\n"
]
} | {
"input": [
"3\n3 6\nabDefb\nbSpoon\nNIKHil\n6 6\naaaaaa\nssssss\nxuisdP\noooooo\nioowoo\nbdylan\n6 5\njhfdb\ncacac\nopqrs\nddddd\nindia\nyucky",
"3\n3 6\nabDefb\nbSpoon\nNIKHil\n6 6\naaaaaa\nsssssr\nxuisdP\noooooo\nioowoo\nbdylan\n6 5\njhfdb\ncacac\nopqrs\nddddd\nindia\nyucky",
"3\n3 6\nbfeDba\nbTpoon\n... |
1303_B. National Project | Your company was appointed to lay new asphalt on the highway of length n. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.
Skipping the repair is necessary because of the climate. The climate in your region is periodical: there are ... | {
"input": [],
"output": []
} | {
"input": [
"3\n5 1 1\n8 10 10\n1000000 1 1000000\n"
],
"output": [
"5\n8\n499999500000\n"
]
} | {
"input": [
"3\n5 1 1\n8 6 10\n1000000 1 1000000\n",
"3\n5 1 1\n8 2 10\n1000000 1 1000000\n",
"3\n5 1 1\n9 2 10\n1000000 1 1000000\n",
"3\n5 1 1\n9 2 10\n1000000 1 1000100\n",
"3\n10 1 1\n9 2 10\n1000000 1 1000100\n",
"3\n10 1 1\n6 2 10\n1000000 1 1000100\n",
"3\n5 1 1\n8 10 10\n1000000 1... |
1346_E. Magic Tricks | Masha is going to participate in a talent show conducted by the university she studies at. She wants to impress the audience with lots of different magic tricks!
For one of her tricks, she uses n sponge balls, one of which is a special one. First, she arranges the balls in a row in such a way that the special ball is ... | {
"input": [],
"output": []
} | {
"input": [
"4 5 1\n3 4\n2 1\n4 1\n3 1\n3 1\n",
"5 7 4\n3 2\n3 2\n4 2\n3 4\n4 1\n3 2\n5 2\n",
"7 15 5\n5 3\n4 2\n6 1\n2 4\n1 6\n3 7\n5 6\n4 2\n6 4\n2 6\n6 3\n6 3\n7 6\n2 6\n7 2\n"
],
"output": [
"\n2 0 3 1 \n",
"\n2 2 0 3 1 \n",
"\n-1 1 1 1 2 1 0 \n"
]
} | {
"input": [],
"output": []
} |
1389_E. Calendar Ambiguity | Berland year consists of m months with d days each. Months are numbered from 1 to m. Berland week consists of w days. The first day of the year is also the first day of the week. Note that the last week of the year might be shorter than w days.
A pair (x, y) such that x < y is ambiguous if day x of month y is the same... | {
"input": [],
"output": []
} | {
"input": [
"5\n6 7 4\n10 7 12\n12 30 7\n1 1 1\n3247834 10298779 625324\n"
],
"output": [
"6\n9\n5\n0\n116461800\n"
]
} | {
"input": [
"5\n6 7 4\n10 7 12\n12 30 6\n1 1 1\n3247834 10298779 625324\n",
"5\n6 7 4\n10 7 12\n12 30 7\n1 1 1\n3247834 18794097 625324\n",
"5\n6 7 1\n10 7 12\n12 30 6\n1 1 1\n3247834 10298779 625324\n",
"5\n6 7 4\n10 7 12\n12 17 4\n1 1 1\n3247834 18794097 625324\n",
"5\n6 7 2\n10 2 12\n12 30 6\n... |
1528_C. Trees of Tranquillity | Soroush and Keshi each have a labeled and rooted tree on n vertices. Both of their trees are rooted from vertex 1.
Soroush and Keshi used to be at war. After endless decades of fighting, they finally became allies to prepare a Codeforces round. To celebrate this fortunate event, they decided to make a memorial graph o... | {
"input": [],
"output": []
} | {
"input": [
"4\n4\n1 2 3\n1 2 3\n5\n1 2 3 4\n1 1 1 1\n6\n1 1 1 1 2\n1 2 1 2 2\n7\n1 1 3 4 4 5\n1 2 1 4 2 5\n"
],
"output": [
"\n1\n4\n1\n3\n"
]
} | {
"input": [
"4\n4\n1 2 3\n1 2 3\n5\n1 2 3 4\n1 1 1 1\n6\n1 2 1 1 2\n1 2 1 2 2\n7\n1 1 3 4 4 5\n1 2 1 4 2 5\n",
"4\n4\n1 2 3\n1 2 3\n5\n1 2 3 4\n1 1 1 1\n6\n1 2 1 1 2\n1 2 1 2 2\n7\n1 1 3 4 4 5\n1 2 1 4 4 5\n",
"4\n4\n1 2 3\n1 2 3\n5\n1 4 3 4\n1 1 1 1\n6\n1 1 1 1 2\n1 2 1 2 2\n7\n1 1 3 4 4 5\n1 2 1 4 2 5\... |
a-new-maximizing-problem-1 | This time Panda is doing great. He is good with mathematical problems. His teacher decided to puzzle him with summation problems.
Consider the following definitions, assuming 1-based indexing:
In the computation of B, one can choose +1 or -1 to multiply, for each arr[i].
Also, you are allowed to re-order the elem... | {
"input": [],
"output": []
} | {
"input": [
"1\n4\n1 2 3 4\n\nSAMPLE"
],
"output": [
"40\n"
]
} | {
"input": [
"1\n4\n1 4 3 4\n\nSAMPLE",
"1\n4\n1 2 3 0\n\nELAMPS",
"1\n4\n1 2 0 0\n\nSPNALE",
"1\n4\n1 0 0 0\n\nSPNALE",
"1\n4\n1 0 1 0\n\nSPNALE",
"1\n4\n1 2 1 4\n\nSAMPLE",
"1\n4\n1 4 4 4\n\nSAMPLE",
"1\n4\n1 2 3 4\n\nSPMALE",
"1\n4\n1 2 3 1\n\nELAMPS",
"1\n4\n1 2 1 0\n\nSPMA... |
birthday-party-6 | Today is Sid’s birthday and he is very excited about this as he is giving a special birthday party to all his friends. In this party they are going to play a game for which Sid have to arrange all his friends in a row such that no two boys should be present which are adjacent to each other. There are total M girls and ... | {
"input": [],
"output": []
} | {
"input": [
"1\n3 2\n\nSAMPLE"
],
"output": [
"72\n"
]
} | {
"input": [
"1\n2 2\n\nSAMPLE",
"1\n2 4\n\nSAMPLE",
"1\n3 1\n\nSAMPLE",
"1\n2 1\n\nSAMPLE",
"1\n4 5\n\nUAMPLE",
"1\n4 1\n\nSAMPLE",
"1\n1 1\n\nSAMPLE",
"1\n6 1\n\nSAMQLE",
"1\n3 2\n\nUAMPLF",
"1\n10 1\n\nSAMQLE",
"1\n9 1\n\nSAMQLE",
"1\n5 2\n\nUBMPLF",
"1\n7 2\n\nU... |
p1-15 | Here is your task. You are given two strings and you have to merge/compress them in single string with minimum length such that both strings can be found (one at a time) by breaking that merged string into two parts.
NOTE:
String s2 should follow string s1.
INPUT
First line contain number of test cases T. Each test ca... | {
"input": [],
"output": []
} | {
"input": [
"2\nroadshow\nshowman\ntarun\ntarunnum\n\nSAMPLE"
],
"output": [
"roadshowman\ntarunnum\n"
]
} | {
"input": [
"2\nroadshow\nhsowman\ntarun\ntarunnum\n\nSAMPLE",
"2\nwoadshor\nhsowman\ntarun\ntarunnum\n\nSAMPLE",
"2\nwoadshor\nisowman\ntarun\ntarunnum\n\nSAMPLE",
"2\nwoadshor\nisowman\nnurat\ntarunnum\n\nSAMPLE",
"2\nwoadshor\nisoxman\nnurat\ntarunnum\n\nSAMPLE",
"2\nwoadshor\nnamxosi\nnur... |
remains | You've recently stumbled upon the remains of a ruined ancient city. Luckily, you've studied enough ancient architecture to know how the buildings were laid out.
The city had n buildings in a row. Unfortunately, all but the first two buildings have deteriorated. All you can see in the city are the heights of the first ... | {
"input": [],
"output": []
} | {
"input": [
"3\n10 7 5\n50 100 50\n1000000000 999999999 1000000000\n\nSAMPLE"
],
"output": [
"25\n1750\n444444445222222222"
]
} | {
"input": [],
"output": []
} |
solvemefirst | Let's Start Simple Write a programe to Sum of two Decimal Value.
SAMPLE INPUT
12.25
3.60
SAMPLE OUTPUT
15.85 | {
"input": [],
"output": []
} | {
"input": [
"12.25\n3.60\n\nSAMPLE"
],
"output": [
"15.85\n"
]
} | {
"input": [
"12.25\n3.60\n\nSAMPLD",
"12.559993105319085\n3.60\n\nASMPME",
"12.530004282831765\n3.60\n\nCOSMAL",
"12.25\n3.60\n\nDLPMAS",
"12.25\n3.60\n\nSAMPKD",
"12.25\n3.60\n\nDKPMAS",
"12.25\n3.60\n\nEKPMAS",
"12.25\n3.60\n\nLAMPSD",
"12.25\n3.60\n\nDLOMAS",
"12.25\n3.60\n... |
p02564 AtCoder Library Practice Contest - SCC | You are given a directed graph with N vertices and M edges, not necessarily simple. The i-th edge is oriented from the vertex a_i to the vertex b_i. Divide this graph into strongly connected components and print them in their topological order.
Constraints
* 1 \leq N \leq 500,000
* 1 \leq M \leq 500,000
* 0 \leq a_i,... | {
"input": [],
"output": []
} | {
"input": [
"6 7\n1 4\n5 2\n3 0\n5 5\n4 1\n0 3\n4 2"
],
"output": [
"4\n1 5\n2 4 1\n1 2\n2 3 0"
]
} | {
"input": [
"6 7\n0 4\n5 2\n3 0\n5 5\n4 1\n0 3\n4 2",
"6 7\n1 4\n5 2\n5 0\n5 5\n4 1\n0 3\n4 2",
"6 7\n0 4\n5 2\n3 0\n5 5\n0 1\n0 3\n4 2",
"6 5\n0 4\n5 2\n3 0\n5 5\n0 1\n0 3\n4 2",
"6 7\n1 5\n5 2\n3 0\n5 5\n4 1\n0 3\n4 2",
"6 7\n0 4\n5 2\n5 0\n5 5\n4 1\n0 3\n4 2",
"6 7\n1 1\n5 2\n5 0\n5 5\... |
p02695 AtCoder Beginner Contest 165 - Many Requirements | Given are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).
Consider a sequence A satisfying the following conditions:
* A is a sequence of N positive integers.
* 1 \leq A_1 \leq A_2 \le \cdots \leq A_N \leq M.
Let us define a score of this sequence as follows:
* The score is the ... | {
"input": [],
"output": []
} | {
"input": [
"3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10",
"10 10 1\n1 10 9 1",
"4 6 10\n2 4 1 86568\n1 4 0 90629\n2 3 0 90310\n3 4 1 29211\n3 4 3 78537\n3 4 2 8580\n1 2 1 96263\n1 4 2 2156\n1 2 0 94325\n1 4 3 94328"
],
"output": [
"110",
"1",
"357500"
]
} | {
"input": [
"10 10 1\n1 10 12 1",
"4 6 10\n2 4 1 86568\n1 4 0 90629\n2 3 0 90310\n3 4 1 29211\n3 4 1 78537\n3 4 2 8580\n1 2 1 96263\n1 4 2 2156\n1 2 0 94325\n1 4 3 94328",
"4 6 10\n2 4 1 86568\n1 4 0 90629\n2 3 0 90310\n3 4 1 29211\n3 4 1 114896\n3 4 2 8580\n1 2 1 96263\n1 4 2 2156\n1 3 0 94325\n1 4 3 94... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.