name stringlengths 2 112 | description stringlengths 29 13k | private_tests dict | public_tests dict | generated_tests dict |
|---|---|---|---|---|
p00252 Railway Ticket | To get on the Shinkansen, you need two tickets, a "ticket" and a "limited express ticket". These are separate tickets because some of the routes may not use the Shinkansen, but for routes that use only the Shinkansen, one ticket can be used as both a ticket and a limited express ticket. It may also be issued.
Automati... | {
"input": [],
"output": []
} | {
"input": [
"0 0 1"
],
"output": [
"Open"
]
} | {
"input": [
"0 0 0",
"1 1 0",
"1 0 0",
"0 1 0",
"0 0 0",
"0 1 0",
"1 0 0",
"1 1 0"
],
"output": [
"Close\n",
"Open\n",
"Close\n",
"Close\n",
"Close\n",
"Close\n",
"Close\n",
"Open\n"
]
} |
p00437 Quality Checking | problem
You are in charge of quality control at a machine manufacturing plant. This machine requires a power supply, a motor, and a cable as parts. The manufacturing plant has a power supply, b motors, and c cables, numbered from 1 to a, a + 1 to a + b, and a + b + 1 to a + b + c, respectively. attached. The trouble i... | {
"input": [],
"output": []
} | {
"input": [
"2 2 2\n4\n2 4 5 0\n2 3 6 0\n1 4 5 0\n2 3 5 1\n0 0 0"
],
"output": [
"2\n1\n1\n0\n1\n0"
]
} | {
"input": [
"2 2 2\n4\n2 4 5 0\n2 3 6 0\n1 4 5 0\n2 3 2 1\n0 0 0",
"2 2 2\n4\n2 4 5 0\n2 3 6 0\n1 4 5 0\n2 3 2 0\n0 0 0",
"3 2 2\n4\n2 4 5 0\n2 3 6 0\n1 4 5 0\n2 3 5 1\n0 0 0",
"2 2 2\n4\n3 4 5 0\n2 3 6 0\n1 4 4 1\n2 3 2 0\n0 0 0",
"2 2 2\n4\n2 4 5 0\n1 3 6 0\n1 4 5 0\n2 3 2 1\n0 0 0",
"3 2 2... |
p00629 Selecting Teams Advanced to Regional | In order to participate in the Asian Regional Qualifiers of the International Collegiate Programming Contest held every year in Japan, we must break through the strict domestic qualifiers.
Even though it is a university competition, multiple teams from one school will participate. Therefore, the following selection ru... | {
"input": [],
"output": []
} | {
"input": [
"6\n1 1 6 200\n2 1 6 300\n3 1 6 400\n4 2 5 1200\n5 1 5 1400\n6 3 4 800\n3\n777 1 5 300\n808 2 4 20\n123 3 6 500\n2\n2 1 3 100\n1 1 3 100\n0"
],
"output": [
"1\n2\n3\n4\n6\n123\n777\n808\n1\n2"
]
} | {
"input": [
"6\n1 1 6 200\n2 1 11 300\n3 1 6 400\n4 2 5 1200\n5 1 5 1400\n6 3 4 800\n3\n777 1 5 300\n808 2 4 20\n123 3 6 500\n2\n2 1 3 100\n1 1 3 100\n0",
"6\n1 1 6 200\n2 1 11 300\n3 0 6 400\n4 2 5 1200\n5 1 5 1400\n6 3 4 800\n3\n777 1 5 300\n808 2 4 20\n123 3 6 500\n2\n2 1 3 100\n1 1 3 100\n0",
"6\n1 1... |
p00773 Tax Rate Changed | Tax Rate Changed
VAT (value-added tax) is a tax imposed at a certain rate proportional to the sale price.
Our store uses the following rules to calculate the after-tax prices.
* When the VAT rate is x%, for an item with the before-tax price of p yen, its after-tax price of the item is p (100+x) / 100 yen, fractions ... | {
"input": [],
"output": []
} | {
"input": [
"5 8 105\n8 5 105\n1 2 24\n99 98 24\n12 13 26\n1 22 23\n1 13 201\n13 16 112\n2 24 50\n1 82 61\n1 84 125\n1 99 999\n99 1 999\n98 99 999\n1 99 11\n99 1 12\n0 0 0"
],
"output": [
"109\n103\n24\n24\n26\n27\n225\n116\n62\n111\n230\n1972\n508\n1004\n20\n7"
]
} | {
"input": [
"5 8 105\n8 5 105\n1 2 24\n4 98 24\n12 13 26\n1 22 23\n1 13 201\n13 16 112\n2 24 50\n1 82 61\n1 84 125\n1 99 999\n99 1 999\n98 99 999\n1 99 11\n99 1 12\n0 0 0",
"5 8 105\n8 5 105\n1 2 24\n4 98 24\n12 5 26\n1 22 23\n1 13 201\n13 16 112\n2 24 50\n1 82 61\n1 84 125\n1 99 999\n99 1 999\n98 99 999\n1 ... |
p00904 Ginkgo Numbers | We will define Ginkgo numbers and multiplication on Ginkgo numbers.
A Ginkgo number is a pair <m, n> where m and n are integers. For example, <1, 1>, <-2, 1> and <-3,-1> are Ginkgo numbers.
The multiplication on Ginkgo numbers is defined by <m, n> * <x, y> = <mx − ny, my + nx>. For example, <1, 1> * <-2, 1> = <-3,-1>... | {
"input": [],
"output": []
} | {
"input": [
"8\n10 0\n0 2\n-3 0\n4 2\n0 -13\n-4 1\n-2 -1\n3 -1"
],
"output": [
"C\nC\nP\nC\nC\nP\nP\nC"
]
} | {
"input": [
"8\n10 0\n0 2\n-3 1\n4 2\n0 -13\n-4 1\n-2 -1\n3 -1",
"8\n10 0\n0 2\n-3 1\n4 2\n0 -13\n-4 1\n-2 -1\n2 -1",
"8\n2 -1\n0 2\n-3 1\n4 2\n0 -13\n-4 1\n-2 -1\n2 -1",
"8\n2 -1\n0 3\n-3 1\n4 2\n0 -13\n-4 1\n-2 -1\n2 -1",
"8\n10 0\n0 3\n-3 0\n4 2\n0 -13\n-4 1\n-2 -1\n3 -1",
"8\n10 0\n0 2\n-... |
p01037 A White Wall | Background
The site of Mr. A's house, which lives in a certain city, is surrounded by white walls. Feeling unsatisfied with the wall, Mr. A decided to invite the children in the neighborhood to paint the wall freely. Ask the children to choose their favorite section of the wall and paint it. So how was the wall painte... | {
"input": [],
"output": []
} | {
"input": [
"4 2\n0 2\n1 2",
"10 3\n2 1\n4 1\n9 2",
"5 3\n0 1\n2 1\n3 1"
],
"output": [
"3 1",
"2 1\n1 2",
"2 1\n1 1"
]
} | {
"input": [
"1 2\n0 2\n1 2",
"4 3\n2 1\n4 1\n9 2",
"3 3\n0 1\n2 1\n3 1",
"4 2\n0 2\n1 4",
"10 3\n2 1\n4 1\n9 1",
"5 3\n0 1\n2 1\n5 1",
"10 3\n0 1\n4 1\n9 2",
"8 3\n4 1\n8 1\n11 3",
"10 3\n0 1\n7 1\n13 2",
"22 3\n1 1\n0 1\n9 2",
"8 3\n0 2\n0 3\n22 3",
"8 3\n0 4\n0 3\n22... |
p01171 Everlasting...? | Everlasting Sa-Ga, a new, hot and very popular role-playing game, is out on October 19, 2008. Fans have been looking forward to a new title of Everlasting Sa-Ga.
Little Jimmy is in trouble. He is a seven-year-old boy, and he obtained the Everlasting Sa-Ga and is attempting to reach the end of the game before his frien... | {
"input": [],
"output": []
} | {
"input": [
"10 15\n30 20\n0 0"
],
"output": [
"a\nb"
]
} | {
"input": [
"10 3\n30 20\n0 0",
"9 15\n30 20\n0 0",
"10 3\n44 33\n0 0",
"10 4\n11 70\n0 0",
"10 3\n8 20\n0 0",
"4 3\n8 20\n0 0",
"4 3\n12 20\n0 0",
"10 3\n30 33\n0 0",
"10 3\n8 35\n0 0",
"8 3\n8 20\n0 0",
"4 5\n12 20\n0 0",
"9 15\n30 3\n0 0",
"2 3\n44 33\n0 0",
... |
p01307 Addition Game | The cat Fabre came up with a simple game using addition and decided to try it with his friend Audrey, also in the cat.
The rules of the game are as follows. First of all, choose a suitable positive integer and start from there. Each player selects two adjacent digits from that number, calculates the sum, and replaces ... | {
"input": [],
"output": []
} | {
"input": [
"3\n1234\n5555\n9"
],
"output": [
"Audrey wins.\nFabre wins.\nAudrey wins."
]
} | {
"input": [
"3\n1234\n8371\n9",
"3\n1234\n1292\n9",
"3\n2133\n1292\n9",
"3\n1687\n10\n7",
"3\n1656\n10\n11",
"3\n3178\n10\n11",
"3\n1499\n29\n11",
"3\n49\n2\n14",
"3\n2133\n261\n9",
"3\n2133\n261\n7",
"3\n2258\n261\n7",
"3\n2258\n3\n7",
"3\n2915\n3\n7",
"3\n291... |
p01476 Range Minimum Query | Problem statement
There are real variables $ X_1, X_2, ... $, and some initial value is assigned. From now on, $ Q $ pieces of information will be given in order. The information given is one of the following two types.
* min $ \\ {X_ {a_i}, X_ {a_i + 1}, ..., X_ {b_i} \\} = y_i $.
* Substitute $ y_i $ for the variab... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 10 100 333\n0 100 1000 555",
"5\n0 1 2 8\n0 2 3 9\n0 2 2 11\n1 2 2 7\n0 1 3 7"
],
"output": [
"NO",
"YES"
]
} | {
"input": [
"2\n1 12 100 333\n0 100 1000 555",
"5\n0 1 2 8\n0 2 3 9\n0 2 2 11\n1 2 3 7\n0 1 3 7",
"2\n2 12 100 333\n0 100 1000 555",
"5\n0 1 2 8\n0 2 5 9\n0 2 2 11\n1 2 3 7\n0 1 3 7",
"5\n0 1 2 8\n0 4 5 9\n0 2 2 11\n1 2 3 7\n0 1 3 7",
"5\n0 1 2 8\n0 4 5 9\n0 2 2 11\n1 2 3 7\n0 1 3 14",
"5... |
p01636 Mysterious Operator | When Mr. Kay was browsing a certain SNS as usual, the problem that "there are people who can solve IQ150 or more" came to the timeline. Mr. Kay has an IQ of over 150, so he solved the problem in an instant without even looking at it. For him, he doesn't have to work on such a mystery. It is enough to leave it to the co... | {
"input": [],
"output": []
} | {
"input": [
"19"
],
"output": [
"1"
]
} | {
"input": [
"5",
"2",
"68",
"2286",
"7",
"1",
"4",
"27",
"8",
"3",
"49",
"6",
"82",
"75",
"123",
"188",
"13",
"12",
"14",
"24",
"9",
"10",
"15",
"11",
"48",
"18",
"50",
"45",
"31",
"194",
"310"... |
p01788 Tokyo Olympics Center | Example
Input
3 3 1
1 1 10 10
AAA
A..
A..
Output
100 | {
"input": [],
"output": []
} | {
"input": [
"3 3 1\n1 1 10 10\nAAA\nA..\nA.."
],
"output": [
"100"
]
} | {
"input": [
"3 3 1\n1 1 10 6\nAAA\nA..\nA..",
"3 3 1\n1 1 20 6\nAAA\nA..\nA..",
"3 3 1\n1 1 0 6\nAAA\nA..\nA..",
"3 3 2\n1 2 10 4\nAAA\nA..\nA..",
"3 3 2\n1 2 10 5\nAAA\nA..\nA..",
"3 3 1\n2 1 10 10\nAAA\nA..\nA..",
"3 3 1\n1 1 20 11\nAAA\nA..\nA..",
"3 3 1\n1 1 1 6\nAAA\nA..\nA..",
... |
p01923 JAG Practice Contest | JAG mock qualifying practice session
The ACM-ICPC OB / OG Association (Japanese Alumni Group; JAG) has N questions in stock of questions to be asked in the mock contest, and each question is numbered with an integer from 1 to N. Difficulty evaluation and recommendation voting are conducted for each problem. Problem i ... | {
"input": [],
"output": []
} | {
"input": [
"5 3\n1 1\n2 3\n3 2\n3 5\n2 1\n4 2\n1 7\n2 1\n1 3\n1 5\n6 1\n1 3\n1 2\n1 8\n1 2\n1 7\n1 6\n20 9\n4 10\n2 4\n5 3\n6 6\n6 3\n7 4\n8 10\n4 6\n7 5\n1 8\n5 7\n1 5\n6 6\n9 9\n5 8\n6 7\n1 4\n6 4\n7 10\n3 5\n19 6\n4 1\n6 5\n5 10\n1 10\n3 10\n4 6\n2 3\n5 4\n2 10\n1 8\n3 4\n3 1\n5 4\n1 10\n1 3\n5 6\n5 2\n1 10\... | {
"input": [
"5 3\n1 1\n2 3\n3 2\n3 5\n2 1\n4 2\n1 9\n2 1\n1 3\n1 5\n6 1\n1 3\n1 2\n1 8\n1 2\n1 7\n1 6\n20 9\n4 10\n2 4\n5 3\n6 6\n6 3\n7 4\n8 10\n4 6\n7 5\n1 8\n5 7\n1 5\n6 6\n9 9\n5 8\n6 7\n1 4\n6 4\n7 10\n3 5\n19 6\n4 1\n6 5\n5 10\n1 10\n3 10\n4 6\n2 3\n5 4\n2 10\n1 8\n3 4\n3 1\n5 4\n1 10\n1 3\n5 6\n5 2\n1 10\... |
p02061 Doubling | B: Twice as own
problem
You will be given Q queries. Since one positive integer N is given for each query, find the number of positive integers M that satisfy the following two conditions.
* 2 Satisfy \ leq M \ leq N
* Of the divisors of M, excluding M, the total product is more than twice that of M
Input format
... | {
"input": [],
"output": []
} | {
"input": [
"3\n43\n9\n24"
],
"output": [
"11\n0\n5"
]
} | {
"input": [
"3\n43\n8\n24",
"3\n80\n8\n24",
"3\n71\n8\n24",
"3\n73\n8\n24",
"3\n73\n8\n9",
"3\n73\n13\n1",
"3\n73\n24\n1",
"3\n7\n24\n1",
"3\n7\n45\n2",
"3\n7\n59\n2",
"3\n7\n118\n1",
"3\n1\n211\n2",
"3\n1\n277\n2",
"3\n2\n535\n0",
"3\n2\n649\n0",
"3\n2... |
p02203 Auction | Auction
square1001 You were watching a certain auction.
An auction is a transaction in which when there are a large number of buyers and the number of items is limited, the one with the highest price is given the right to buy. (From the 7th edition of the Shinmei Kokugo Dictionary)
The rules of the auction here are ... | {
"input": [],
"output": []
} | {
"input": [
"5\n8 6 9 1 20"
],
"output": [
"3\n5"
]
} | {
"input": [
"5\n8 6 9 1 0",
"5\n0 6 9 1 0",
"5\n1 1 1 1 0",
"5\n0 1 1 2 4",
"5\n0 6 6 1 0",
"5\n0 5 6 1 0",
"5\n0 5 6 2 0",
"5\n0 5 6 3 0",
"5\n0 4 6 3 0",
"5\n-1 4 6 3 0",
"5\n-1 4 9 3 0",
"5\n-1 4 0 3 0",
"5\n-1 4 -1 3 0",
"5\n0 4 -1 3 0",
"5\n0 4 0 3 0",... |
p02357 Sliding Minimum Elements | For a given array $a_1, a_2, a_3, ... , a_N$ of $N$ elements and an integer $L$, find the minimum of each possible sub-arrays with size $L$ and print them from the beginning. For example, for an array $\\{1, 7, 7, 4, 8, 1, 6\\}$ and $L = 3$, the possible sub-arrays with size $L = 3$ includes $\\{1, 7, 7\\}$, $\\{7, 7, ... | {
"input": [],
"output": []
} | {
"input": [
"7 3\n1 7 7 4 8 1 6"
],
"output": [
"1 4 4 1 1"
]
} | {
"input": [
"7 3\n1 7 7 4 6 1 6",
"7 3\n1 7 3 4 6 1 6",
"7 3\n1 7 0 4 6 1 6",
"7 3\n0 7 7 4 8 1 6",
"7 3\n1 7 7 4 6 1 0",
"7 3\n0 7 7 4 8 2 6",
"7 3\n1 7 7 5 6 1 0",
"7 2\n1 7 0 4 5 1 6",
"7 3\n1 7 7 3 6 1 0",
"7 3\n1 2 3 3 6 1 8",
"7 3\n0 7 7 8 12 2 6",
"7 6\n1 7 7 3 ... |
chefarrp | Chef likes problems involving arrays. Unfortunately, the last one he tried to solve didn't quite get solved.
Chef has an array A of N positive numbers. He wants to find the number of subarrays for which the sum and product of elements are equal.
Please help Chef find this number.
Input
The first line of input con... | {
"input": [],
"output": []
} | {
"input": [
"3\n3\n1 3 2\n4\n4 1 2 1\n6\n1 2 2 2 2 1"
],
"output": [
"4\n5\n9\n"
]
} | {
"input": [
"3\n3\n1 3 2\n4\n4 1 3 1\n6\n1 2 2 2 2 1",
"3\n3\n1 3 2\n4\n4 1 3 1\n6\n1 2 2 0 2 1",
"3\n3\n1 3 2\n4\n4 1 3 1\n6\n1 1 2 0 2 1",
"3\n3\n1 3 2\n4\n4 2 3 1\n6\n1 2 2 2 2 1",
"3\n3\n1 5 2\n4\n4 2 3 1\n6\n1 2 2 2 2 1",
"3\n3\n1 3 3\n4\n4 1 3 1\n6\n1 0 2 0 2 1",
"3\n3\n1 3 4\n4\n4 ... |
devugrap | Grapes of Coderpur are very famous. Devu went to the market and saw that there were N people selling grapes. He didn’t like it because things were not very structured. So, he gave a task to Dhinwa to make things better. If Dhinwa successfully completes the task, Devu will be happy.
Devu wants to change the number of ... | {
"input": [],
"output": []
} | {
"input": [
"2\n2 2\n3 5\n3 7\n10 16 18"
],
"output": [
"2\n8\n"
]
} | {
"input": [
"2\n2 2\n3 5\n3 7\n8 16 18",
"2\n2 2\n3 8\n3 7\n8 16 18",
"2\n2 2\n3 8\n3 7\n8 16 7",
"2\n2 1\n5 8\n3 7\n8 16 7",
"2\n2 2\n5 8\n2 7\n7 16 7",
"2\n2 2\n3 5\n3 7\n10 1 18",
"2\n2 2\n5 8\n3 7\n8 11 7",
"2\n2 1\n5 8\n3 11\n8 16 7",
"2\n2 2\n5 1\n2 7\n8 16 7",
"2\n2 2\n... |
insoma3 | Stepford Street was a dead end street. The houses on Stepford Street were bought by wealthy millionaires. They had them extensively altered so that as one progressed along the street, the height of the buildings increased rapidly. However, not all millionaires were created equal. Some refused to follow this trend and k... | {
"input": [],
"output": []
} | {
"input": [
"6\n1 2 4 5 3 6"
],
"output": [
"2\n"
]
} | {
"input": [
"6\n1 0 4 5 3 6",
"6\n1 -1 4 0 3 6",
"6\n0 2 4 5 3 6",
"6\n2 -1 8 5 3 6",
"6\n0 -2 4 7 3 2",
"6\n1 -2 7 5 3 2",
"6\n2 -2 13 7 3 1",
"6\n1 -1 4 5 3 6",
"6\n2 -1 4 5 3 6",
"6\n2 -1 4 0 3 6",
"6\n1 -1 4 7 3 6",
"6\n2 -1 4 0 3 12",
"6\n1 -1 4 7 3 8",
"6... |
nextnum | The Head Chef has received his id from the Association of Byteland . He wants to know the numerical rank of his number among the numbers that can be formed by the exact same digits ( i.e. among numbers having same number of 0's , 1's ... 9's as his id ) . Note that id's can start with 0 . Given a number, find the rank... | {
"input": [],
"output": []
} | {
"input": [
"2\n276\n762"
],
"output": [
"2\n6"
]
} | {
"input": [
"2\n473\n762",
"2\n473\n370",
"2\n336\n432",
"2\n438\n861",
"2\n286\n861",
"2\n64\n10",
"2\n15\n10",
"2\n7\n18",
"2\n276\n1324",
"2\n924\n762",
"2\n143\n370",
"2\n473\n589",
"2\n48\n675",
"2\n48\n665",
"2\n64\n6",
"2\n276\n1240",
"2\n211... |
salary | Little chief has his own restaurant in the city. There are N workers there. Each worker has his own salary. The salary of the i-th worker equals to Wi (i = 1, 2, ..., N). Once, chief decided to equalize all workers, that is, he wants to make salaries of all workers to be equal. But for this goal he can use only one ope... | {
"input": [],
"output": []
} | {
"input": [
"2\n3\n1 2 3\n2\n42 42"
],
"output": [
"3\n0\n"
]
} | {
"input": [
"2\n3\n1 4 3\n2\n42 42",
"2\n3\n1 4 3\n2\n42 28",
"2\n3\n1 4 3\n2\n38 42",
"2\n3\n1 0 3\n2\n38 42",
"2\n3\n1 -1 3\n2\n38 42",
"2\n3\n1 0 1\n2\n38 42",
"2\n3\n2 0 1\n2\n38 42",
"2\n3\n1 4 3\n2\n42 7",
"2\n3\n1 0 3\n2\n61 42",
"2\n3\n2 0 1\n2\n38 36",
"2\n3\n1 4 ... |
zeroes | Virat loves mathematical questions. The other day he came across an interesting question which required him to find out the number of trailing zeroes for the
function. F(n) = 1^1*2^2......N^N,where N is an integer. Virat solved the problem after a few attempts. He asked the same
question from his friend Rohit to see if... | {
"input": [],
"output": []
} | {
"input": [
"3\n5\n10\n2"
],
"output": [
"5\n15\n0"
]
} | {
"input": [],
"output": []
} |
1364_B. Most socially-distanced subsequence | Given a permutation p of length n, find its subsequence s_1, s_2, …, s_k of length at least 2 such that:
* |s_1-s_2|+|s_2-s_3|+…+|s_{k-1}-s_k| is as big as possible over all subsequences of p with length at least 2.
* Among all such subsequences, choose the one whose length, k, is as small as possible.
If mul... | {
"input": [],
"output": []
} | {
"input": [
"2\n3\n3 2 1\n4\n1 3 4 2\n"
],
"output": [
"2\n3 1 \n3\n1 4 2 \n"
]
} | {
"input": [
"2\n3\n3 2 1\n4\n1 3 7 2\n",
"2\n3\n3 4 1\n4\n1 3 7 2\n",
"2\n3\n3 4 1\n4\n1 5 8 2\n",
"2\n3\n3 2 1\n4\n1 5 8 2\n",
"2\n3\n6 2 1\n4\n1 5 8 2\n",
"2\n3\n3 4 1\n4\n1 5 14 2\n",
"2\n3\n3 4 1\n4\n1 5 6 2\n",
"2\n3\n3 4 1\n4\n1 5 14 3\n",
"2\n3\n3 2 1\n4\n1 6 7 3\n",
"2... |
mario-and-queen | Legends who were born in 90s remember Mario very well. As we all are aware of that fabulous video game our little Mario tackling with all the problems and barriers coming his way , he finally saves his Queen from the giant monster Dragon.
In this problem we let you play the game but with a little twist. The aim is sam... | {
"input": [],
"output": []
} | {
"input": [
"2\n3\n. . Q\n. . $\nM $ .\n3\nM . .\n$ $ .\nQ $ .\n\nSAMPLE"
],
"output": [
"Case 1: 2 < 2 3 4 5 >\nCase 2: -1"
]
} | {
"input": [],
"output": []
} |
p02536 ACL Beginner Contest - Connect Cities | There are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i.
Snuke can perform the following operation zero or more times:
* Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities.
After he... | {
"input": [],
"output": []
} | {
"input": [
"3 1\n1 2"
],
"output": [
"1"
]
} | {
"input": [
"3 1\n1 1",
"5 1\n1 1",
"6 1\n1 1",
"3 1\n3 2",
"5 1\n3 2",
"2 1\n1 2",
"9 1\n1 2",
"15 1\n1 2",
"10 1\n1 2",
"10 1\n1 1",
"8 1\n2 4",
"19 1\n1 2",
"18 1\n1 2",
"24 1\n1 4",
"27 1\n1 5",
"13 1\n4 2",
"21 1\n8 2",
"45 1\n4 14",
"1... |
p02667 NOMURA Programming Competition 2020 - Binary Programming | Takahashi has an empty string S and a variable x whose initial value is 0.
Also, we have a string T consisting of `0` and `1`.
Now, Takahashi will do the operation with the following two steps |T| times.
* Insert a `0` or a `1` at any position of S of his choice.
* Then, increment x by the sum of the digits in the o... | {
"input": [],
"output": []
} | {
"input": [
"1101",
"0111101101"
],
"output": [
"5",
"26"
]
} | {
"input": [
"1001",
"0111101111",
"1000",
"0111001111",
"1010",
"1010011111",
"0010001111",
"0010",
"0010001011",
"0001",
"0010001001",
"0110001001",
"0010001000",
"0010001100",
"0000",
"0110011100",
"0010111110",
"0010110111",
"0110110011",... |
p02796 Keyence Programming Contest 2020 - Robot Arms | In a factory, there are N robots placed on a number line. Robot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative.
We want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect. Here, for each i (1 \leq i \leq N... | {
"input": [],
"output": []
} | {
"input": [
"5\n10 1\n2 1\n4 1\n6 1\n8 1",
"2\n8 20\n1 10",
"4\n2 4\n4 3\n9 3\n100 5"
],
"output": [
"5",
"1",
"3"
]
} | {
"input": [
"5\n10 1\n2 2\n4 1\n6 1\n8 1",
"2\n8 20\n1 13",
"4\n2 4\n4 3\n14 3\n100 5",
"4\n4 16\n4 3\n6 2\n101 5",
"5\n18 1\n2 1\n4 1\n6 1\n8 1",
"5\n10 1\n2 2\n4 1\n6 1\n8 2",
"2\n12 20\n1 13",
"4\n4 4\n4 3\n14 3\n100 5",
"2\n12 14\n1 13",
"4\n4 4\n4 3\n28 3\n100 5",
"2\... |
p02932 Japanese Student Championship 2019 Qualification - Candy Retribution | Find the number of sequences of N non-negative integers A_1, A_2, ..., A_N that satisfy the following conditions:
* L \leq A_1 + A_2 + ... + A_N \leq R
* When the N elements are sorted in non-increasing order, the M-th and (M+1)-th elements are equal.
Since the answer can be enormous, print it modulo 10^9+7.
Const... | {
"input": [],
"output": []
} | {
"input": [
"4 2 3 7",
"141592 6535 89793 238462",
"2 1 4 8"
],
"output": [
"105",
"933832916",
"3"
]
} | {
"input": [
"3 2 3 7",
"141592 6535 140953 238462",
"2 1 1 8",
"3 2 3 9",
"3 4 3 9",
"3 2 6 9",
"141592 9415 89793 238462",
"3 4 3 7",
"194528 6535 140953 238462",
"2 1 1 3",
"141592 9415 89793 104902",
"3 4 5 7",
"194528 6535 140953 193508",
"4 1 1 3",
"6 ... |
p03068 Tenka1 Programmer Beginner Contest 2019 - *e**** ********e* *e****e* ****e** | You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`.
Constraints
* 1 \leq K \leq N\leq 10
* S is a string of length N consisting of lowercase English letters.
* N... | {
"input": [],
"output": []
} | {
"input": [
"6\neleven\n5",
"9\neducation\n7",
"5\nerror\n2"
],
"output": [
"e*e*e*",
"******i**",
"*rr*r"
]
} | {
"input": [
"9\neducation\n4",
"5\norrer\n2",
"9\nedubation\n4",
"9\nedubation\n6",
"9\nedubation\n8",
"9\nedubatinn\n8",
"9\nnnitabude\n8",
"9\nedubatinn\n1",
"9\nedubatinn\n2",
"6\neleven\n4",
"9\neducation\n9",
"5\nrorre\n2",
"5\norrer\n1",
"9\nedubatinn\n7"... |
p03211 AtCoder Beginner Contest 114 - 754 | There is a string S consisting of digits `1`, `2`, ..., `9`. Lunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)
The master's favorite number is 753. The closer to this number, the better. What is the mini... | {
"input": [],
"output": []
} | {
"input": [
"35753",
"1234567876",
"1111111111"
],
"output": [
"0",
"34",
"642"
]
} | {
"input": [
"43594",
"1133184093",
"1110111111",
"80343",
"1646883079",
"93622",
"978408132",
"120326",
"1514858721",
"226242",
"518385143",
"177719",
"391005951",
"38621",
"747321877",
"63510",
"385429923",
"1011001000",
"77673",
"13964... |
p03360 AtCoder Beginner Contest 096 - Maximum Sum | There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard after... | {
"input": [],
"output": []
} | {
"input": [
"5 3 11\n1",
"3 3 4\n2"
],
"output": [
"30",
"22"
]
} | {
"input": [
"7 3 11\n1",
"3 3 4\n4",
"7 5 11\n1",
"3 3 4\n0",
"7 5 11\n0",
"4 3 4\n0",
"10 5 11\n0",
"4 3 1\n0",
"10 5 21\n0",
"4 1 1\n0",
"17 5 21\n0",
"3 1 1\n0",
"17 3 21\n0",
"4 2 1\n0",
"27 3 21\n0",
"11 0 1\n0",
"5 -2 1\n0",
"5 -3 1\n0",
... |
p03518 CODE FESTIVAL 2017 Elimination Tournament Round 2 (Parallel) - Many Swaps Sorting | Snuke has a sequence p, which is a permutation of (0,1,2, ...,N-1). The i-th element (0-indexed) in p is p_i.
He can perform N-1 kinds of operations labeled 1,2,...,N-1 any number of times in any order. When the operation labeled k is executed, the procedure represented by the following code will be performed:
for(i... | {
"input": [],
"output": []
} | {
"input": [
"9\n1 0 4 3 5 6 2 8 7",
"5\n4 2 0 1 3"
],
"output": [
"11\n3\n6\n1\n3\n5\n2\n4\n7\n8\n6\n3",
"4\n2\n3\n1\n2"
]
} | {
"input": [
"9\n1 0 4 3 5 1 2 8 7",
"5\n2 2 0 1 3",
"5\n3 2 0 1 3",
"9\n1 0 4 3 7 1 4 8 7",
"9\n1 0 4 3 12 1 4 8 7",
"5\n3 0 0 0 3",
"9\n1 0 4 3 12 1 8 8 7",
"5\n3 0 -1 0 3",
"9\n1 0 4 3 12 1 8 16 7",
"9\n1 1 4 3 14 1 8 16 7",
"9\n1 1 3 3 14 1 8 16 7",
"9\n1 1 3 3 14 1... |
p03683 AtCoder Regular Contest 076 - Reconciled? | Snuke has N dogs and M monkeys. He wants them to line up in a row.
As a Japanese saying goes, these dogs and monkeys are on bad terms. ("ken'en no naka", literally "the relationship of dogs and monkeys", means a relationship of mutual hatred.) Snuke is trying to reconsile them, by arranging the animals so that there a... | {
"input": [],
"output": []
} | {
"input": [
"100000 100000",
"3 2",
"1 8",
"2 2"
],
"output": [
"530123477",
"12",
"0",
"8"
]
} | {
"input": [
"100010 100000",
"3 4",
"1 2",
"4 4",
"2 3",
"000011 000010",
"001010 001011",
"000101 000101",
"000110 000111",
"001111 001110",
"9 8",
"4 5",
"010010 010011",
"010100 010100",
"3 0",
"0 8",
"100010 110000",
"4 0",
"0 6",
"3... |
p03836 AtCoder Beginner Contest 051 - Back and Forth | Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up.
Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1.
Here, both the x- and y-coordinates before and after each movement must ... | {
"input": [],
"output": []
} | {
"input": [
"0 0 1 2",
"-2 -2 1 1"
],
"output": [
"UURDDLLUUURRDRDDDLLU",
"UURRURRDDDLLDLLULUUURRURRDDDLLDL"
]
} | {
"input": [
"-1 0 1 2",
"-2 -2 1 2",
"-1 0 1 4",
"-1 0 1 0",
"-2 -2 0 4",
"-2 0 1 0",
"-4 -2 0 4",
"0 0 1 0",
"-4 -4 0 4",
"-4 0 0 4",
"-4 0 0 0",
"0 0 0 2",
"-2 -1 1 1",
"-1 -1 1 2",
"-2 -3 1 2",
"-2 -2 -1 2",
"-2 -2 0 5",
"-4 -1 0 4",
"0 0... |
p04003 AtCoder Regular Contest 061 - Snuke's Subway Trip | Snuke's town has a subway system, consisting of N stations and M railway lines. The stations are numbered 1 through N. Each line is operated by a company. Each company has an identification number.
The i-th ( 1 \leq i \leq M ) line connects station p_i and q_i bidirectionally. There is no intermediate station. This li... | {
"input": [],
"output": []
} | {
"input": [
"8 11\n1 3 1\n1 4 2\n2 3 1\n2 5 1\n3 4 3\n3 6 3\n3 7 3\n4 8 4\n5 6 1\n6 7 5\n7 8 5",
"2 0",
"3 3\n1 2 1\n2 3 1\n3 1 2"
],
"output": [
"2",
"-1",
"1"
]
} | {
"input": [
"8 11\n1 3 1\n1 4 2\n2 3 1\n2 5 1\n3 4 3\n3 6 3\n3 7 3\n4 8 4\n5 11 1\n6 7 5\n7 8 5",
"4 0",
"3 3\n1 2 1\n2 3 1\n3 2 2",
"1 0",
"5 0",
"3 3\n1 2 1\n2 3 2\n3 2 2",
"3 3\n1 2 2\n2 3 1\n3 2 2",
"3 0\n1 2 1\n2 3 1\n3 2 2",
"3 0\n1 2 1\n2 2 1\n3 2 2",
"3 0\n1 2 1\n2 2 1... |
p00089 The Shortest Path on A Rhombic Path | <image>
Arrange integers (0 or more and 99 or less) in a rhombus as illustrated in Fig. 1. Create a program that reads the data representing the rhombus and outputs the maximum value of the sum of the integers that pass when starting from the top and proceeding to the bottom according to the following rules.
* At ea... | {
"input": [],
"output": []
} | {
"input": [
"7\n3,8\n8,1,0\n2,7,4,4\n4,5,2,6,5\n2,7,4,4\n8,1,0\n3,8\n7"
],
"output": [
"55"
]
} | {
"input": [
"7\n3,8\n8,1,0\n2,7,4,4\n4,5,2,6,5\n2,7,4,4\n8,1,0\n8,3\n7",
"7\n3,8\n8,1,0\n2,7,4,4\n4,5,2,6,5\n2,7,4,4\n8,1,0\n8,3\n3",
"7\n3,8\n8,1,0\n2,7,4,4\n4,5,2,6,5\n4,4,7,2\n8,1,0\n8,3\n3",
"7\n3,8\n8,1,0\n2,7,4,4\n4,5,2,6,5\n4,4,7,2\n8,1,0\n8,3\n0",
"7\n3,8\n8,1,0\n2,7,4,4\n4,5,2,6,5\n2,7,4... |
p00221 FizzBuzz | There is a game that uses numbers called "Fizz Buzz". In this game, multiple players count the numbers one by one, starting with 1, and each player says only one number after the previous player. At that time, you must say "Fizz" if it is divisible by 3, "Buzz" if it is divisible by 5, and "FizzBuzz" if it is divisible... | {
"input": [],
"output": []
} | {
"input": [
"5 7\n1\n2\nFizz\n4\nBuzz\n6\n7\n3 5\n1\n2\n3\n4\n5\n0 0"
],
"output": [
"2 3 4 5\n1"
]
} | {
"input": [
"5 7\n1\n0\nFizz\n4\nBuzz\n6\n7\n3 5\n1\n2\n3\n4\n5\n0 0",
"5 7\n1\n0\nFizz\n4\nBuzz\n6\n2\n3 5\n1\n2\n3\n4\n5\n0 0",
"5 7\n1\n0\nFizz\n2\nBuzz\n6\n2\n3 5\n1\n2\n4\n4\n8\n0 0",
"5 7\n1\n0\nFizz\n2\nzuzB\n6\n2\n3 5\n1\n2\n4\n4\n8\n0 0",
"5 7\n1\n2\nFizz\n4\nBuzz\n6\n7\n3 5\n1\n1\n3\n4\... |
p00383 Points on a Straight Line | The university of A stages a programming contest this year as has been the case in the past. As a member of the team in charge of devising the problems, you have worked out a set of input data for a problem, which is an arrangement of points on a 2D plane in the coordinate system. The problem requires that any combinat... | {
"input": [],
"output": []
} | {
"input": [
"5 4\n0 0\n1 0\n1 1\n0 1\n2 2",
"7 5\n0 0\n1 0\n1 1\n0 1\n2 0\n3 0\n4 0"
],
"output": [
"0",
"1"
]
} | {
"input": [
"7 7\n0 0\n1 0\n1 1\n0 1\n2 0\n3 0\n4 0",
"5 4\n1 -1\n1 0\n1 2\n1 1\n3 2",
"7 7\n0 0\n1 0\n1 1\n-1 1\n2 0\n3 0\n4 0",
"5 4\n0 0\n1 0\n1 2\n0 1\n2 2",
"7 5\n0 0\n1 0\n1 1\n0 1\n2 0\n3 1\n4 0",
"7 9\n0 0\n1 0\n1 1\n0 1\n2 0\n3 0\n4 0",
"7 7\n0 0\n1 0\n1 1\n-1 1\n2 0\n3 0\n6 0",
... |
p00599 Combinatorial Topology | It was long believed that a 2-dimensional place can not be filled with a finite set of polygons in aperiodic way. British mathematician, Sir Roger Penrose, developed an aperiodic tiling over the years and established a theory of what is known today as quasicrystals.
The classic Penrose tiles consist of two rhombi with... | {
"input": [],
"output": []
} | {
"input": [
"4\n-5.000000 0.000000\n5.000000 0.000000\n9.635255 14.265848\n-0.364745 14.265848\n3\n-1.000000 0.000000\n0.000000 0.000000\n0.000000 1.000000"
],
"output": [
"0 150\n-1 -1"
]
} | {
"input": [],
"output": []
} |
p00735 Monday-Saturday Prime Factors | Chief Judge's log, stardate 48642.5. We have decided to make a problem from elementary number theory. The problem looks like finding all prime factors of a positive integer, but it is not.
A positive integer whose remainder divided by 7 is either 1 or 6 is called a 7N+{1,6} number. But as it is hard to pronounce, we s... | {
"input": [],
"output": []
} | {
"input": [
"205920\n262144\n262200\n279936\n299998\n1"
],
"output": [
"205920: 6 8 13 15 20 22 55 99\n262144: 8\n262200: 6 8 15 20 50 57 69 76 92 190 230 475 575 874 2185\n279936: 6 8 27\n299998: 299998"
]
} | {
"input": [
"205920\n262144\n262200\n279936\n152244\n1",
"205920\n262144\n299662\n279936\n152244\n1",
"205920\n262144\n262200\n259214\n152244\n1",
"205920\n262144\n299662\n279936\n101746\n1",
"205920\n262144\n299662\n279936\n112663\n1",
"205920\n52578\n299662\n279936\n112663\n1",
"205920\... |
p00875 Repeated Substitution with Sed | Do you know "sed," a tool provided with Unix? Its most popular use is to substitute every occurrence of a string contained in the input string (actually each input line) with another string β. More precisely, it proceeds as follows.
1. Within the input string, every non-overlapping (but possibly adjacent) occurrences... | {
"input": [],
"output": []
} | {
"input": [
"2\na bb\nb aa\na\nbbbbbbbb\n1\na aa\na\naaaaa\n3\nab aab\nabc aadc\nad dee\nabc\ndeeeeeeeec\n10\na abc\nb bai\nc acf\nd bed\ne abh\nf fag\ng abe\nh bag\ni aaj\nj bbb\na\nabacfaabe\n0"
],
"output": [
"3\n-1\n7\n4"
]
} | {
"input": [
"2\na bb\nb aa\na\nbbbbbbbb\n1\na aa\na\naaaaa\n3\nab aab\nabc aadc\nad dee\nabc\ndeeeeeeeec\n10\na abc\nb bai\nc acf\nd bed\ne abh\nf fag\ng abe\nh bag\ni aaj\nj bbb\na\nabaceaabe\n0",
"2\na bb\nb aa\nb\nbbbbbbbb\n1\nb aa\na\naaaaa\n3\nab aab\nabc aadc\nad dee\nabc\ndeeeeeeeec\n10\na abc\nb bai\... |
p01006 Nasty Boys | Problem
Taro hides important books in the school locker, so he manages them more strictly than other people, and in addition to the keys provided by the school, he has installed the following button authentication type keys. ..
<image>
However, Taro, who easily forgets his password, has a habit of making it possible... | {
"input": [],
"output": []
} | {
"input": [
"ABCFI\nABCABCABC\nAEI\nEFC\n(中略)\nDEHED\nEEEEE\n(以上でちょうど1000個)"
],
"output": [
"ABCFI\nEFC\n(中略)\nDEHED"
]
} | {
"input": [
"ABCFI\nABCABCACC\nAEI\nEFC\n(中略)\nDEHED\nEEEEE\n(以上でちょうど1000個)",
"ABCFI\nABCACCACC\nAEI\nEFC\n(中略)\nDEHEC\nEEEEE\n(以上でちょうど1000個)",
"ABCFJ\nABCACCACC\nAEI\nEFC\n(中略)\nDEHEC\nEEEEE\n(以上でちょうど1000個)",
"ABCFJ\nABBACACCC\nAEI\nCFE\n(中畦)\nDEHEC\nEEEEE\n(以上でちょうど1000個)",
"IFCBA\nABCACCACC\nAE... |
p01138 Osaki | Osaki
Osaki
English text is not available in this practice contest.
The Yamanote Line is a circular railway line laid in the 23 wards of Tokyo. The total route distance is 34.5km, and one lap takes about one hour. There are 29 stations in total. The line color is Uguisu color. The peak congestion rate exceeds 200%, ... | {
"input": [],
"output": []
} | {
"input": [
"3\n05:47:15 09:54:40\n12:12:59 12:13:00\n16:30:20 21:18:53\n6\n00:00:00 03:00:00\n01:00:00 03:00:00\n02:00:00 03:00:00\n03:00:00 04:00:00\n03:00:00 05:00:00\n03:00:00 06:00:00\n0"
],
"output": [
"1\n3"
]
} | {
"input": [
"3\n05:47:15 04:45:90\n12:12:59 12:13:00\n16:30:20 21:18:53\n6\n00:00:00 03:00:00\n01:00:00 03:00:00\n02:00:00 03:00:00\n03:00:00 04:00:00\n03:00:00 05:00:00\n03:00:00 06:00:00\n0",
"3\n05:47:15 09:54:40\n12:12:59 12:13:00\n16:30:20 21:18:53\n6\n00:00:00 03:00:00\n01:00:00 03:00:00\n02:00:00 03:0... |
p01277 Symmetry | Open Binary and Object Group organizes a programming contest every year. Mr. Hex belongs to this group and joins the judge team of the contest. This year, he created a geometric problem with its solution for the contest. The problem required a set of points forming a line-symmetric polygon for the input. Preparing the ... | {
"input": [],
"output": []
} | {
"input": [
"4\n0 2\n0 0\n-1 0\n1 0",
"4\n0 1\n1 0\n0 0\n1 1",
"9\n-1 1\n0 1\n1 1\n-1 0\n0 0\n1 0\n-1 -1\n0 -1\n1 -1",
"4\n0 1\n1 -1\n0 0\n1 1",
"3\n-1 -1\n0 0\n1 1"
],
"output": [
"Yes",
"Yes",
"No",
"No",
"No"
]
} | {
"input": [
"4\n0 2\n0 0\n-2 0\n1 0",
"4\n0 1\n1 -1\n0 -1\n1 1",
"3\n-2 -1\n0 0\n1 1",
"4\n0 1\n1 -1\n-1 -1\n1 1",
"3\n-2 -1\n0 0\n1 0",
"4\n0 1\n1 -1\n-1 0\n1 1",
"3\n-1 -1\n0 0\n1 0",
"3\n-1 -1\n0 -1\n1 0",
"3\n-2 -1\n0 -1\n1 0",
"3\n-2 -1\n0 -1\n0 0",
"3\n-2 -1\n1 -1\n0... |
p01447 Earth Invasion Diary of Miyabi-sensei | The Quarkgo Empire Expeditionary Force is an evil organization that plans to invade the Earth. In keeping with the tradition of the invaders, they continued to send monsters at a pace of one every week, targeting the area around Tokyo in Japan. However, each time, five warriors calling themselves the Human Squadron Ear... | {
"input": [],
"output": []
} | {
"input": [
"30",
"8",
"2000000000"
],
"output": [
"4",
"2",
"20"
]
} | {
"input": [
"57",
"13",
"1204648530",
"3",
"5",
"22801121",
"11933788",
"2291365",
"784277",
"166022",
"269992",
"50327",
"11679",
"1145",
"676",
"107",
"104442668",
"5353",
"3727082973",
"518772949",
"169668482",
"16",
"1369... |
p01596 Magnum Tornado | Problem F: Magnum Tornado
We have a toy that consists of a small racing circuit and a tiny car. For simplicity you can regard the circuit as a 2-dimensional closed loop, made of line segments and circular arcs. The circuit has no branchings. All segments and arcs are connected smoothly, i.e. there are no sharp corners... | {
"input": [],
"output": []
} | {
"input": [
"5\n0 1 0 2\n1 3 2 3\n2 2 1 2\n1 1 2 1\n2 0 1 0",
"12\n4 5 4 6\n3 7 1 7\n0 8 0 10\n1 11 3 11\n4 10 4 9\n5 8 99 8\n100 7 100 4\n99 3 4 3\n3 2 3 1\n2 0 1 0\n0 1 0 3\n1 4 3 4"
],
"output": [
"9.712",
"27.406"
]
} | {
"input": [
"5\n0 1 0 4\n1 3 2 3\n2 2 1 2\n1 1 2 1\n2 0 1 0",
"5\n0 1 0 4\n1 3 2 6\n0 2 1 2\n1 1 2 1\n2 0 1 0",
"12\n4 5 4 6\n3 7 1 7\n0 8 0 10\n1 11 3 11\n4 10 4 9\n5 8 99 8\n100 7 100 4\n99 3 4 3\n3 2 0 1\n2 0 1 0\n0 1 0 3\n1 4 3 4",
"12\n4 5 4 6\n3 7 1 7\n0 8 0 10\n1 11 3 11\n4 10 4 9\n5 8 99 8\n1... |
p01753 Magic Bullet | In 20XX AD, a school competition was held. The tournament has finally left only the final competition. You are one of the athletes in the competition.
The competition you participate in is to compete for the time it takes to destroy all the blue objects placed in the space. Athletes are allowed to bring in competition... | {
"input": [],
"output": []
} | {
"input": [
"5 5\n-38 -71 -293 75 1\n-158 -38 -405 66 1\n-236 -303 157 266 1\n316 26 411 190 1\n207 -312 -27 196 1\n-50 292 -375 -401 389 -389\n460 278 409 -329 -303 411\n215 -220 -200 309 -474 300\n261 -494 -87 -300 123 -463\n386 378 486 -443 -64 299",
"5 1\n0 10 0 5 2\n0 20 0 5 12\n0 30 0 5 22\n0 40 0 5 32... | {
"input": [
"5 5\n-38 -71 -293 75 1\n-158 -38 -405 66 1\n-236 -303 157 266 1\n316 26 411 190 1\n207 -312 -27 196 1\n-50 292 -375 -401 389 -389\n460 278 409 -329 -303 411\n215 -220 -200 309 -474 300\n310 -494 -87 -300 123 -463\n386 378 486 -443 -64 299",
"5 1\n0 10 0 5 2\n0 20 0 6 12\n0 30 0 5 22\n0 40 0 5 32... |
p01893 Lost Graph | Problem statement
You and AOR Ika are preparing for a graph problem in competitive programming. Generating input cases is AOR Ika-chan's job. The input case for that problem is a directed graph of the $ N $ vertices. The vertices are numbered from $ 1 $ to $ N $. Edges may contain self-loops, but not multiple edges.
... | {
"input": [],
"output": []
} | {
"input": [
"3\n1 2 0 0\n1 2 0 0"
],
"output": [
"YES\n0 1 0\n0 0 1\n0 0 0"
]
} | {
"input": [
"3\n1 2 0 0\n1 2 1 0",
"3\n1 2 0 0\n1 2 1 -1",
"3\n1 2 0 0\n2 2 1 0",
"3\n1 2 0 0\n2 2 2 0",
"3\n1 2 0 0\n2 2 0 0",
"3\n1 1 0 0\n2 2 0 0",
"3\n1 2 1 0\n2 2 0 0",
"3\n1 2 1 0\n3 2 0 0",
"3\n2 2 1 0\n3 2 0 0",
"3\n2 2 1 0\n3 2 0 1",
"3\n4 2 1 0\n3 2 0 1",
"3\... |
p02030 Information Search | A: Information Search
problem
The posting list is a list in which there is a correspondence between the search term and the appearing document ID. For example
* Hokkaido: 1, 2, 4, 9
* Sightseeing: 1, 3, 4, 7
And so on.
From the above posting list, if you search for and, the document with ID 1, 4 will be hit, and... | {
"input": [],
"output": []
} | {
"input": [
"4 4\n1 2 4 9\n1 3 4 7"
],
"output": [
"2 6\n1\n4\n1\n2\n3\n4\n7\n9"
]
} | {
"input": [
"4 4\n1 2 5 9\n1 3 4 7",
"4 4\n1 2 5 9\n2 3 4 7",
"4 4\n1 2 4 9\n1 3 4 14",
"4 4\n1 2 4 9\n0 3 4 7",
"4 4\n1 2 5 9\n0 3 4 7",
"4 4\n1 3 5 9\n0 3 4 7",
"4 4\n1 2 5 9\n1 2 4 7",
"4 4\n1 2 5 9\n2 3 4 13",
"4 4\n1 3 5 9\n0 3 4 12",
"4 4\n1 2 5 9\n1 3 4 13",
"4 4\n1... |
p02173 Space Travel | Story
A long time ago, in a galaxy far away.
In the midst of a storm of civil war, a vicious Galactic Empire army struck a secret rebel base.
Escaped from the dreaded pursuit of the Imperial Starfleet, the Freedom Warriors, led by Wook Starwalker, decide to build a new secret base on the outskirts of the galaxy.
As a ... | {
"input": [],
"output": []
} | {
"input": [
"6 6\n0 8 0\n2 3 0\n2 5 0\n4 3 0\n4 5 0\n6 0 0\n1 3\n2 3\n3 5\n5 4\n4 2\n4 6",
"2 1\n1 1 1\n2 2 2\n1 2",
"2 2\n1 1 1\n2 2 2\n1 2\n2 1",
"10 7\n-65870833 -68119923 -51337277\n-59513976 -24997697 -46968492\n-37069671 -90713666 -45043609\n-31144219 43731960 -5258464\n-27501033 90001758 13168... | {
"input": [
"6 6\n0 8 0\n2 3 0\n2 5 0\n4 3 0\n4 5 0\n6 0 0\n1 3\n2 3\n3 5\n5 4\n4 2\n2 6",
"2 1\n1 1 0\n2 2 2\n1 2",
"2 2\n1 1 1\n2 2 4\n1 2\n2 1",
"10 7\n-65870833 -29935806 -51337277\n-59513976 -24997697 -46968492\n-37069671 -90713666 -45043609\n-31144219 43731960 -5258464\n-27501033 90001758 13168... |
p02313 Area of Intersection between Two Circles | Write a program which prints the area of intersection between given circles $c1$ and $c2$.
Constraints
* $-10,000 \leq c1x, c1y, c2x, c2y \leq 10,000$
* $1 \leq c1r, c2r \leq 10,000$
Input
The input is given in the following format.
$c1x\; c1y\; c1r$
$c2x\; c2y\; c2r$
$c1x$, $c1y$ and $c1r$ represent the coordin... | {
"input": [],
"output": []
} | {
"input": [
"1 0 1\n0 0 3",
"0 0 1\n2 0 2"
],
"output": [
"3.14159265358979311600",
"1.40306643968573875104"
]
} | {
"input": [
"1 0 1\n1 0 3",
"0 0 1\n3 0 2",
"1 1 2\n1 -1 1",
"0 -1 2\n3 0 2",
"1 2 2\n-1 0 1",
"-1 -1 3\n3 -1 2",
"-1 -1 3\n3 0 2",
"-1 -1 2\n0 0 2",
"-2 -1 2\n0 0 2",
"0 -1 2\n0 0 2",
"0 -1 3\n0 0 2",
"2 3 2\n0 0 2",
"0 1 1\n2 0 2",
"0 0 2\n3 0 2",
"-1 -1 ... |
p02461 Map: Range Search | For a dictionary $M$ that stores elements formed by a pair of a string key and an integer value, perform a sequence of the following operations. Note that each key in $M$ must be unique.
* insert($key$, $x$): Insert an element formed by a pair of $key$ and $x$ to $M$.
* get($key$): Print the value with the specified $... | {
"input": [],
"output": []
} | {
"input": [
"9\n0 blue 4\n0 red 1\n0 white 5\n1 red\n1 blue\n2 red\n1 black\n1 red\n3 w z"
],
"output": [
"1\n4\n0\n0\nwhite 5"
]
} | {
"input": [
"9\n0 blue 4\n0 red 1\n0 white 5\n1 rdd\n1 blue\n2 red\n1 black\n1 red\n3 w z",
"9\n0 blue 4\n0 red 1\n0 white 5\n1 rdd\n1 blte\n2 red\n1 black\n1 red\n3 w z",
"9\n0 blue 4\n0 red 1\n0 wgite 5\n1 red\n1 blue\n2 red\n1 black\n1 red\n3 w z",
"9\n0 blue 4\n0 red 1\n0 white 5\n1 rdd\n1 blue\n... |
banrob | Two cheeky thieves (Chef being one of them, the more talented one of course) have came across each other in the underground vault of the State Bank of Churuland. They are shocked! Indeed, neither expect to meet a colleague in such a place with the same intentions to carry away all the money collected during Churufest 2... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 0.5\n2 0.5"
],
"output": [
"1000000000.0 0.0\n500000000.0 500000000.0"
]
} | {
"input": [
"2\n1 1.4637197254221004\n2 0.5",
"2\n1 2.313532452170189\n3 0.5",
"2\n1 2.8078480964381605\n3 0.7263910755021805",
"2\n1 2.8078480964381605\n3 0.8528247809161967",
"2\n1 2.8078480964381605\n3 1.3528766004396018",
"2\n1 2.8078480964381605\n3 1.9817989605527244",
"2\n1 2.807848... |
cmb03 | Given two binary strings, A (of length 10) and B (of length 5),
output 1 if B is a substring of A and 0 otherwise.
Input
The first line contains the number of test cases n. This is followed by n lines each consisting of pairs of binary strings A and B separated by a single space.
Output
output 1 if B is a sub... | {
"input": [],
"output": []
} | {
"input": [
"1\n1010110010 10110"
],
"output": [
"1\n"
]
} | {
"input": [
"1\n1010110110 10110",
"1\n1010100110 10110",
"1\n0010100110 10110",
"1\n0010100110 00110",
"1\n0000100110 10110",
"1\n0000100110 10100",
"1\n0001100110 10100",
"1\n0001100100 10100",
"1\n0001100100 00100",
"1\n0101100100 00100",
"1\n1010110110 10010",
"1\n... |
flow014 | A certain grade of steel is graded according to the following conditions.
Hardness must be greater than 50.
Carbon content must be less than 0.7.
Tensile strength must be greater than 5600.
The grades are as follows:
Grade is 10 if all three conditions are met.
Grade is 9 if conditions (i) and (ii) are met.
Grade ... | {
"input": [],
"output": []
} | {
"input": [
"3 \n53 0.6 5602\n45 0 4500\n0 0 0"
],
"output": [
"10\n6\n6\n"
]
} | {
"input": [
"3 \n67 0.6 5602\n45 0 4500\n0 0 0",
"3 \n67 0.6 5602\n78 0 4500\n0 0 0",
"3 \n74 0.7029782275732623 13440\n78 -1 4466\n0 -1 0",
"3 \n127 1.5460478864469624 13440\n71 -1 8462\n1 -1 0",
"3 \n127 1.5460478864469624 13440\n16 -1 8462\n1 -1 0",
"3 \n000 4.094246707215373 13440\n16 0 1... |
levy | Problem Statement
Levy's conjecture, named after Hyman Levy, states that all odd integers greater than 5 can be represented as the sum of an odd prime number and an even semiprime. To put it algebraically, 2n + 1 = p + 2q always has a solution in primes p and q (not necessary to be distinct) for n > 2. (Source: Wikiped... | {
"input": [],
"output": []
} | {
"input": [
"3\n2\n7\n11"
],
"output": [
"0\n1\n2\n"
]
} | {
"input": [
"3\n2\n9\n11",
"3\n2\n9\n16",
"3\n2\n4\n16",
"3\n2\n12\n11",
"3\n2\n8\n16",
"3\n2\n8\n21",
"3\n2\n8\n5",
"3\n4\n3\n1",
"3\n6\n3\n1",
"3\n2\n9\n5",
"3\n1\n38\n23",
"3\n3\n33\n6",
"3\n7\n4\n16",
"3\n4\n18\n11",
"3\n2\n19\n23",
"3\n2\n73\n23",
... |
prb01 | Alice and Bob are meeting after a long time. As usual they love to play some math games. This times Alice takes the call and decides the game. The game is very simple, Alice says out an integer and Bob has to say whether the number is prime or not. Bob as usual knows the logic but since Alice doesn't give Bob much time... | {
"input": [],
"output": []
} | {
"input": [
"5\n23\n13\n20\n1000\n99991"
],
"output": [
"yes\nyes\nno\nno\nyes\n"
]
} | {
"input": [
"5\n32\n13\n20\n1000\n99991",
"5\n23\n13\n20\n1100\n99991",
"5\n30\n14\n20\n1100\n99991",
"5\n30\n12\n3\n1111\n99991",
"5\n23\n13\n20\n1100\n79308",
"5\n30\n12\n20\n1100\n13959",
"5\n30\n12\n3\n1111\n17947",
"5\n30\n13\n5\n1100\n99991",
"5\n11\n10\n20\n1100\n99991",
... |
taand | Given an array of n non-negative integers: A1, A2, …, AN. Your mission is finding a pair of integers Au, Av (1 ≤ u < v ≤ N) such that (Au and Av) is as large as possible.
And is a bit-wise operation which is corresponding to & in C++ and Java.
Input
The first line of the input contains a single integer N. The ith ... | {
"input": [],
"output": []
} | {
"input": [
"4\n2\n4\n8\n10"
],
"output": [
"8\n"
]
} | {
"input": [
"4\n2\n6\n8\n10",
"4\n2\n4\n2\n10",
"4\n1\n6\n10\n10",
"4\n2\n4\n0\n8",
"4\n1\n6\n10\n6",
"4\n2\n4\n2\n7",
"4\n1\n11\n23\n11",
"4\n4\n11\n9\n16",
"4\n1\n16\n1\n10",
"4\n4\n11\n18\n16",
"4\n0\n21\n9\n17",
"4\n1\n6\n13\n12",
"4\n1\n8\n7\n5",
"4\n2\n3\... |
1223_D. Sequence Sorting | You are given a sequence a_1, a_2, ..., a_n, consisting of integers.
You can apply the following operation to this sequence: choose some integer x and move all elements equal to x either to the beginning, or to the end of a. Note that you have to move all these elements in one direction in one operation.
For example,... | {
"input": [],
"output": []
} | {
"input": [
"3\n7\n3 1 6 6 3 1 1\n8\n1 1 4 4 4 7 8 8\n7\n4 2 5 2 6 2 7\n"
],
"output": [
"2\n0\n1\n"
]
} | {
"input": [
"3\n7\n3 1 6 6 3 1 1\n8\n1 1 4 4 4 7 8 8\n7\n4 2 5 2 6 2 5\n",
"3\n7\n3 1 6 6 3 1 1\n8\n1 1 4 4 4 7 8 8\n7\n4 2 5 3 6 2 5\n",
"3\n7\n3 1 6 6 3 1 1\n8\n1 1 7 4 4 7 8 8\n7\n4 2 5 3 6 2 5\n",
"3\n7\n3 1 6 6 3 1 1\n8\n1 1 4 5 4 7 8 8\n7\n4 2 5 2 6 2 5\n",
"3\n7\n3 1 6 6 3 1 1\n8\n2 1 4 4 ... |
130_G. CAPS LOCK ON | You are given a string which consists of letters and other characters. Convert it to uppercase, i.e., replace all lowercase letters with corresponding uppercase ones. Keep the rest of characters unchanged.
Input
The only line of input contains a string between 1 and 100 characters long. Each character of the string h... | {
"input": [],
"output": []
} | {
"input": [
"cOdEfOrCeS\n",
"ulr#4:befunge-RULES!\n"
],
"output": [
"CODEFORCES\n",
"ULR#4:BEFUNGE-RULES!\n"
]
} | {
"input": [],
"output": []
} |
683_I. Loader | A loader works in a warehouse, which is a rectangular field with size n × m. Some cells of this field are free, others are occupied by pillars on which the roof of the warehouse rests.
There is a load in one of the free cells, and the loader in another. At any moment, the loader and the load can not be in the cells w... | {
"input": [],
"output": []
} | {
"input": [
"3 3\n..Y\n.BX\n..T\n",
"3 3\n.BY\n...\nTXX\n"
],
"output": [
"YES\nwSwsE\n",
"NO\n"
]
} | {
"input": [],
"output": []
} |
72_D. Perse-script | Two good friends were trying to make a new programming language called Perse-script.
The most important part of this language is strings. A string in Perse-script is put between characters "
So for example "Hello" is a string. But Hello is a variable name or a keyword, which are not considered in this problem.
Perse... | {
"input": [],
"output": []
} | {
"input": [
"\"HelloWorld\"\n",
"REVerse(substr(\"helloworld\",1,5))\n",
"conCAT(rEveRSE(\"olleh\"),\"world\")\n",
"reversE(concAT(substr(\"hello\",1,2),sUbstr(\"world\",1,5,1)))\n",
"suBstr(\"Noruz\",1,4,2)\n"
],
"output": [
"\"HelloWorld\"\n",
"\"olleh\"\n",
"\"helloworld\"\n",
... | {
"input": [],
"output": []
} |
captain-strategy | Captain America needs to lead his soldiers in his war against the Red Skull. He organized his team in such a way that he can estimate his soldiers’ energy-levels and capacity at any moment, which would help him make crucial decisions as to whom to dispatch to which areas of the war.
He organized his army in the form o... | {
"input": [],
"output": []
} | {
"input": [
"5 8\n7 2 0 5 8\n1 2\n2 3\n2 4\n1 5\nQ 1\nQ 2\nU 2 4\nQ 1\nQ 2\nU 5 3\nQ 1\nQ 2\n\nSAMPLE"
],
"output": [
"22\n7\n24\n9\n19\n9\n"
]
} | {
"input": [
"5 8\n7 2 0 5 8\n1 2\n2 3\n2 4\n1 5\nQ 1\nQ 2\nU 2 4\nQ 1\nQ 2\nU 5 3\nQ 1\nQ 2\n\nELPMAS",
"5 5\n7 2 0 5 8\n1 2\n2 3\n2 4\n1 5\nQ 1\nQ 2\nU 2 4\nQ 1\nQ 2\nU 5 3\nQ 1\nQ 2\n\nELPMAS",
"5 5\n7 2 0 5 8\n1 2\n2 3\n2 4\n1 5\nQ 1\nQ 2\nU 2 5\nQ 1\nQ 2\nU 5 3\nQ 1\nQ 2\n\nELPMAS",
"5 8\n7 2 0 5... |
detective-holmes-and-gba | Students of Maharaja Agrasen Institute of Technology, are going for long trip. Along with one teacher who is programmer. In the middle of trip , he decided to ask a question to all the students as they were making a lot of noise.
There are total N students and teacher has M Candies and wants to distribute among all . ... | {
"input": [],
"output": []
} | {
"input": [
"1\n9 16 2\n\nSAMPLE"
],
"output": [
"8"
]
} | {
"input": [
"1\n4 16 2\n\nSAMPLE",
"1\n3 16 2\n\nSAMPLE",
"1\n6 15 2\n\nE@PMLS",
"1\n12 15 4\n\nD@PMLS",
"1\n19 15 4\n\nD@PMLS",
"1\n33 15 2\n\nD@PMLS",
"1\n33 22 2\n\nD@PMLS",
"1\n29 4 2\n\nM@PDLS",
"1\n51 6 2\n\nSLDP@M",
"1\n51 10 2\n\nSLDP@M",
"1\n51 2 2\n\nSLDP@M",
... |
gayle-and-his-legacy-7 | Chris Gayle has a legacy of hitting sixes in his innings. He loves to hit sixes. Now in a particular match, he already know that he will face total of (N + 1) balls which means that he will get out on (N + 1)^th ball. So he has decided to hit sixes in each of the initial N balls. He will require some power Pi to hit a ... | {
"input": [],
"output": []
} | {
"input": [
"1\n2 7\n3 6\n2 4\n\nSAMPLE"
],
"output": [
"YES\n"
]
} | {
"input": [
"1\n2 7\n3 6\n1 4\n\nSAMPLE",
"1\n2 7\n1 8\n2 9\n\nSAMPLE",
"1\n2 7\n5 6\n1 4\n\nSAMPLE",
"1\n2 7\n3 6\n2 1\n\nSAMPLE",
"1\n2 7\n3 6\n2 6\n\nSAMPLE",
"1\n2 7\n5 6\n1 4\n\nTAMPLE",
"1\n2 7\n3 2\n2 1\n\nSAMPLE",
"1\n2 7\n1 6\n2 6\n\nSAMPLE",
"1\n2 7\n5 6\n1 4\n\nTAMPME",... |
p02598 AtCoder Beginner Contest 174 - Logs | We have N logs of lengths A_1,A_2,\cdots A_N.
We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t.
Find the shortest possible length of the longest log after at most K cuts, and print it a... | {
"input": [],
"output": []
} | {
"input": [
"3 0\n3 4 5",
"2 3\n7 9",
"10 10\n158260522 877914575 602436426 24979445 861648772 623690081 433933447 476190629 262703497 211047202"
],
"output": [
"5",
"4",
"292638192"
]
} | {
"input": [
"2 6\n7 9",
"10 10\n158260522 877914575 938084412 24979445 861648772 623690081 433933447 476190629 262703497 211047202",
"2 6\n1 9",
"3 0\n3 1 5",
"10 10\n158260522 877914575 602436426 24979445 861648772 623690081 433933447 476190629 262703497 180972685",
"10 1\n158260522 87791457... |
p02729 AtCoder Beginner Contest 159 - The Number of Even Pairs | We have N+M balls, each of which has an integer written on it.
It is known that:
* The numbers written on N of the balls are even.
* The numbers written on M of the balls are odd.
Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.
It c... | {
"input": [],
"output": []
} | {
"input": [
"13 3",
"1 1",
"4 3",
"2 1",
"0 3"
],
"output": [
"81",
"0",
"9",
"1",
"3"
]
} | {
"input": [
"13 5",
"1 2",
"4 0",
"0 5",
"13 6",
"1 3",
"0 0",
"2 2",
"4 6",
"2 3",
"4 2",
"2 6",
"2 11",
"4 11",
"5 -1",
"8 2",
"4 -2",
"7 11",
"3 -4",
"8 4",
"4 -3",
"7 9",
"6 -4",
"14 4",
"7 4",
"6 -5",
"25... |
p02862 AtCoder Beginner Contest 145 - Knight | There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.
When the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).
In how many ways can the knight reach the square (X, Y)?
Find the number of ways modulo 10^9 + 7.
Constraints
* 1 \leq X \leq 10^6
* 1 \l... | {
"input": [],
"output": []
} | {
"input": [
"999999 999999",
"2 2",
"3 3"
],
"output": [
"151840682",
"0",
"2"
]
} | {
"input": [
"728601 999999",
"2 0",
"123395 134890",
"1 2",
"1279413 999999",
"432914 823357",
"266891 229081",
"524173 402356",
"502635 840600",
"419854 442868",
"593126 1184107",
"416331 256674",
"533212 442868",
"416331 415425",
"533212 841058",
"416... |
p02996 AtCoder Beginner Contest 131 - Megalomania | Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.
Let the current time be time 0. Kizahashi has N jobs numbered 1 to N.
It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B... | {
"input": [],
"output": []
} | {
"input": [
"3\n334 1000\n334 1000\n334 1000",
"5\n2 4\n1 9\n1 8\n4 9\n3 12",
"30\n384 8895\n1725 9791\n170 1024\n4 11105\n2 6\n578 1815\n702 3352\n143 5141\n1420 6980\n24 1602\n849 999\n76 7586\n85 5570\n444 4991\n719 11090\n470 10708\n1137 4547\n455 9003\n110 9901\n15 8578\n368 3692\n104 1286\n3 4\n366... | {
"input": [
"3\n334 1000\n334 1000\n334 1100",
"30\n384 8895\n1725 9791\n170 1024\n4 11105\n2 6\n578 1815\n702 3352\n143 5141\n1420 6980\n24 1602\n849 999\n76 7586\n85 5570\n444 4991\n719 11090\n470 10708\n1137 4547\n455 9003\n110 9901\n15 8578\n718 3692\n104 1286\n3 4\n366 12143\n7 6649\n610 2374\n152 7324\... |
p03137 AtCoder Beginner Contest 117 - Streamline | We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:
Move... | {
"input": [],
"output": []
} | {
"input": [
"3 7\n-10 -3 0 9 -100 2 17",
"2 5\n10 12 1 2 14",
"100 1\n-100000"
],
"output": [
"19",
"5",
"0"
]
} | {
"input": [
"3 7\n-10 -1 0 9 -100 2 17",
"100 1\n-151489",
"3 7\n-8 -1 0 9 -100 2 17",
"3 7\n-10 -3 0 9 -100 2 18",
"2 5\n10 12 1 4 14",
"6 7\n-8 -1 0 9 -100 2 17",
"2 5\n10 12 1 4 21",
"2 7\n-8 -1 0 9 -100 2 17",
"3 7\n-10 -3 0 9 -5 0 17",
"3 7\n-8 -1 0 9 -100 0 17",
"2 5... |
p03282 AtCoder Beginner Contest 106 - To Infinity | Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows:
* Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `888888... | {
"input": [],
"output": []
} | {
"input": [
"299792458\n9460730472580800",
"3\n157",
"1214\n4"
],
"output": [
"2",
"3",
"2"
]
} | {
"input": [
"299792458\n16007747457388278",
"3\n162",
"1214\n1",
"1214\n8",
"299792458\n5161700883731392",
"3\n102",
"1214\n9",
"299792458\n6594324861078428",
"3\n74",
"1214\n17",
"299792458\n8352290250781537",
"3\n93",
"1214\n2",
"299792458\n16265126384663115"... |
p03437 AtCoder Petrozavodsk Contest 001 - Two Integers | You are given positive integers X and Y. If there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it. If it does not exist, print -1.
Constraints
* 1 ≤ X,Y ≤ 10^9
* X and Y are integers.
Input
Input is given from Standard Input in... | {
"input": [],
"output": []
} | {
"input": [
"3 3",
"8 6"
],
"output": [
"-1",
"16"
]
} | {
"input": [
"3 4",
"8 2",
"8 3",
"6 4",
"2 3",
"15 2",
"7 2",
"13 2",
"1 2",
"11 6",
"5 2",
"16 6",
"9 7",
"4 3",
"-2 4",
"25 6",
"12 5",
"19 6",
"22 5",
"31 14",
"14 4",
"46 6",
"10 3",
"33 6",
"17 5",
"29 16",
... |
p03596 CODE FESTIVAL 2017 qual A - Squeezing Slimes | There are A slimes lining up in a row. Initially, the sizes of the slimes are all 1.
Snuke can repeatedly perform the following operation.
* Choose a positive even number M. Then, select M consecutive slimes and form M / 2 pairs from those slimes as follows: pair the 1-st and 2-nd of them from the left, the 3-rd and ... | {
"input": [],
"output": []
} | {
"input": [
"10\n3 1 4 1 5 9 2 6 5 3",
"4\n2 1 2 2",
"1\n1",
"2\n3 3"
],
"output": [
"10",
"2",
"0",
"2"
]
} | {
"input": [
"4\n2 1 2 4",
"1\n2",
"2\n11 3",
"2\n3 1",
"2\n18 1",
"10\n3 1 1 1 5 9 2 6 5 3",
"2\n51 1",
"10\n3 1 1 1 5 9 2 11 5 3",
"2\n1 1",
"2\n72 2",
"10\n3 1 1 2 6 9 2 10 3 3",
"10\n3 1 1 2 5 9 2 10 1 3",
"2\n6 3",
"2\n7 3",
"2\n11 4",
"4\n3 1 2 4",... |
p03753 square869120Contest #4 - Calendar 2 | Input Format
The input format is following:
n m q
a_1 a_2 ... a_q
Output Format
Print the number of connected part in one line.
Constraints
* n ≤ 10^{12}
* 7n is divisible by m.
* 1 ≤ q ≤ m ≤ 10^5
* 0 ≤ a_1 < a_2 < ... < a_q < m
Scoring
Subtask 1 [100 points]
* n ≤ 100000.
Subtask 2 [90 points]
* m i... | {
"input": [],
"output": []
} | {
"input": [
"10 14 8\n5 6 7 8 9 10 11 12",
"7 7 3\n1 3 5"
],
"output": [
"10",
"4"
]
} | {
"input": [
"10 14 8\n5 6 7 8 9 10 11 23",
"7 7 2\n1 3 5",
"10 14 8\n5 6 2 8 9 10 11 23",
"7 7 2\n0 3 5",
"7 7 0\n0 3 5",
"10 14 8\n5 6 7 8 9 10 12 12",
"10 14 8\n5 2 12 8 13 10 1 12",
"10 14 8\n5 2 12 8 13 2 1 12",
"12 1 3\n5 0 1 7 5 3 5 39",
"19 6 1\n0 5 0",
"10 14 8\n5 ... |
p03917 CODE FESTIVAL 2016 Final - Reverse Grid | Snuke has a grid with H rows and W columns. The square at the i-th row and j-th column contains a character S_{i,j}.
He can perform the following two kinds of operation on the grid:
* Row-reverse: Reverse the order of the squares in a selected row.
* Column-reverse: Reverse the order of the squares in a selected colu... | {
"input": [],
"output": []
} | {
"input": [
"2 2\ncf\ncf",
"1 12\ncodefestival"
],
"output": [
"6",
"2"
]
} | {
"input": [
"1 12\nctdefesoival",
"0 12\nctdefesoival",
"2 2\ncf\ndf",
"2 2\ncf\nde",
"0 12\nctdffesoival",
"0 1\nctdffesoival",
"0 1\ncfdftesoival",
"0 2\ncfdftesoival",
"0 4\ncfdftesoival",
"0 2\ncfdftetoival",
"0 4\ncfdftetoival",
"2 0\ncf\ncf",
"1 7\ncodefestiv... |
p00020 Capitalize | Write a program which replace all the lower-case letters of a given text with the corresponding captital letters.
Input
A text including lower-case letters, periods, and space is given in a line. The number of characters in the text is less than or equal to 200.
Output
Print the converted text.
Example
Input
t... | {
"input": [],
"output": []
} | {
"input": [
"this is a pen."
],
"output": [
"THIS IS A PEN."
]
} | {
"input": [
"this is b pen.",
"tiis is b pen.",
"tiis is a pen.",
"tiis it a pen.",
"tiis it a pem.",
"tiis it a .mep",
"tiis it b .mep",
"tiis it b pem.",
"tiis it b qem.",
"tiis ti b qem.",
"tiis th b qem.",
"tihs th b qem.",
"tihs ht b qem.",
"tihs it b qem.... |
p00151 Grid | There is a n × n grid D where each cell contains either 1 or 0.
Your task is to create a program that takes the gird data as input and computes the greatest number of consecutive 1s in either vertical, horizontal, or diagonal direction.
For example, the consecutive 1s with greatest number in the figure below is circl... | {
"input": [],
"output": []
} | {
"input": [
"5\n00011\n00101\n01000\n10101\n00010\n8\n11000001\n10110111\n01100111\n01111010\n11111111\n01011010\n10100010\n10000001\n2\n01\n00\n3\n000\n000\n000\n0"
],
"output": [
"4\n8\n1\n0"
]
} | {
"input": [
"5\n00011\n00101\n01000\n10101\n00010\n8\n11000001\n10110111\n01100111\n01111010\n11111111\n01001010\n10100010\n10000001\n2\n01\n00\n3\n000\n000\n000\n0",
"5\n01011\n00101\n01000\n10101\n00010\n8\n11000001\n10110111\n01100111\n01111010\n11111111\n01001010\n10100000\n10000001\n0\n01\n00\n3\n000\n0... |
p00308 Unknown Germ | Unknown pathogen
Dr. Hideyo discovered an unknown pathogen. This pathogen has a chain structure in which two types of bacteria called Akdamakin and Zendamakin are linked in a straight line. We want to detoxify this pathogen for humankind.
It is known that this pathogen weakens when the length is 2 or less and is deto... | {
"input": [],
"output": []
} | {
"input": [
"6\noooxxxx\nooooxxx\noxxooxxo\nooxx\noo\nooo"
],
"output": [
"-1\n7\nsplit 0 0\njoin 2 1\nsplit 3 4\nsplit 4 0\njoin 7 6\nsplit 8 2\nsplit 9 0\n3\nsplit 0 1\nsplit 2 1\nsplit 4 1\n-1\n0\n1\nsplit 0 0"
]
} | {
"input": [
"6\noooxxxx\nooooxxx\noxxooxxo\nooxx\noo\noon",
"6\noooxxxx\nooooxxx\noxxooxxo\nooxx\noo\nonn",
"6\noooxxxx\noooowxx\noxxooxxo\nooxx\noo\noon",
"6\noooxxxx\noooowxx\nooxoxxxo\nooxx\noo\noon",
"6\noooxxxx\nooonxxx\noxxooxxo\nooxx\nop\nonn",
"6\noooxwwx\nooooxxx\noxxooxxo\nonyx\noo\... |
p00472 A Traveler | problem
You are a traveler traveling on the JOI Highway. The JOI Highway is a road that extends straight from east to west, and there are n post towns on the JOI Highway. Numbered. The westernmost post town on the JOI highway is post town 1, and the easternmost post town is post town n.
You have decided to depart fro... | {
"input": [],
"output": []
} | {
"input": [
"7 5\n2\n1\n1\n3\n2\n1\n2\n-1\n3\n2\n-3"
],
"output": [
"18"
]
} | {
"input": [
"7 5\n2\n1\n2\n3\n2\n1\n2\n-1\n3\n2\n-3",
"7 5\n2\n0\n2\n3\n2\n1\n2\n-1\n3\n2\n-3",
"7 5\n2\n1\n1\n3\n2\n1\n2\n-1\n1\n2\n-3",
"7 5\n2\n1\n1\n0\n2\n1\n2\n-1\n1\n2\n-3",
"7 5\n2\n1\n2\n3\n0\n1\n2\n-1\n3\n2\n-1",
"7 5\n1\n0\n2\n3\n2\n1\n2\n-1\n3\n1\n-3",
"7 5\n2\n0\n1\n0\n2\n1\n2... |
p00664 Cosmic Market | Cosmic market, commonly known as Kozumike, is the largest coterie spot sale in the universe. Doujin lovers of all genres gather at Kozumike. In recent years, the number of visitors to Kozumike has been increasing. If everyone can enter from the beginning, it will be very crowded and dangerous, so admission is restricte... | {
"input": [],
"output": []
} | {
"input": [
"5 5 5\n0 0 1\n0 0 0\n0 2 0\n1 2 1\n0 0 0\n5 5 5\n1 4 0\n0 1 1\n0 4 1\n1 3 0\n0 3 1\n5 5 5\n1 0 0\n0 3 0\n1 2 1\n0 4 0\n0 1 1\n0 0 0"
],
"output": [
"4\n13\n8"
]
} | {
"input": [
"5 5 5\n0 0 1\n0 0 0\n0 2 0\n1 2 1\n0 0 0\n5 5 5\n1 4 0\n0 1 1\n0 4 1\n1 3 0\n0 3 1\n5 5 5\n1 0 1\n0 3 0\n1 2 1\n0 4 0\n0 1 1\n0 0 0",
"5 5 5\n0 0 2\n0 0 0\n0 2 0\n1 2 1\n0 0 0\n5 5 5\n1 4 0\n0 1 1\n0 4 1\n1 3 0\n0 3 1\n5 5 5\n1 0 0\n0 3 0\n1 2 1\n0 4 0\n0 1 1\n0 0 0",
"5 5 5\n0 0 1\n0 0 0\n0... |
p00807 Beehives | Taro and Hanako, students majoring in biology, have been engaged long in observations of beehives. Their interest is in finding any egg patterns laid by queen bees of a specific wild species. A queen bee is said to lay a batch ofeggs in a short time. Taro and Hanako have never seen queen bees laying eggs. Thus, every t... | {
"input": [],
"output": []
} | {
"input": [
"5\nfaafd\nbcbdb\n-\nbcbdb\nbccac\n-\nfaafd\naafdd\n-\naaafddd\naaaeff\n-\naaedd\naafdd\n-"
],
"output": [
"true\ntrue\nfalse\nfalse\nfalse"
]
} | {
"input": [
"5\nfaafd\nbcbdb\n-\nbcbdb\nbccac\n-\nfaafd\naafdd\n-\naaafddd\nffeaaa\n-\naaedd\naafdd\n-",
"5\nfaafd\nbccdb\n-\nbcbdb\nbccac\n-\nfaafd\naafdd\n-\naaafddd\naaaeff\n-\naaedd\naafdd\n-",
"5\nfaafd\nbccdb\n-\nbcbdb\nbccbc\n-\nfaafd\naafdd\n-\naaafddd\naaaeff\n-\naaedd\naafdd\n-",
"5\nfaafd\... |
p00938 Wall Clocks | Example
Input
2 10 6
4 4 E
6 4 W
Output
2 | {
"input": [],
"output": []
} | {
"input": [
"2 10 6\n4 4 E\n6 4 W"
],
"output": [
"2"
]
} | {
"input": [
"2 19 6\n4 4 E\n6 4 W",
"2 19 1\n4 4 E\n6 0 W",
"2 19 6\n4 4 E\n6 0 W",
"2 19 10\n4 4 E\n6 0 W",
"3 19 10\n4 4 E\n6 0 W",
"3 19 10\n4 4 E\n6 -1 W",
"2 10 9\n4 4 E\n6 4 W",
"2 28 6\n4 4 E\n6 0 W",
"1 19 10\n4 4 E\n6 0 W",
"3 19 5\n4 4 E\n6 -1 W",
"3 19 10\n4 3 E... |
p01071 Monochrome Tile | Problem
There are W white square tiles in the horizontal direction and H in the vertical direction, for a total of W x H tiles.
On the morning of day i, Taro has a tile that exists in a rectangular area with the axith tile from the left and the ayith tile from the top on the upper left, and the bxith tile from the le... | {
"input": [],
"output": []
} | {
"input": [
"5 4\n5\n1 1 3 3\n3 2 4 2\n4 3 5 4\n1 4 5 4\n4 1 4 1"
],
"output": [
"9\n9\n13\n13\n14"
]
} | {
"input": [],
"output": []
} |
p01205 Goofy Converter | Nathan O. Davis is a student at the department of integrated systems. He is now taking a class in in- tegrated curcuits. He is an idiot. One day, he got an assignment as follows: design a logic circuit that takes a sequence of positive integers as input, and that outputs a sequence of 1-bit integers from which the orig... | {
"input": [],
"output": []
} | {
"input": [
"4 4\n4 3 2 2\n4 4\n4 3 2 3\n0 0"
],
"output": [
"1111001\nGoofy"
]
} | {
"input": [
"4 4\n4 3 2 2\n4 4\n4 3 0 3\n0 0",
"4 4\n4 3 4 2\n4 4\n4 3 0 3\n0 0",
"4 5\n4 3 2 3\n4 8\n4 5 1 6\n0 0",
"4 4\n4 3 2 1\n4 4\n4 3 1 3\n0 0",
"4 4\n8 3 2 2\n4 4\n4 3 3 3\n0 0",
"4 4\n4 3 2 2\n4 4\n3 3 4 3\n0 0",
"4 4\n4 3 0 2\n4 4\n3 3 4 3\n0 0",
"4 4\n4 3 2 2\n4 4\n0 3 2 3\... |
p01341 Save your cats | Nicholas Y. Alford was a cat lover. He had a garden in a village and kept many cats in his garden. The cats were so cute that people in the village also loved them.
One day, an evil witch visited the village. She envied the cats for being loved by everyone. She drove magical piles in his garden and enclosed the cats w... | {
"input": [],
"output": []
} | {
"input": [
"3 3\n0 0\n3 0\n0 4\n1 2\n2 3\n3 1",
"6 6\n0 0\n0 1\n1 0\n30 0\n0 40\n30 40\n1 2\n2 3\n3 1\n4 5\n5 6\n6 4",
"4 3\n0 0\n-100 0\n100 0\n0 100\n1 2\n1 3\n1 4",
"6 7\n2 0\n6 0\n8 2\n6 3\n0 5\n1 7\n1 2\n2 3\n3 4\n4 1\n5 1\n5 4\n5 6"
],
"output": [
"3.000",
"31.000",
"0.000",
... | {
"input": [
"3 3\n0 0\n3 0\n0 4\n1 4\n2 3\n3 1",
"6 7\n2 0\n6 -1\n8 2\n6 3\n0 5\n1 7\n1 2\n2 3\n3 4\n4 1\n5 1\n5 4\n5 6",
"6 6\n0 0\n0 1\n1 0\n30 0\n0 40\n30 40\n1 2\n2 3\n3 1\n4 5\n5 6\n11 4",
"6 7\n2 0\n6 0\n8 2\n6 2\n0 5\n1 7\n1 2\n2 3\n3 4\n4 1\n5 1\n5 4\n5 6",
"6 7\n2 0\n6 -1\n8 2\n6 3\n0 5\... |
p01508 Longest Lane | Mr. KM, the mayor of KM city, decided to build a new elementary school. The site for the school has an awkward polygonal shape, which caused several problems. The most serious problem was that there was not enough space for a short distance racetrack. Your task is to help Mr. KM to calculate the maximum possible length... | {
"input": [],
"output": []
} | {
"input": [
"4\n0 0\n10 0\n10 10\n0 10\n3\n0 0\n1 0\n0 1\n0"
],
"output": [
"Case 1: 14.142135624\nCase 2: 1.41421356"
]
} | {
"input": [
"4\n0 -1\n10 0\n10 10\n0 10\n3\n0 0\n1 0\n0 1\n0",
"4\n0 -1\n10 1\n10 5\n0 10\n3\n0 0\n1 0\n0 1\n0",
"4\n0 0\n10 0\n16 10\n0 10\n3\n0 0\n1 0\n0 1\n0",
"4\n0 -1\n10 0\n10 10\n0 10\n3\n0 0\n2 0\n0 1\n0",
"4\n0 -1\n10 0\n3 10\n0 10\n3\n0 0\n2 0\n0 1\n0",
"4\n0 0\n10 0\n10 10\n1 10\n3... |
p01679 SIRO Challenge | Problem Statement
You are now participating in the Summer Training Camp for Programming Contests with your friend Jiro, who is an enthusiast of the ramen chain SIRO. Since every SIRO restaurant has its own tasteful ramen, he wants to try them at as many different restaurants as possible in the night. He doesn't have p... | {
"input": [],
"output": []
} | {
"input": [
"2 1 1 1 10\n1 2 3\n2 4\n2 1 1 1 9\n1 2 3\n2 4\n4 2 2 4 50\n1 2 5\n3 4 5\n2 15\n3 15\n4 6 3 1 29\n1 2 20\n3 2 10\n4 1 5\n3 1 5\n2 4 3\n3 4 4\n2 1\n4 5\n3 3\n0 0 0 0 0"
],
"output": [
"1\n0\n1\n3"
]
} | {
"input": [
"2 1 1 1 10\n1 2 3\n2 4\n2 1 1 1 9\n1 2 3\n2 4\n4 2 2 4 50\n1 2 5\n3 4 5\n2 15\n3 7\n4 6 3 1 29\n1 2 20\n3 2 10\n4 1 5\n3 1 5\n2 4 3\n3 4 4\n2 1\n4 5\n3 3\n0 0 0 0 0",
"2 1 1 1 0\n1 2 3\n2 4\n2 1 1 1 9\n1 2 3\n2 4\n4 2 2 4 50\n1 2 5\n3 4 5\n2 15\n3 10\n4 6 3 1 29\n1 0 13\n3 2 10\n4 1 5\n3 1 5\n2 ... |
p01823 Marching Course | Example
Input
3 3 4
1 2 1 1
2 3 2 4
3 1 1 1
Output
6 | {
"input": [],
"output": []
} | {
"input": [
"3 3 4\n1 2 1 1\n2 3 2 4\n3 1 1 1"
],
"output": [
"6"
]
} | {
"input": [
"3 3 4\n1 2 1 1\n2 3 3 4\n3 1 1 1",
"3 3 4\n1 2 1 1\n2 3 3 5\n3 1 1 1",
"3 3 4\n2 2 1 1\n2 3 3 5\n3 1 1 0",
"3 3 4\n1 2 1 1\n2 3 1 4\n3 1 1 1",
"3 3 7\n2 2 1 1\n2 3 3 5\n3 1 1 1",
"3 3 2\n1 2 1 1\n2 3 1 4\n3 1 1 1",
"3 3 7\n2 2 1 1\n2 3 4 5\n3 1 1 1",
"3 3 0\n2 2 1 1\n2 3 ... |
p01958 Prime-Factor Prime | A positive integer is called a "prime-factor prime" when the number of its prime factors is prime. For example, $12$ is a prime-factor prime because the number of prime factors of $12 = 2 \times 2 \times 3$ is $3$, which is prime. On the other hand, $210$ is not a prime-factor prime because the number of prime factors ... | {
"input": [],
"output": []
} | {
"input": [
"180 180",
"999000001 1000000000",
"575 57577",
"9900001 10000000",
"1 9",
"10 20"
],
"output": [
"1",
"592955",
"36172",
"60997",
"4",
"6"
]
} | {
"input": [
"180 355",
"575 105187",
"1 12",
"8 355",
"575 184476",
"1 17",
"575 263927",
"8 29",
"575 229506",
"1 7",
"8 52",
"373 229506",
"16 52",
"373 397405",
"2 9",
"10 52",
"373 767091",
"2 8",
"4 52",
"373 999491",
"4 58",
... |
p02105 Zombie Hunter | Problem
Gaccho is enthusiastic about the popular game Zombie Hunter. In this game, there are 5 types of armor dedicated to the head, torso, arms, hips, and legs, and the player character (PC) operated by Gaccho can have up to 1 armor for each part of the body. Can be equipped.
In addition, the weight and defense power... | {
"input": [],
"output": []
} | {
"input": [
"7 10 11\n1 1 0\n1 0 1\n2 2 2\n3 3 5\n4 1 3\n5 1 3\n5 5 -1",
"7 10 10\n1 1 0\n1 0 1\n2 2 2\n3 3 5\n4 1 3\n5 1 3\n5 5 -1"
],
"output": [
"Yes",
"No"
]
} | {
"input": [
"7 10 11\n1 1 0\n1 0 1\n2 4 2\n3 3 5\n4 1 3\n5 1 3\n5 5 -1",
"7 7 11\n1 1 0\n1 0 1\n2 4 2\n3 3 5\n4 1 3\n5 1 3\n5 5 -1",
"7 10 10\n1 1 0\n1 0 1\n2 2 2\n3 3 3\n4 1 3\n5 1 3\n5 5 -1",
"7 10 10\n1 1 0\n1 0 1\n2 2 2\n3 3 3\n4 1 3\n5 1 3\n5 2 -1",
"7 7 11\n1 1 0\n1 0 1\n2 0 2\n3 3 5\n4 1 3... |
p02245 8 Puzzle | The goal of the 8 puzzle problem is to complete pieces on $3 \times 3$ cells where one of the cells is empty space.
In this problem, the space is represented by 0 and pieces are represented by integers from 1 to 8 as shown below.
1 3 0
4 2 5
7 8 6
You can move a piece toward the empty space at one step. Your goal ... | {
"input": [],
"output": []
} | {
"input": [
"1 3 0\n4 2 5\n7 8 6"
],
"output": [
"4"
]
} | {
"input": [
"1 4 0\n5 2 3\n7 8 6"
],
"output": [
"14\n"
]
} |
p02391 Small | Write a program which prints small/large/equal relation of given two integers a and b.
Constraints
* -1000 ≤ a, b ≤ 1000
Input
Two integers a and b separated by a single space are given in a line.
Output
For given two integers a and b, print
a < b
if a is less than b,
a > b
if a is greater than b, and
a... | {
"input": [],
"output": []
} | {
"input": [
"5 5",
"1 2",
"4 3"
],
"output": [
"a == b",
"a",
"a > b"
]
} | {
"input": [
"5 10",
"1 1",
"2 0",
"2 3",
"5 6",
"0 1",
"2 5",
"5 12",
"-1 1",
"2 8",
"5 19",
"-1 0",
"9 19",
"0 0",
"1 0",
"9 16",
"1 -1",
"2 1",
"7 16",
"1 -2",
"3 1",
"2 16",
"0 -2",
"5 1",
"1 16",
"-1 -2",
... |
algfact | The chef was chatting with his friend who was a mathematician.Chef said "Hi !".
His friend replied that '!' is the symbol of factorial.
Chef had never heard about it and he asked more about it. Then his friend taught him how to calculate the factorial of a number.
Chef loved that But as always he got tired after calcul... | {
"input": [],
"output": []
} | {
"input": [
"3\n5\n4\n6"
],
"output": [
"120\n24\n720\n"
]
} | {
"input": [
"3\n5\n7\n6",
"3\n5\n7\n12",
"3\n5\n13\n12",
"3\n5\n8\n6",
"3\n4\n7\n6",
"3\n5\n2\n12",
"3\n10\n13\n12",
"3\n5\n5\n6",
"3\n2\n7\n6",
"3\n2\n2\n12",
"3\n10\n21\n12",
"3\n3\n5\n6",
"3\n2\n7\n11",
"3\n2\n2\n5",
"3\n10\n38\n12",
"3\n2\n8\n11",
... |
chefteam | Chef has N subordinates. In order to complete a very important order he will choose exactly K of them. He can't choose less than K since it will be not enough to complete the order in time. On the other hand if he chooses more than K subordinates he can't control them during the operation. Help him to find the number o... | {
"input": [],
"output": []
} | {
"input": [
"3\n2 1\n3 3\n10 5"
],
"output": [
"2\n1\n252\n"
]
} | {
"input": [
"3\n2 1\n3 4\n10 5",
"3\n3 1\n3 4\n10 5",
"3\n5 2\n3 4\n10 5",
"3\n5 2\n4 4\n10 5",
"3\n5 2\n5 4\n10 5",
"3\n5 2\n5 4\n10 3",
"3\n5 2\n5 4\n9 3",
"3\n5 2\n10 4\n9 3",
"3\n5 2\n10 5\n9 3",
"3\n5 2\n2 5\n9 3",
"3\n5 1\n2 5\n9 3",
"3\n9 1\n2 5\n9 3",
"3\n9... |
ds15 | Background
Given a natural number n, find the summation of all its proper divisors.
Definition: A proper divisor of a natural number is the divisor that is strictly less than the number. e.g. number 20 has 5 proper divisors: 1, 2, 4, 5, 10, and the divisor summation is: 1 + 2 + 4 + 5 + 10 = 22.
Input:
An integer s... | {
"input": [],
"output": []
} | {
"input": [
"3\n2\n10\n20"
],
"output": [
"1\n8\n22\n"
]
} | {
"input": [
"3\n2\n10\n9",
"3\n2\n10\n7",
"3\n2\n10\n28",
"3\n2\n15\n7",
"3\n2\n3\n7",
"3\n2\n4\n11",
"3\n2\n6\n11",
"3\n2\n10\n24",
"3\n4\n10\n7",
"3\n2\n4\n28",
"3\n4\n3\n11",
"3\n2\n7\n28",
"3\n2\n9\n28",
"3\n3\n3\n4",
"3\n3\n10\n20",
"3\n2\n18\n9",
... |
kc01 | Points:10
The Indian Heights School believes that learning with the aid of technology is the fastest way to do so. It is a pioneer in innovation and virtual classrooms in the country. Keeping in accordance with its practices, the school wants to integrate software and automate various functions at the classroom level. ... | {
"input": [],
"output": []
} | {
"input": [
"2\n5 3\n10 5"
],
"output": [
"10\n252\n"
]
} | {
"input": [
"2\n5 0\n10 5",
"2\n10 0\n12 5",
"2\n10 0\n5 5",
"2\n10 0\n5 2",
"2\n5 3\n10 9",
"2\n10 0\n12 6",
"2\n9 0\n13 5",
"2\n10 0\n12 2",
"2\n1 3\n19 9",
"2\n5 0\n5 1",
"2\n10 0\n12 1",
"2\n10 1\n0 3",
"2\n9 1\n0 3",
"2\n1 1\n19 13",
"2\n9 2\n-1 2",
... |
numpath | The Head Chef is interested in studying interactions between his chefs . There are N chefs with ids 1 to N . Each chef trusts some of the other chefs . The relation of trust is one way . Also , a chef may trust chefs only with ids strictly greater than his/her id .A chef with id = i , trusts the chefs with next ni id... | {
"input": [],
"output": []
} | {
"input": [
"3 3\n2\n1\n0\n2\n1\n2"
],
"output": [
"2\n1"
]
} | {
"input": [
"3 3\n2\n1\n-1\n2\n1\n2",
"3 2\n2\n1\n-1\n2\n1\n2",
"4 3\n2\n1\n0\n2\n1\n2",
"3 3\n2\n0\n-1\n2\n1\n2",
"3 2\n2\n2\n0\n2\n0\n2",
"4 3\n2\n1\n0\n2\n1\n4",
"3 3\n2\n0\n-1\n2\n0\n2",
"3 3\n2\n1\n-1\n2\n1\n1",
"4 3\n2\n1\n0\n2\n1\n1",
"3 3\n2\n-1\n0\n2\n1\n0",
"1 1\... |
smhte | Problem Statement
Given a number , find whether it is a power of 2 or not
NOTE There is a limit in Source code.
Input
The first Line contains T , the no of test cases followed by T lines.
Each line has a integer X
Output
Output has T lines , with each line indicating whethet the number is a power of 2 or not(... | {
"input": [],
"output": []
} | {
"input": [
"4\n4\n0\n6\n8"
],
"output": [
"1\n0\n0\n1"
]
} | {
"input": [
"4\n4\n0\n6\n2",
"4\n4\n0\n11\n3",
"4\n6\n0\n11\n3",
"4\n6\n0\n11\n4",
"4\n13\n-3\n1\n2",
"4\n5\n1\n0\n3",
"4\n5\n1\n0\n4",
"4\n1\n2\n0\n1",
"4\n-2\n1\n1\n2",
"4\n-2\n1\n1\n3",
"4\n1\n3\n1\n5",
"4\n1\n1\n1\n5",
"4\n0\n0\n2\n15",
"4\n1\n1\n0\n-1",
... |
1240_B. Sequence Sorting | You are given a sequence a_1, a_2, ..., a_n, consisting of integers.
You can apply the following operation to this sequence: choose some integer x and move all elements equal to x either to the beginning, or to the end of a. Note that you have to move all these elements in one direction in one operation.
For example,... | {
"input": [],
"output": []
} | {
"input": [
"3\n7\n3 1 6 6 3 1 1\n8\n1 1 4 4 4 7 8 8\n7\n4 2 5 2 6 2 7\n"
],
"output": [
"2\n0\n1\n"
]
} | {
"input": [
"3\n7\n3 1 6 6 3 1 1\n8\n1 1 4 4 4 7 8 8\n7\n2 2 5 2 6 2 7\n",
"3\n7\n3 1 6 6 3 1 1\n8\n1 1 4 4 4 7 8 2\n7\n2 2 5 2 6 2 7\n",
"3\n7\n3 1 6 6 3 1 1\n8\n1 1 4 4 4 3 8 2\n7\n2 2 5 2 6 2 7\n",
"3\n7\n3 1 6 6 3 1 1\n8\n1 1 4 4 4 3 8 2\n7\n2 2 5 4 6 2 7\n",
"3\n7\n3 1 6 6 3 1 1\n8\n1 1 4 4 ... |
1282_C. Petya and Exam | Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes.
The exam consists of n problems that can be solved in T minutes. Thus, the exam begins at time 0 and ends at time T. Petya can leave the exam at any integer time from 0... | {
"input": [],
"output": []
} | {
"input": [
"10\n3 5 1 3\n0 0 1\n2 1 4\n2 5 2 3\n1 0\n3 2\n1 20 2 4\n0\n16\n6 20 2 5\n1 1 0 1 0 0\n0 8 2 9 11 6\n4 16 3 6\n1 0 1 1\n8 3 5 6\n6 20 3 6\n0 1 0 0 1 0\n20 11 3 20 16 17\n7 17 1 6\n1 1 0 1 0 0 0\n1 7 0 11 10 15 10\n6 17 2 6\n0 0 1 0 0 1\n7 6 3 7 10 12\n5 17 2 5\n1 1 1 1 0\n17 11 10 6 4\n1 1 1 2\n0\n1\... | {
"input": [
"10\n3 5 1 3\n0 0 1\n2 1 4\n2 5 2 3\n1 0\n3 2\n1 20 2 4\n0\n16\n6 20 2 5\n1 1 0 1 0 0\n0 8 2 9 11 6\n4 16 3 6\n1 0 1 1\n8 3 5 6\n6 20 3 6\n0 1 0 0 1 0\n20 11 3 20 16 17\n7 17 1 6\n1 1 0 1 0 0 0\n1 6 0 11 10 15 10\n6 17 2 6\n0 0 1 0 0 1\n7 6 3 7 10 12\n5 17 2 5\n1 1 1 1 0\n17 11 10 6 4\n1 1 1 2\n0\n1\... |
1302_D. Dijkstra | This is an unusual problem in an unusual contest, here is the announcement: [http://codeforces.com/blog/entry/73543](//codeforces.com/blog/entry/73543)
Find the distance between vertices 1 and n in an undirected weighted graph.
Input
The first line contains two integers n, m (1 ≤ n, m ≤ 2 ⋅ 10^5) — the number of ver... | {
"input": [],
"output": []
} | {
"input": [
"3 3\n1 2 5\n2 3 1\n1 3 7\n"
],
"output": [
"\n6\n"
]
} | {
"input": [],
"output": []
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.