name stringlengths 2 112 | description stringlengths 29 13k | private_tests dict | public_tests dict | generated_tests dict |
|---|---|---|---|---|
abacus05 | Geek Sundaram is extremely anxious. He is in a hectic schedule. He has to study for his assessment the next day, watch FRIENDS tv show (in spite of watching every episode more than 5 times.. :P ), prepare questions for the programming contest and also complete his projects. So his friends try to calm him down by advisi... | {
"input": [],
"output": []
} | {
"input": [
"2\n10 20 30 40 500\n1 2 3 4 5"
],
"output": [
"YES\nNO"
]
} | {
"input": [
"2\n10 20 30 40 500\n1 2 0 4 5",
"2\n18 48 35 40 505\n1 0 -1 4 7",
"2\n16 37 1 29 55\n1 -1 -4 4 7",
"2\n8 1 0 -1 4\n-1 -1 1 2 0",
"2\n10 30 30 40 500\n1 2 0 4 5",
"2\n10 30 35 40 500\n1 2 0 4 5",
"2\n10 30 35 40 500\n1 4 0 4 5",
"2\n10 42 35 40 500\n1 4 0 4 5",
"2\n10 ... |
cheflcm | Chef wants to hire a new assistant. He published an advertisement regarding that in a newspaper. After seeing the advertisement, many candidates have applied for the job. Now chef wants to shortlist people for the interviews, so he gave all of them one problem which they must solve in order to get shortlisted.
The pro... | {
"input": [],
"output": []
} | {
"input": [
"2\n1\n2"
],
"output": [
"1\n3\n"
]
} | {
"input": [
"2\n1\n3",
"2\n2\n3",
"2\n2\n5",
"2\n2\n2",
"2\n2\n1",
"2\n4\n5",
"2\n4\n1",
"2\n4\n8",
"2\n4\n2",
"2\n4\n6",
"2\n8\n2",
"2\n2\n6",
"2\n15\n2",
"2\n1\n5",
"2\n15\n1",
"2\n11\n1",
"2\n21\n1",
"2\n30\n1",
"2\n30\n2",
"2\n1\n4",... |
dishown | This summer, there is a worldwide competition being held in Chef Town and some of the best chefs of the world are participating. The rules of this competition are quite simple.
Each participant needs to bring his or her best dish. The judges will initially assign a score to each of the dishes. Now, several rounds wil... | {
"input": [],
"output": []
} | {
"input": [
"1\n2\n1 2\n2\n0 1 2\n1 1"
],
"output": [
"2\n"
]
} | {
"input": [
"1\n2\n1 3\n2\n0 1 2\n1 1",
"1\n2\n1 1\n2\n0 1 2\n1 1",
"1\n2\n1 3\n2\n0 1 1\n1 1",
"1\n2\n0 1\n2\n0 2 2\n1 0",
"1\n4\n0 1\n2\n0 2 2\n1 0",
"1\n2\n0 1\n1\n0 1 1\n1 0",
"1\n3\n0 1\n2\n0 1 2\n1 0",
"1\n6\n0 1\n2\n0 1 2\n1 0",
"1\n4\n0 1\n2\n0 1 2\n1 0",
"1\n3\n0 1\n2... |
intest | The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two positive integ... | {
"input": [],
"output": []
} | {
"input": [
"7 3\n1\n51\n966369\n7\n9\n999996\n11"
],
"output": [
"4\n"
]
} | {
"input": [
"7 3\n1\n34\n966369\n7\n9\n999996\n11",
"7 3\n1\n34\n966369\n7\n9\n40177\n11",
"7 3\n1\n62\n334284\n16\n7\n60700\n7",
"6 3\n1\n62\n201449\n16\n7\n60700\n7",
"7 2\n1\n62\n334284\n16\n12\n40177\n12",
"7 1\n1\n62\n334284\n26\n12\n40177\n7",
"7 3\n1\n62\n334284\n18\n12\n13002\n7",... |
nita02 | At the function of Republic day at NIT Agartala the warden of hostel has to visit the ground and
check the arrangement of the chairs for guests.
In the ground of NIT Agartala all the chairs are arranged in N rows and M columns.
Warden has to check that in each row all the chairs must have same color and adjacent rows ... | {
"input": [],
"output": []
} | {
"input": [
"5 6\n0 0 0 0 1 0\n1 1 1 1 1 1\n1 1 1 1 1 1\n2 2 2 2 2 2\n3 3 3 3 3 3",
"5 6\n0 0 0 0 0 0\n1 1 1 1 1 1\n2 2 2 2 2 2\n1 1 1 1 1 1\n3 3 3 3 3 3"
],
"output": [
"NO",
"YES"
]
} | {
"input": [],
"output": []
} |
seagm2 | Sereja is playing a game called Winner Eats Sandwich with his friends. There are N persons in total, including Sereja. Sereja is allotted the number 1, while his friends are allotted numbers from 2 to N. A set of this game consists of M parts. Probability that a player numbered i wins part j of any set is p[i][j]. Sere... | {
"input": [],
"output": []
} | {
"input": [
"2\n2 2\n1.0000 1.0000\n0.0000 0.0000\n2 3\n0.5000 0.5000 0.5000\n0.5000 0.5000 0.5000"
],
"output": [
"1.000000\n0.500000\n"
]
} | {
"input": [
"2\n2 2\n1.0000 1.0000\n0.0000 0.0000\n2 3\n1.2649803683768097 0.5000 0.5000\n0.5000 0.5000 0.5000",
"2\n2 2\n1.0000 1.7642945663583927\n0.0000 0.0000\n2 3\n0.5000 0.5000 0.5000\n0.5000 0.5000 0.5000",
"2\n2 2\n1.0000 1.7642945663583927\n0.0000 0.0000\n2 3\n1.1663487372862706 0.5000 0.5000\n0... |
1300_B. Assigning to Classes | Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th student has... | {
"input": [],
"output": []
} | {
"input": [
"3\n1\n1 1\n3\n6 5 4 1 2 3\n5\n13 4 20 13 2 5 8 3 17 16\n"
],
"output": [
"0\n1\n5\n"
]
} | {
"input": [
"3\n1\n1 1\n3\n6 5 4 1 2 3\n5\n13 4 7 13 2 5 8 3 17 16\n",
"3\n1\n1 1\n3\n6 5 4 1 2 3\n5\n13 4 7 13 2 5 10 3 17 16\n",
"3\n1\n1 1\n3\n6 5 4 1 2 3\n5\n13 4 7 22 2 5 1 3 16 16\n",
"3\n1\n1 1\n3\n6 5 4 1 2 3\n5\n13 4 10 22 2 5 10 3 16 16\n",
"3\n1\n1 2\n3\n6 5 4 1 2 3\n5\n13 4 7 13 2 5 8... |
1324_C. Frog Jumps | There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to the left. ... | {
"input": [],
"output": []
} | {
"input": [
"6\nLRLRRLL\nL\nLLR\nRRRR\nLLLLLL\nR\n"
],
"output": [
"3\n2\n3\n1\n7\n1\n"
]
} | {
"input": [
"6\nRRLRLLL\nL\nLLR\nRRRR\nLLLLLL\nR\n",
"6\nMRLRRLL\nL\nLLR\nRRRR\nLLLLLL\nR\n",
"6\nLLLRLRR\nL\nLRL\nRRRR\nLLLLLL\nR\n",
"6\nLRLRLRL\nL\nLLR\nRRRR\nLLLLLL\nR\n",
"6\nLLLLRRR\nL\nLRL\nRRRR\nLLLLLL\nR\n",
"6\nRLLLLRQ\nL\nLLR\nRRRR\nLLLLLL\nR\n",
"6\nLRLRRLL\nL\nLRL\nRRRR\nLLLL... |
1385_C. Make It Good | You are given an array a consisting of n integers. You have to find the length of the smallest (shortest) prefix of elements you need to erase from a to make it a good array. Recall that the prefix of the array a=[a_1, a_2, ..., a_n] is a subarray consisting several first elements: the prefix of the array a of length k... | {
"input": [],
"output": []
} | {
"input": [
"5\n4\n1 2 3 4\n7\n4 3 3 8 4 5 2\n3\n1 1 1\n7\n1 3 1 4 5 3 2\n5\n5 4 3 2 3\n"
],
"output": [
"0\n4\n0\n2\n3\n"
]
} | {
"input": [
"5\n4\n1 2 3 4\n7\n4 3 3 8 4 5 2\n3\n1 1 1\n7\n1 3 1 7 5 3 2\n5\n5 4 3 2 3\n",
"5\n4\n1 2 3 4\n7\n4 3 3 8 4 5 2\n3\n1 1 1\n7\n1 3 1 0 5 3 2\n5\n5 4 3 2 3\n",
"5\n4\n1 2 3 4\n7\n4 5 3 8 4 5 2\n3\n1 1 1\n7\n1 3 1 4 0 3 2\n5\n5 4 3 2 3\n",
"5\n4\n1 2 3 4\n7\n8 3 4 8 4 5 2\n3\n1 1 1\n7\n1 3 1... |
64_F. Domain | This problem doesn't contain real-world specifications about domains, just use the problem statement as a formal document to solve the problem.
The given string s is a domain name if it contains the characters "a"-"z", "0"-"9" and dots. No two dots shoud follow one after another (consecutive). The dots split the given... | {
"input": [],
"output": []
} | {
"input": [
"codeforces.com\n",
"mail.v-kontakte.ru\n"
],
"output": [
"YES\n",
"NO\n"
]
} | {
"input": [],
"output": []
} |
comrades-ii-6 | It’s the year 2552, the Humans just won a war against a very powerful alien race that had invaded our solar system. The Human army is in celebration mode!
The army has n soldiers. The soldiers are numbers from 1 to n. The army has a superiority hierarchy. Every soldier has one immediate superior. The superior of a su... | {
"input": [],
"output": []
} | {
"input": [
"2\n3\n0 1 1\n2\n2 0\n\nSAMPLE"
],
"output": [
"2 1\n1 0"
]
} | {
"input": [],
"output": []
} |
find-handi-bhaiya | ACT I
Handi Bhaiya is a very notorious kid and always troubles his parents and friends. One day his naughtiness lead him to a demon Kali(THE COBRA COMMANDER) who trapped him into a triangular magic cell. Handi Bhaiya parents want their kid back and asks for your help.
ACT II
You knew that the entire humanity will hate... | {
"input": [],
"output": []
} | {
"input": [
"4\n15 15 15\n13 13 14\n3 4 5\n10 12 23\n\nSAMPLE"
],
"output": [
"YES. It is a equilateral triangle.\nYES. It is a isosceles triangle.\nYES. It is a scalene triangle.\nNO"
]
} | {
"input": [
"4\n13 15 15\n13 13 14\n3 4 5\n10 12 23\n\nSAMPLE",
"4\n13 27 15\n13 13 14\n3 4 5\n10 12 23\n\nSAMPLE",
"4\n1 27 15\n13 13 14\n2 4 5\n10 12 23\n\nSAMPLF",
"4\n1 27 15\n13 5 14\n2 6 5\n10 12 23\n\nSAMPLF",
"4\n2 27 15\n13 6 14\n2 6 3\n10 12 23\n\nSAMPLF",
"4\n2 27 15\n13 6 14\n2 6 ... |
imagination-game-easy-contest | Two players are playing with N-dimensional rectangular with sizes of its sides (a1, a2, ... aN). (Let's call this rectangular as "cube"). Initially there is one cell marked with coordinates (x1, x2, ... xN).
On his/her turn a player should divide a current cube into two cubes by exactly one cut along one of the val... | {
"input": [],
"output": []
} | {
"input": [
"2\n2\n2 2\n1 1\n2\n2 3\n1 2\n\n\nSAMPLE"
],
"output": [
"Second\nFirst"
]
} | {
"input": [],
"output": []
} |
rajasthans-bawri | Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance.
Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from... | {
"input": [],
"output": []
} | {
"input": [
"3\n2 7 4 7\n5 2 3 1\n9 2 7 1\n\nSAMPLE"
],
"output": [
"Not Possible\nPossible\nPossible\n"
]
} | {
"input": [
"3\n2 7 4 7\n5 2 3 1\n9 0 7 1\n\nSAMPLE",
"3\n2 7 4 17\n5 4 3 1\n9 0 8 0\n\nSAMPLE",
"3\n2 7 4 17\n5 4 6 1\n9 0 8 0\n\nSAMPLE",
"3\n2 7 4 17\n5 1 6 2\n9 0 13 0\n\nSAMPLE",
"3\n1 26 0 7\n1 21 3 -1\n232 0 1 -1\n\nPKELAS",
"3\n0 5 0 -1\n1 3 4 -1\n216 0 0 -1\n\nPJELAS",
"3\n2 7 0 ... |
p02543 ACL Contest 1 - Keep Distances | There are N points on a number line, i-th of which is placed on coordinate X_i. These points are numbered in the increasing order of coordinates. In other words, for all i (1 \leq i \leq N-1), X_i < X_{i+1} holds. In addition to that, an integer K is given.
Process Q queries.
In the i-th query, two integers L_i and R... | {
"input": [],
"output": []
} | {
"input": [
"5 3\n1 2 4 7 8\n2\n1 5\n1 2",
"15 220492538\n4452279 12864090 23146757 31318558 133073771 141315707 263239555 350278176 401243954 418305779 450172439 560311491 625900495 626194585 891960194\n5\n6 14\n1 8\n1 13\n7 12\n4 12"
],
"output": [
"4\n2",
"4\n6\n11\n2\n3"
]
} | {
"input": [
"5 3\n1 2 4 4 8\n2\n1 5\n1 2",
"5 3\n1 4 4 4 8\n2\n1 5\n1 2",
"15 220492538\n4452279 12864090 23146757 31318558 133073771 141315707 263239555 350278176 401243954 418305779 450172439 560311491 625900495 626194585 891960194\n5\n9 14\n1 8\n1 13\n7 12\n4 12",
"15 220492538\n3365326 12864090 2... |
p02674 AtCoder Grand Contest 044 - Name-Preserving Clubs | There are N people (with different names) and K clubs. For each club you know the list of members (so you have K unordered lists). Each person can be a member of many clubs (and also 0 clubs) and two different clubs might have exactly the same members. The value of the number K is the minimum possible such that the fol... | {
"input": [],
"output": []
} | {
"input": [
"123456789123456789",
"2",
"26",
"4",
"3",
"13"
],
"output": [
"-1",
"1",
"-1",
"7",
"1",
"6"
]
} | {
"input": [
"119107271329329921",
"27",
"5",
"9",
"7",
"8",
"11",
"6",
"10",
"12",
"20",
"33213408621377322",
"45",
"26939847318901699",
"12809773843701327",
"15368855316243065",
"15",
"5452054052106793",
"18",
"4107947535538903",
"1... |
p02802 AtCoder Beginner Contest 151 - Welcome to AtCoder | Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).
The number of Takahashi's correct answers is the number of problems on which he received an `A... | {
"input": [],
"output": []
} | {
"input": [
"6 0",
"2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA",
"100000 3\n7777 AC\n7777 AC\n7777 AC"
],
"output": [
"0 0",
"2 2",
"1 0"
]
} | {
"input": [
"100000 3\n7777 AC\n7777 AC\n7777 CA",
"100000 3\n12676 AC\n7777 AC\n7777 CA",
"1 0",
"4 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA",
"4 5\n1 WA\n1 AC\n0 WA\n2 AC\n2 WA",
"100000 3\n6234 AC\n7777 AC\n7777 AC",
"2 0",
"2 -1",
"2 -2",
"2 -4",
"2 -6",
"0 -6",
"-1 -6"... |
p02938 AtCoder Beginner Contest 138 - Coincidence | Given are integers L and R. Find the number, modulo 10^9 + 7, of pairs of integers (x, y) (L \leq x \leq y \leq R) such that the remainder when y is divided by x is equal to y \mbox{ XOR } x.
What is \mbox{ XOR }?
The XOR of integers A and B, A \mbox{ XOR } B, is defined as follows:
* When A \mbox{ XOR } B is writte... | {
"input": [],
"output": []
} | {
"input": [
"2 3",
"10 100",
"1 1000000000000000000"
],
"output": [
"3",
"604",
"68038601"
]
} | {
"input": [
"3 3",
"10 110",
"1 1000000100000000000",
"3 0",
"10 111",
"4 110",
"4 100",
"6 110",
"6 111",
"5 111",
"9 111",
"16 111",
"1 011",
"3 100",
"6 100",
"2 5",
"15 100",
"1 1000000000010000000",
"3 4",
"1 100",
"1 1000000100... |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
... | {
"input": [],
"output": []
} | {
"input": [
"1\n2\n4\n8\n9\n15",
"15\n18\n26\n35\n36\n18"
],
"output": [
"Yay!",
":("
]
} | {
"input": [
"1\n0\n4\n8\n9\n15",
"15\n18\n26\n35\n36\n2",
"1\n0\n8\n8\n9\n15",
"15\n18\n26\n35\n34\n2",
"1\n0\n5\n8\n9\n15",
"15\n18\n13\n35\n34\n2",
"1\n0\n5\n8\n4\n15",
"15\n5\n13\n35\n34\n2",
"1\n0\n5\n8\n8\n15",
"15\n5\n13\n35\n34\n3",
"1\n0\n5\n13\n8\n15",
"15\n5\... |
p03217 Dwango Programming Contest V - Square Rotation | Niwango-kun, an employee of Dwango Co., Ltd., likes Niconico TV-chan, so he collected a lot of soft toys of her and spread them on the floor.
Niwango-kun has N black rare soft toys of Niconico TV-chan and they are spread together with ordinary ones. He wanted these black rare soft toys to be close together, so he deci... | {
"input": [],
"output": []
} | {
"input": [
"19 2\n1 3\n2 3\n0 1\n1 1\n2 1\n3 1\n4 4\n5 4\n6 4\n7 4\n8 4\n8 3\n8 2\n8 1\n8 0\n7 0\n6 0\n5 0\n4 0",
"3 1\n0 0\n1 0\n2 0",
"8 3\n0 0\n0 3\n3 0\n3 3\n2 2\n2 5\n5 2\n5 5"
],
"output": [
"4",
"1",
"4"
]
} | {
"input": [
"19 2\n1 3\n2 3\n0 1\n1 1\n2 1\n3 1\n4 4\n5 4\n6 4\n7 4\n8 4\n8 1\n8 2\n8 1\n8 0\n7 0\n6 0\n5 0\n4 0",
"3 2\n0 0\n1 0\n2 0",
"1 4\n0 0\n2 1\n2 0",
"8 3\n0 0\n0 3\n6 0\n1 3\n2 0\n2 10\n5 2\n0 8",
"17 2\n0 5\n2 3\n1 0\n1 2\n3 1\n3 1\n3 5\n5 1\n5 4\n7 4\n8 4\n6 1\n1 2\n6 1\n8 1\n11 0\n11... |
p03366 AtCoder Grand Contest 023 - Go Home | There are N apartments along a number line, numbered 1 through N. Apartment i is located at coordinate X_i. Also, the office of AtCoder Inc. is located at coordinate S. Every employee of AtCoder lives in one of the N apartments. There are P_i employees who are living in Apartment i.
All employees of AtCoder are now le... | {
"input": [],
"output": []
} | {
"input": [
"15 409904902\n94198000 15017\n117995501 7656764\n275583856 313263626\n284496300 356635175\n324233841 607\n360631781 148\n472103717 5224\n497641071 34695\n522945827 816241\n554305668 32\n623788284 22832\n667409501 124410641\n876731548 12078\n904557302 291749534\n918215789 5",
"3 2\n1 3\n3 4\n4 2"... | {
"input": [
"3 2\n0 3\n3 4\n4 2",
"15 409904902\n94198000 15017\n117995501 7656764\n275583856 313263626\n284496300 356635175\n324233841 607\n360631781 148\n472103717 5224\n497641071 34695\n522945827 816241\n554305668 32\n623788284 22832\n667409501 128425253\n876731548 12078\n904557302 291749534\n918215789 5"... |
p03526 CODE FESTIVAL 2017 Final - Zabuton | In the final of CODE FESTIVAL in some year, there are N participants. The height and power of Participant i is H_i and P_i, respectively.
Ringo is hosting a game of stacking zabuton (cushions).
The participants will line up in a row in some order, and they will in turn try to add zabuton to the stack of zabuton. Init... | {
"input": [],
"output": []
} | {
"input": [
"3\n2 4\n3 1\n4 1",
"10\n1 3\n8 4\n8 3\n9 1\n6 4\n2 3\n4 2\n9 2\n8 3\n0 1",
"3\n0 2\n1 3\n3 4"
],
"output": [
"3",
"5",
"2"
]
} | {
"input": [
"3\n2 4\n3 1\n4 2",
"10\n1 3\n8 4\n8 3\n10 1\n6 4\n2 3\n4 2\n9 2\n8 3\n0 1",
"3\n0 2\n1 0\n3 4",
"10\n1 3\n8 4\n8 3\n10 1\n12 4\n2 3\n4 2\n9 2\n8 3\n0 1",
"10\n1 3\n0 4\n15 3\n10 1\n8 4\n2 3\n4 2\n9 1\n8 3\n0 1",
"10\n2 3\n0 4\n15 3\n10 1\n8 4\n2 1\n4 2\n9 1\n8 0\n0 1",
"10\n2... |
p03689 AtCoder Grand Contest 016 - +/- Rectangle | You are given four integers: H, W, h and w (1 ≤ h ≤ H, 1 ≤ w ≤ W). Determine whether there exists a matrix such that all of the following conditions are held, and construct one such matrix if the answer is positive:
* The matrix has H rows and W columns.
* Each element of the matrix is an integer between -10^9 and 10^... | {
"input": [],
"output": []
} | {
"input": [
"2 4 1 2",
"3 4 2 3",
"3 3 2 2"
],
"output": [
"No",
"Yes\n2 -5 8 7\n3 -5 -4 -5\n2 1 -1 7",
"Yes\n1 1 1\n1 -4 1\n1 1 1"
]
} | {
"input": [
"0 4 1 2",
"3 4 4 3",
"4 3 2 2",
"4 3 3 2",
"3 6 4 2",
"3 10 4 2",
"5 10 6 2",
"5 10 2 2",
"2 4 4 1",
"4 2 3 2",
"1 4 4 2",
"3 11 4 2",
"3 15 4 2",
"3 2 6 2",
"9 10 6 2",
"5 10 2 4",
"2 5 1 4",
"3 3 2 3",
"4 2 3 3",
"3 15 2 2... |
p03842 AtCoder Grand Contest 008 - Next or Nextnext | You are given an integer sequence a of length N. How many permutations p of the integers 1 through N satisfy the following condition?
* For each 1 ≤ i ≤ N, at least one of the following holds: p_i = a_i and p_{p_i} = a_i.
Find the count modulo 10^9 + 7.
Constraints
* 1 ≤ N ≤ 10^5
* a_i is an integer.
* 1 ≤ a_i ≤ ... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 1",
"3\n1 1 1",
"3\n2 1 1",
"3\n1 2 3",
"13\n2 1 4 3 6 7 5 9 10 8 8 9 11"
],
"output": [
"1",
"0",
"2",
"4",
"6"
]
} | {
"input": [
"2\n2 1",
"13\n2 1 4 3 6 7 5 9 10 8 8 9 13",
"13\n2 1 4 3 6 7 5 9 9 8 8 9 13",
"2\n1 2",
"13\n2 1 4 3 6 7 5 9 10 8 13 9 11",
"13\n2 1 2 3 6 7 5 9 10 8 13 9 11",
"3\n2 2 3",
"13\n2 1 4 3 6 7 5 9 9 15 8 9 13",
"13\n2 1 4 0 6 7 5 9 9 15 8 9 13",
"2\n2 2",
"13\n2 1... |
p04009 AtCoder Grand Contest 004 - Salvage Robots | We have a grid with H rows and W columns. The state of the cell at the i-th (1≤i≤H) row and j-th (1≤j≤W) column is represented by a letter a_{ij}, as follows:
* `.` : This cell is empty.
* `o` : This cell contains a robot.
* `E` : This cell contains the exit. `E` occurs exactly once in the whole grid.
Snuke is tryi... | {
"input": [],
"output": []
} | {
"input": [
"5 11\nooo.ooo.ooo\no.o.o...o..\nooo.oE..o..\no.o.o.o.o..\no.o.ooo.ooo",
"3 4\no...\no...\noooE",
"3 3\no.o\n.Eo\nooo",
"2 2\nE.\n.."
],
"output": [
"12",
"5",
"3",
"0"
]
} | {
"input": [
"5 11\nooo.ooo.ooo\n..o...o.o.o\nooo.oE..o..\no.o.o.o.o..\no.o.ooo.ooo",
"3 3\no.o\n.Ep\nooo",
"3 2\nE.\n..",
"5 11\nooo.oo-oooo\n..o...o.n.o\nooo/oE..o..\no.o.o.o.o..\np.o.ooo.ooo",
"5 11\nooo.oo-oooo\n..o...o.n.o\n..o..Eo/ooo\n..o.o.o.o.o\np.o.ooo.ooo",
"3 8\no...\no...\noooE",
... |
p00095 Surf Smelt Fishing Contest | A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt.
Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest par... | {
"input": [],
"output": []
} | {
"input": [
"6\n1 14\n2 25\n3 42\n4 11\n5 40\n6 37"
],
"output": [
"3 42"
]
} | {
"input": [
"6\n1 14\n4 25\n3 42\n4 11\n5 40\n6 37",
"6\n1 14\n4 25\n3 42\n4 11\n5 60\n6 37",
"6\n1 14\n2 25\n3 81\n4 11\n5 40\n6 37",
"6\n1 14\n4 25\n3 72\n4 11\n5 60\n6 37",
"6\n1 14\n2 25\n3 63\n4 11\n5 40\n6 37",
"6\n1 14\n2 25\n3 55\n4 11\n4 40\n6 59",
"6\n1 14\n2 6\n3 3\n4 3\n5 40\n... |
p00227 Thanksgiving | As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices.
One day, a group of three good friends living in the Matsunaga housing complex bloomed with a... | {
"input": [],
"output": []
} | {
"input": [
"4 2\n50 40 100 80\n7 3\n400 300 100 700 200 600 500\n0 0"
],
"output": [
"150\n2100"
]
} | {
"input": [
"4 2\n50 40 100 80\n7 3\n400 300 100 700 200 600 57\n0 0",
"4 2\n50 40 100 80\n7 3\n400 300 100 700 352 600 57\n0 0",
"4 3\n50 40 100 80\n7 3\n400 300 100 700 352 600 57\n0 0",
"4 3\n50 40 100 80\n7 3\n400 290 100 700 352 600 57\n0 0",
"4 3\n50 40 100 80\n7 3\n400 290 000 700 352 600 ... |
p00389 Pilling Blocks | We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing.
We have to build the tower abiding by the following ... | {
"input": [],
"output": []
} | {
"input": [
"5 2",
"4 2"
],
"output": [
"4",
"3"
]
} | {
"input": [
"5 4",
"4 8",
"6 8",
"10 8",
"10 4",
"15 3",
"29 3",
"29 5",
"3 7",
"1 14",
"2 11",
"29 6",
"18 7",
"51 6",
"58 6",
"11 16",
"31 16",
"27 16",
"24 8",
"51 7",
"23 60",
"44 6",
"31 23",
"21 61",
"47 16",
... |
p00605 Vampirish Night | There is a vampire family of N members. Vampires are also known as extreme gourmets. Of course vampires' foods are human blood. However, not all kinds of blood is acceptable for them. Vampires drink blood that K blood types of ones are mixed, and each vampire has his/her favorite amount for each blood type.
You, cook ... | {
"input": [],
"output": []
} | {
"input": [
"2 3\n5 4 5\n1 2 3\n3 2 1\n3 5\n1 2 3 4 5\n0 1 0 1 2\n0 1 1 2 2\n1 0 3 1 1\n0 0"
],
"output": [
"Yes\nNo"
]
} | {
"input": [
"2 3\n5 4 5\n1 2 3\n3 2 1\n3 5\n1 2 3 4 5\n-1 1 0 1 2\n0 1 1 2 2\n1 0 3 1 1\n0 0",
"2 3\n5 4 5\n1 2 3\n3 2 1\n3 5\n1 2 3 4 5\n0 1 -1 1 2\n0 1 1 2 2\n1 0 3 1 1\n0 0",
"2 3\n2 4 5\n1 2 3\n3 2 1\n3 5\n1 2 3 4 5\n-1 1 0 1 2\n0 1 1 2 2\n1 0 3 1 1\n0 0",
"2 3\n5 4 5\n1 2 3\n3 4 1\n3 5\n1 2 3 7 ... |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | {
"input": [],
"output": []
} | {
"input": [
"3\nACM\nIBM\nICPC\n3\nGAME\nBEST\nGAMER\n4\nA\nB\nC\nAB\n3\nA\nB\nCD\n3\nONE\nTWO\nTHREE\n3\nTWO\nTHREE\nFIVE\n3\nMOV\nPOP\nDIV\n9\nA\nB\nC\nD\nE\nF\nG\nH\nIJ\n0"
],
"output": [
"4\n1\n8\n30\n0\n0\n0\n40320"
]
} | {
"input": [
"3\nACM\nIBM\nICPC\n3\nGAME\nBEST\nGAMER\n4\nA\nB\nC\nAB\n3\nA\nB\nCD\n3\nONE\nTWO\nTHREE\n3\nTWO\nTHREE\nFIVE\n3\nMOV\nPOP\nDIV\n9\nA\nB\nC\nD\nE\nF\nG\nG\nIJ\n0",
"3\nACM\nIBM\nICPC\n3\nGAME\nBEST\nGAMER\n4\nA\nB\nC\nAB\n3\nA\nB\nCD\n3\nONE\nTWO\nTHREE\n3\nTOW\nTHREE\nFIVE\n3\nMOV\nPOP\nDIV\n9\... |
p00881 Twenty Questions | Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence of boole... | {
"input": [],
"output": []
} | {
"input": [
"8 1\n11010101\n11 4\n00111001100\n01001101011\n01010000011\n01100110001\n11 16\n01000101111\n01011000000\n01011111001\n01101101001\n01110010111\n01110100111\n10000001010\n10010001000\n10010110100\n10100010100\n10101010110\n10110100010\n11001010011\n11011001001\n11111000111\n11111011101\n11 12\n10000... | {
"input": [
"8 1\n11010101\n11 4\n00111001100\n01001101011\n01010000011\n01100110001\n11 16\n01000101111\n01011000000\n01011111001\n01101101001\n01110010111\n01110100111\n10000001010\n10010001000\n10010110100\n10100010100\n10101010110\n10110100010\n11001010011\n11011001001\n11111000111\n11111011101\n11 12\n10000... |
p01012 Planarian Regeneration | Notes
For this problem, it is recommended to use floating point numbers, which are more accurate than double.
Input
m n x
k l y
For input, six integers m, n, x, k, l, y are given in the above input format.
These six integers correspond to those in the problem statement, repeating the horizontal m: n cut x times... | {
"input": [],
"output": []
} | {
"input": [
"1 2 2\n1 1 1",
"1 2 0\n3 4 0",
"1 1 1\n1 1 1"
],
"output": [
"0.490741",
"1.000000",
"0.562500"
]
} | {
"input": [
"1 2 2\n1 0 1",
"1 2 0\n6 4 0",
"1 0 1\n1 1 1",
"1 2 1\n3 4 0",
"1 0 1\n3 4 1",
"1 0 0\n4 1 1",
"1 2 1\n1 1 1",
"1 4 2\n1 0 1",
"0 0 1\n3 4 1",
"1 2 1\n2 1 1",
"1 5 2\n1 0 1",
"1 -1 0\n3 4 2",
"1 5 4\n1 0 1",
"-1 0 1\n3 8 1",
"1 2 0\n3 1 2",
... |
p01144 Princess's Marriage | Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent more money t... | {
"input": [],
"output": []
} | {
"input": [
"2 8\n5 6\n4 5\n3 1\n5 10\n5 10\n5 10\n0 0"
],
"output": [
"5\n140"
]
} | {
"input": [
"2 8\n5 6\n4 5\n3 2\n5 10\n5 10\n5 10\n0 0",
"2 8\n5 6\n4 5\n3 2\n5 10\n3 10\n5 10\n0 0",
"2 8\n5 6\n4 5\n3 2\n1 10\n5 10\n5 10\n0 0",
"2 8\n5 6\n4 5\n3 1\n3 10\n5 10\n5 10\n0 0",
"2 8\n5 6\n4 5\n3 2\n5 10\n7 10\n5 10\n0 0",
"2 8\n5 6\n4 5\n3 2\n0 10\n5 10\n5 10\n0 0",
"2 8\n5... |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(⋅) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 ≤ S, A, C ≤ 15 and M = 256.
Now suppose we have some input string I(⋅), where each character in the string is an integer between 0 and (M - ... | {
"input": [],
"output": []
} | {
"input": [
"5\n5 4 3 2 1\n5\n7 7 7 7 7\n10\n186 8 42 24 154 40 10 56 122 72\n0"
],
"output": [
"0 1 1\n0 0 0\n8 7 14"
]
} | {
"input": [
"5\n5 4 3 2 1\n5\n7 7 7 7 7\n10\n186 8 42 24 154 40 10 56 122 141\n0",
"5\n5 4 3 2 1\n5\n7 12 2 0 7\n10\n372 8 42 18 154 40 10 56 122 141\n0",
"5\n5 4 3 4 1\n5\n7 11 7 7 14\n0\n186 8 42 24 154 21 10 56 122 72\n0",
"5\n5 4 3 4 1\n5\n13 11 1 7 14\n0\n186 8 64 24 241 21 13 22 122 72\n0",
... |
p01453 Spring Tiles | One morning when you woke up, it was in a springy labyrinth.
I don't know why I'm in such a strange place. You have the option of waiting for help here, but you know from experience that if you stay in a labyrinth like this for a long time, a gust of wind will surely blow you away. It was. However, the time until the ... | {
"input": [],
"output": []
} | {
"input": [
"8 6\n########\n#..##g.#\n#*#.*#.#\n#......#\n#*s#*.*#\n########",
"8 6\n\n..##g.#\n*#.*#.#\n......#\n*s#*.*#",
"21 11\n\n*#*.*.*.*.*.*.*.*#*#\n*#...............#*#\n*#.#.#.#.#.#.#.#.#*#\n.#.#.#.#.#.#.#.#.##\n...................#\n.#.#.#.#.#.#.#.#.##\ns#.#.#.#.#.#.#.#.#g#\n...................... | {
"input": [
"8 9\n########\n#..##g.#\n#*#.*#.#\n#......#\n#*s#*.*#\n########",
"21 11\n\n*#*.*.*.*.*.*.*.*#*#\n*#...............#*#\n*#.#.#.#.\".#.#.#.#*#\n.#.#.#.#.#.#.#.#.##\n...................#\n.#.#.#.#.#.#.#.#.##\ns#.#.#.#.#.#.#.#.#g#\n...................#\n...................#",
"7 8\n\n...#*.*#\n... |
p01603 Sanpo | Sanpo
Problem Statement
The cats love walking. There are new discoveries as you walk down the road.
The town where Sora lives consists of N squares and N-1 roads.
The road just connects the two squares and does not branch or intersect.
For the road, the time t to walk, the upper limit m of the number of discoveries... | {
"input": [],
"output": []
} | {
"input": [
"2 10000\n1 2 1 10 1",
"4 5\n1 2 1 4 7\n2 3 1 2 77\n2 4 1 2 777",
"5 15\n1 2 3 2 1\n2 3 3 2 1\n1 4 8 2 777\n1 5 1 3 10"
],
"output": [
"10",
"1568",
"32"
]
} | {
"input": [
"5 15\n1 2 3 2 1\n3 3 3 2 1\n1 4 8 2 777\n1 5 1 3 10",
"4 5\n1 2 1 4 7\n2 3 1 2 77\n2 4 1 2 55",
"5 15\n1 2 3 2 1\n2 3 1 2 1\n1 4 8 2 777\n1 5 1 3 10",
"5 15\n1 2 3 2 1\n3 4 3 2 1\n1 4 8 2 777\n1 5 1 2 10",
"2 10000\n1 2 1 10 0",
"4 5\n1 2 1 4 14\n2 3 1 2 77\n2 4 1 2 777",
"5 ... |
p01759 Vongress | Taro loves a game called Vongress. Vongress is a camp game played on a board that is a convex polygon consisting of n vertices.
In this game, m players place one piece each inside the board. The position of the piece is represented by a set of x-coordinate and y-coordinate, and the size of the piece is not considered.... | {
"input": [],
"output": []
} | {
"input": [
"4 5\n1 1\n-1 1\n-1 -1\n1 -1\n1\n1\n1\n1\n1"
],
"output": [
"0.0000000000 0.0000000000\n0.6324555320 0.6324555320\n-0.6324555320 0.6324555320\n-0.6324555320 -0.6324555320\n0.6324555320 -0.6324555320"
]
} | {
"input": [
"4 1\n1 1\n-1 1\n-1 -1\n1 -1\n1\n1\n1\n1\n1",
"2 1\n1 0\n-1 1\n-1 -1\n1 -1\n1\n0\n1\n1\n0",
"2 1\n1 0\n-1 0\n-1 -1\n1 -1\n1\n0\n1\n1\n0",
"2 1\n1 -1\n-1 0\n0 -1\n0 -1\n1\n1\n1\n2\n1",
"2 1\n1 -1\n-1 -1\n0 -1\n0 -1\n1\n1\n2\n4\n1",
"4 1\n1 -1\n-1 -1\n0 0\n0 -1\n1\n1\n2\n4\n1",
... |
p01899 Yamanote-line Game | B: Yamanote-line Game-Yamanote-line Game-
Bean (?) Knowledge
The Yamanote line is convenient. The reason is that you can ride as many laps as time allows just by paying 130 yen. However, if you board with a ticket, you must be careful about the valid time of the ticket. It seems safe with an IC card. Taking advantage... | {
"input": [],
"output": []
} | {
"input": [
"5 130\n130 170 100 120 140"
],
"output": [
"50"
]
} | {
"input": [
"5 130\n130 170 100 122 140",
"3 130\n130 170 100 122 140",
"1 130\n130 170 100 122 86",
"1 58\n60 60 010 102 86",
"1 58\n68 60 010 102 166",
"6 130\n130 170 100 120 140",
"5 130\n130 170 100 138 140",
"1 48\n68 5 100 72 104",
"1 53\n68 4 100 72 104",
"6 130\n130 1... |
p02036 Donuts Orientation | G: Donuts Orientation
story
Homu-chan's recent boom is making sweets. It seems that he makes a lot of sweets and shares them with his friends. Homu-chan seems to be trying to make donuts this time.
There are many important things in making donuts. Not only the dough and seasoning, but also the decorations to make it... | {
"input": [],
"output": []
} | {
"input": [
"3 1000000007"
],
"output": [
"204"
]
} | {
"input": [
"6 1000000007",
"4 652113297",
"8 1477679329",
"12 1477679329",
"3 1016398657",
"12 1000000007",
"11 1477679329",
"12 925928194",
"5 1659382658",
"9 1477679329",
"7 1016398657",
"9 7274994",
"9 6855975",
"18 6855975",
"11 832737751",
"18 127... |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | {
"input": [],
"output": []
} | {
"input": [
"2\n5 10 5 5\n4 4 2 2"
],
"output": [
"14"
]
} | {
"input": [
"2\n5 11 5 5\n4 4 2 2",
"2\n5 11 5 4\n4 4 1 2",
"2\n5 17 5 4\n4 4 1 2",
"2\n9 17 1 0\n4 1 2 3",
"2\n9 2 1 1\n4 1 4 3",
"2\n2 0 4 1\n10 2 3 16",
"2\n5 1 5 1\n5 2 3 13",
"2\n5 1 5 1\n1 2 3 13",
"2\n5 10 5 5\n4 4 3 2",
"2\n5 11 5 8\n4 4 1 2",
"2\n5 17 5 4\n1 4 0 2... |
p02322 Knapsack Problem with Limitations II | You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most $W$, that is capacity of the knapsack.
* You ... | {
"input": [],
"output": []
} | {
"input": [
"2 100\n1 1 100\n2 1 50",
"5 1000000000\n3 5 1000000000\n7 6 1000000000\n4 4 1000000000\n6 8 1000000000\n2 5 1000000000",
"4 8\n4 3 2\n2 1 1\n1 2 4\n3 2 2"
],
"output": [
"150",
"1166666666",
"12"
]
} | {
"input": [
"5 1000000000\n3 1 1000000000\n7 6 1000000000\n4 4 1000000000\n6 8 1000000000\n2 5 1000000000",
"4 8\n4 3 2\n2 1 1\n1 2 4\n2 2 2",
"5 1000000000\n4 1 1000000000\n7 6 1000100000\n4 4 1000000000\n6 14 1000000000\n2 5 1000000000",
"5 1000000000\n3 5 1000000000\n7 6 1000000000\n4 4 1000000000... |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | {
"input": [],
"output": []
} | {
"input": [
"12",
"126"
],
"output": [
"12: 2 2 3",
"126: 2 3 3 7"
]
} | {
"input": [
"23",
"7",
"38",
"22",
"30",
"4",
"31",
"6",
"27",
"3",
"11",
"2",
"13",
"19",
"8",
"5",
"20",
"121",
"29",
"39",
"37",
"21",
"10",
"15",
"16",
"9",
"18",
"36",
"217",
"58",
"49",
... |
ce02 | It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order.
WAP to check that if 2 such numbers have this property
Input:
The first line will consist of the total number of test cases T(1 ≤ T ≤ 10).
The next T lines will consist of one number on each lin... | {
"input": [],
"output": []
} | {
"input": [
"5\n23\n45\n123\n123\n1234\n123\n1223\n1222\n1223\n1234"
],
"output": [
"0\n1\n0\n0\n0"
]
} | {
"input": [
"5\n23\n45\n123\n123\n804\n123\n1223\n1222\n1223\n1234",
"5\n20\n29\n123\n92\n804\n35\n1223\n1222\n1223\n1234",
"5\n0\n0\n184\n001\n51\n23\n4842\n1\n11\n0010",
"5\n0\n-2\n0\n010\n1\n1\n570\n0\n16\n0000",
"5\n-1\n-1\n59\n001\n9\n9\n10529\n1\n35\n0010",
"5\n23\n45\n123\n123\n804\n35... |
decstr | Statement
You need to find a string which has exactly K positions in it such that the character at that position comes alphabetically later than the character immediately after it. If there are many such strings, print the one which has the shortest length. If there is still a tie, print the string which comes the le... | {
"input": [],
"output": []
} | {
"input": [
"2\n1\n2"
],
"output": [
"ba\ncba\n"
]
} | {
"input": [
"2\n2\n2",
"2\n2\n3",
"2\n3\n2",
"2\n2\n5",
"2\n4\n5",
"2\n3\n5",
"2\n5\n5",
"2\n5\n8",
"2\n4\n8",
"2\n1\n1",
"2\n2\n4",
"2\n1\n3",
"2\n6\n2",
"2\n2\n1",
"2\n6\n5",
"2\n4\n6",
"2\n5\n4",
"2\n4\n16",
"2\n1\n5",
"2\n5\n2",
... |
iitk1p02 | Awesomeness of a string is defined by a pair of a character C and an integer F, satisfying the following conditions :
C must belong to the given string S and there must be a substring subS of S having length equal to F such that all the characters in subS are equal to c.
F should be as large as possible.
Yo... | {
"input": [],
"output": []
} | {
"input": [
"abbbaaabad"
],
"output": [
"a\n3"
]
} | {
"input": [],
"output": []
} |
name2 | In an attempt to control the rise in population, Archer was asked to come up with a plan. This time he is targeting marriages. Archer, being as intelligent as he is, came up with the following plan:
A man with name M is allowed to marry a woman with name W, only if M is a subsequence of W or W is a subsequence of M.
A ... | {
"input": [],
"output": []
} | {
"input": [
"3\njohn johanna\nira ira\nkayla jayla"
],
"output": [
"YES\nYES\nNO\n"
]
} | {
"input": [
"3\njohn johanna\nira ria\nkayla jayla",
"3\njohn johanna\nria ria\nkayla jayla",
"3\njogn johanna\nria qia\nkayma jayla",
"3\nipoh o`gomka\nbjr bjr\njmya` aayjk",
"3\njohn johanna\nria ria\nkayma jayla",
"3\njohn johanna\nria qia\nkayma jayla",
"3\nngoj johanna\nria qia\nkaym... |
rrmatrix | Given two matrices A and B. Both have N rows and M columns. In the matrix A, numbers from 1 to MN have been written in row major order. Row major order numbers cells from left to right, and top to bottom. That is,
1 2 3 ... M
A = M+1 M+2 ... | {
"input": [],
"output": []
} | {
"input": [
"1\n4 5"
],
"output": [
"2\n"
]
} | {
"input": [
"1\n3 5",
"1\n3 2",
"1\n4 10",
"1\n6 6",
"1\n1 10",
"1\n0 0",
"1\n1 19",
"1\n1 22",
"1\n1 5",
"1\n1 8",
"1\n1 17",
"1\n1 1",
"1\n1 9",
"1\n1 23",
"1\n-1 -1",
"1\n1 18",
"1\n1 7",
"1\n1 14",
"1\n-2 -2",
"1\n1 63",
"1\n1 10... |
wordcnt | You have to submit the assignment tomorrow. It has to be 1000 words long and your lecturer has warned you about writing in really big handwriting so that you can get away with writing less. And how many words have you used?
You don't know because you have not written this program yet. Just find the number of words per ... | {
"input": [],
"output": []
} | {
"input": [
"4\nI can do this!\nYes, I will win\nCode Haxor!\nTaqneeq FTW!"
],
"output": [
"4\n4\n2\n2\n"
]
} | {
"input": [
"4\nI can do this!\nYes, J will win\nCode Haxor!\nTaqneeq FTW!",
"4\nJ can od this!\nXes+ I xill niw\nCode !roxaH\nqeenqaT FT W",
"4\nJ can do this!\nYes, J will win\nCode Haxor!\nTaqneeq FTW!",
"4\nJ nac do this!\nYes, J will win\nCode Haxor!\nTaqneeq FTW!",
"4\nJ nac do this!\nYes, ... |
1404_A. Balanced Bitstring | A bitstring is a string consisting only of the characters 0 and 1. A bitstring is called k-balanced if every substring of size k of this bitstring has an equal amount of 0 and 1 characters (k/2 of each).
You are given an integer k and a string s which is composed only of characters 0, 1, and ?. You need to determine w... | {
"input": [],
"output": []
} | {
"input": [
"9\n6 4\n100110\n3 2\n1?1\n3 2\n1?0\n4 4\n????\n7 4\n1?0??1?\n10 10\n11??11??11\n4 2\n1??1\n4 4\n?0?0\n6 2\n????00\n"
],
"output": [
"YES\nYES\nNO\nYES\nYES\nNO\nNO\nYES\nNO\n"
]
} | {
"input": [
"9\n6 4\n100110\n3 2\n1?1\n3 2\n1?0\n4 4\n????\n7 4\n1?0??1?\n10 10\n11??11??11\n4 2\n1??1\n4 4\n0?0?\n6 2\n????00\n",
"9\n6 4\n100110\n3 2\n1?1\n3 2\n1?0\n4 4\n????\n7 4\n1?0??1?\n10 10\n11??11??11\n4 2\n1?1?\n4 4\n?0?0\n6 2\n00????\n",
"9\n6 4\n100110\n3 2\n1?0\n3 2\n1?0\n4 4\n????\n7 4\n1?... |
code-hunt | Little Stuart has reached the final level of 'Code Hunt', the annual treasure hunt organised by HackerEarth. Now for the final level, Little Stuart has to choose a door from infinite number of doors numbered from 1 to infinity. Out of these only one door contains the grand prize. The clue for finding the correct door i... | {
"input": [],
"output": []
} | {
"input": [
"2\n3\n10 2 3\n2\n3 5\n\nSAMPLE"
],
"output": [
"1\n0\n"
]
} | {
"input": [
"2\n3\n10 2 3\n2\n5 5\n\nSAMPLE",
"2\n3\n10 2 3\n2\n5 4\n\nSAMPLE",
"2\n3\n13 2 3\n0\n7 4\n\nLAMPTE",
"2\n1\n10 1 3\n2\n1 1\n\nLPNASE",
"2\n3\n10 2 1\n2\n5 5\n\nSAMPLE",
"2\n3\n10 2 2\n0\n7 4\n\nSAMPLE",
"2\n3\n10 2 5\n2\n5 4\n\nDLPMAS",
"2\n3\n10 2 3\n2\n7 4\n\nSAMPLE",
... |
magical-power | Raja tranports boxes from one place to another.But the boxes are too heavy it is very diffcult for him to transport them.But he is Raja:-p he has a magical power he can choose any random number D and if sum of weight of two continuous boxes one after another is divisble by that number then he can change both boxes in t... | {
"input": [],
"output": []
} | {
"input": [
"1\n5\n5 7 7 15 12\n7\n\nSAMPLE"
],
"output": [
"5 2 15 12\n"
]
} | {
"input": [
"1\n5\n5 7 7 15 12\n13\n\nSAMPLE",
"1\n5\n5 7 7 15 5\n25\n\nSAMPLE",
"1\n5\n5 14 7 15 5\n25\n\nSAMPLE",
"1\n5\n5 14 7 26 5\n16\n\nSAMPLE",
"1\n5\n5 7 7 15 0\n7\n\nSAMPLE",
"1\n5\n5 7 7 16 12\n13\n\nSAMPLE",
"1\n5\n8 7 7 15 5\n25\n\nSAMPLE",
"1\n5\n5 14 7 15 3\n25\n\nSAMPLE... |
p02658 AtCoder Beginner Contest 169 - Multiplication 2 | Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.
However, if the result exceeds 10^{18}, print `-1` instead.
Constraints
* 2 \leq N \leq 10^5
* 0 \leq A_i \leq 10^{18}
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
A_1 ... A_N
Output
P... | {
"input": [],
"output": []
} | {
"input": [
"3\n101 9901 999999000001",
"2\n1000000000 1000000000",
"31\n4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0"
],
"output": [
"-1",
"1000000000000000000",
"0"
]
} | {
"input": [
"3\n101 9901 1693005451348",
"31\n4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 0 2 7 9 5 0",
"3\n101 8497 834116832270",
"3\n101 5000 834116832270",
"3\n101 5000 29935402316",
"3\n111 5000 29935402316",
"3\n111 5000 36731156058",
"3\n011 5000 36731156058",
"2\n000... |
p02787 AtCoder Beginner Contest 153 - Crested Ibis vs Monster | Ibis is fighting with a monster.
The health of the monster is H.
Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points.
The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health.
Ibis wins wh... | {
"input": [],
"output": []
} | {
"input": [
"9 3\n8 3\n4 2\n2 1",
"9999 10\n540 7550\n691 9680\n700 9790\n510 7150\n415 5818\n551 7712\n587 8227\n619 8671\n588 8228\n176 2461",
"100 6\n1 1\n2 3\n3 9\n4 27\n5 81\n6 243"
],
"output": [
"4",
"139815",
"100"
]
} | {
"input": [
"9999 10\n540 7550\n691 13640\n700 9790\n510 7150\n415 5818\n551 7712\n587 8227\n619 8671\n588 8228\n176 2461",
"100 6\n1 1\n2 3\n3 9\n4 27\n5 81\n5 243",
"110 6\n1 1\n2 3\n3 9\n4 27\n5 81\n5 243",
"9999 10\n540 7550\n691 20670\n700 9790\n863 7150\n415 5818\n551 7712\n587 8227\n619 8671\n... |
p02923 AtCoder Beginner Contest 139 - Lower | There are N squares arranged in a row from left to right.
The height of the i-th square from the left is H_i.
You will land on a square of your choice, then repeat moving to the adjacent square on the right as long as the height of the next square is not greater than that of the current square.
Find the maximum numb... | {
"input": [],
"output": []
} | {
"input": [
"5\n10 4 8 7 3",
"4\n1 2 3 4",
"7\n4 4 5 6 6 5 5"
],
"output": [
"2",
"0",
"3"
]
} | {
"input": [
"5\n10 4 8 13 3",
"4\n1 2 3 6",
"7\n4 4 8 6 6 5 5",
"7\n7 4 8 6 6 5 8",
"5\n12 4 8 4 3",
"5\n10 4 8 12 3",
"4\n1 2 6 6",
"7\n7 4 8 6 6 5 5",
"5\n12 4 8 12 3",
"4\n1 4 3 6",
"4\n0 4 3 6",
"7\n7 3 8 6 6 5 8",
"5\n12 4 10 4 3",
"4\n0 4 3 7",
"7\n7 ... |
p03058 AtCoder Grand Contest 033 - Adding Edges | You are given a tree T with N vertices and an undirected graph G with N vertices and M edges. The vertices of each graph are numbered 1 to N. The i-th of the N-1 edges in T connects Vertex a_i and Vertex b_i, and the j-th of the M edges in G connects Vertex c_j and Vertex d_j.
Consider adding edges to G by repeatedly ... | {
"input": [],
"output": []
} | {
"input": [
"13 11\n6 13\n1 2\n5 1\n8 4\n9 7\n12 2\n10 11\n1 9\n13 7\n13 11\n8 10\n3 8\n4 13\n8 12\n4 7\n2 3\n5 11\n1 4\n2 11\n8 10\n3 5\n6 9\n4 10",
"5 3\n1 2\n1 3\n3 4\n1 5\n5 4\n2 5\n1 5",
"7 5\n1 5\n1 4\n1 7\n1 2\n2 6\n6 3\n2 5\n1 3\n1 6\n4 6\n4 7"
],
"output": [
"27",
"6",
"11"
]
} | {
"input": [
"7 5\n1 5\n1 4\n2 7\n1 2\n2 6\n6 3\n2 5\n1 3\n1 6\n4 6\n4 7",
"7 5\n1 5\n1 4\n1 7\n1 2\n2 6\n6 3\n3 5\n1 3\n1 6\n4 6\n4 7",
"5 1\n1 2\n1 3\n3 4\n1 5\n5 4\n2 5\n1 5",
"5 2\n1 2\n1 3\n3 4\n1 5\n5 4\n2 5\n1 5",
"5 2\n1 2\n2 3\n3 4\n1 5\n5 4\n2 5\n1 5",
"13 11\n6 13\n1 2\n5 1\n8 4\n9 ... |
p03202 AtCoder Grand Contest 029 - Lexicographic constraints | There are N strings arranged in a row. It is known that, for any two adjacent strings, the string to the left is lexicographically smaller than the string to the right. That is, S_1<S_2<...<S_N holds lexicographically, where S_i is the i-th string from the left.
At least how many different characters are contained in ... | {
"input": [],
"output": []
} | {
"input": [
"3\n3 2 1",
"5\n2 3 2 1 2"
],
"output": [
"2",
"2"
]
} | {
"input": [
"3\n3 4 1",
"5\n2 1 2 1 2",
"5\n2 1 1 1 2",
"5\n3 1 1 1 1",
"3\n1 3 4",
"3\n3 5 1",
"5\n2 1 2 2 2",
"3\n3 5 2",
"5\n3 1 2 2 2",
"3\n3 5 3",
"5\n6 1 2 2 2",
"3\n3 7 3",
"5\n1 1 2 2 2",
"3\n3 1 3",
"5\n1 1 2 1 2",
"5\n1 1 2 1 4",
"3\n3 3 1... |
p03349 AtCoder Grand Contest 024 - Sequence Growing Hard | Find the number of the possible tuples of sequences (A_0,A_1,...,A_N) that satisfy all of the following conditions, modulo M:
* For every i (0\leq i\leq N), A_i is a sequence of length i consisting of integers between 1 and K (inclusive);
* For every i (1\leq i\leq N), A_{i-1} is a subsequence of A_i, that is, there e... | {
"input": [],
"output": []
} | {
"input": [
"2 2 100",
"4 3 999999999",
"150 150 998244353"
],
"output": [
"5",
"358",
"186248260"
]
} | {
"input": [
"4 2 100",
"4 3 1692604129",
"4 1 100",
"4 0 1692604129",
"2 2 110",
"2 3 100",
"300 150 998244353",
"4 4 1692604129",
"1 2 110",
"3 3 110",
"10 2 100",
"8 2 1466674655",
"8 3 1466674655",
"6 2 100",
"3 2 100",
"2 4 100",
"150 162 998244... |
p03509 Code Festival Team Relay (Parallel) - White and Blue | Ringo Kingdom Congress is voting on a bill.
N members are present, and the i-th member (1 ≤ i ≤ N) has w_i white ballots and b_i blue ballots. Each member i will put all the w_i white ballots into the box if he/she is in favor of the bill, and put all the b_i blue ballots into the box if he/she is not in favor of the ... | {
"input": [],
"output": []
} | {
"input": [
"5 60\n6 3\n5 9\n3 4\n7 8\n4 7",
"4 75\n1 1\n1 1\n1 1\n1 1",
"4 75\n1 1\n1 1\n1 1\n100 1"
],
"output": [
"3",
"3",
"1"
]
} | {
"input": [
"5 60\n6 3\n5 9\n3 4\n7 0\n4 7",
"4 17\n1 1\n1 1\n1 1\n000 1",
"4 75\n1 1\n1 1\n1 1\n000 2",
"2 93\n8 3\n8 8\n3 3\n7 8\n4 7",
"5 87\n6 3\n5 9\n3 4\n7 8\n4 7",
"4 75\n1 1\n1 1\n1 1\n000 1",
"5 60\n11 3\n5 9\n3 4\n7 0\n4 7",
"5 60\n11 3\n5 9\n3 4\n13 0\n4 7",
"4 17\n1 1\... |
p03670 AtCoder Grand Contest 017 - Zigzag | There are N(N+1)/2 dots arranged to form an equilateral triangle whose sides consist of N dots, as shown below. The j-th dot from the left in the i-th row from the top is denoted by (i, j) (1 \leq i \leq N, 1 \leq j \leq i). Also, we will call (i+1, j) immediately lower-left to (i, j), and (i+1, j+1) immediately lower-... | {
"input": [],
"output": []
} | {
"input": [
"3 2 1\n1 2 0",
"3 2 2\n1 1 1\n2 1 0",
"5 4 2\n1 3 1\n4 2 0",
"20 20 0"
],
"output": [
"6",
"0",
"172",
"881396682"
]
} | {
"input": [
"3 1 1\n1 2 0",
"3 2 2\n1 1 1\n2 1 1",
"3 1 1\n0 2 0",
"3 0 1\n0 2 0",
"3 3 1\n1 2 0",
"4 2 1\n1 2 0",
"3 3 1\n1 1 0",
"3 2 2\n0 1 1\n2 1 1",
"4 2 1\n1 3 0",
"3 2 1\n0 2 -1",
"4 2 1\n0 3 0",
"4 3 0\n2 -1 0",
"8 4 2\n1 3 1\n4 2 0",
"6 3 1\n1 2 0",
... |
p03825 AtCoder Grand Contest 009 - Eternal Average | There are N zeros and M ones written on a blackboard. Starting from this state, we will repeat the following operation: select K of the rational numbers written on the blackboard and erase them, then write a new number on the blackboard that is equal to the arithmetic mean of those K numbers. Here, assume that N + M - ... | {
"input": [],
"output": []
} | {
"input": [
"2 2 2",
"3 4 3",
"150 150 14"
],
"output": [
"5",
"9",
"937426930"
]
} | {
"input": [
"4 2 2",
"2 3 2",
"150 241 14",
"8 2 2",
"2 1 2",
"5 2 2",
"2 0 2",
"1 3 2",
"2 2 4",
"8 2 4",
"7 2 2",
"4 4 2",
"6 2 2",
"14 2 4",
"7 3 2",
"5 1 2",
"26 2 4",
"4 1 2",
"20 2 4",
"7 1 2",
"26 2 2",
"4 3 2",
"23 2 ... |
p03992 CODE FESTIVAL 2016 qual A - CODEFESTIVAL 2016 | This contest is `CODE FESTIVAL`. However, Mr. Takahashi always writes it `CODEFESTIVAL`, omitting the single space between `CODE` and `FESTIVAL`.
So he has decided to make a program that puts the single space he omitted.
You are given a string s with 12 letters. Output the string putting a single space between the fi... | {
"input": [],
"output": []
} | {
"input": [
"POSTGRADUATE",
"ABCDEFGHIJKL",
"CODEFESTIVAL"
],
"output": [
"POST GRADUATE",
"ABCD EFGHIJKL",
"CODE FESTIVAL"
]
} | {
"input": [
"ETAUDARGTSOP",
"AACDEFGHIJKL",
"COCEFESTIVAL",
"POSTGRADUATF",
"ALCDEFGHIJKA",
"COCEFESTIV@L",
"POSTGRAUDATF",
"AKJIHGFEDCLA",
"L@VITSEFECOC",
"POSTGRATDATF",
"GKJIHAFEDCLA",
"L@VITREFECOC",
"PRSTGOAUDATF",
"GFJIHAKEDCLA",
"L@VITREFFCOC",
"... |
p00080 Third Root | The solution of $ x ^ 3 = q $ is to calculate the recurrence formula $ x_ {n + 1} = x_n-\ frac {x_ {n} ^ 3 --q} {3x_ {n} ^ 2} $ It can be calculated approximately with.
Put a positive number $ \ frac {q} {2} $ in $ x_1 $
$ x_2 = x_1-\ frac {x_ {1} ^ 3 --q} {3x_ {1} ^ 2} $, $ x_3 = x_2-\ frac {x_ {2} ^ 3 --q} {3x_ {2}... | {
"input": [],
"output": []
} | {
"input": [
"15\n15\n-1"
],
"output": [
"2.466212\n2.466212"
]
} | {
"input": [
"15\n29\n-1",
"15\n31\n-1",
"15\n47\n-1",
"15\n19\n-1",
"15\n33\n-1",
"15\n43\n-1",
"15\n84\n-1",
"15\n10\n-1",
"15\n55\n-1",
"15\n99\n-1",
"15\n8\n-1",
"15\n153\n-1",
"15\n3\n-1",
"15\n62\n-1",
"15\n123\n-1",
"15\n194\n-1",
"15\n35\n-1"... |
p00212 Highway Express Bus | Mr. A is planning to travel alone on a highway bus (hereinafter referred to as "bus") during his high school holidays. First, Mr. A chose the town he wanted to visit the most and made it his destination. Next, you have to decide the route to transfer the bus from the departure point to the destination. When connecting,... | {
"input": [],
"output": []
} | {
"input": [
"1 3 3 1 3\n1 3 2000\n1 2 1000\n2 3 1000\n2 3 3 1 3\n1 3 2300\n1 2 1000\n2 3 1200\n2 6 6 5 1\n1 2 1500\n1 3 4500\n2 6 2000\n5 4 1000\n6 4 2200\n3 5 3000\n0 0 0 0 0"
],
"output": [
"1000\n1100\n3750"
]
} | {
"input": [
"1 3 3 1 3\n1 3 2000\n1 2 1000\n2 3 1001\n2 3 3 1 3\n1 3 2300\n1 2 1000\n2 3 1200\n2 6 6 5 1\n1 2 1500\n1 3 4500\n2 6 2000\n5 4 1000\n6 4 2200\n3 5 3000\n0 0 0 0 0",
"1 3 3 1 3\n1 3 2000\n1 2 1000\n2 3 1000\n2 3 3 1 3\n1 3 2300\n1 2 1000\n2 3 1200\n2 6 6 5 1\n1 2 26\n1 3 4500\n2 6 2000\n5 4 1000\... |
p00372 Party | The students in a class in Akabe high-school define the relation “acquaintance” as:
* If A and B are friends, then A is acquainted with B.
* If A and B are friends and B is acquainted with C, then A is acquainted with C.
They define the relation “companion” as:
* Suppose A is acquainted with B, and two classmates ... | {
"input": [],
"output": []
} | {
"input": [
"3 2\n0 1\n1 2",
"7 8\n0 1\n1 2\n1 3\n2 3\n0 4\n4 5\n4 6\n5 6"
],
"output": [
"2",
"6"
]
} | {
"input": [
"3 2\n1 1\n1 2",
"7 3\n0 1\n1 2\n1 3\n2 3\n0 4\n4 5\n4 6\n5 6",
"4 3\n0 1\n1 2\n1 3\n2 3\n0 3\n4 5\n4 6\n5 6",
"5 2\n1 1\n1 2",
"7 8\n0 1\n1 2\n1 3\n3 3\n0 4\n4 5\n4 6\n5 6",
"7 5\n0 1\n1 2\n1 3\n2 3\n0 3\n4 5\n2 6\n5 11",
"10 0\n2 2\n6 2\n2 5\n0 9\n-1 3\n4 0\n7 6\n8 1",
"... |
p00589 Extraordinary Girl II | She loves e-mail so much! She sends e-mails by her cellular phone to her friends when she has breakfast, she talks with other friends, and even when she works in the library! Her cellular phone has somewhat simple layout (Figure 1). Pushing button 1 once displays a character (’), pushing
<image>
it twice in series di... | {
"input": [],
"output": []
} | {
"input": [
"666660666\n44444416003334446633111\n20202202000333003330333"
],
"output": [
"No\nI'm fine.\naaba f ff"
]
} | {
"input": [
"666660666\n62238520449600706121638\n20202202000333003330333",
"666660666\n62238520449600706121638\n20470251257982382367886",
"666660666\n79768964391256325078385\n20470251257982382367886",
"666660666\n79768964391256325078385\n25978567800744130697792",
"666660666\n559999747734406459983... |
p00726 The Genome Database of All Space Life | In 2300, the Life Science Division of Federal Republic of Space starts a very ambitious project to complete the genome sequencing of all living creatures in the entire universe and develop the genomic database of all space life. Thanks to scientific research over many years, it has been known that the genome of any spe... | {
"input": [],
"output": []
} | {
"input": [
"ABC 3\nABC 0\n2(4(AB)3(XY))10C 30\n1000(1000(1000(1000(1000(1000(NM)))))) 999999\n0 0"
],
"output": [
"0\nA\nC\nM"
]
} | {
"input": [
"ABC 3\nABC 1\n2(4(AB)3(XY))10C 30\n1000(1000(1000(1000(1000(1000(NM)))))) 999999\n0 0",
"ABC 3\nABC 0\n2(4(AB)3(XY))10C 3\n1000(1000(1000(1000(1000(1000(NM)))))) 999999\n0 0",
"ABC 3\nABC 2\n2(4(AB)3(XY))10C 30\n1000(1000(1000(1000(1000(1000(NM)))))) 999999\n0 0",
"ABC 3\nABC 0\n2(4(AB)3... |
p00866 Stopped Watches | In the middle of Tyrrhenian Sea, there is a small volcanic island called Chronus. The island is now uninhabited but it used to be a civilized island. Some historical records imply that the island was annihilated by an eruption of a volcano about 800 years ago and that most of the people in the island were killed by pyr... | {
"input": [],
"output": []
} | {
"input": [
"3\n8 8 18\n32 32 32\n57 2 57\n5\n49 3 49\n7 30 44\n27 21 21\n33 56 56\n21 46 4\n3\n45 52 28\n36 26 36\n20 55 50\n10\n33 8 39\n50 57 43\n35 21 12\n21 17 11\n16 21 58\n45 40 53\n45 30 53\n39 1 8\n55 48 30\n7 48 15\n0"
],
"output": [
"00:00:00 00:00:10\n06:14:56 06:32:09\n07:27:37 07:32:02\n05:... | {
"input": [
"3\n8 8 18\n32 32 32\n57 2 57\n5\n49 3 49\n7 30 44\n27 21 21\n33 56 56\n21 46 4\n3\n45 52 28\n36 26 36\n40 55 50\n10\n33 8 39\n50 57 43\n35 21 12\n21 17 11\n16 21 58\n45 40 53\n45 30 53\n39 1 8\n55 48 30\n7 48 15\n0",
"3\n8 8 18\n32 32 32\n57 2 57\n5\n49 3 49\n7 30 44\n27 21 21\n33 56 56\n21 46 4... |
p00997 Dungeon (II) | You are involved in the development of a certain game. The game is for players to explore randomly generated dungeons. As a specification of the game, I want to show the player the danger level of the dungeon in advance and select whether to search for the generated dungeon or to regenerate a new dungeon.
There are n ... | {
"input": [],
"output": []
} | {
"input": [
"4\n0 1 3\n1 2 5\n1 3 2",
"6\n0 2 5\n2 1 1\n2 3 10\n3 5 4\n3 4 2"
],
"output": [
"23",
"111"
]
} | {
"input": [
"6\n0 2 5\n2 1 1\n2 3 10\n3 5 2\n3 4 2",
"6\n0 2 5\n2 1 0\n2 3 10\n3 5 2\n3 4 2",
"4\n0 1 3\n0 2 5\n1 3 2",
"6\n0 2 5\n2 1 1\n2 3 6\n3 5 4\n3 4 2",
"6\n0 2 5\n2 1 1\n2 3 18\n3 5 2\n3 4 2",
"6\n0 2 5\n2 1 1\n2 3 6\n3 5 7\n3 4 2",
"6\n0 2 5\n3 1 1\n2 3 18\n3 5 2\n3 4 2",
"6\... |
p01129 Data Center on Fire | It's a little future story from now on. Recording devices with high-density storage and long-term storage have been developed, but the speed at which content is produced is unusually high, so a data center was established. When the data center was first established, it was a small building, but due to repeated expansio... | {
"input": [],
"output": []
} | {
"input": [
"5 2\n5000\n10 20 0 30 5\n10 1000 6 1\n20 500 8 1\n3 40 25 30\n0 0"
],
"output": [
"50 84.000"
]
} | {
"input": [
"5 2\n5000\n10 20 0 46 5\n10 1000 6 1\n20 500 8 1\n3 40 25 30\n0 0",
"5 2\n5000\n10 20 0 46 5\n10 1000 6 1\n20 500 8 1\n3 40 25 58\n0 0",
"5 2\n5000\n18 20 0 46 5\n10 1000 6 1\n20 500 8 1\n3 40 25 58\n0 0",
"5 2\n4999\n18 20 0 46 10\n10 1000 6 1\n20 500 8 1\n3 40 25 58\n0 0",
"5 2\n49... |
p01268 Matsuzaki Number | Professor Matsuzaki is a scientist studying the truth of the universe. Life, the universe, all the answers are said to be 42, but Professor Matsuzaki thinks that this alone is not enough to elucidate the truth of the universe. Professor Matsuzaki believes that the truth of the universe is represented by a function cons... | {
"input": [],
"output": []
} | {
"input": [
"0 55\n0 1\n0 2\n0 3\n10 1\n10 2\n10 3\n10 4\n10 5\n10 6\n11 1\n11 2\n11 3\n100000 100\n-1 -1"
],
"output": [
"42\n4\n5\n6\n22\n24\n26\n28\n30\n30\n26\n30\n32\n200274"
]
} | {
"input": [
"0 55\n0 1\n0 2\n0 3\n10 1\n10 2\n10 3\n10 4\n10 5\n10 6\n11 1\n11 2\n11 3\n100001 100\n-1 -1",
"0 55\n0 1\n0 2\n0 3\n10 1\n10 2\n10 3\n10 4\n10 5\n10 1\n11 1\n11 2\n11 3\n100001 100\n-1 -1",
"0 55\n0 1\n0 2\n0 3\n10 1\n10 2\n10 3\n10 4\n10 5\n19 6\n11 1\n11 2\n11 3\n100000 100\n-1 -1",
"... |
p01438 Butterfly | Claire is a man-eater. She's a real man-eater. She's going around with dozens of guys. She's dating all the time. And one day she found some conflicts in her date schedule. D'oh!
So she needs to pick some dates and give the others up. The dates are set by hours like 13:00 to 15:00. She may have more than one date with... | {
"input": [],
"output": []
} | {
"input": [
"2\n2 100\n10 12\n14 16\n2 200\n12 13\n18 20\n4\n1 100\n6 22\n1 1000\n6 22\n1 10000\n6 22\n1 100000\n6 22\n16\n1 100000000\n6 7\n1 100000000\n7 8\n1 100000000\n8 9\n1 100000000\n9 10\n1 100000000\n10 11\n1 100000000\n11 12\n1 100000000\n12 13\n1 100000000\n13 14\n1 100000000\n14 15\n1 100000000\n15 1... | {
"input": [
"2\n2 100\n10 12\n14 16\n2 200\n12 13\n18 20\n4\n1 100\n6 22\n1 1000\n6 22\n1 10000\n6 22\n1 100000\n6 22\n16\n1 100000000\n6 7\n1 100000000\n7 8\n1 100000000\n8 9\n1 110000000\n9 10\n1 100000000\n10 11\n1 100000000\n11 12\n1 100000000\n12 13\n1 100000000\n13 14\n1 100000000\n14 15\n1 100000000\n15 1... |
p01585 Mickle's Beam | Major Mickle is commanded to protect a secret base which is being attacked by N tanks. Mickle has an ultimate laser rifle called Mickle's beam. Any object shot by this beam will be immediately destroyed, and there is no way for protection. Furthermore, the beam keeps going through even after destroying objects. The bea... | {
"input": [],
"output": []
} | {
"input": [
""
],
"output": [
""
]
} | {
"input": [],
"output": []
} |
p01744 Dense Amidakuji | There is an Amidakuji that consists of w vertical bars and has a height (the number of steps to which horizontal bars can be added) of h. w is an even number. Of the candidates for the place to add the horizontal bar of this Amidakuji, the ath from the top and the bth from the left are called (a, b). (When a horizontal... | {
"input": [],
"output": []
} | {
"input": [
"4 4 1\n3 3",
"10 6 10\n10 4\n4 4\n5 1\n4 2\n7 3\n1 3\n2 4\n8 2\n7 5\n7 1"
],
"output": [
"2\n3\n4\n1",
"1\n4\n3\n2\n5\n6"
]
} | {
"input": [
"8 4 1\n3 3",
"10 6 10\n10 4\n4 4\n5 1\n4 2\n7 3\n1 3\n2 4\n8 2\n3 5\n7 1",
"10 6 10\n10 4\n4 4\n5 1\n6 2\n7 3\n1 3\n2 4\n8 2\n7 5\n7 1",
"8 4 0\n3 3",
"3 4 0\n5 3",
"4 4 0\n3 3",
"8 2 0\n3 3",
"4 4 1\n3 1",
"10 6 10\n10 4\n4 2\n5 1\n4 2\n7 3\n1 3\n2 4\n8 2\n7 5\n7 1",... |
p01884 Similarity of Subtrees | Example
Input
5
1 2
1 3
1 4
1 5
Output
6 | {
"input": [],
"output": []
} | {
"input": [
"5\n1 2\n1 3\n1 4\n1 5"
],
"output": [
"6"
]
} | {
"input": [
"5\n1 2\n1 3\n1 4\n0 5",
"5\n2 2\n1 3\n1 4\n0 3",
"5\n1 2\n1 2\n1 4\n1 5",
"5\n1 3\n1 3\n3 4\n0 5",
"5\n2 2\n2 3\n1 4\n0 5",
"5\n4 2\n1 3\n1 4\n1 4",
"5\n1 2\n2 3\n1 4\n1 5",
"5\n1 2\n1 3\n1 4\n0 2",
"5\n1 2\n1 3\n1 4\n0 3",
"5\n1 3\n1 3\n1 4\n0 5",
"5\n1 3\n1 ... |
p02021 Working | G: Working
Kou decided to do the same number of jobs every day for the next $ N $.
$ A_i $ jobs are added on the $ i $ day of the $ N $ day.
Mr. Kou has no work to do now, and he doesn't have to finish all the work by the $ N $ day.
How many jobs can you do in a day?
However, Mr. Kou is excellent, so he can do as ... | {
"input": [],
"output": []
} | {
"input": [
"5\n4 2 5 3 1"
],
"output": [
"3"
]
} | {
"input": [
"5\n4 2 5 3 0",
"5\n14 3 0 1 -1",
"5\n19 3 0 2 -1",
"5\n8 1 1 -1 0",
"5\n48 -2 1 -2 -1",
"5\n48 0 1 -2 -2",
"5\n78 0 -2 -1 -3",
"5\n6 0 -2 0 -3",
"5\n-1 6 0 3 0",
"5\n-2 11 1 1 0",
"5\n-4 2 -2 -2 2",
"5\n2 -12 1 -1 16",
"5\n0 -12 2 -1 32",
"5\n-2 -1... |
p02163 How old are you | Problem
It seems that a magician with a smoky smell will show off his magic.
"Now, think of one favorite integer."
You decide to think of your counting years in your head.
The magician has thrown the query $ N $ times.
Each query is one of the following:
1. "Multiply the number you have in mind by $ x $."
2. "Add ... | {
"input": [],
"output": []
} | {
"input": [
"3\n1 2\n2 10\n3 8",
"10\n1 10\n1 10\n1 10\n1 10\n1 10\n1 10\n1 10\n1 10\n1 10\n1 10"
],
"output": [
"-2 2",
"0 10000000000"
]
} | {
"input": [
"3\n1 2\n2 10\n2 8",
"10\n1 10\n1 10\n1 10\n1 10\n2 10\n1 10\n1 10\n1 10\n1 10\n1 10",
"3\n1 2\n1 10\n2 8",
"3\n1 1\n1 10\n2 8",
"3\n1 1\n1 10\n2 13",
"3\n1 1\n1 13\n2 13",
"3\n1 1\n1 13\n3 13",
"3\n1 0\n1 13\n3 13",
"3\n1 0\n1 7\n1 13",
"3\n1 0\n1 7\n2 13",
"3... |
p02304 Segment Intersections: Manhattan Geometry | For given $n$ segments which are parallel to X-axis or Y-axis, find the number of intersections of them.
Constraints
* $1 \leq n \leq 100,000$
* $ -1,000,000,000 \leq x_1, y_1, x_2, y_2 \leq 1,000,000,000$
* Two parallel segments never overlap or touch.
* The number of intersections $\leq 1,000,000$
Input
In the fi... | {
"input": [],
"output": []
} | {
"input": [
"6\n2 2 2 5\n1 3 5 3\n4 1 4 4\n5 2 7 2\n6 1 6 3\n6 5 6 7"
],
"output": [
"3"
]
} | {
"input": [
"6\n2 2 2 5\n1 3 5 3\n4 1 4 4\n5 2 7 2\n6 1 6 3\n4 5 6 7",
"6\n2 2 2 5\n1 3 5 3\n4 1 4 4\n2 2 7 2\n6 1 6 3\n6 5 6 7",
"6\n2 2 2 5\n1 3 2 3\n4 1 4 4\n5 2 7 2\n6 1 6 3\n4 5 6 7",
"6\n2 2 2 5\n1 3 10 3\n4 1 4 4\n2 2 7 2\n6 1 6 3\n6 5 6 7",
"6\n2 2 2 5\n1 3 2 3\n4 1 4 4\n8 2 7 2\n6 1 6 3\... |
p02451 Binary Search | For a given sequence $A = \\{a_0, a_1, ..., a_{n-1}\\}$ which is sorted by ascending order, find a specific value $k$ given as a query.
Constraints
* $1 \leq n \leq 100,000$
* $1 \leq q \leq 200,000$
* $0 \leq a_0 \leq a_1 \leq ... \leq a_{n-1} \leq 1,000,000,000$
* $0 \leq k_i \leq 1,000,000,000$
Input
The input i... | {
"input": [],
"output": []
} | {
"input": [
"4\n1 2 2 4\n3\n2\n3\n5"
],
"output": [
"1\n0\n0"
]
} | {
"input": [
"4\n1 2 2 4\n3\n2\n3\n6",
"4\n1 1 2 4\n3\n0\n3\n8",
"4\n0 1 2 7\n3\n0\n7\n10",
"4\n0 1 2 6\n3\n0\n3\n6",
"4\n1 2 1 4\n2\n0\n3\n8",
"4\n0 1 2 7\n1\n0\n5\n3",
"4\n0 2 3 4\n3\n2\n3\n4",
"4\n0 1 2 7\n1\n-1\n5\n3",
"4\n0 2 1 3\n3\n-1\n3\n6",
"4\n0 2 2 1\n3\n4\n3\n0",
... |
ccaurcc5 | An integer is said to be prime palindrome if it is a prime number and its reverse is same as that of the original number.
Your task is to output the sum of all such prime palindromes lies between the range N and M (N and M both are inclusive).
Input description.
The first line of input contains an integer Tdenoting... | {
"input": [],
"output": []
} | {
"input": [
"1\n1 101"
],
"output": [
"129"
]
} | {
"input": [
"1\n1 111",
"1\n2 100",
"1\n0 001",
"1\n0 010",
"1\n3 110",
"1\n3 010",
"1\n3 011",
"1\n4 110",
"1\n8 110",
"1\n6 011",
"1\n4 100",
"1\n6 110",
"1\n6 010",
"1\n13 110",
"1\n11 011",
"1\n4 010",
"1\n2 111",
"1\n2 110",
"1\n0 100",... |
csixievr | Now a days it is possible to access particular website without typing it's full name. This helps in reducing the typing time. So in this you are given a website name as input and you have to cut short it's name and print the shoretd length of the website. The shortened version of the website name will be such that a us... | {
"input": [],
"output": []
} | {
"input": [
"2\nwww.google.com\nwww.yahoo.com"
],
"output": [
"7/14\n6/13"
]
} | {
"input": [
"2\nwww.moogle.cog\nwww.yahoo.com",
"2\nwww.google.com\nwww.yaioo.com",
"2\nwww.gnogle.com\nwww.yaioo.com",
"2\nwww.gnogle.com\ncww.y`ioo.wom",
"2\ngoc.elwoow.mgx\nmoc.onhay.www",
"2\nxgm.woowcf.log\nmoc.onhay.www",
"2\nwww.gnogld.com\nlow.ooiay.vwc",
"2\nwww.gnogld.com\nc... |
high | In some countries building highways takes a lot of time... Maybe that's because there are many possiblities to construct a network of highways and engineers can't make up their minds which one to choose. Suppose we have a list of cities that can be connected directly. Your task is to count how many ways there are to bu... | {
"input": [],
"output": []
} | {
"input": [
"4\n4 5\n3 4\n4 2\n2 3\n1 2\n1 3\n\n2 1\n2 1\n\n1 0\n\n3 3\n1 2\n2 3\n3 1"
],
"output": [
"8\n1\n1\n3"
]
} | {
"input": [],
"output": []
} |
mixtures | Harry Potter has n mixtures in front of him, arranged in a row.Each mixture has one of 100 different colors (colors have numbers from 0 to 99).
He wants to mix all these mixtures together. At each step, he is going to take two mixtures that stand next to each other and mix them together, and put the resulting mixture ... | {
"input": [],
"output": []
} | {
"input": [
"2\n18 19\n3\n40 60 20"
],
"output": [
"342\n2400\n"
]
} | {
"input": [
"2\n18 19\n3\n40 60 36",
"2\n18 28\n3\n40 60 36",
"2\n18 2\n3\n40 60 36",
"2\n18 23\n3\n40 60 37",
"2\n18 1\n3\n40 60 36",
"2\n18 11\n3\n40 60 37",
"2\n24 11\n3\n40 60 37",
"2\n24 8\n3\n40 60 37",
"2\n29 19\n3\n40 60 36",
"2\n10 28\n3\n40 60 36",
"2\n8 2\n3\n40... |
repstr | Given a string S (containing at most 10^5 lowercase English letters). You are requested to find out from continuous substrings a string having length from L to H, which appears the most times; if there are more than one answer, find the most length.
Input
There are several test cases (fifteen at most), each formed as ... | {
"input": [],
"output": []
} | {
"input": [
"3 5\naabcbcbca\n3 5\nbaaaababababbababbab\n1 4\nabcd\n0 0"
],
"output": [
"2 4\n6 3\n1 4"
]
} | {
"input": [],
"output": []
} |
tsx02 | Byteland is a country whose population squares every year. The president of Byteland is aware of the situation and wants to take proper steps to control the population. For this he wants to estimate the population of the country for a given year. As President is weak in Math, He needs your help to solve this problem.
... | {
"input": [],
"output": []
} | {
"input": [
"2\n5 2002\n3 2000"
],
"output": [
"625\n3\n"
]
} | {
"input": [
"2\n5 2955\n3 2000",
"2\n7 2955\n3 2000",
"2\n7 2955\n6 2000",
"2\n7 3525\n6 1480",
"2\n6 3525\n6 1480",
"2\n6 1343\n6 1480",
"2\n0 1419\n6 1480",
"2\n1 3405\n6 1480",
"2\n1 3171\n8 1075",
"2\n1 4734\n8 2055",
"2\n1 4734\n1 2055",
"2\n2 4135\n1 1308",
"... |
1252_E. Songwriter | Andi is a mathematician, a computer scientist, and a songwriter. After spending so much time writing songs, he finally writes a catchy melody that he thought as his best creation. However, the singer who will sing the song/melody has a unique vocal range, thus, an adjustment may be needed.
A melody is defined as a seq... | {
"input": [],
"output": []
} | {
"input": [
"16 1 8 6\n1 3 5 6 7 8 9 10 3 7 8 9 10 11 12 12\n",
"16 1 8 6\n1 3 5 6 7 8 9 10 3 7 8 9 10 11 12 13\n",
"16 1 10 10\n1 3 5 6 7 8 9 10 3 7 8 9 1 11 12 13\n"
],
"output": [
"\n1 2 3 4 5 6 7 8 2 3 4 5 6 7 8 8\n",
"\n-1\n",
"\n1 2 3 4 5 6 7 8 1 2 3 4 1 2 3 4\n"
]
} | {
"input": [],
"output": []
} |
1494_E. A-Z Graph | You are given a directed graph consisting of n vertices. Each directed edge (or arc) labeled with a single character. Initially, the graph is empty.
You should process m queries with it. Each query is one of three types:
* "+ u v c" — add arc from u to v with label c. It's guaranteed that there is no arc (u, v) in... | {
"input": [],
"output": []
} | {
"input": [
"3 11\n+ 1 2 a\n+ 2 3 b\n+ 3 2 a\n+ 2 1 b\n? 3\n? 2\n- 2 1\n- 3 2\n+ 2 1 c\n+ 3 2 d\n? 5\n"
],
"output": [
"\nYES\nNO\nYES\n"
]
} | {
"input": [
"3 11\n+ 1 2 a\n+ 2 3 c\n+ 3 2 a\n+ 2 1 b\n? 3\n? 2\n- 2 1\n- 3 2\n+ 2 1 c\n+ 3 2 d\n? 5\n",
"3 11\n+ 1 2 a\n+ 1 3 c\n+ 3 2 a\n+ 2 1 b\n? 6\n? 4\n- 2 1\n- 3 2\n+ 2 1 c\n+ 3 2 d\n? 5\n",
"3 11\n+ 1 2 a\n+ 1 3 c\n+ 3 2 a\n+ 2 1 b\n? 6\n? 5\n- 2 1\n- 3 2\n+ 2 1 c\n+ 3 2 d\n? 5\n",
"3 11\n+ 1... |
314_A. Sereja and Contest | During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants.
Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2, ..., the... | {
"input": [],
"output": []
} | {
"input": [
"5 0\n5 3 4 1 2\n",
"10 -10\n5 5 1 7 5 1 2 4 9 2\n"
],
"output": [
"2\n3\n4\n",
"2\n4\n5\n7\n8\n9\n"
]
} | {
"input": [
"5 0\n5 3 5 1 2\n",
"10 -10\n5 4 1 7 5 1 2 4 9 2\n",
"10 -10\n5 4 1 7 5 1 1 4 9 2\n",
"10 -4\n5 4 1 7 5 1 2 4 9 2\n",
"10 -13\n5 7 1 1 5 1 1 4 9 2\n",
"10 -6\n5 2 1 9 5 2 4 4 9 2\n",
"10 -10\n4 4 1 7 5 1 1 1 9 2\n",
"10 -13\n5 1 1 7 5 1 1 4 9 2\n",
"10 -6\n5 2 1 8 5 2 ... |
575_I. Robots protection | Company "Robots industries" produces robots for territory protection. Robots protect triangle territories — right isosceles triangles with catheti parallel to North-South and East-West directions.
Owner of some land buys and sets robots on his territory to protect it. From time to time, businessmen want to build offic... | {
"input": [],
"output": []
} | {
"input": [
"17 10\n1 1 3 2 4\n1 3 10 3 7\n1 2 6 8 2\n1 3 9 4 2\n2 4 4\n1 4 15 10 6\n2 7 7\n2 9 4\n2 12 2\n2 13 8\n"
],
"output": [
"2\n2\n2\n0\n1\n"
]
} | {
"input": [
"17 10\n1 1 3 2 4\n1 3 10 3 7\n1 2 6 8 2\n1 3 9 4 2\n2 4 4\n1 4 15 10 6\n2 7 7\n2 9 6\n2 12 2\n2 13 8\n",
"17 10\n1 1 3 2 4\n1 3 10 3 7\n1 2 6 8 2\n1 3 9 4 2\n2 4 4\n1 4 15 10 6\n2 7 7\n2 9 3\n2 12 2\n2 13 8\n",
"17 10\n1 1 3 2 4\n1 3 10 3 7\n1 2 6 8 2\n1 3 9 3 2\n2 4 4\n1 4 15 15 6\n2 7 7\n2... |
chotu-and-hug-day | "Too close Yet too far"
It is well known that our chotu is chotu (Height-wise :P). On Hug day his short height is creating problems for him as most of the girls are taller than him so he can't hug them properly. To overcome the problem he has decided that he shall hug the girl whose height is closest to him.
Given th... | {
"input": [],
"output": []
} | {
"input": [
"2\n5 4\n10 1 2 3 6 \n4 8\n8 8 8 8\n\nSAMPLE"
],
"output": [
"1\n0"
]
} | {
"input": [
"2\n5 4\n10 1 2 4 6 \n4 8\n8 8 8 8\n\nSAMPLE",
"2\n5 4\n10 1 2 7 6 \n4 8\n8 8 8 8\n\nSAMPLE",
"2\n5 0\n10 1 2 7 6 \n4 8\n8 8 8 8\n\nSAMPLE",
"2\n4 4\n10 0 2 6 6 \n1 15\n8 8 8 8\n\nASMPLE",
"2\n4 4\n10 0 2 6 6 \n4 13\n8 1 0 6\n\nBSMPLE",
"2\n4 8\n10 0 2 9 6 \n4 13\n8 1 0 6\n\nBSMPL... |
x-game | Rohan is programmer. He designed a game called X-Game. In this game, there are N number of soldiers, represented in terms of their powers. The algorithm of this game arranges all soldiers in all possible different groups.
Every group will fight among the soldiers of the same group and after the fight ends, the remain... | {
"input": [],
"output": []
} | {
"input": [
"1\n3\n1 2 3\n\nSAMPLE"
],
"output": [
"12\n"
]
} | {
"input": [
"1\n3\n1 2 3\n\nSAMPME",
"1\n3\n1 2 -1\n\nSAMPME",
"1\n3\n1 0 0\n\nSAMPME",
"1\n3\n2 4 3\n\nSAMPME",
"1\n3\n2 4 0\n\nEMPMAS",
"1\n3\n1 4 0\n\nEMPMAS",
"1\n3\n4 4 0\n\nEMPSAN",
"1\n3\n4 14 0\n\nEMPSAN",
"1\n3\n0 2 0\n\nEMPSAN",
"1\n3\n0 0 0\n\nEMPSAN",
"1\n2\n1 ... |
p02637 AtCoder Grand Contest 046 - Permutation Cover | Given are an integer K and integers a_1,\dots, a_K. Determine whether a sequence P satisfying below exists. If it exists, find the lexicographically smallest such sequence.
* Every term in P is an integer between 1 and K (inclusive).
* For each i=1,\dots, K, P contains a_i occurrences of i.
* For each term in P, there... | {
"input": [],
"output": []
} | {
"input": [
"5\n3 1 4 1 5",
"3\n2 4 3",
"4\n3 2 3 2"
],
"output": [
"-1",
"2 1 3 2 2 3 1 2 3",
"1 2 3 4 1 3 1 2 4 3"
]
} | {
"input": [
"5\n1 1 4 1 5",
"3\n1 1 1",
"3\n1 1 2",
"3\n1 2 2",
"3\n2 1 2",
"3\n2 1 1",
"3\n2 2 4",
"3\n2 4 4",
"3\n2 2 1",
"5\n1 1 1 1 1",
"5\n1 1 1 1 2",
"3\n1 4 3",
"4\n0 2 3 2",
"5\n1 1 2 1 5",
"3\n0 4 3",
"4\n0 0 3 2",
"5\n1 1 2 0 5",
"3\n1... |
p02768 AtCoder Beginner Contest 156 - Bouquet | Akari has n kinds of flowers, one of each kind.
She is going to choose one or more of these flowers to make a bouquet.
However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.
How many different bouquets are there that Akari can make?
Find the count modulo (10^9 + 7).
Here,... | {
"input": [],
"output": []
} | {
"input": [
"4 1 3",
"1000000000 141421 173205"
],
"output": [
"7",
"34076506"
]
} | {
"input": [
"4 0 3",
"1000000000 32745 173205",
"1000010000 32745 173205",
"1001010000 32745 173205",
"1001010000 32745 41728",
"1000000000 60937 173205",
"1000010001 32745 173205",
"1001011000 32745 173205",
"1011010000 32745 41728",
"1000010101 32745 173205",
"1001011000... |
p02903 AtCoder Grand Contest 038 - 01 Matrix | We have a square grid with H rows and W columns. Snuke wants to write 0 or 1 in each of the squares. Here, all of the following conditions have to be satisfied:
* For every row, the smaller of the following is A: the number of 0s contained in the row, and the number of 1s contained in the row. (If these two numbers ar... | {
"input": [],
"output": []
} | {
"input": [
"3 3 1 1",
"1 5 2 0"
],
"output": [
"100\n010\n001",
"01010"
]
} | {
"input": [
"3 3 0 1",
"1 5 2 -1",
"3 6 0 1",
"1 5 4 -1",
"3 10 0 1",
"2 5 4 -1",
"2 6 4 -1",
"1 5 0 0",
"3 3 0 2",
"1 5 2 1",
"6 6 0 1",
"3 4 0 1",
"1 10 2 -1",
"3 9 -2 1",
"2 6 5 -1",
"6 10 -2 1",
"1 10 -4 1",
"3 5 -1 1",
"1 5 1 0",
"3... |
p03038 AtCoder Beginner Contest 127 - Integer Cards | You have N cards. On the i-th card, an integer A_i is written.
For each j = 1, 2, ..., M in this order, you will perform the following operation once:
Operation: Choose at most B_j cards (possibly zero). Replace the integer written on each chosen card with C_j.
Find the maximum possible sum of the integers written o... | {
"input": [],
"output": []
} | {
"input": [
"10 3\n1 8 5 7 100 4 52 33 13 5\n3 10\n4 30\n1 4",
"3 2\n5 1 4\n2 3\n1 5",
"3 2\n100 100 100\n3 99\n3 99",
"11 3\n1 1 1 1 1 1 1 1 1 1 1\n3 1000000000\n4 1000000000\n3 1000000000"
],
"output": [
"338",
"14",
"300",
"10000000001"
]
} | {
"input": [
"10 3\n1 8 5 7 100 4 7 33 13 5\n3 10\n4 30\n1 4",
"3 2\n5 1 1\n2 3\n1 5",
"3 2\n100 100 100\n0 99\n3 99",
"11 3\n1 1 1 1 1 1 1 1 1 1 1\n3 1000000000\n4 1000000000\n3 1000000001",
"10 2\n0 8 5 7 100 4 7 33 24 5\n3 10\n4 30\n1 4",
"3 2\n5 1 1\n2 3\n1 7",
"10 2\n0 8 5 7 100 4 7 3... |
p03179 Educational DP Contest - Permutation | Let N be a positive integer. You are given a string s of length N - 1, consisting of `<` and `>`.
Find the number of permutations (p_1, p_2, \ldots, p_N) of (1, 2, \ldots, N) that satisfy the following condition, modulo 10^9 + 7:
* For each i (1 \leq i \leq N - 1), p_i < p_{i + 1} if the i-th character in s is `<`, a... | {
"input": [],
"output": []
} | {
"input": [
"20\n>>>><>>><>><>>><<>>",
"5\n<<<<",
"4\n<><"
],
"output": [
"217136290",
"1",
"5"
]
} | {
"input": [
"20\n>><<>>><>><>>><>>>>",
"20\n>><<>>><>>>>>><>>><",
"4\n<<>",
"20\n>>>><>>>>><<>>><<>>",
"20\n<>>><>>><>>>>>><<>>",
"20\n>><<>>><>>>><>>>>><",
"20\n<>>><>>>>>><<>>><>>",
"20\n>>>><>>><>>>>>><<<>",
"20\n>><<>>><>>><>><>>>>",
"20\n>><>>><><>>>>><>>><",
"20\n>><... |
p03327 AtCoder Beginner Contest 099 - ABD | Decades have passed since the beginning of AtCoder Beginner Contest.
The contests are labeled as `ABC001`, `ABC002`, ... from the first round, but after the 999-th round `ABC999`, a problem occurred: how the future rounds should be labeled?
In the end, the labels for the rounds from the 1000-th to the 1998-th are dec... | {
"input": [],
"output": []
} | {
"input": [
"1000",
"1481",
"999"
],
"output": [
"ABD",
"ABD",
"ABC"
]
} | {
"input": [
"1001",
"300",
"1506",
"1101",
"972",
"260",
"1111",
"842",
"352",
"0111",
"793",
"98",
"0011",
"1539",
"47",
"0010",
"2343",
"42",
"1010",
"4600",
"33",
"0000",
"7410",
"56",
"1100",
"2152",
"107"... |
p03483 AtCoder Regular Contest 088 - Papple Sort | You are given a string S consisting of lowercase English letters. Determine whether we can turn S into a palindrome by repeating the operation of swapping two adjacent characters. If it is possible, find the minimum required number of operations.
Constraints
* 1 \leq |S| \leq 2 × 10^5
* S consists of lowercase Englis... | {
"input": [],
"output": []
} | {
"input": [
"snuke",
"ataatmma",
"eel"
],
"output": [
"-1",
"4",
"1"
]
} | {
"input": [
"snkue",
"aatatmma",
"aatmtmaa",
"eoe",
"efl",
"snkuf",
"lfe",
"fnkus",
"aatltmaa",
"fle",
"suknf",
"aamtltaa",
"gle",
"sunkf",
"aamaltta",
"gel",
"tunkf",
"attlamaa",
"gfl",
"uunkf",
"alttamaa",
"egl",
"fknuu",
... |
p03648 AtCoder Regular Contest 079 - Decrease (Contestant ver.) | We have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller.
* Determine the largest element in the sequence (if there is more than one, choose one). Decrease the value of this element... | {
"input": [],
"output": []
} | {
"input": [
"0",
"1",
"1234567894848",
"2",
"3"
],
"output": [
"4\n3 3 3 3",
"3\n1 0 3",
"10\n1000 193 256 777 0 1 1192 1234567891011 48 425",
"2\n2 2",
"7\n27 0 0 0 0 0 0"
]
} | {
"input": [
"-1",
"4",
"2307894359683",
"8",
"-2",
"-4",
"-3",
"3500144313336",
"15",
"7",
"-7",
"-8",
"4048027520392",
"16",
"-6",
"-12",
"-11",
"2609800078127",
"6",
"-22",
"13",
"-9",
"4080169873978",
"11",
"-37",
... |
p03804 AtCoder Beginner Contest 054 - Template Matching | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.
A pixel is the smallest element of an image, and in this problem it is a square of size 1×1.
Also, the given images are binary images, and the color of each pixel is either white or bl... | {
"input": [],
"output": []
} | {
"input": [
"3 2\n#.#\n.#.\n#.#\n#.\n.#",
"4 1\n....\n....\n....\n....",
"3 2\n.#\n.#.\n.#\n.\n.#"
],
"output": [
"Yes",
"No",
"Yes"
]
} | {
"input": [
"3 2\n#.#\n.#.\n#-#\n#.\n.#",
"3 2\n-#\n.#.\n.#\n.\n.#",
"4 0\n....\n....\n....\n....",
"3 2\n#.#\n.\".\n#-#\n#.\n.#",
"4 1\n..-.\n....\n....\n....",
"3 2\n-#\n.#.\n#.\n.\n.#",
"3 2\n#.#\n.\".\n#-#\n$.\n.#",
"0 1\n..-.\n....\n....\n....",
"0 2\n#.#\n.\".\n#-#\n$.\n.#",... |
p03972 CODE FESTIVAL 2016 qual B - Gr-idian MST | On an xy plane, in an area satisfying 0 ≤ x ≤ W, 0 ≤ y ≤ H, there is one house at each and every point where both x and y are integers.
There are unpaved roads between every pair of points for which either the x coordinates are equal and the difference between the y coordinates is 1, or the y coordinates are equal and... | {
"input": [],
"output": []
} | {
"input": [
"4 3\n2\n4\n8\n1\n2\n9\n3",
"2 2\n3\n5\n2\n7"
],
"output": [
"60",
"29"
]
} | {
"input": [
"4 3\n2\n6\n8\n1\n2\n9\n3",
"2 2\n3\n6\n2\n7",
"0 3\n2\n6\n8\n1\n2\n9\n3",
"2 2\n3\n9\n2\n7",
"0 3\n2\n6\n13\n1\n2\n9\n3",
"2 2\n3\n16\n2\n7",
"2 2\n3\n32\n2\n7",
"2 2\n0\n32\n2\n7",
"0 3\n1\n6\n8\n1\n2\n9\n0",
"2 2\n-1\n32\n2\n7",
"0 3\n0\n6\n8\n1\n2\n9\n0",
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.