name stringlengths 2 112 | description stringlengths 29 13k | private_tests dict | public_tests dict | generated_tests dict |
|---|---|---|---|---|
p01043 Yu-kun Likes a Treasure | Background
The kindergarten attached to the University of Aizu is a kindergarten where children who love programming gather. Yu, one of the kindergarten children, loves treasure as much as programming. Yu will continue to explore the cave today in search of treasure. So Yu decided to write a program to find the walkin... | {
"input": [],
"output": []
} | {
"input": [
"4 4\n3\n0 5\n3 8\n0 8\n1 7\n3\n1 3\n4 3\n1 6\n2 4\n5\n2 0\n7 0\n7 2\n3 2\n2 3\n6 1\n3\n6 2\n7 7\n2 7\n6 6",
"3 2\n3\n0 2\n3 5\n0 5\n1 4\n3\n1 0\n4 0\n1 3\n2 1\n3\n2 2\n4 3\n2 4\n3 3",
"3 1\n4\n0 4\n2 4\n2 7\n0 7\n1 6\n5\n1 0\n6 0\n4 5\n2 2\n1 4\n4 2\n3\n2 6\n6 4\n6 7\n5 6"
],
"output": [... | {
"input": [],
"output": []
} |
p01176 Controlled Tournament | National Association of Tennis is planning to hold a tennis competition among professional players. The competition is going to be a knockout tournament, and you are assigned the task to make the arrangement of players in the tournament.
You are given the detailed report about all participants of the competition. The ... | {
"input": [],
"output": []
} | {
"input": [
"2 1\n0 1\n0 0\n2 1\n0 0\n1 0\n3 3\n0 1 1\n0 0 1\n0 0 0\n3 3\n0 1 0\n0 0 0\n1 1 0\n3 1\n0 1 0\n0 0 0\n1 1 0\n3 3\n0 1 0\n0 0 1\n1 0 0\n6 4\n0 0 0 0 0 1\n1 0 1 0 1 0\n1 0 0 1 1 0\n1 1 0 0 1 0\n1 0 0 0 0 0\n0 1 1 1 1 0\n7 2\n0 1 0 0 0 1 0\n0 0 1 0 1 1 1\n1 0 0 1 1 0 0\n1 1 0 0 0 1 0\n1 0 0 1 0 0 1\n0 0... | {
"input": [
"2 1\n0 1\n0 0\n2 1\n0 0\n1 0\n3 3\n0 1 1\n0 0 1\n0 0 0\n3 3\n0 1 0\n0 0 0\n1 1 0\n3 1\n0 1 0\n0 0 0\n1 1 0\n3 3\n0 1 0\n0 0 1\n1 0 0\n6 4\n0 0 0 0 0 1\n1 0 1 0 1 0\n1 0 0 1 1 0\n1 1 0 0 1 0\n1 0 0 0 0 0\n0 1 1 1 1 0\n7 2\n0 1 0 0 0 1 0\n0 0 1 0 1 1 1\n1 0 0 1 1 0 0\n1 1 0 0 0 1 0\n1 0 0 1 0 0 1\n0 0... |
p01312 Cat Burglar and Friday House | Natsume loves big cats. On Natsume's school road, there is a house commonly known as a cat mansion. The house is famous for having a lot of cats, and Natsume often encountered her cats in front of this house on her way to school and played with them. One day, Natsume learned a shocking fact. It was that the owner of th... | {
"input": [],
"output": []
} | {
"input": [
"2\n0 0\n0 0\n15:00:00\n18:00:00\n1\n4 0 7199 1125 7199 1125 8324 0 8324\n0 0\n0 0\n15:00:00\n18:00:00\n1\n4 0 7201 1125 7201 1125 8326 0 8326"
],
"output": [
"1\n17 59 59.076923\n0\n15 00 00.000000"
]
} | {
"input": [
"2\n0 0\n0 0\n15:00:00\n18:00:00\n1\n4 0 7199 1125 7199 1125 8324 0 8324\n0 1\n0 0\n15:00:00\n18:00:00\n1\n4 0 7201 1125 7201 1125 8326 0 8326",
"2\n0 0\n0 0\n15:00:00\n18:00:00\n1\n4 0 7199 1125 7199 1125 8324 0 8324\n0 0\n0 0\n15:00:00\n18:00:00\n1\n4 0 7201 1125 7201 1125 8326 0 6318",
"2\... |
p01481 Lucky Dip | Time Limit: 8 sec / Memory Limit: 64 MB
Example
Input
10 10
.....#....
.....#....
.....#....
######....
..........
####......
....###...
t..#..####
...##.....
....#...##
3
0 3
0 5
4 6
Output
2 | {
"input": [],
"output": []
} | {
"input": [
"10 10\n.....#....\n.....#....\n.....#....\n######....\n..........\n####......\n....###...\nt..#..####\n...##.....\n....#...##\n3\n0 3\n0 5\n4 6"
],
"output": [
"2"
]
} | {
"input": [
"10 10\n.....#....\n.....#....\n.....#....\n######....\n..........\n####......\n....###...\nt..#..####\n...##.....\n##...#....\n3\n0 3\n0 5\n4 6",
"10 10\n.....#....\n.....#....\n.....#-...\n######....\n..........\n####......\n....###...\nt..#..####\n...##.....\n##...#....\n3\n0 3\n0 9\n4 6",
... |
p01642 Reverse Game | There was a girl who had a hobby of Othello. I enjoy Othello with my family when I have time.
One day, the girl tried to play Othello as usual. However, everyone was so busy that no one played. So I came up with a game that can be played by one person using Othello's board and spinning top.
problem
Othello pieces ar... | {
"input": [],
"output": []
} | {
"input": [
"1 3\n1 1 1"
],
"output": [
"4"
]
} | {
"input": [
"1 3\n2 1 0",
"1 3\n0 0 0",
"1 4\n0 0 0",
"2 6\n2 1 0",
"1 2\n0 0 1",
"1 6\n0 0 0",
"4 4\n0 0 0",
"1 11\n0 0 0",
"1 17\n0 0 0",
"7 1\n0 0 0",
"1 12\n0 0 0",
"4 11\n0 0 0",
"1 3\n0 1 1",
"1 3\n0 0 1",
"1 3\n3 1 0",
"1 4\n0 0 1",
"1 3\n0 1... |
p01794 Cost Performance Flow | Example
Input
2 1
1 2
1 2 1 1
Output
1/2 | {
"input": [],
"output": []
} | {
"input": [
"2 1\n1 2\n1 2 1 1"
],
"output": [
"1/2"
]
} | {
"input": [
"2 1\n1 2\n1 2 1 2",
"2 0\n1 2\n1 2 1 1",
"4 1\n1 2\n1 2 1 1",
"4 1\n1 2\n1 2 2 2",
"2 1\n1 2\n1 2 1 3",
"3 0\n1 2\n1 2 1 1",
"5 0\n1 2\n1 2 1 1",
"5 0\n1 2\n0 2 1 1",
"5 0\n1 2\n0 2 1 0",
"3 0\n1 2\n0 2 1 0",
"2 0\n1 2\n1 2 1 2",
"3 -1\n1 2\n1 2 1 1",
... |
p01928 Matryoshka Doll | Matryoshka
Matryoshka is a famous Russian folk craft doll. Matryoshka can be divided into upper and lower parts, and when opened, there is another smaller doll inside. The nesting structure is such that when the small doll that appears is opened, a smaller doll is contained.
<image>
You found an unusually shaped ma... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 2 3\n4 2 3\n3\n2 5 2\n3 3 4\n5 5 5\n5\n1 1 1\n2 2 2\n3 3 3\n4 4 4\n5 5 5\n5\n1 1 1\n2 1 1\n3 1 1\n4 1 1\n5 1 1\n10\n3 1 4\n1 5 9\n2 6 5\n3 5 8\n9 7 9\n3 2 3\n8 4 6\n2 6 4\n3 3 8\n3 2 7\n0"
],
"output": [
"24\n145\n125\n15\n864"
]
} | {
"input": [
"2\n1 4 3\n4 2 3\n3\n2 5 2\n3 3 4\n5 5 5\n5\n1 1 1\n2 2 2\n3 3 3\n4 4 4\n5 5 5\n5\n1 1 1\n2 1 1\n3 1 1\n4 1 1\n5 1 1\n10\n3 1 4\n1 5 9\n2 6 5\n3 5 8\n9 7 9\n3 2 3\n8 4 6\n2 6 4\n3 3 8\n3 2 7\n0",
"2\n1 4 3\n4 2 3\n3\n2 5 2\n3 3 4\n5 5 5\n5\n1 1 1\n2 2 2\n3 3 3\n4 4 4\n5 5 5\n5\n2 1 1\n2 1 1\n3 1 ... |
p02066 Treasure Hunter | G: Treasure Hunter
problem
There are N treasure trove, each of which is numbered from 1 to N. A treasure of value p_i lies in the i-th mountain, and this treasure can be obtained when you visit the mountain. Once you get the treasure, you can only get the treasure once, because the treasure will disappear from the mo... | {
"input": [],
"output": []
} | {
"input": [
"3 10\n6 8 2\n1 2 3\n2 3 8"
],
"output": [
"14"
]
} | {
"input": [
"3 10\n6 8 2\n1 2 1\n2 3 8",
"3 10\n6 6 2\n1 2 1\n2 3 8",
"3 10\n6 6 5\n1 2 1\n2 3 8",
"3 10\n12 6 2\n1 2 1\n2 3 8",
"3 6\n6 6 5\n1 2 1\n2 3 8",
"3 5\n12 6 2\n1 2 0\n2 3 8",
"3 10\n0 8 2\n1 2 3\n2 3 8",
"3 10\n6 3 4\n1 2 0\n2 3 8",
"3 18\n10 7 5\n1 2 0\n2 3 8",
"3 ... |
p02208 Cutlet Sandwich | Cutlet Sandwich
In some worlds, there are $ X $ types of "sandwiches", $ Y $ types of "cutlets", and $ Z $ types of "curry" foods.
There is a $ N $ type of "cutlet sandwich" in this world, and the $ i $ type of cutlet sandwich is made from the $ A_i $ type of sand and the $ B_i $ type of cutlet.
There is also a $ M ... | {
"input": [],
"output": []
} | {
"input": [
"1 1 1 1 1 1 1\n1 1\n1 1"
],
"output": [
"1"
]
} | {
"input": [
"2 1 1 1 1 1 1\n1 1\n1 1",
"2 1 1 1 1 1 1\n1 0\n1 1",
"1 1 1 1 2 1 1\n1 1\n1 1",
"2 0 1 1 1 1 1\n1 1\n1 1",
"0 1 1 1 1 1 1\n1 1\n1 1",
"1 1 1 1 1 1 1\n1 1\n2 1",
"1 1 1 1 1 1 1\n2 1\n2 1",
"2 1 1 1 1 1 1\n2 0\n1 1",
"1 2 1 1 1 1 1\n1 1\n2 1",
"4 1 1 1 1 1 1\n2 0\n1... |
p02362 Single Source Shortest Path (Negative Edges) | Constraints
* 1 ≤ |V| ≤ 1000
* 0 ≤ |E| ≤ 2000
* -10000 ≤ di ≤ 10000
* There are no parallel edges
* There are no self-loops
Input
An edge-weighted graph G (V, E) and the source r.
|V| |E| r
s0 t0 d0
s1 t1 d1
:
s|E|-1 t|E|-1 d|E|-1
|V| is the number of vertices and |E| is the number of edges in G. The graph verti... | {
"input": [],
"output": []
} | {
"input": [
"4 5 1\n0 1 2\n0 2 3\n1 2 -5\n1 3 1\n2 3 2",
"4 5 0\n0 1 2\n0 2 3\n1 2 -5\n1 3 1\n2 3 2",
"4 6 0\n0 1 2\n0 2 3\n1 2 -5\n1 3 1\n2 3 2\n3 1 0"
],
"output": [
"INF\n0\n-5\n-3",
"0\n2\n-3\n-1",
"NEGATIVE CYCLE"
]
} | {
"input": [
"4 5 1\n0 1 2\n0 3 3\n1 2 -5\n1 3 1\n2 3 2",
"4 5 0\n0 1 2\n0 2 3\n1 2 -5\n2 3 1\n2 3 2",
"4 6 0\n0 1 2\n0 2 3\n1 2 -5\n1 3 1\n3 3 2\n3 1 0",
"4 5 0\n0 1 2\n0 2 3\n1 0 -5\n2 3 1\n2 3 2",
"4 5 2\n0 1 2\n0 3 3\n1 2 -5\n1 3 2\n2 3 2",
"4 0 1\n0 0 2\n1 2 3\n2 0 -5\n2 3 1\n0 2 2",
... |
chcoinsg | Chef is playing a game with his friend Misha. They have a pile containg N coins. Players take alternate turns, removing some coins from the pile. On each turn, a player can remove either one coin or coins equal to some prime power (i.e. p^x coins, where p - prime number and x - positive integer). Game ends when the pil... | {
"input": [],
"output": []
} | {
"input": [
"2\n1\n8"
],
"output": [
"Chef\nChef\n"
]
} | {
"input": [
"2\n0\n8",
"2\n0\n6",
"2\n-1\n1",
"2\n-4\n0",
"2\n0\n1",
"2\n0\n0",
"2\n0\n-1",
"2\n1\n-1",
"2\n2\n-1",
"2\n-1\n-1",
"2\n-2\n-1",
"2\n-4\n-1",
"2\n-4\n-2",
"2\n-4\n1",
"2\n-3\n1",
"2\n-3\n2",
"2\n-4\n2",
"2\n-6\n2",
"2\n-1\n2",
... |
devarray | Devu has an array A consisting of N positive integers. He would like to perform following operation on array.
Pick some two elements a, b in the array (a could be same as b, but their corresponding indices in the array should not be same).
Remove both the elements a and b and instead add a number x such that x lies be... | {
"input": [],
"output": []
} | {
"input": [
"2 4\n1 3\n1\n2\n3\n4",
"1 2\n1\n1\n2"
],
"output": [
"Yes\nYes\nYes\nNo\n",
"Yes\nNo\n"
]
} | {
"input": [
"2 4\n1 3\n1\n4\n3\n4",
"2 4\n1 3\n1\n2\n3\n3",
"1 2\n1 3\n1\n4\n3\n4",
"2 4\n1 3\n1\n2\n3\n5",
"2 4\n1 3\n1\n2\n5\n4",
"1 2\n2 3\n1\n4\n3\n4",
"2 4\n1 3\n1\n0\n3\n2",
"1 1\n1\n0\n0",
"0 2\n2 3\n1\n2\n3\n4",
"1 3\n2 3\n1\n4\n4\n0",
"2 4\n1 3\n0\n0\n3\n10",
... |
iitk2p02 | Sumo was travelling alone at night, suddenly he saw a spaceship and out of it came an alien named KK. Obviously, the alien had a different language and thus couldn't communicate readily. After some psycho-telepathic talk, Sumo realised that KK's language has M distinct characters. And a valid word in his language satis... | {
"input": [],
"output": []
} | {
"input": [
"2\n3 3\n1 4"
],
"output": [
"6\n4"
]
} | {
"input": [],
"output": []
} |
ndlvote | Did you ever hear about 'crossing the bridge noodle' ? Let me tell you that it's not some kind of bridge made of noodles. It's a dish, a kind of rice noodle soup. Mr.Ping makes the best noodle soup and his son Po is eagerly waiting for the user reviews in his father's blog. Users can vote with a (+) or a (-) and accord... | {
"input": [],
"output": []
} | {
"input": [
"2\nP 1\nP 2\n\n2\nP 2\nM -2\n\n0"
],
"output": [
"1\n1\n"
]
} | {
"input": [
"2\nP 1\nP 2\n\n2\nP 0\nM -2\n\n0",
"2\nP 1\nP 4\n\n2\nP 0\nM -2\n\n0",
"2\nQ 1\nP 4\n\n2\nP -1\nM -2\n\n0",
"2\nQ 1\nP 4\n\n2\nP -1\nM -3\n\n0",
"2\nQ 2\nP 4\n\n0\nP 0\nM -2\n\n0",
"2\nQ 2\nP 8\n\n2\nP -1\nM -3\n\n0",
"2\nP 1\nP 5\n\n2\nQ 0\nM -2\n\n0",
"2\nQ 2\nP 9\n\n2\... |
rubix4 | Given an array A of N numbers, find out the minimum number of elements to be changed to ensure that the new array becomes a consecutive sequence of numbers. For example, given A = {2, 3, 6, 7, 8} where N = 5, it is obvious that we can change the first two elements in A to get the new array A' = {4, 5, 6, 7, 8}.
(Note: ... | {
"input": [],
"output": []
} | {
"input": [
"2\n3\n1 4 5\n7\n99 8 9 102 103 16 17"
],
"output": [
"1\n4"
]
} | {
"input": [
"2\n3\n1 4 5\n7\n99 7 9 102 103 16 17",
"2\n3\n1 4 5\n7\n99 13 5 62 103 16 17",
"2\n3\n0 4 5\n7\n36 13 5 62 103 16 20",
"2\n3\n1 4 9\n6\n99 13 0 62 103 16 20",
"2\n3\n1 4 9\n6\n187 13 0 62 103 16 20",
"2\n1\n1 1 5\n6\n99 18 0 8 103 28 20",
"2\n3\n1 4 6\n7\n99 13 0 62 197 41 20... |
xornuber | Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1.
Input
The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case.
Output
For ea... | {
"input": [],
"output": []
} | {
"input": [
"1\n3"
],
"output": [
"1\n"
]
} | {
"input": [
"1\n1",
"1\n2",
"1\n7",
"1\n15",
"1\n31",
"1\n63",
"1\n127",
"1\n6",
"1\n4",
"1\n8",
"1\n10",
"1\n11",
"1\n5",
"1\n18",
"1\n36",
"1\n27",
"1\n59",
"1\n20",
"1\n49",
"1\n40",
"1\n51",
"1\n66",
"1\n90",
"1\n73",... |
1426_C. Increase and Copy | Initially, you have the array a consisting of one element 1 (a = [1]).
In one move, you can do one of the following things:
* Increase some (single) element of a by 1 (choose some i from 1 to the current length of a and increase a_i by one);
* Append the copy of some (single) element of a to the end of the array... | {
"input": [],
"output": []
} | {
"input": [
"5\n1\n5\n42\n1337\n1000000000\n"
],
"output": [
"0\n3\n11\n72\n63244\n"
]
} | {
"input": [
"5\n1\n5\n42\n1337\n1000001000\n",
"5\n1\n7\n42\n1337\n1000001000\n",
"5\n1\n7\n42\n259\n1000001000\n",
"5\n1\n7\n42\n284\n1000001000\n",
"5\n1\n2\n42\n284\n1000001000\n",
"5\n1\n2\n42\n129\n1000001000\n",
"5\n1\n2\n51\n129\n1000001000\n",
"5\n1\n5\n16\n1337\n1000001000\n"... |
1550_B. Maximum Cost Deletion | You are given a string s of length n consisting only of the characters 0 and 1.
You perform the following operation until the string becomes empty: choose some consecutive substring of equal characters, erase it from the string and glue the remaining two parts together (any of them can be empty) in the same order. For... | {
"input": [],
"output": []
} | {
"input": [
"3\n3 2 0\n000\n5 -2 5\n11001\n6 1 -4\n100111\n"
],
"output": [
"6\n15\n-2\n"
]
} | {
"input": [
"3\n3 2 0\n000\n5 -2 5\n11001\n6 1 -4\n110111\n",
"3\n3 2 0\n000\n5 -2 5\n11001\n6 1 -7\n110111\n",
"3\n3 2 0\n000\n5 -2 5\n11001\n6 1 0\n100111\n",
"3\n3 2 0\n000\n5 -4 5\n11001\n6 1 -4\n110111\n",
"3\n3 2 0\n000\n5 -2 5\n11001\n6 1 -13\n110111\n",
"3\n3 2 0\n000\n5 -2 5\n11001\n... |
316_F3. Suns and Rays | Smart Beaver became interested in drawing. He draws suns. However, at some point, Smart Beaver realized that simply drawing suns is boring. So he decided to design a program that will process his drawings. You are given a picture drawn by the beaver. It will have two colors: one for the background and one for the suns ... | {
"input": [],
"output": []
} | {
"input": [],
"output": []
} | {
"input": [],
"output": []
} |
beginners-task-4 | Naruto is a fan of numbers, he likes to play with them. This time he decided to multiply numbers and produce output. After every k elements he decides to find x^m, where x is the multiplication till k elements and m is a random number that naruto takes. Help naruto find the output.
As answer could be large, help him,... | {
"input": [],
"output": []
} | {
"input": [
"2\n5 2 2 5\n1 2 3 4 5\n5 2 2 5\n1 2 3 4 6\n\nSAMPLE"
],
"output": [
"0\n4"
]
} | {
"input": [
"2\n5 2 2 5\n1 2 3 4 9\n5 2 2 5\n1 2 3 4 6\n\nSAMPLE",
"2\n5 2 2 5\n1 2 3 4 3\n5 2 2 5\n1 2 3 4 6\n\nSAMPLE",
"2\n5 2 2 5\n1 2 3 4 9\n5 1 2 5\n1 2 3 4 6\n\nSAMPLE",
"2\n5 2 2 5\n1 0 3 4 9\n5 2 2 5\n1 2 3 6 6\n\nSAMPLE",
"2\n5 2 2 5\n1 2 1 6 9\n5 2 2 5\n1 2 3 6 6\n\nSAMPLE",
"2\n5 ... |
color-code | Our Earth is so beautiful due to the various amazing colours it contains. Now on Earth day we invited Species from Mars (called Martian) Planet to celebrate it with us and to let them know our Earth.
Martians got so much attracted with the beauty of our Earth and invited people of Earth to visit their Planet Mars.
Bu... | {
"input": [],
"output": []
} | {
"input": [
"2\n15 9 120\n255 98 174\n\nSAMPLE"
],
"output": [
"Case 1: 0Z 09 78 \nCase 2: ZZ 62 UY \n"
]
} | {
"input": [
"2\n15 9 120\n255 98 110\n\nSAMPLE",
"2\n15 9 120\n255 14 110\n\nSAMPLE",
"2\n15 11 120\n255 14 110\n\nSAMPLE",
"2\n15 11 137\n255 14 110\n\nSAMPLE",
"2\n15 11 137\n190 14 110\n\nSAMPME",
"2\n27 11 137\n190 14 110\n\nSAMPME",
"2\n15 9 140\n255 98 174\n\nSAMPLE",
"2\n15 9 1... |
feasible-relations | As a programmer, you sometimes have to deal with some math and this is the time to do it. You are given a list of binary relations, equalities and inequalities, like a = b, a != d, b = c etc. Your task is to output YES if you can assign integers to input variables in such a way, that you can satisfy all equalities and ... | {
"input": [],
"output": []
} | {
"input": [
"2\n2 2\n1 = 2\n1 != 2\n3 2\n1 = 2\n2 != 3\n\nSAMPLE"
],
"output": [
"NO\nYES"
]
} | {
"input": [],
"output": []
} |
non-fibo | Seeing the fame received by the Fibonacci numbers, the other Natural Numbers were feeling jealous. Therefore, to give them their shot at glory Mr. Non-Fibo now wants you to tell him the N^th- Non Fibonacci Number.
Input:
First line contains T which is the number of test cases.
T lines follow each with an integer N.
O... | {
"input": [],
"output": []
} | {
"input": [
"3\n1\n2\n3\n\nSAMPLE"
],
"output": [
"4\n6\n7\n"
]
} | {
"input": [
"3\n2\n2\n3\n\nSAMPLE",
"3\n1\n2\n3\n\nELPMAS",
"3\n2\n4\n3\n\nSAMPLE",
"3\n2\n2\n1\n\nEMPM@S",
"3\n1\n2\n5\n\nELPMAS",
"3\n4\n4\n3\n\nSAMPLE",
"3\n1\n1\n5\n\nELPMAS",
"3\n8\n4\n3\n\nSAMPLE",
"3\n8\n6\n3\n\nSAMPME",
"3\n8\n6\n6\n\nSAMPME",
"3\n14\n6\n6\n\nSAMPM... |
quantum-and-divisibility-2 | Quantum love solving mathematical problems. One day his teacher give him problem on divisibility to check his mathematical skills. He give him four numbers a,b,c,d and asked him to check whether (a^b) is divisible by (c^d) or not. As the constrains are high, so quantum need your help to answer the query.
INPUT
First ... | {
"input": [],
"output": []
} | {
"input": [
"1\n4 6 2 4\n\nSAMPLE"
],
"output": [
"Divisible"
]
} | {
"input": [
"1\n4 6 1 4\n\nSAMPLE",
"1\n3 4 2 2\n\nSAMPLE",
"1\n4 4 2 4\n\nSAMPLE",
"1\n4 6 2 1\n\nSAMPLE",
"1\n4 4 2 2\n\nSAMPLE",
"1\n4 3 2 1\n\nSAMPLE",
"1\n4 0 2 1\n\nSAMPLE",
"1\n1 4 2 2\n\nSAMPLE",
"1\n8 0 2 1\n\nSAMPLE",
"1\n1 4 2 2\n\nELPMAS",
"1\n8 0 2 1\n\nELPMAS... |
zeros-in-factorial | Ram was busy calclutaing the factorials of some numbers. He saw a pattern in the number of zeros in the end of the factorial.
Let n be the number and Z(n) be the number of zeros in the end of the factorial of n then for
x < y
Z (x) ≤ Z(y)
i.e. the function never decreases.
He is solving a problem and wants to calcu... | {
"input": [],
"output": []
} | {
"input": [
"1\n2 5\n\nSAMPLE"
],
"output": [
"1"
]
} | {
"input": [],
"output": []
} |
p02663 NOMURA Programming Competition 2020 - Study Scheduling | In this problem, we use the 24-hour clock.
Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study for K consecutive minutes while he is up. What is the length of the period in which he can start studying?
Constraint... | {
"input": [],
"output": []
} | {
"input": [
"10 0 15 0 30",
"10 0 12 0 120"
],
"output": [
"270",
"0"
]
} | {
"input": [
"10 0 15 0 25",
"4 0 12 0 120",
"10 -1 15 0 25",
"4 0 12 0 102",
"10 -1 15 0 14",
"4 0 12 0 22",
"10 -1 15 1 14",
"4 0 12 -1 22",
"6 -1 15 1 14",
"8 0 12 -1 22",
"6 -1 15 1 5",
"8 0 12 -1 34",
"6 -2 15 1 5",
"11 0 12 -1 34",
"6 -2 16 1 5",
"... |
p02792 AtCoder Beginner Contest 152 - Handstand 2 | Given is a positive integer N.
Find the number of pairs (A, B) of positive integers not greater than N that satisfy the following condition:
* When A and B are written in base ten without leading zeros, the last digit of A is equal to the first digit of B, and the first digit of A is equal to the last digit of B.
Con... | {
"input": [],
"output": []
} | {
"input": [
"2020",
"200000",
"25",
"100",
"1"
],
"output": [
"40812",
"400000008",
"17",
"108",
"1"
]
} | {
"input": [
"73",
"3093",
"50",
"101",
"0",
"11",
"1020",
"78",
"001",
"6",
"2011",
"92",
"9",
"2158",
"127",
"989",
"68",
"30",
"1478",
"21",
"2424",
"2",
"3",
"816",
"34",
"767",
"184",
"7",
"5",
... |
p02928 Japanese Student Championship 2019 Qualification - Kleene Inversion | We have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}.
Let B be a sequence of K \times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2.
Find the inversion number of B, modulo 10^9 + 7.
Here the inversion number of B is defined as the number of o... | {
"input": [],
"output": []
} | {
"input": [
"2 2\n2 1",
"10 998244353\n10 9 8 7 5 6 3 4 2 1",
"3 5\n1 1 1"
],
"output": [
"3",
"185297239",
"0"
]
} | {
"input": [
"2 2\n2 2",
"10 998244353\n10 9 8 7 5 6 3 4 4 1",
"3 5\n1 1 0",
"2 2\n0 2",
"10 998244353\n10 9 8 7 5 5 3 4 4 1",
"3 5\n1 2 0",
"10 998244353\n10 9 8 7 5 5 0 4 4 1",
"2 -4\n2 -1",
"2 2\n2 0",
"3 5\n0 1 1",
"10 1468376359\n10 9 8 7 5 6 3 4 4 1",
"3 5\n0 2 0"... |
p03064 Tenka1 Programmer Contest 2019 - Three Colors | You are given N integers. The i-th integer is a_i. Find the number, modulo 998244353, of ways to paint each of the integers red, green or blue so that the following condition is satisfied:
* Let R, G and B be the sums of the integers painted red, green and blue, respectively. There exists a triangle with positive area... | {
"input": [],
"output": []
} | {
"input": [
"4\n1\n1\n1\n2",
"6\n1\n3\n2\n3\n5\n2",
"20\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\n3\n2\n3\n8\n4"
],
"output": [
"18",
"150",
"563038556"
]
} | {
"input": [
"4\n1\n1\n0\n2",
"6\n1\n3\n0\n3\n5\n2",
"20\n3\n1\n2\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\n3\n2\n3\n8\n4",
"4\n1\n1\n0\n3",
"6\n1\n3\n0\n3\n5\n0",
"20\n3\n1\n2\n1\n5\n9\n2\n2\n5\n3\n5\n8\n9\n7\n9\n3\n2\n3\n8\n4",
"20\n3\n1\n2\n1\n5\n9\n2\n2\n5\n3\n5\n8\n9\n7\n9\n3\n2\n3\n12\n4"... |
p03207 AtCoder Beginner Contest 115 - Christmas Eve Eve | In some other world, today is the day before Christmas Eve.
Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan).
He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 i... | {
"input": [],
"output": []
} | {
"input": [
"4\n4320\n4320\n4320\n4320",
"3\n4980\n7980\n6980"
],
"output": [
"15120",
"15950"
]
} | {
"input": [
"4\n4320\n7204\n4320\n4320",
"3\n32\n7980\n6980",
"3\n32\n7980\n615",
"3\n6\n7980\n615",
"3\n6\n7980\n329",
"3\n6\n7980\n207",
"3\n7\n7980\n207",
"3\n7\n7980\n269",
"3\n7\n4428\n269",
"3\n7\n4428\n505",
"3\n3\n4428\n505",
"4\n4320\n582\n4320\n4320",
"3\... |
p03354 AtCoder Beginner Contest 097 - Equals | We have a permutation of the integers from 1 through N, p_1, p_2, .., p_N. We also have M pairs of two integers between 1 and N (inclusive), represented as (x_1,y_1), (x_2,y_2), .., (x_M,y_M). AtCoDeer the deer is going to perform the following operation on p as many times as desired so that the number of i (1 ≤ i ≤ N)... | {
"input": [],
"output": []
} | {
"input": [
"5 1\n1 2 3 4 5\n1 5",
"10 8\n5 3 6 8 7 10 9 1 2 4\n3 1\n4 1\n5 9\n2 5\n6 5\n3 5\n8 9\n7 9",
"3 2\n3 2 1\n1 2\n2 3",
"5 2\n5 3 1 4 2\n1 3\n5 4"
],
"output": [
"5",
"8",
"3",
"2"
]
} | {
"input": [
"3 2\n3 2 1\n1 2\n1 3",
"5 2\n5 3 1 4 3\n1 3\n5 4",
"10 8\n5 3 6 8 7 10 9 1 2 4\n3 1\n4 2\n5 9\n2 5\n6 5\n3 5\n8 9\n7 9",
"5 2\n5 3 1 4 2\n1 2\n5 4",
"10 8\n5 3 6 8 7 10 9 1 2 4\n3 1\n7 1\n5 9\n2 8\n6 5\n3 5\n8 9\n7 9",
"10 8\n5 3 6 8 7 10 9 1 2 4\n3 1\n4 1\n5 9\n2 2\n6 5\n3 5\n8 ... |
p03514 Code Festival Team Relay (Parallel) - Indifferent | We have 2N pots. The market price of the i-th pot (1 ≤ i ≤ 2N) is p_i yen (the currency of Japan).
Now, you and Lunlun the dachshund will alternately take one pot. You will go first, and we will continue until all the pots are taken by you or Lunlun. Since Lunlun does not know the market prices of the pots, she will a... | {
"input": [],
"output": []
} | {
"input": [
"1\n150000\n108",
"2\n50000\n50000\n100000\n100000"
],
"output": [
"150000.0",
"183333.3333333333"
]
} | {
"input": [
"1\n43783\n108",
"2\n50000\n66868\n100000\n100000",
"2\n50000\n66868\n110000\n100000",
"1\n36572\n91",
"2\n50000\n66868\n110000\n110000",
"2\n50000\n63435\n110000\n110000",
"1\n9258\n99",
"2\n50000\n63435\n111000\n110000",
"2\n50000\n63435\n111000\n110001",
"1\n139... |
p03677 AtCoder Regular Contest 077 - guruguru | Snuke is buying a lamp. The light of the lamp can be adjusted to m levels of brightness, represented by integers from 1 through m, by the two buttons on the remote control.
The first button is a "forward" button. When this button is pressed, the brightness level is increased by 1, except when the brightness level is m... | {
"input": [],
"output": []
} | {
"input": [
"4 6\n1 5 1 4",
"10 10\n10 9 8 7 6 5 4 3 2 1"
],
"output": [
"5",
"45"
]
} | {
"input": [
"10 10\n10 9 8 7 6 7 4 3 2 1",
"4 8\n1 5 1 4",
"10 10\n10 9 8 7 1 7 4 3 2 1",
"4 8\n1 5 1 5",
"2 10\n10 9 8 7 1 7 4 3 2 1",
"1 8\n1 5 2 1",
"4 19\n10 9 3 9 2 14 4 0 4 1",
"7 19\n10 9 3 9 2 14 4 0 4 1",
"7 19\n2 9 3 9 2 14 4 0 4 1",
"7 19\n2 9 3 18 2 14 4 0 4 1",
... |
p03832 AtCoder Regular Contest 067 - Grouping | There are N people, conveniently numbered 1 through N. We want to divide them into some number of groups, under the following two conditions:
* Every group contains between A and B people, inclusive.
* Let F_i be the number of the groups containing exactly i people. Then, for all i, either F_i=0 or C≤F_i≤D holds.
... | {
"input": [],
"output": []
} | {
"input": [
"10 3 4 2 5",
"7 2 3 1 3",
"1000 1 1000 1 1000",
"3 1 3 1 2"
],
"output": [
"0",
"105",
"465231251",
"4"
]
} | {
"input": [
"7 3 4 2 5",
"8 2 3 1 3",
"1000 1 1000 2 1000",
"1000 1 1000 3 1000",
"10 3 7 2 5",
"7 1 3 1 3",
"1000 1 1000 1 1001",
"7 1 6 2 5",
"0 3 8 2 7",
"2 1 3 1 2",
"8 2 5 1 3",
"1000 1 1000 4 1010",
"1000 1 1001 5 1010",
"10 1 3 2 2",
"13 1 6 2 5",
... |
p03997 AtCoder Beginner Contest 045 - Trapezoids | You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.
<image>
An example of a trapezoid
Find the area of this trapezoid.
Constraints
* 1≦a≦100
* 1≦b≦100
* 1≦h≦100
* All input values are integers.
* h is even.
Input
The input is given from Standard Input i... | {
"input": [],
"output": []
} | {
"input": [
"4\n4\n4",
"3\n4\n2"
],
"output": [
"16",
"7"
]
} | {
"input": [
"4\n4\n7",
"3\n6\n2",
"4\n8\n7",
"3\n10\n2",
"4\n8\n6",
"3\n10\n3",
"4\n9\n6",
"3\n12\n2",
"4\n5\n6",
"3\n2\n2",
"4\n5\n12",
"3\n1\n2",
"4\n5\n0",
"3\n2\n3",
"4\n5\n-1",
"4\n4\n-1",
"3\n0\n1",
"3\n0\n2",
"3\n-1\n2",
"4\n0\n-1... |
p00085 Joseph's Potato | <image>
There used to be a game called Joseph's potatoes. Let's say n people are participating. Participants form a circle facing the center and are numbered starting from 1. One hot potato is given to participant n (the large number 30 inside the figure on the left). Participants who are given the potatoes will give... | {
"input": [],
"output": []
} | {
"input": [
"41 3\n30 9\n0 0"
],
"output": [
"31\n21"
]
} | {
"input": [
"41 3\n21 9\n0 0",
"41 2\n21 9\n0 0",
"75 2\n21 9\n0 0",
"41 5\n30 9\n0 0",
"41 4\n21 9\n0 0",
"4 2\n21 9\n0 0",
"50 4\n21 9\n0 0",
"4 4\n21 9\n0 0",
"50 6\n21 9\n0 0",
"8 4\n21 9\n0 0",
"41 3\n30 2\n0 0",
"44 3\n21 9\n0 0",
"57 2\n21 9\n0 0",
"41 5... |
p00217 Walking in the Hospital | At Aizu Riverside Hospital, inpatients walk twice a day for rehabilitation and health promotion. As the number of people trying to recover their physical strength by walking is increasing day by day in order to leave the hospital energetically, the director plans to give a present to the person who walked the longest d... | {
"input": [],
"output": []
} | {
"input": [
"5\n263 2345 2504\n1 3210 1985\n5000 1501 4132\n10000 503 3107\n51 1758 2690\n3\n345 5000 2396\n7 3910 1590\n6789 2525 3616\n0"
],
"output": [
"5000 5633\n345 7396"
]
} | {
"input": [
"5\n263 2345 2504\n1 3210 1985\n5000 1501 4132\n10001 503 3107\n51 1758 2690\n3\n345 5000 2396\n7 3910 1590\n6789 2525 3616\n0",
"5\n263 1519 1817\n2 1240 1985\n5000 1501 4132\n10001 503 3107\n51 1421 2690\n3\n345 1628 2396\n7 3910 1590\n5982 2525 3616\n0",
"5\n263 1519 1817\n2 1240 1985\n500... |
p00377 Cake Party | I’m planning to have a party on my birthday. Many of my friends will come to the party. Some of them will come with one or more pieces of cakes, but it is not certain if the number of the cakes is a multiple of the number of people coming.
I wish to enjoy the cakes equally among the partiers. So, I decided to apply th... | {
"input": [],
"output": []
} | {
"input": [
"7 5\n8 8 8 8 8",
"5 4\n5 5 6 5",
"100 3\n3 3 3"
],
"output": [
"5",
"4",
"1"
]
} | {
"input": [
"4 5\n8 8 8 8 8",
"5 2\n5 5 6 5",
"100 3\n1 3 3",
"4 5\n8 8 2 8 8",
"4 5\n8 8 2 0 8",
"4 5\n8 7 2 0 8",
"1 5\n8 7 2 0 8",
"1 5\n8 7 4 0 8",
"0 5\n8 7 4 0 8",
"5 4\n2 7 5 10",
"0 5\n8 7 4 0 15",
"0 5\n11 7 4 0 15",
"0 1\n11 7 4 0 15",
"5 2\n1 15 11 1... |
p00595 Greatest Common Divisor | Please find the greatest common divisor of two natural numbers. A clue is: The Euclid's algorithm is a way to resolve this task.
Input
The input file consists of several lines with pairs of two natural numbers in each line. The numbers do not exceed 100000.
The number of pairs (datasets) is less than 50.
Output
... | {
"input": [],
"output": []
} | {
"input": [
"57 38\n60 84"
],
"output": [
"19\n12"
]
} | {
"input": [
"57 38\n19 84",
"57 38\n6 84",
"101 38\n6 84",
"101 47\n6 88",
"100 47\n11 88",
"57 18\n19 84",
"101 47\n6 37",
"101 47\n6 21",
"100 38\n10 84",
"100 88\n6 169",
"100 38\n8 84",
"100 88\n6 252",
"62 8\n19 84",
"101 112\n7 252",
"101 86\n9 9",
... |
p00731 Cliff Climbing | At 17:00, special agent Jack starts to escape from the enemy camp. There is a cliff in between the camp and the nearest safety zone. Jack has to climb the almost vertical cliff by stepping his feet on the blocks that cover the cliff. The cliff has slippery blocks where Jack has to spend time to take each step. He also ... | {
"input": [],
"output": []
} | {
"input": [
"6 6\n4 4 X X T T\n4 7 8 2 X 7\n3 X X X 1 8\n1 2 X X X 6\n1 1 2 4 4 7\nS S 2 3 X X\n2 10\nT 1\n1 X\n1 X\n1 X\n1 1\n1 X\n1 X\n1 1\n1 X\nS S\n2 10\nT X\n1 X\n1 X\n1 X\n1 1\n1 X\n1 X\n1 1\n1 X\nS S\n10 10\nT T T T T T T T T T\nX 2 X X X X X 3 4 X\n9 8 9 X X X 2 9 X 9\n7 7 X 7 3 X X 8 9 X\n8 9 9 9 6 3 X ... | {
"input": [
"6 6\n4 4 X X T T\n4 7 8 2 X 7\n1 X X X 1 8\n1 2 X X X 6\n1 1 2 4 4 7\nS S 2 3 X X\n2 10\nT 1\n1 X\n1 X\n1 X\n1 1\n1 X\n1 X\n1 1\n1 X\nS S\n2 10\nT X\n1 X\n1 X\n1 X\n1 1\n1 X\n1 X\n1 1\n1 X\nS S\n10 10\nT T T T T T T T T T\nX 2 X X X X X 3 4 X\n9 8 9 X X X 2 9 X 9\n7 7 X 7 3 X X 8 9 X\n8 9 9 9 6 3 X ... |
p00871 Top Spinning | Spinning tops are one of the most popular and the most traditional toys. Not only spinning them, but also making one’s own is a popular enjoyment.
One of the easiest way to make a top is to cut out a certain shape from a cardboard and pierce an axis stick through its center of mass. Professionally made tops usually ha... | {
"input": [],
"output": []
} | {
"input": [
"start 0 0\narc 2 2 -2\nline 2 5\narc 0 3 -2\nclose\nstart -1 1\nline 2 1\nline 2 2\nline -2 2\narc -3 1 -1\nline -3 -2\narc -2 -3 -1\nline 2 -3\nline 2 -2\nline -1 -2\nline -1 -1\narc -1 0 2\nclose\nstart 0 0\nline 3 0\nline 5 -1\narc 4 -2 -1\nline 6 -2\nline 6 1\nline 7 3\narc 8 2 -1\nline 8 4\nlin... | {
"input": [
"start 0 0\narc 2 2 -2\nline 2 5\narc 0 3 -2\nclose\nstart -1 1\nline 2 1\nline 2 2\nline -2 2\narc -3 1 -1\nline -3 -2\narc -2 -3 -1\nline 2 -3\nline 2 -2\nline -1 -2\nline -1 -1\narc -1 0 2\nclose\nstart 0 0\nline 3 0\nline 5 -1\narc 4 -2 -1\nline 6 -2\nline 6 1\nline 7 3\narc 8 2 -2\nline 8 4\nlin... |
p01002 Smartphone Game | Problem
Let's implement a function of a popular smartphone game. The game is based on the following specifications.
* 5 types of blocks are installed in 5 * 5 squares.
* Scores are set for each type of block.
* In addition to the block score, a bonus score is set for the score. The first bonus score is 1.
* You can a... | {
"input": [],
"output": []
} | {
"input": [
"0\n1 1 1 5 5\n5 5 5 5 5\n5 5 1 5 5\n5 1 1 1 5\n5 5 5 5 5\n0 0 0 0 1\n2\n1 2 3 4 5\n2 3 4 5 5\n2 3 4 5 5\n3 4 5 5 1\n5 4 3 2 1\n100 99 98 97 96\n5\n1 2 3 4 5\n2 3 4 5 1\n1 2 3 4 5\n5 4 3 2 1\n1 2 3 4 5\n99 79 31 23 56\n-1"
],
"output": [
"17\n2040\n926"
]
} | {
"input": [
"0\n1 1 1 5 5\n5 5 5 5 5\n5 5 1 5 5\n5 1 1 1 5\n5 5 5 5 5\n0 0 0 0 1\n2\n1 2 3 4 5\n2 3 4 5 5\n2 3 4 5 5\n3 4 5 9 1\n5 4 3 2 1\n100 99 98 97 96\n5\n1 2 3 4 5\n2 3 4 5 1\n1 2 3 4 5\n5 4 3 2 1\n1 2 3 4 5\n99 79 31 23 56\n-1",
"0\n1 1 1 5 5\n5 5 5 5 5\n5 5 1 5 5\n5 1 1 1 5\n5 5 5 5 5\n0 0 0 0 1\n2\n... |
p01134 Area Separation | Mr. Yamada Springfield Tanaka was appointed as Deputy Deputy Director of the National Land Readjustment Business Bureau. Currently, his country is in the midst of a major land readjustment, and if this land readjustment can be completed smoothly, his promotion is certain.
However, there are many people who are not hap... | {
"input": [],
"output": []
} | {
"input": [
"2\n-100 -20 100 20\n-20 -100 20 100\n2\n-100 -20 -20 -100\n20 100 100 20\n0"
],
"output": [
"4\n3"
]
} | {
"input": [
"2\n-100 -20 100 20\n-20 -100 18 100\n2\n-100 -20 -20 -100\n20 100 100 20\n0",
"2\n-100 -20 100 34\n-20 -100 18 100\n0\n-100 -20 -20 -186\n20 100 100 23\n0",
"2\n-3 0 000 29\n-2 -100 18 100\n0\n-100 -20 -13 -280\n20 100 100 2\n0",
"2\n-100 -20 100 20\n-20 -100 20 100\n2\n-100 -34 -20 -100... |
p01273 Infected Computer | Adam Ivan is working as a system administrator at Soy Group, Inc. He is now facing at a big trouble: a number of computers under his management have been infected by a computer virus. Unfortunately, anti-virus system in his company failed to detect this virus because it was very new.
Adam has identified the first comp... | {
"input": [],
"output": []
} | {
"input": [
"3 2\n1 1 2\n2 2 3\n3 2\n2 3 2\n1 2 1\n0 0"
],
"output": [
"3\n1"
]
} | {
"input": [
"3 2\n1 1 3\n2 2 3\n3 2\n2 3 2\n1 2 1\n0 0",
"3 2\n1 1 2\n2 2 3\n3 2\n2 3 2\n1 2 0\n0 0",
"4 2\n1 0 3\n1 2 3\n3 2\n2 3 2\n2 2 1\n0 0",
"3 2\n1 1 3\n1 2 3\n3 2\n2 1 2\n1 2 0\n0 0",
"3 2\n1 0 3\n1 2 3\n3 2\n2 1 2\n1 2 0\n0 0",
"3 2\n1 1 3\n1 2 3\n3 2\n2 3 2\n1 2 1\n0 0",
"3 2\n1... |
p01443 Number Sorting | Consider sets of natural numbers. Some sets can be sorted in the same order numerically and lexicographically. {2, 27, 3125, 9000} is one example of such sets; {2, 27, 243} is not since lexicographic sorting would yield {2, 243, 27}.
Your task is to write a program that, for the set of integers in a given range [A,B] ... | {
"input": [],
"output": []
} | {
"input": [
"1 10 1000\n1 100000 1000000000\n999999999 1000099998 1000000000\n0 0 0"
],
"output": [
"513\n899507743\n941554688"
]
} | {
"input": [
"1 10 1000\n1 100000 1000000000\n999999999 1000099998 1000000001\n0 0 0",
"1 9 1000\n1 100000 1000000000\n999999999 1000099998 1000000001\n0 0 0",
"1 8 1000\n1 100000 1000000000\n999999999 1000099998 1000000001\n0 0 0",
"1 10 1000\n1 100000 1000000000\n999999999 1000099998 1000000010\n0 0... |
p01592 Blame Game | Problem B: Blame Game
Alice and Bob are in a factional dispute. Recently a big serious problem arised in a project both Alice and Bob had been working for. This problem was caused by lots of faults of Alice's and Bob's sides; those faults are closely related.
Alice and Bob started to blame each other. First, Alice cl... | {
"input": [],
"output": []
} | {
"input": [
"1 1\n1 1",
"3 3\n3 1 2 3\n1 3\n1 3"
],
"output": [
"Bob",
"Alice"
]
} | {
"input": [
"1 1\n2 1",
"1 1\n0 1",
"3 3\n3 0 2 3\n1 3\n1 3",
"1 2\n2 1",
"1 2\n0 1",
"1 2\n0 0",
"1 1\n0 2",
"2 1\n0 0",
"1 2\n1 0",
"3 3\n3 0 2 3\n1 3\n0 3",
"1 0\n0 0",
"1 0\n0 -1",
"1 3\n2 1",
"1 0\n0 1",
"1 4\n0 0",
"2 2\n0 0",
"1 3\n1 0",
... |
p01749 Substring Pairs | Sunuke came up with a pun called "s de t t", but forgot it. Sunuke remembers the following.
* The length of s is N.
* The length of t is M.
* t is a substring of s. (There is a part of consecutive M characters of s that matches t.)
Divide the number of possible combinations as (s, t) by 1,000,000,007 to find the re... | {
"input": [],
"output": []
} | {
"input": [
"3 2 2",
"200 50 1000"
],
"output": [
"14",
"678200960"
]
} | {
"input": [
"200 50 1100",
"180 50 1000",
"180 50 1001",
"180 50 0001",
"3 3 2",
"180 50 1010",
"180 43 1001",
"140 50 1001",
"168 50 1001",
"3 3 4",
"168 42 1001",
"168 42 0011",
"168 42 0111",
"168 8 0111",
"168 8 0011",
"168 16 0011",
"127 16 001... |
p01889 Compressed Formula | Example
Input
1
5 1
Output
11111 | {
"input": [],
"output": []
} | {
"input": [
"1\n5 1"
],
"output": [
"11111"
]
} | {
"input": [
"1\n5 0",
"1\n5 2",
"1\n20 1",
"1\n10 2",
"1\n29 1",
"1\n10 3",
"1\n29 2",
"1\n10 5",
"1\n4 1",
"1\n14 2",
"1\n10 1",
"1\n4 2",
"1\n1 2",
"1\n1 3",
"1\n1 6",
"1\n1 12",
"1\n1 9",
"1\n1 8",
"1\n2 8",
"1\n4 8",
"1\n1 4",
... |
p02026 Demon's Cedar | L: Sugi (Demon's Cedar)
Tsukinose decided to change the trees all over the city to sugi trees and annoy people with hay fever in order to do something devilish.
There are $ N $ types of trees. The heavenly rank of the $ i $ tree is $ A_i $, and the rank in the demon world is $ B_i $. Also, the $ 1 $ type of tree is S... | {
"input": [],
"output": []
} | {
"input": [
"3\n1 2 5\n6 3 4"
],
"output": [
"0\n1\n2"
]
} | {
"input": [
"3\n0 2 5\n6 3 4",
"3\n0 2 5\n5 3 4",
"3\n0 2 5\n5 4 4",
"3\n0 0 5\n5 4 4",
"3\n0 0 7\n5 4 3",
"3\n0 0 7\n9 5 3",
"3\n0 -1 7\n9 10 5",
"3\n0 -1 7\n16 10 5",
"3\n0 -1 7\n16 4 5",
"3\n1 -1 1\n-1 0 4",
"3\n1 -1 1\n-2 0 4",
"3\n2 0 5\n-8 -1 2",
"3\n2 1 5\n-... |
p02168 Double or Increment | Problem
One day, mo3tthi and tubuann decided to play a game with magic pockets and biscuits.
Now there are $ K $ pockets, numbered $ 1,2, \ ldots, K $.
The capacity of the $ i $ th pocket is $ M_i $, which initially contains $ N_i $ biscuits.
mo3tthi and tubuann start with mo3tthi and perform the following series of o... | {
"input": [],
"output": []
} | {
"input": [
"1\n2 4",
"2\n2 3\n3 8",
"10\n2 8\n5 9\n7 20\n8 41\n23 48\n90 112\n4 5\n7 7\n2344 8923\n1 29"
],
"output": [
"mo3tthi",
"tubuann",
"mo3tthi"
]
} | {
"input": [
"1\n2 5",
"2\n1 3\n3 9",
"2\n1 3\n3 8",
"10\n2 8\n5 9\n7 20\n8 41\n23 48\n112 112\n4 5\n7 7\n2344 8923\n1 29",
"1\n2 6",
"10\n2 14\n5 9\n7 20\n8 41\n23 48\n112 112\n4 5\n7 7\n2344 8923\n1 29",
"1\n2 7",
"10\n2 14\n5 9\n7 20\n12 41\n23 48\n112 112\n4 5\n7 7\n2344 8923\n1 29... |
p02309 Cross Points of Circles | For given two circles $c1$ and $c2$, print the coordinates of the cross points of them.
Constraints
* The given circle have at least one cross point and have different center coordinates.
* $-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... | {
"input": [],
"output": []
} | {
"input": [
"0 0 2\n2 0 2",
"0 0 2\n0 3 1"
],
"output": [
"1.00000000 -1.73205080 1.00000000 1.73205080",
"0.00000000 2.00000000 0.00000000 2.00000000"
]
} | {
"input": [
"0 -1 2\n2 0 2",
"0 0 2\n0 2 1",
"0 -1 2\n0 0 2",
"0 -1 2\n0 0 1",
"0 -1 1\n0 0 1",
"0 -1 2\n2 0 4",
"0 -1 2\n2 0 3",
"0 -2 2\n0 0 2",
"1 -1 2\n0 0 2",
"0 -1 2\n-1 0 1",
"1 -2 2\n0 0 2",
"-1 -1 2\n-1 0 1",
"1 -1 2\n0 -1 2",
"2 -1 2\n0 -1 2",
"2 ... |
p02457 Set: Range Search | For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.
* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.
* find($x$): Report the number of $x$ in $S$ (0 or 1).
* delete($x$): Delete $x$ from $S$.
* dump($L$, $R... | {
"input": [],
"output": []
} | {
"input": [
"9\n0 1\n0 2\n0 3\n2 2\n1 1\n1 2\n1 3\n0 4\n3 2 4"
],
"output": [
"1\n2\n3\n1\n0\n1\n3\n3\n4"
]
} | {
"input": [
"9\n0 1\n0 2\n0 3\n2 2\n1 1\n1 2\n0 3\n0 4\n3 2 4",
"9\n0 1\n0 2\n0 3\n2 2\n1 0\n1 2\n0 3\n0 4\n3 2 6",
"9\n0 1\n0 2\n0 3\n2 2\n1 0\n1 2\n0 3\n0 5\n3 2 10",
"9\n0 1\n0 2\n0 3\n2 2\n1 0\n1 3\n0 3\n0 5\n3 3 10",
"9\n0 1\n0 2\n0 3\n2 2\n2 1\n1 2\n1 3\n0 4\n3 2 4",
"9\n0 1\n0 2\n0 3\n... |
cc1 | Problem description.
Chris brown and Rihanna are in a nxn grid(1 indexed). Chris brown want to reach Rihanna in minimum number of moves but the thing is he can move only diagonally and whatever may be the number of steps he takes it is considered as only one move unless he takes a turn. So in one move he can take as ma... | {
"input": [],
"output": []
} | {
"input": [
"2\n4\n1 1 3 3 \n4\n1 1 1 3"
],
"output": [
"1\n2"
]
} | {
"input": [],
"output": []
} |
csixierl | Given a string, count the number of aplhabets which are repeated
Input
The first line contains a single integer T <= 40, the number of test cases. T test cases follow. The only line of each test case contains a non-empty text composed only of letters of English alphabet. The length of the text is less then 100. Ther... | {
"input": [],
"output": []
} | {
"input": [
"3\naalmlc\naPlmFl\nXcCnLb"
],
"output": [
"2\n1\n1\n"
]
} | {
"input": [
"3\naalmlc\naPlmFl\nXdCnLb",
"3\nablmlc\naPlmFl\nXcCnLb",
"3\nablmlc\naFlmPl\nXcBnLa",
"3\nablmlc\nkPamFl\nXLBnca",
"3\nmkcl`a\naPlmFl\nLdCmWa",
"3\nmkcl`a\naPkmFl\nLdCmWa",
"3\nbblmlc\nkPbGlk\nWLcoBb",
"3\nbblmlc\njPbGlk\nWLcoBb",
"3\nnalm`d\ncmkFPl\nLVmcCb",
"3\n... |
hes | Ananya, is a class 12 student and is preparing for IIT-JEE examination to be held later this year out of the 3 subjects asked in IIT JEE , physics, chemistry and mathematics she only likes mathematics and is a virtuoso in mathematics seeing her mathematical skills her school math teachers built an inferiority complex ... | {
"input": [],
"output": []
} | {
"input": [
"3\n2 4\n3 4\n9 3"
],
"output": [
"16 7\n81 9\n729 18\n"
]
} | {
"input": [
"3\n2 4\n3 4\n12 3",
"3\n4 4\n3 4\n12 3",
"3\n4 4\n3 4\n4 3",
"3\n4 4\n3 4\n3 3",
"3\n7 4\n3 4\n3 3",
"3\n7 2\n3 4\n3 3",
"3\n7 2\n3 4\n4 3",
"3\n9 2\n3 4\n4 3",
"3\n9 2\n3 4\n4 2",
"3\n9 4\n3 4\n4 2",
"3\n4 4\n3 4\n4 2",
"3\n4 4\n3 1\n4 2",
"3\n4 4\n3 ... |
misterm | Chef is array maniac.He use to play with arrays.Chef's friend given him an array of size n-1 integers and these integers are in the range of 1 to n. There are no duplicates in array. One of the integers is missing in the array.Now chef has to write efficient code to find the missing integer.Please help him to find the ... | {
"input": [],
"output": []
} | {
"input": [
"2\n9\n8 9 3 2 4 5 7 6 \n5\n3 1 2 4"
],
"output": [
"1\n5"
]
} | {
"input": [
"2\n9\n8 9 3 2 4 5 7 6 \n2\n3 1 2 4",
"2\n9\n8 9 1 2 4 5 7 6 \n2\n0 1 2 6",
"2\n9\n8 9 3 1 4 5 7 6 \n5\n3 1 2 4",
"2\n9\n8 9 3 1 4 5 7 6 \n4\n3 1 2 4",
"2\n9\n8 9 2 1 4 5 7 6 \n4\n3 1 3 4",
"2\n9\n8 9 3 1 4 5 7 2 \n5\n3 1 2 4",
"2\n9\n8 9 3 1 4 5 7 2 \n5\n3 1 2 5",
"2\n9\n... |
ren2013k | You are provided with a set of numbers which is infinitely large. The numbers in this set are of the form :-
{ 2^2^n + 1 } where n is a positive integer. Now these set of numbers are kept in sorted order.
Now queries are defined on this set such that given a range of terms [X...Y] you must calculate the sum of pairwis... | {
"input": [],
"output": []
} | {
"input": [
"1\n1 3"
],
"output": [
"3"
]
} | {
"input": [],
"output": []
} |
tsort | Given the list of numbers, you are to sort them in non decreasing order.
Input
t – the number of numbers in list, then t lines follow [t <= 10^6].
Each line contains one integer: N [0 <= N <= 10^6]
Output
Output given numbers in non decreasing order.
Example
Input:
5
5
3
6
7
1
Output:
1
3
5
6
7 | {
"input": [],
"output": []
} | {
"input": [
"5\n5\n3\n6\n7\n1"
],
"output": [
"1\n3\n5\n6\n7\n"
]
} | {
"input": [
"5\n5\n3\n3\n7\n1",
"5\n0\n3\n3\n7\n1",
"5\n1\n3\n3\n7\n1",
"5\n1\n3\n3\n7\n2",
"5\n1\n1\n3\n7\n2",
"5\n1\n1\n3\n11\n2",
"5\n1\n1\n3\n11\n4",
"5\n1\n0\n3\n11\n4",
"5\n1\n0\n3\n17\n4",
"5\n1\n0\n3\n17\n3",
"5\n1\n0\n3\n17\n1",
"5\n1\n0\n3\n17\n2",
"5\n2\... |
1040_D. Subway Pursuit | This is an interactive problem.
In the Wonderful Metropolis of the Future, there is no need in subway train drivers. Due to the technological progress, they were replaced by the Artificial Intelligence (AI). Unfortunately, one day the predictions of sci-fi writers came true: the AI rebelled and now there is an uncontr... | {
"input": [],
"output": []
} | {
"input": [
"10 2\n\nYes\n\nNo\n\nYes\n\nYes\n"
],
"output": [
"2 2\n"
]
} | {
"input": [
"1 2\n\nYes\n\nNo\n\nYer\n\nYes\n",
"1 2\n\nseY\n\nNo\n\nYes\n\nYds\n",
"1 2\n\nYes\n\noN\n\nYer\n\nYes\n",
"1 2\n\nYes\n\nNo\n\nYer\n\nYds\n",
"1 2\n\nYes\n\noN\n\nYer\n\nseY\n",
"1 0\n\nYes\n\noN\n\nYer\n\nseY\n",
"1 2\n\nYes\n\noN\n\nYer\n\nYds\n",
"1 2\n\nYes\n\noN\n\n... |
1252_D. Find String in a Grid | You have a grid G containing R rows (numbered from 1 to R, top to bottom) and C columns (numbered from 1 to C, left to right) of uppercase characters. The character in the r^{th} row and the c^{th} column is denoted by G_{r, c}. You also have Q strings containing uppercase characters. For each of the string, you want t... | {
"input": [],
"output": []
} | {
"input": [
"3 3 5\nABC\nBCD\nDAB\nABC\nBC\nBD\nAC\nA\n",
"2 3 3\nAAA\nAAA\nA\nAAA\nAAAAA\n"
],
"output": [
"\n2\n3\n1\n0\n2\n",
"\n6\n4\n0\n"
]
} | {
"input": [],
"output": []
} |
1423_N. BubbleSquare Tokens | BubbleSquare social network is celebrating 13^{th} anniversary and it is rewarding its members with special edition BubbleSquare tokens. Every member receives one personal token. Also, two additional tokens are awarded to each member for every friend they have on the network. Yet, there is a twist – everyone should end... | {
"input": [],
"output": []
} | {
"input": [
"3 3\n1 2\n1 3\n2 3\n",
"2 1\n1 2\n"
],
"output": [
"0\n\n1 2 0\n1 3 2\n2 3 1\n",
"1\n1 \n1 2 0\n"
]
} | {
"input": [
"5 3\n1 2\n1 3\n2 3\n",
"5 3\n1 2\n1 3\n2 5\n",
"2 0\n1 2\n",
"2 1\n1 4\n",
"3 1\n1 2\n",
"0 1\n1 2\n",
"2 1\n2 4\n",
"2 1\n1 16\n",
"3 1\n1 3\n",
"3 1\n2 3\n",
"2 0\n1 4\n",
"2 0\n1 0\n",
"2 -1\n1 4\n",
"2 0\n1 8\n",
"2 0\n1 -1\n",
"2 -1\n1... |
1469_B. Red and Blue | Monocarp had a sequence a consisting of n + m integers a_1, a_2, ..., a_{n + m}. He painted the elements into two colors, red and blue; n elements were painted red, all other m elements were painted blue.
After painting the elements, he has written two sequences r_1, r_2, ..., r_n and b_1, b_2, ..., b_m. The sequence ... | {
"input": [],
"output": []
} | {
"input": [
"4\n4\n6 -5 7 -3\n3\n2 3 -4\n2\n1 1\n4\n10 -3 2 2\n5\n-1 -2 -3 -4 -5\n5\n-1 -2 -3 -4 -5\n1\n0\n1\n0\n"
],
"output": [
"\n13\n13\n0\n0\n"
]
} | {
"input": [
"4\n4\n6 -5 7 -3\n3\n2 3 -4\n2\n1 1\n4\n10 -3 0 2\n5\n-1 -2 -3 -4 -5\n5\n-1 -2 -3 -4 -5\n1\n0\n1\n0\n",
"4\n4\n4 -5 7 -4\n3\n2 3 -4\n2\n1 1\n4\n10 -3 0 2\n5\n-1 -2 -3 0 -5\n5\n-1 -2 -3 -4 -5\n1\n0\n1\n0\n",
"4\n4\n4 -5 2 -4\n3\n2 3 -4\n2\n1 1\n4\n10 -3 0 2\n5\n-1 -2 -3 -1 -5\n5\n-1 -2 -3 -4 -... |
23_B. Party | n people came to a party. Then those, who had no friends among people at the party, left. Then those, who had exactly 1 friend among those who stayed, left as well. Then those, who had exactly 2, 3, ..., n - 1 friends among those who stayed by the moment of their leaving, did the same.
What is the maximum amount of pe... | {
"input": [],
"output": []
} | {
"input": [
"1\n3\n"
],
"output": [
"1\n"
]
} | {
"input": [
"1\n4\n",
"1\n2\n",
"1\n7\n",
"1\n5\n",
"1\n6\n",
"1\n9\n",
"1\n11\n",
"1\n12\n",
"1\n13\n",
"1\n18\n",
"1\n24\n",
"1\n23\n",
"1\n31\n",
"1\n27\n",
"1\n39\n",
"1\n54\n",
"1\n50\n",
"1\n44\n",
"1\n108\n",
"1\n14\n",
"1\n85... |
e-musical-sequences | Valentina had a birthday recently.
She got a special piano from parents.
They told her about the piano melodies and the connection with the mathematical sequences.
She got amazed and started to use piano keys to create her own musical sequences.
The piano has m keys, numbered 0 through m-1.
Valentina has already hit... | {
"input": [],
"output": []
} | {
"input": [
"3\n4 10 4\n1 3 3 7\n4 10 5\n1 3 3 7\n1 2 12345678987654321\n1\n\nSAMPLE"
],
"output": [
"6\n9\n1\n"
]
} | {
"input": [
"3\n4 5 4\n1 3 3 7\n4 10 5\n1 3 3 7\n1 2 12345678987654321\n1\n\nSAMPLE",
"3\n4 5 4\n1 3 3 7\n4 10 5\n2 3 3 5\n1 2 12345678987654321\n1\n\nSAMPLE",
"3\n4 5 4\n1 3 3 7\n4 10 2\n1 3 3 5\n1 2 12345678987654321\n1\n\nSAMPLE",
"3\n4 6 4\n1 3 3 7\n4 10 5\n2 3 3 5\n1 2 12345678987654321\n1\n\nSA... |
p02636 AtCoder Grand Contest 046 - Secret Passage | Given is a string S consisting of `0` and `1`. Find the number of strings, modulo 998244353, that can result from applying the following operation on S zero or more times:
* Remove the two characters at the beginning of S, erase one of them, and reinsert the other somewhere in S. This operation can be applied only whe... | {
"input": [],
"output": []
} | {
"input": [
"110001",
"11101111011111000000000110000001111100011111000000001111111110000000111111111",
"0001"
],
"output": [
"24",
"697354558",
"8"
]
} | {
"input": [
"110011",
"11101111011111000000000110000001111100011111000000001101111110000000111111111",
"0000",
"110010",
"11101111011101000000000110000001111100011111000000001101111110000000111111111",
"0010",
"110000",
"1110111101110000000000011000000111110001111100000000110111111000... |
p02767 AtCoder Beginner Contest 156 - Rally | There are N people living on a number line.
The i-th person lives at coordinate X_i.
You are going to hold a meeting that all N people have to attend.
The meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to atte... | {
"input": [],
"output": []
} | {
"input": [
"7\n14 14 2 13 56 2 37",
"2\n1 4"
],
"output": [
"2354",
"5"
]
} | {
"input": [
"7\n14 14 3 13 56 2 37",
"2\n0 4",
"7\n14 14 3 13 56 2 0",
"2\n0 1",
"7\n14 14 3 12 56 2 0",
"7\n19 14 3 12 56 2 0",
"7\n19 14 3 24 56 2 0",
"7\n11 14 3 24 56 2 0",
"7\n11 14 3 24 56 1 0",
"7\n11 14 3 33 56 1 0",
"7\n11 14 3 33 21 1 0",
"7\n11 14 6 33 21 1 ... |
p02902 AtCoder Beginner Contest 142 - Pure | Given is a directed graph G with N vertices and M edges.
The vertices are numbered 1 to N, and the i-th edge is directed from Vertex A_i to Vertex B_i.
It is guaranteed that the graph contains no self-loops or multiple edges.
Determine whether there exists an induced subgraph (see Notes) of G such that the in-degree a... | {
"input": [],
"output": []
} | {
"input": [
"6 9\n1 2\n2 3\n3 4\n4 5\n5 6\n5 1\n5 2\n6 1\n6 2",
"4 5\n1 2\n2 3\n2 4\n4 1\n4 3",
"4 5\n1 2\n2 3\n2 4\n1 4\n4 3"
],
"output": [
"4\n2\n3\n4\n5",
"3\n1\n2\n4",
"-1"
]
} | {
"input": [
"4 5\n1 2\n2 3\n2 4\n4 1\n8 3",
"6 0\n1 2\n1 2\n4 4\n7 3\n0 0\n9 2\n5 2\n6 1\n6 2",
"6 9\n1 2\n2 3\n3 4\n6 5\n5 6\n5 1\n5 2\n6 1\n6 2",
"6 9\n1 2\n2 3\n4 4\n6 5\n5 6\n5 1\n5 2\n6 1\n6 2",
"6 9\n1 2\n2 3\n4 4\n6 5\n5 1\n5 1\n5 2\n6 1\n6 2",
"6 3\n1 2\n2 3\n4 4\n6 5\n5 1\n5 1\n5 2\n... |
p03037 AtCoder Beginner Contest 127 - Prison | We have N ID cards, and there are M gates.
We can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.
How many of the ID cards allow us to pass all the gates alone?
Constraints
* All values in input are integers.
* 1 \leq N \leq 10^5
* 1 \leq M \leq 10^5
* ... | {
"input": [],
"output": []
} | {
"input": [
"100000 1\n1 100000",
"4 2\n1 3\n2 4",
"10 3\n3 6\n5 7\n6 9"
],
"output": [
"100000",
"2",
"1"
]
} | {
"input": [
"101000 1\n1 100000",
"4 2\n1 6\n2 4",
"10 3\n3 6\n7 7\n6 9",
"101000 1\n1 100100",
"101000 1\n1 100110",
"101000 1\n1 100010",
"101100 1\n2 100110",
"8 3\n1 7\n7 7\n1 11",
"8 1\n1 7\n7 7\n2 11",
"4 1\n1 4\n2 4",
"7 1\n3 4\n7 7\n8 9",
"8 1\n1 6\n10 3\n1 11"... |
p03178 Educational DP Contest - Digit Sum | Find the number of integers between 1 and K (inclusive) satisfying the following condition, modulo 10^9 + 7:
* The sum of the digits in base ten is a multiple of D.
Constraints
* All values in input are integers.
* 1 \leq K < 10^{10000}
* 1 \leq D \leq 100
Input
Input is given from Standard Input in the following ... | {
"input": [],
"output": []
} | {
"input": [
"98765432109876543210\n58",
"30\n4",
"1000000009\n1"
],
"output": [
"635270834",
"6",
"2"
]
} | {
"input": [
"98765432109876543210\n66",
"30\n1",
"1000000009\n2",
"98765432109876543210\n18",
"1000000009\n4",
"98765432109876543210\n11",
"1000000009\n5",
"98765432109876543210\n12",
"1000000009\n9",
"98765432109876543210\n10",
"1000000009\n7",
"98765432109876543210\n... |
p03326 AtCoder Beginner Contest 100 - Patisserie ABC | Takahashi became a pastry chef and opened a shop La Confiserie d'ABC to celebrate AtCoder Beginner Contest 100.
The shop sells N kinds of cakes.
Each kind of cake has three parameters "beauty", "tastiness" and "popularity". The i-th kind of cake has the beauty of x_i, the tastiness of y_i and the popularity of z_i.
Th... | {
"input": [],
"output": []
} | {
"input": [
"5 3\n1 -2 3\n-4 5 -6\n7 -8 -9\n-10 11 -12\n13 -14 15",
"10 5\n10 -80 21\n23 8 38\n-94 28 11\n-26 -2 18\n-69 72 79\n-26 -86 -54\n-72 -50 59\n21 65 -32\n40 -94 87\n-62 18 82",
"5 3\n3 1 4\n1 5 9\n2 6 5\n3 5 8\n9 7 9",
"3 2\n2000000000 -9000000000 4000000000\n7000000000 -5000000000 30000000... | {
"input": [
"5 3\n1 -2 3\n-4 5 -6\n7 -8 -9\n-10 19 -12\n13 -14 15",
"10 5\n10 -80 21\n23 8 38\n-94 28 11\n-26 -2 18\n-69 72 79\n-26 -86 -54\n-72 -50 48\n21 65 -32\n40 -94 87\n-62 18 82",
"5 3\n1 -2 3\n-4 5 -6\n7 -8 -16\n-10 19 -12\n13 -14 15",
"5 5\n1 -2 3\n-4 5 -6\n7 -8 -16\n-10 19 -12\n13 -14 15",
... |
p03480 AtCoder Beginner Contest 083 - Wide Flip | You are given a string S consisting of `0` and `1`. Find the maximum integer K not greater than |S| such that we can turn all the characters of S into `0` by repeating the following operation some number of times.
* Choose a contiguous segment [l,r] in S whose length is at least K (that is, r-l+1\geq K must be satisfi... | {
"input": [],
"output": []
} | {
"input": [
"100000000",
"010",
"00001111"
],
"output": [
"8",
"2",
"4"
]
} | {
"input": [
"100000010",
"011",
"00001101",
"111",
"00011101",
"100000101",
"11111111",
"000000000",
"100000011",
"100001011",
"101",
"10011101",
"100101011",
"001",
"00011001",
"100001111",
"000",
"10011001",
"100001101",
"110",
"10... |
p03647 AtCoder Regular Contest 079 - Cat Snuke and a Voyage | In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N.
There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i.
Cat Snuk... | {
"input": [],
"output": []
} | {
"input": [
"5 5\n1 3\n4 5\n2 3\n2 4\n1 4",
"100000 1\n1 99999",
"4 3\n1 2\n2 3\n3 4",
"3 2\n1 2\n2 3"
],
"output": [
"POSSIBLE",
"IMPOSSIBLE",
"IMPOSSIBLE",
"POSSIBLE"
]
} | {
"input": [
"5 5\n1 1\n4 5\n2 3\n2 4\n1 4",
"100000 1\n0 99999",
"4 3\n1 3\n2 3\n3 4",
"5 5\n1 1\n4 5\n1 3\n2 4\n1 4",
"100100 1\n0 99999",
"4 3\n1 3\n3 3\n3 4",
"5 5\n2 3\n4 5\n2 3\n2 4\n1 4",
"100000 1\n1 69651",
"4 3\n1 1\n2 3\n3 4",
"5 5\n1 1\n4 5\n2 3\n2 4\n1 0",
"110... |
p03803 AtCoder Beginner Contest 054 - One Card Poker | Alice and Bob are playing One Card Poker.
One Card Poker is a two-player game using playing cards.
Each card in this game shows an integer between `1` and `13`, inclusive.
The strength of a card is determined by the number written on it, as follows:
Weak `2` < `3` < `4` < `5` < `6` < `7` < `8` < `9` < `10` < `11` < `... | {
"input": [],
"output": []
} | {
"input": [
"8 6",
"1 1",
"13 1"
],
"output": [
"Alice",
"Draw",
"Bob"
]
} | {
"input": [
"8 7",
"2 1",
"0 0",
"8 3",
"3 1",
"7 3",
"4 1",
"7 1",
"7 2",
"5 6",
"1 0",
"0 1",
"12 3",
"1 3",
"10 1",
"7 4",
"5 10",
"1 5",
"13 4",
"1 10",
"1 8",
"9 4",
"1 9",
"9 3",
"1 2",
"2 2",
"8 9",
... |
p03971 CODE FESTIVAL 2016 qual B - Qualification simulator | There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these.
Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from t... | {
"input": [],
"output": []
} | {
"input": [
"12 5 2\ncabbabaacaba",
"5 2 2\nccccc",
"10 2 3\nabccabaabb"
],
"output": [
"No\nYes\nYes\nYes\nYes\nNo\nYes\nYes\nNo\nYes\nNo\nNo",
"No\nNo\nNo\nNo\nNo",
"Yes\nYes\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo"
]
} | {
"input": [
"12 5 0\ncabbabaacaba",
"12 5 1\ncacbabaacaba",
"12 5 1\ncaababaccaba",
"12 7 1\ncaababaccaba",
"12 7 2\ncaababaccaba",
"12 14 0\ncaababaccaba",
"12 6 2\ncabbabaacaba",
"10 2 0\nabccabaabb",
"12 5 1\nabacaababcac",
"12 7 1\nabaccababaac",
"12 7 2\ncaababaccbba"... |
p00060 Card Game | There is one card each with the numbers from "1" to "10", for a total of 10 cards. This card has numbers on the front and nothing on the back. Using this card, you and your opponent will play the game according to the following rules.
1. You and your opponent are dealt a total of two cards, one face up and one back up... | {
"input": [],
"output": []
} | {
"input": [
"1 2 3\n5 6 9\n8 9 10"
],
"output": [
"YES\nYES\nNO"
]
} | {
"input": [
"1 2 3\n5 6 8\n8 9 10",
"1 2 3\n5 2 9\n8 1 10",
"1 2 3\n5 2 9\n8 9 10",
"1 2 3\n5 2 8\n8 1 10",
"1 2 3\n5 2 8\n5 1 10",
"1 4 3\n5 2 9\n8 9 10",
"1 2 3\n5 2 9\n8 2 10",
"1 2 3\n5 2 8\n8 1 5",
"1 2 3\n5 1 8\n5 1 10",
"1 4 3\n5 1 9\n8 9 10",
"1 2 3\n5 1 8\n5 2 10"... |
p00191 Baby Tree | Dr. Sato, a botanist, invented a number of special fertilizers for seedlings. When you give the fertilizer to the seedlings, the size of the seedlings changes in a blink of an eye. However, it was found that fertilizer has the following side effects.
* The size of the seedlings does not change with the fertilizer give... | {
"input": [],
"output": []
} | {
"input": [
"3 3\n1.3 3.0 0.5\n2.4 2.1 1.0\n3.0 0.8 1.2\n2 2\n1.0 1.0\n1.0 1.0\n0 0"
],
"output": [
"9.00\n1.00"
]
} | {
"input": [
"3 3\n1.3 3.0 0.5\n2.4 2.1 1.0\n3.0 0.8 1.2\n2 2\n1.0 1.953209014063742\n1.0 1.0\n0 0",
"3 3\n1.3 3.0 0.5\n2.9487871182122434 2.1 1.0\n3.0 0.8 1.2\n2 2\n1.0 1.0\n1.0 1.0\n0 0",
"3 3\n1.3 3.0 0.5\n2.9487871182122434 2.1 1.0\n3.0 0.8 1.2\n2 2\n1.2415885279949683 1.0\n1.0 1.0\n0 0",
"3 3\n1.... |
p00346 Quiet Town | Ekiden competitions are held every year in Aizukuni. The country of Aiz is dotted with N towns, each numbered from 1 to N. Several towns are connected by roads that allow them to come and go directly to each other. You can also follow several roads between any town. The course of the tournament is decided as follows.
... | {
"input": [],
"output": []
} | {
"input": [
"7 11\n1 2 2\n1 3 1\n2 4 2\n2 5 2\n2 6 1\n3 4 1\n3 5 1\n3 6 1\n4 7 2\n5 7 2\n6 7 1",
"4 5\n1 2 2\n1 3 2\n2 3 1\n2 4 2\n3 4 1"
],
"output": [
"3\n2\n4\n5",
"1\n2"
]
} | {
"input": [
"7 11\n1 2 2\n1 3 1\n2 4 2\n2 5 2\n2 6 1\n6 4 1\n3 5 1\n3 6 1\n4 7 2\n5 7 2\n6 7 1",
"7 11\n2 2 2\n1 3 1\n2 4 2\n2 5 2\n2 6 1\n6 4 1\n3 5 1\n3 6 1\n4 7 2\n5 7 2\n6 7 1",
"7 11\n1 2 2\n1 3 1\n2 4 2\n2 5 2\n2 6 1\n3 4 1\n3 5 2\n3 6 1\n4 7 2\n2 7 2\n6 7 1",
"7 11\n2 2 2\n1 3 1\n2 4 2\n2 5 3\... |
p00542 Selecting Subjects | problem
JOI took six subjects: physics, chemistry, biology, earth science, history, and geography. Each test was scored on a 100-point scale.
JOI chooses 3 subjects from 4 subjects of physics, chemistry, biology, and earth science, and 1 subject from 2 subjects of history and geography.
When choosing a subject so th... | {
"input": [],
"output": []
} | {
"input": [
"100\n34\n76\n42\n10\n0"
],
"output": [
"228"
]
} | {
"input": [
"100\n34\n76\n67\n10\n0",
"100\n34\n76\n96\n10\n0",
"100\n34\n93\n96\n10\n0",
"100\n34\n41\n96\n10\n0",
"100\n4\n41\n96\n17\n0",
"100\n4\n41\n96\n1\n0",
"100\n4\n68\n96\n1\n0",
"100\n4\n68\n73\n1\n-1",
"100\n4\n66\n73\n1\n-1",
"100\n4\n66\n36\n1\n-1",
"100\n4\n... |
p00706 Get Many Persimmon Trees | Seiji Hayashi had been a professor of the Nisshinkan Samurai School in the domain of Aizu for a long time in the 18th century. In order to reward him for his meritorious career in education, Katanobu Matsudaira, the lord of the domain of Aizu, had decided to grant him a rectangular estate within a large field in the Ai... | {
"input": [],
"output": []
} | {
"input": [
"16\n10 8\n2 2\n2 5\n2 7\n3 3\n3 8\n4 2\n4 5\n4 8\n6 4\n6 7\n7 5\n7 8\n8 1\n8 4\n9 6\n10 3\n4 3\n8\n6 4\n1 2\n2 1\n2 4\n3 4\n4 2\n5 3\n6 1\n6 2\n3 2\n0"
],
"output": [
"4\n3"
]
} | {
"input": [
"16\n10 8\n2 2\n2 5\n2 7\n3 3\n3 8\n4 2\n4 5\n4 8\n6 4\n6 7\n7 5\n7 8\n8 1\n8 4\n9 6\n10 3\n4 3\n8\n6 4\n1 2\n2 1\n2 4\n3 4\n4 2\n5 3\n6 1\n3 2\n3 2\n0",
"16\n10 8\n2 2\n2 5\n2 7\n3 3\n3 8\n4 2\n4 5\n4 8\n6 4\n6 7\n7 5\n7 8\n8 1\n8 4\n9 6\n10 3\n4 3\n8\n6 4\n1 2\n2 1\n2 4\n3 4\n4 2\n5 3\n1 1\n3 2... |
p00845 How I Wonder What You Are! | One of the questions children often ask is "How many stars are there in the sky?" Under ideal conditions, even with the naked eye, nearly eight thousands are observable in the northern hemisphere. With a decent telescope, you may find many more, but, as the sight field will be limited, you may find much less at a time.... | {
"input": [],
"output": []
} | {
"input": [
"3\n100 0 500\n-500.243 -200.1 -300.5\n0 300 200\n2\n1 1 1 0.65\n-1 0 0 1.57\n3\n1 0 0\n0 1 0\n0 0 1\n4\n1 -1 -1 0.9553\n-1 1 -1 0.9554\n-1 -1 1 0.9553\n-1 1 -1 0.9554\n3\n1 0 0\n0 1 0\n0 0 1\n4\n1 -1 -1 0.9553\n-1 1 -1 0.9553\n-1 -1 1 0.9553\n-1 1 -1 0.9553\n0"
],
"output": [
"2\n1\n0"
]
} | {
"input": [
"3\n100 0 500\n-500.243 -199.7339381714296 -300.5\n0 300 200\n2\n1 1 1 0.65\n-1 0 0 1.57\n3\n1 0 0\n0 1 0\n0 0 1\n4\n1 -1 -1 0.9553\n-1 1 -1 0.9554\n-1 -1 1 0.9553\n-1 1 -1 0.9554\n3\n1 0 0\n0 1 0\n0 0 1\n4\n1 -1 -1 0.9553\n-1 1 -1 0.9553\n-1 -1 1 0.9553\n-1 1 -1 0.9553\n0",
"3\n100 0 500\n-500.2... |
p00977 Colorful Tree | Colorful Tree
A tree structure with some colors associated with its vertices and a sequence of commands on it are given. A command is either an update operation or a query on the tree. Each of the update operations changes the color of a specified vertex, without changing the tree structure. Each of the queries asks t... | {
"input": [],
"output": []
} | {
"input": [
"5\n1 2\n2 3\n3 4\n2 5\n1 2 1 2 3\n11\nQ 1\nQ 2\nQ 3\nQ 4\nU 5 1\nQ 1\nU 3 2\nQ 1\nQ 2\nU 5 4\nQ 1"
],
"output": [
"2\n2\n0\n-1\n3\n2\n2\n0"
]
} | {
"input": [
"5\n1 2\n2 3\n3 4\n3 5\n1 2 1 2 3\n11\nQ 1\nQ 2\nQ 3\nQ 4\nU 5 1\nQ 1\nU 3 2\nQ 1\nQ 2\nU 5 4\nQ 1",
"5\n1 2\n2 3\n3 4\n2 5\n1 2 1 2 3\n11\nQ 1\nQ 2\nQ 3\nQ 4\nU 5 1\nQ 1\nU 3 2\nQ 1\nQ 2\nU 5 4\nQ 2",
"5\n1 2\n2 3\n3 4\n2 5\n1 2 1 2 3\n11\nQ 1\nQ 2\nQ 3\nQ 4\nU 5 1\nQ 1\nU 3 2\nQ 1\nQ 2\nU 5... |
p01109 Income Inequality | Income Inequality
We often compute the average as the first step in processing statistical data. Yes, the average is a good tendency measure of data, but it is not always the best. In some cases, the average may hinder the understanding of the data.
For example, consider the national income of a country. As the term ... | {
"input": [],
"output": []
} | {
"input": [
"7\n15 15 15 15 15 15 15\n4\n10 20 30 60\n10\n1 1 1 1 1 1 1 1 1 100\n7\n90 90 90 90 90 90 10\n7\n2 7 1 8 2 8 4\n0"
],
"output": [
"7\n3\n9\n1\n4"
]
} | {
"input": [
"7\n15 15 15 15 15 23 15\n4\n10 20 30 60\n10\n1 1 1 1 1 1 1 1 1 100\n7\n90 90 90 90 90 90 10\n7\n2 7 1 8 2 8 4\n0",
"7\n15 15 1 15 15 23 15\n4\n10 20 30 60\n10\n1 1 1 1 1 1 1 1 1 100\n7\n90 90 90 90 90 90 10\n7\n2 7 1 8 2 11 4\n0",
"7\n23 15 1 15 15 23 15\n4\n10 20 30 60\n10\n1 1 1 1 1 1 1 1 ... |
p01247 Japanese Style Pub | You’ve just entered a Japanese-style pub, or an izakaya in Japanese, for a drinking party (called nomi-kai) with your dear friends.
Now you are to make orders for glasses of hard and soft drink as requested by the participants. But unfortunately, most staffs in typical izakayas are part-time workers; they are not used... | {
"input": [],
"output": []
} | {
"input": [
"3\n0.7 0.1 0.2\n0.1 0.8 0.1\n0.0 0.0 1.0\n4 3 2\n8\n0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125\n0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125\n0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125\n0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125\n0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125\n0.1... | {
"input": [
"3\n0.7 0.1 0.2\n0.1 0.8 0.1\n0.0 0.0 1.0\n4 3 2\n8\n0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125\n0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125\n0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125\n0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125\n0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125\n0.1... |
p01408 Brilliant Stars | Training is indispensable for achieving good results at ICPC. Rabbit wants to win at ICPC, so he decided to practice today as well.
Today's training is to train your eyesight and concentration by observing many stars shining in the night sky. Rabbits can record the characteristics of stars with their own sense.
Rabbi... | {
"input": [],
"output": []
} | {
"input": [
"11 5\n1 2\n3 4\n5 6\n7 8\n9 10",
"4 3\n1 2\n1 3\n1 4",
"9 14\n1 2\n1 3\n2 3\n3 4\n3 5\n3 6\n3 7\n3 8\n3 9\n4 5\n4 6\n5 6\n7 8\n8 9"
],
"output": [
"6\n32",
"3\n1",
"4\n6"
]
} | {
"input": [
"11 5\n1 2\n3 4\n5 6\n9 8\n9 10",
"11 5\n1 3\n3 4\n5 6\n9 8\n9 10",
"20 5\n1 2\n3 4\n5 6\n1 8\n9 10",
"11 5\n1 3\n3 4\n5 6\n3 8\n9 10",
"20 5\n1 2\n3 1\n5 6\n9 8\n9 10",
"11 5\n1 2\n3 4\n4 6\n1 8\n1 10",
"17 5\n1 2\n3 4\n5 6\n7 8\n9 10",
"14 5\n1 4\n3 4\n5 6\n9 8\n9 10",
... |
p01562 Area Folding | You are given one polygonal line, which is a collection of line segments. Your task is to calculate the sum of areas enclosed by the polygonal line.
A point is defined to be "enclosed" if and only if the point is unreachable without crossing at least one line segment from the point at infinity.
Input
The first lin... | {
"input": [],
"output": []
} | {
"input": [
"5\n0 0\n1 1\n1 0\n0 1\n1 0",
"7\n26 52\n33 12\n-51 68\n16 61\n43 -26\n87 24\n12 10",
"16\n0 0\n1 0\n1 1\n0 1\n0 2\n0 3\n1 3\n1 2\n2 2\n2 3\n3 3\n3 2\n3 1\n2 1\n2 0\n3 0",
"5\n0 0\n1 1\n1 0\n0 1\n0 0",
"21\n1 1\n-1 1\n-1 2\n-2 2\n-2 1\n-1 1\n-1 -1\n-2 -1\n-2 -2\n-1 -2\n-1 -1\n1 -1\n1 ... | {
"input": [
"5\n0 0\n1 1\n1 1\n0 1\n1 0",
"7\n26 52\n33 12\n-51 63\n16 61\n43 -26\n87 24\n12 10",
"16\n0 0\n1 0\n1 1\n0 1\n0 2\n0 3\n1 3\n1 2\n2 2\n2 3\n3 3\n3 2\n5 1\n2 1\n2 0\n3 0",
"21\n1 1\n-1 1\n-1 2\n-2 2\n-2 1\n-1 1\n-1 -1\n-2 -1\n-2 -2\n-1 -2\n-1 -1\n1 -1\n1 -2\n2 -2\n2 -1\n1 -1\n1 1\n2 1\n0 ... |
p01724 Phutball | Ikta, who hates to lose, has recently been enthusiastic about playing games using the Go board. However, neither Go nor Gomoku can beat my friends at all, so I decided to give a special training to the lesser-known game Phutball.
This game is a difficult game, so I decided to give special training so that I could win ... | {
"input": [],
"output": []
} | {
"input": [
"...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n.....XX........\n.....XXXO..... | {
"input": [
"...............\n...............\n...............\n...............\n...............\n.........../...\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n.....XX........\n.....XXXO..... |
p01862 How To Make Stars | E: How To Make Stars-
story
Kitano Kisaka Gakuin 1st grade stardust bell! I like the stars of the bells! At night, I'm always secretly watching the stars on the roof of the school with my childhood friend Hanayo-chin! But unfortunately the weather today is rainy ... With this, you can't see the stars! What should I d... | {
"input": [],
"output": []
} | {
"input": [
"2\n10 5"
],
"output": [
"1\n-10.00 -6.48\n-10.79 -8.91\n-13.34 -8.91\n-11.28 -10.41\n-12.07 -12.84\n-10.00 -11.34\n-7.93 -12.84\n-8.72 -10.41\n-6.66 -8.91\n-9.21 -8.91\n2\n10.00 12.34\n9.47 10.72\n7.77 10.72\n9.15 9.72\n8.62 8.10\n10.00 9.10\n11.38 8.10\n10.85 9.72\n12.23 10.72\n10.53 10.72"... | {
"input": [
"2\n9 5",
"2\n18 5",
"2\n18 9",
"2\n18 1",
"2\n28 1",
"2\n29 1",
"2\n9 1",
"2\n5 1",
"2\n5 2",
"2\n1 1",
"2\n1 0",
"2\n2 0",
"2\n4 0",
"2\n4 1",
"2\n2 -1",
"2\n3 -2",
"2\n3 0",
"2\n5 0",
"2\n5 -1",
"2\n0 -1",
"2\n0 0",
... |
p01997 Right triangle | problem
Given the lengths of $ 2 $ sides that are not the hypotenuse of a right triangle, $ A $ and $ B $. The side of length $ A $ overlaps the $ x $ axis, and the side of length $ B $ overlaps the $ y $ axis.
Do the following:
1. Rotate the triangle around the $ x $ axis.
2. Rotate the shape created by performing ... | {
"input": [],
"output": []
} | {
"input": [
"1 2"
],
"output": [
"33.510322"
]
} | {
"input": [
"2 2",
"1 3",
"0 6",
"1 10",
"1 1",
"0 9",
"2 5",
"0 4",
"-1 11",
"-1 0",
"-1 8",
"-1 7",
"-1 12",
"-2 -1",
"-4 -2",
"-8 -3",
"-11 -4",
"-13 -5",
"-8 -6",
"-23 -12",
"-9 -7",
"-26 -9",
"-74 -8",
"2 3",
"0 ... |
p02143 Painting | Problem
Given a sequence $ X $ of length $ N $. In the initial state, all $ X $ elements are $ 0 $. In addition, a pair of $ M $ integers $ (A_i, B_i) $ is given. Do the following for each pair and output the final sequence $ X $.
* For the integer $ j $$ (1 \ le j \ le N) $, add the remainder of $ (A_i + j) $ divide... | {
"input": [],
"output": []
} | {
"input": [
"14 12\n1 4\n2 3\n0 5\n1 4\n1 2\n0 8\n0 2\n0 10\n0 1\n0 8\n3 10\n1 10",
"5 3\n1 4\n3 7\n0 1000"
],
"output": [
"15\n24\n25\n31\n35\n44\n32\n25\n24\n15\n16\n25\n31\n40",
"7\n10\n9\n5\n8"
]
} | {
"input": [
"14 12\n0 4\n2 3\n0 5\n1 4\n1 2\n0 8\n0 2\n0 10\n0 1\n0 8\n3 10\n1 10",
"5 3\n1 4\n3 4\n0 1000",
"5 3\n1 2\n3 4\n0 1000",
"14 12\n1 4\n2 3\n1 5\n1 4\n1 2\n0 8\n0 2\n0 10\n0 1\n0 8\n3 10\n1 10",
"5 3\n2 4\n3 7\n0 1000",
"14 12\n0 4\n2 3\n0 5\n1 4\n1 2\n0 8\n0 3\n0 10\n0 1\n0 8\n3 1... |
p02284 Binary Search Tree II | Write a program which performs the following operations to a binary search tree $T$ by adding the find operation to A: Binary Search Tree I.
* insert $k$: Insert a node containing $k$ as key into $T$.
* find $k$: Report whether $T$ has a node containing $k$.
* print: Print the keys of the binary search tree by inorde... | {
"input": [],
"output": []
} | {
"input": [
"10\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\nfind 12\ninsert 17\ninsert 25\nfind 16\nprint"
],
"output": [
"yes\nno\n 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88"
]
} | {
"input": [
"10\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 29\nfind 12\ninsert 17\ninsert 25\nfind 16\nprint",
"10\ninsert 30\ninsert 88\ninsert 12\ninsert 2\ninsert 20\nfind 12\ninsert 17\ninsert 25\nfind 16\nprint",
"10\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 29\nfind 15\ninsert 17\n... |
p02431 Vector | For a dynamic array $A = \\{a_0, a_1, ...\\}$ of integers, perform a sequence of the following operations:
* pushBack($x$): add element $x$ at the end of $A$
* randomAccess($p$):print element $a_p$
* popBack(): delete the last element of $A$
$A$ is a 0-origin array and it is empty in the initial state.
Constraints... | {
"input": [],
"output": []
} | {
"input": [
"8\n0 1\n0 2\n0 3\n2\n0 4\n1 0\n1 1\n1 2"
],
"output": [
"1\n2\n4"
]
} | {
"input": [
"8\n0 0\n0 2\n0 3\n2\n0 4\n1 0\n1 1\n1 2",
"8\n0 0\n0 2\n0 3\n2\n0 4\n1 0\n1 1\n1 1",
"8\n0 0\n0 2\n0 3\n2\n1 0\n1 0\n1 1\n1 1",
"8\n0 1\n0 2\n0 4\n2\n0 4\n1 0\n1 1\n1 2",
"8\n0 0\n0 2\n0 3\n2\n0 4\n1 0\n1 1\n0 2",
"8\n0 0\n0 2\n0 3\n2\n0 4\n1 0\n1 1\n1 0",
"8\n0 0\n0 3\n0 3\n... |
cdva1504 | Many years ago there was a kingdom called 'sentence', which comprises of two groups namely strings and integers. Strings consists of all the characters and alphabets(both capital and small) whereas the integers consists of all
the kinds of numbers. 'A' was the leader of strings and was prefer over '0' the leader of in... | {
"input": [],
"output": []
} | {
"input": [
"2\nCodeVaitam 2015@Nit agartala.\nCodechef"
],
"output": [
"CodeVaitam @Nit agartala.\nCodechef"
]
} | {
"input": [
"2\nCodeVaitam 2115@Nit agartala.\nCodechef",
"2\nCodeVaisam 2115@Nit agartala.\nCodechef",
"2\nCodeVaisam 211@5Nit .alatraga\nCodechef",
"2\nCadeVoisam 211@5Nit .alatraga\nCodechef",
"2\nCadeVoisam 211@5Nit agartala.\nCodechef",
"2\nCadeVoisam 211@5Nit agartal`.\nCodechef",
"... |
dbz16xs1 | Shil has a number X.He challenges you to find minimum positive number K such that F(K) is equal to X.
F(x) is defined as 1^2^3^....x. ^ denotes the bitwise Xor operation
Input
First line of input will consists of total number of test cases T.Next T lines contains a number X.
Output
For each test case , outpu... | {
"input": [],
"output": []
} | {
"input": [
"3\n1\n2\n100"
],
"output": [
"1\n-1\n100"
]
} | {
"input": [],
"output": []
} |
igame | After a long period of relaxation Alice and Bob decided to play a game.
This time of course not a number game. The rules of the game are as follows:
There is a vehicle situated at the point (m, n) of a rectangular grid.
Only one corner of the rectangular grid is defined, i.e. the left-top point (0, 0),
which is also kn... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 1 0 0\n2 4 1 2"
],
"output": [
"Alice\nBob"
]
} | {
"input": [
"2\n1 0 0 0\n2 4 1 2",
"2\n1 0 0 0\n2 4 0 2",
"2\n1 1 -1 0\n2 4 0 2",
"2\n1 1 -1 0\n2 3 0 2",
"2\n1 0 -1 0\n2 4 0 2",
"2\n1 1 -1 0\n2 1 0 2",
"2\n1 1 -1 0\n2 2 0 2",
"2\n1 1 -1 -1\n2 2 0 2",
"2\n2 1 -1 -1\n2 2 0 2",
"2\n2 1 -1 -1\n1 2 0 2",
"2\n1 1 -1 -1\n1 2 0... |
muldiv | You are given integers N,K and M and operation F. Operation F is defined for an integer as follows:
F:
for i from 1 to M inclusive, do
if N is a multiple of K,
divide N by K
else,
multiply N by K
print N
Perform the operation F on N.
Input
The first line contains a single integer T the number of test cases.
... | {
"input": [],
"output": []
} | {
"input": [
"2\n42 3 2\n6 7 1"
],
"output": [
"42\n42"
]
} | {
"input": [
"2\n42 3 2\n6 7 2",
"2\n10 3 4\n6 8 2",
"2\n10 3 4\n0 8 2",
"2\n17 3 4\n0 6 4",
"2\n12 3 4\n0 12 4",
"2\n12 3 4\n1 12 4",
"2\n1 3 4\n1 12 4",
"2\n1 1 20\n0 17 0",
"2\n51 3 2\n6 7 1",
"2\n42 3 2\n6 7 3",
"2\n42 3 4\n10 7 2",
"2\n1 3 3\n1 17 0",
"2\n2 3 8... |
rrcopy | You had an array of integer numbers. You also had a beautiful operations called "Copy-Paste" which allowed you to copy any contiguous subsequence of your array and paste it in any position of your array. For example, if you have array [1, 2, 3, 4, 5] and copy it's subsequence from the second to the fourth element and p... | {
"input": [],
"output": []
} | {
"input": [
"2\n5\n1 1 1 1 1\n5\n1 2 3 1 2"
],
"output": [
"1\n3\n"
]
} | {
"input": [
"2\n5\n1 1 1 1 1\n5\n1 2 6 1 2",
"2\n5\n1 0 1 1 1\n5\n1 3 3 1 2",
"2\n5\n1 0 1 2 1\n5\n1 3 3 1 2",
"2\n5\n1 1 1 1 1\n5\n1 2 6 0 2",
"2\n5\n1 0 1 1 1\n5\n0 3 3 1 2",
"2\n5\n1 0 1 2 1\n5\n1 3 3 1 3",
"2\n5\n1 1 1 1 1\n5\n1 2 1 1 2",
"2\n5\n1 0 1 1 1\n5\n0 6 3 1 2",
"2\n5... |
wdtbam | Chef is going to participate in a new quiz show: "Who dares to be a millionaire?"
According to the rules of the game, contestants must answer N questions. The quiz being famous for its difficulty, each question has 26 candidate answers, but only one of which is correct. Answers are denoted by capital Latin letters from... | {
"input": [],
"output": []
} | {
"input": [
"3\n5\nABCDE\nEBCDA\n0 10 20 30 40 50\n4\nCHEF\nQUIZ\n4 3 2 1 0\n8\nABBABAAB\nABABABAB\n100 100 100 100 100 100 100 100 100"
],
"output": [
"30\n4\n100\n"
]
} | {
"input": [
"3\n5\nABCDE\nEBCDA\n0 8 20 30 40 50\n4\nCHEF\nQUIZ\n4 3 2 1 0\n8\nABBABAAB\nABABABAB\n100 100 100 100 100 100 100 100 100",
"3\n5\nABCDE\nEBBDA\n0 8 20 30 40 50\n1\nCHEF\nQUIZ\n4 3 2 1 0\n8\nABBABAAB\nBABABABA\n100 100 100 100 000 100 100 100 100",
"3\n5\nABCDE\nEBCDA\n0 8 20 30 40 50\n4\nCH... |
1297_F. Movie Fan | Recently, Polycarp has been a fan of cinema novelties and is trying not to miss them!
In the near future, n new movies will be released: the i-th of them will be airing from the day a_i and to the day b_i. This means that if Polycarp wants to watch the i-th movie in the cinema, he must do so in the period from a_i to ... | {
"input": [],
"output": []
} | {
"input": [
"3\n7 2\n1 2\n1 3\n2 2\n2 3\n1 1\n2 3\n1 2\n5 3\n1 1\n1 1\n1 1\n1 1\n1 1\n6 1\n13 13\n31 31\n25 25\n12 12\n14 14\n10 10\n"
],
"output": [
"\n1\n1 3 2 3 1 4 2 \n1\n1 1 1 2 2 \n0\n13 31 25 12 14 10 \n"
]
} | {
"input": [],
"output": []
} |
1402_B. Roads | The government of Treeland wants to build a new road network. There are 2N cities in Treeland. The unfinished plan of the road network already contains N road segments, each of which connects two cities with a straight line. No two road segments have a common point (including their endpoints). Your task is to determine... | {
"input": [],
"output": []
} | {
"input": [
"5\n1 3 3 6\n5 1 5 3\n3 3 6 5\n2 1 4 1\n2 3 4 2\n"
],
"output": [
"\n2 1 1 3\n2 3 2 1\n3 3 2 3\n5 1 4 2\n"
]
} | {
"input": [],
"output": []
} |
1425_A. Arena of Greed | Lately, Mr. Chanek frequently plays the game Arena of Greed. As the name implies, the game's goal is to find the greediest of them all, who will then be crowned king of Compfestnesia.
The game is played by two people taking turns, where Mr. Chanek takes the first turn. Initially, there is a treasure chest containing N... | {
"input": [],
"output": []
} | {
"input": [
"2\n5\n6\n"
],
"output": [
"2\n4\n"
]
} | {
"input": [
"2\n6\n6\n",
"2\n12\n6\n",
"2\n24\n6\n",
"2\n45\n6\n",
"2\n34\n6\n",
"2\n58\n6\n",
"2\n48\n6\n",
"2\n3\n6\n",
"2\n4\n6\n",
"2\n1\n6\n",
"2\n1\n12\n",
"2\n1\n16\n",
"2\n1\n10\n",
"2\n4\n10\n",
"2\n4\n20\n",
"2\n2\n20\n",
"2\n2\n27\n",
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.