name
stringlengths
2
112
description
stringlengths
29
13k
private_tests
dict
public_tests
dict
generated_tests
dict
1277_A. Happy Birthday, Polycarp!
Hooray! Polycarp turned n years old! The Technocup Team sincerely congratulates Polycarp! Polycarp celebrated all of his n birthdays: from the 1-th to the n-th. At the moment, he is wondering: how many times he turned beautiful number of years? According to Polycarp, a positive integer is beautiful if it consists of ...
{ "input": [], "output": [] }
{ "input": [ "6\n18\n1\n9\n100500\n33\n1000000000\n" ], "output": [ "10\n1\n9\n45\n12\n81\n" ] }
{ "input": [ "6\n1\n1\n9\n100500\n33\n1000000000\n", "6\n1\n1\n3\n100500\n33\n1000000000\n", "6\n18\n1\n9\n100500\n65\n1000000000\n", "6\n1\n1\n9\n100500\n51\n1000000000\n", "6\n1\n1\n9\n46796\n51\n1000000000\n", "6\n1\n1\n9\n46796\n25\n1000000000\n", "6\n1\n1\n9\n46796\n33\n1000000000\n",...
1297_A. Likes Display
Polycarp is working on the implementation of displaying likes on the Codehorses social network. The number of likes should be displayed in a format that will be easy to read by users. It was decided that for large numbers of likes the format should be like 123K (one hundred twenty-three thousand) or like 56M (fifty-six...
{ "input": [], "output": [] }
{ "input": [ "9\n999\n123\n0\n1782\n31415926\n1500\n999999\n35499710\n2000000000\n" ], "output": [ "\n999\n123\n0\n2K\n31M\n2K\n1M\n35M\n2000M\n" ] }
{ "input": [], "output": [] }
1339_E. Perfect Triples
Consider the infinite sequence s of positive integers, created by repeating the following steps: 1. Find the lexicographically smallest triple of positive integers (a, b, c) such that * a ⊕ b ⊕ c = 0, where ⊕ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR). * a, b, ...
{ "input": [], "output": [] }
{ "input": [ "9\n1\n2\n3\n4\n5\n6\n7\n8\n9\n" ], "output": [ "1\n2\n3\n4\n8\n12\n5\n10\n15\n" ] }
{ "input": [ "9\n2\n2\n3\n4\n5\n6\n7\n8\n9\n", "9\n2\n2\n3\n4\n5\n6\n7\n8\n17\n", "9\n2\n2\n3\n4\n5\n6\n13\n8\n17\n", "9\n2\n2\n3\n4\n5\n6\n13\n8\n19\n", "9\n2\n2\n3\n4\n5\n6\n13\n8\n33\n", "9\n2\n2\n3\n4\n5\n9\n13\n8\n33\n", "9\n2\n2\n3\n4\n5\n9\n13\n8\n28\n", "9\n2\n2\n3\n4\n4\n9\n13...
690_F3. Tree of Life (hard)
To add insult to injury, the zombies have taken all but two drawings from Heidi! Please help her recover the Tree of Life from only these two drawings. Input The input format is the same as in the medium version, except that now the bound on n is 2 ≤ n ≤ 1000 and that k = 2. Output The same as in the medium version...
{ "input": [], "output": [] }
{ "input": [ "1\n9 2\n6\n4 3\n5 4\n6 1\n8 6\n8 2\n7 1\n5\n8 6\n8 7\n8 1\n7 3\n5 1\n" ], "output": [ "YES\n2 1\n3 1\n4 1\n5 4\n6 5\n7 6\n8 5\n9 8\n" ] }
{ "input": [ "1\n9 2\n6\n4 3\n5 4\n6 1\n8 6\n8 2\n7 1\n5\n8 6\n8 7\n8 1\n7 4\n5 1\n", "1\n9 2\n6\n4 3\n2 4\n6 1\n8 6\n8 2\n7 1\n5\n8 6\n8 7\n8 1\n7 4\n5 1\n", "1\n9 2\n6\n4 3\n5 4\n6 1\n8 6\n8 4\n7 1\n5\n8 6\n5 7\n8 1\n7 4\n5 1\n", "1\n9 2\n6\n4 3\n5 4\n6 1\n8 6\n8 4\n7 1\n5\n8 6\n2 7\n8 1\n7 4\n5 1\n...
city-and-campers
"Money money MONEY, I want money" thought Alex. "Now how do I get money? Well... I'll open up a camp!" Well, unfortunately things didn't go so well for Alex's campers, and now there are N campers wandering around the city aimlessly. You have to handle Q queries; which consist of two groups finding each other and becom...
{ "input": [], "output": [] }
{ "input": [ "2 1\n1 2\n\nSAMPLE" ], "output": [ "0" ] }
{ "input": [], "output": [] }
lucky-string-jackpot-1
Kuldeep's girlfriend Christie recently got her PhD in Maths. So to celebrate, they both decided to play games with mathematical sequences for their date nights. The game they are playing today is "Jackpot Palindrome", the objective of the game is to find out length of the largest palindrome which only contains the dig...
{ "input": [], "output": [] }
{ "input": [ "4\n1\n2\n3\n4\n\nSAMPLE" ], "output": [ "1\n1\n1\n2\n" ] }
{ "input": [ "4\n1\n2\n3\n4\n\nSLMPAE", "4\n1\n2\n1\n2\n\nSLMPAE", "4\n1\n2\n2\n6\n\nSLMPAE", "4\n1\n0\n2\n3\n\nSPMLAE", "4\n1\n0\n2\n6\n\nSPMLAE", "4\n0\n0\n2\n6\n\nSPMLAE", "4\n0\n0\n0\n6\n\nSPMLAE", "4\n0\n0\n-1\n6\n\nSPMLAE", "4\n0\n-1\n0\n6\n\nEALOOS", "4\n0\n0\n0\n4\n\nEA...
navi-and-his-friend
Navi is a famous shopkeeper in his locality. He gives discounts to his regular customers. Some new rules have been made due to which he is in trouble. According to the new rules, any shopkeeper can sale his items to only one customer in a day. But every customer has some issues like the total money they have or the tot...
{ "input": [], "output": [] }
{ "input": [ "1\n3\n10 20\n20 30\n30 40\n50 2\n\nSAMPLE" ], "output": [ "For Day #1:\n30" ] }
{ "input": [], "output": [] }
product-of-and-gate
Heading ##There are two integers A and B. You are required to compute the bitwise AND amongst all natural numbers lying between A and B, both inclusive. Input Format First line of the input contains T, the number of testcases to follow. Each testcase in a newline contains A and B separated by a single space. Constrai...
{ "input": [], "output": [] }
{ "input": [ "3 \n12 15 \n2 3 \n8 13\n\nSAMPLE" ], "output": [ "12\n2\n8\n" ] }
{ "input": [ "3 \n8 15 \n2 3 \n8 13\n\nSAMPLE", "3 \n12 13 \n2 3 \n8 13\n\nSAMPLE", "3 \n12 13 \n2 3 \n0 13\n\nSAMPLE", "3 \n0 13 \n2 3 \n8 13\n\nSAMPLE", "3 \n0 24 \n0 3 \n8 11\n\nSAMPLE", "3 \n12 13 \n0 3 \n8 13\n\nSAMPLE", "3 \n12 13 \n0 3 \n0 13\n\nSAMPLE", "3 \n0 13 \n0 3 \n0 13\n...
the-castle-gate-july-easy
Gudi, a fun loving girl from the city of Dun, travels to Azkahar - a strange land beyond the mountains. She arrives at the gates of Castle Grey, owned by Puchi,the lord of Azkahar to claim the treasure that it guards. However, destiny has other plans for her as she has to move through floors, crossing obstacles on her...
{ "input": [], "output": [] }
{ "input": [ "3\n4\n6\n8\n\nSAMPLE" ], "output": [ "3\n12\n21\n" ] }
{ "input": [ "3\n4\n6\n15\n\nSAMPLE", "3\n4\n10\n15\n\nSAMPLE", "3\n4\n14\n15\n\nSAMPLE", "3\n4\n16\n15\n\nSAMPLE", "3\n4\n13\n15\n\nSAMPLE", "3\n4\n20\n15\n\nSAMPLE", "3\n4\n24\n15\n\nSAMPLE", "3\n7\n24\n15\n\nSAMPLE", "3\n7\n6\n8\n\nSAMPLE", "3\n8\n6\n15\n\nSAMPLE", "3\n6...
xenny-and-k-equal-triplets
Xenny had N numbers and he loved equal triplets (An equal triplet is group of 3 numbers that are equal). He defined a K-equal-triplet as a triplet in which all 3 integers were equal to K. Given an integer K, he wanted to find out the probability of getting a K-equal triplet, from the N numbers. Xenny is bad at underst...
{ "input": [], "output": [] }
{ "input": [ "1\n5 4\n1 4 4 4 1\n\nSAMPLE" ], "output": [ "1/10\n" ] }
{ "input": [ "1\n5 4\n1 4 4 4 1\n\nSAMPEL", "1\n5 7\n1 4 4 4 0\n\nSAMPLE", "1\n5 0\n0 0 0 4 0\n\nSANPLE", "1\n5 4\n1 4 4 4 0\n\nSAMPLE", "1\n5 12\n1 4 4 4 0\n\nSAMPLE", "1\n5 12\n1 4 4 4 -1\n\nSAMPLE", "1\n5 12\n1 4 4 6 -1\n\nSAMPLE", "1\n5 6\n1 4 4 4 0\n\nSAMPLE", "1\n5 7\n1 4 4 1...
p02648 Tokio Marine & Nichido Fire Insurance Programming Contest 2020 - Knapsack Queries on a tree
We have a rooted binary tree with N vertices, where the vertices are numbered 1 to N. Vertex 1 is the root, and the parent of Vertex i (i \geq 2) is Vertex \left[ \frac{i}{2} \right]. Each vertex has one item in it. The item in Vertex i has a value of V_i and a weight of W_i. Now, process the following query Q times: ...
{ "input": [], "output": [] }
{ "input": [ "15\n123 119\n129 120\n132 112\n126 109\n118 103\n115 109\n102 100\n130 120\n105 105\n132 115\n104 102\n107 107\n127 116\n121 104\n121 115\n8\n8 234\n9 244\n10 226\n11 227\n12 240\n13 237\n14 206\n15 227", "3\n1 2\n2 3\n3 4\n3\n1 1\n2 5\n3 5" ], "output": [ "256\n255\n250\n247\n255\n259\n...
{ "input": [ "15\n123 119\n129 120\n132 112\n126 109\n118 103\n115 109\n102 100\n130 120\n105 105\n132 2\n104 102\n107 107\n127 116\n121 104\n121 115\n8\n8 234\n9 244\n10 226\n11 227\n12 240\n13 237\n14 206\n15 227", "3\n1 2\n2 3\n3 4\n3\n1 1\n2 5\n3 10", "15\n123 119\n129 120\n132 112\n126 109\n118 103\n...
p02777 AtCoder Beginner Contest 154 - Remaining Balls
We have A balls with the string S written on each of them and B balls with the string T written on each of them. From these balls, Takahashi chooses one with the string U written on it and throws it away. Find the number of balls with the string S and balls with the string T that we have now. Constraints * S, T, and ...
{ "input": [], "output": [] }
{ "input": [ "red blue\n3 4\nred", "red blue\n5 5\nblue" ], "output": [ "2 4", "5 4" ] }
{ "input": [ "red blue\n3 2\nred", "red blte\n3 0\nred", "red blue\n5 0\nred", "red blue\n7 0\nred", "red blue\n5 1\nred", "red blue\n0 0\nred", "red blte\n3 4\nred", "red blue\n1 0\nred", "red blue\n11 0\nred", "red blue\n-1 0\nred", "red blue\n11 -1\nred", "red bkfu\n...
p02912 AtCoder Beginner Contest 141 - Powerful Discount Tickets
Takahashi is going to buy N items one by one. The price of the i-th item he buys is A_i yen (the currency of Japan). He has M discount tickets, and he can use any number of them when buying an item. If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nea...
{ "input": [], "output": [] }
{ "input": [ "1 100000\n1000000000", "10 1\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000", "4 4\n1 9 3 5", "3 3\n2 13 8" ], "output": [ "0", "9500000000", "6", "9" ] }
{ "input": [ "1 101000\n1000000000", "10 1\n1000000000 1001000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000", "3 3\n2 13 3", "10 1\n1000000000 1001000000 1000000000 1000000000 1000000000 1000000000 1000000000 1010000000 1000000000 1000000000", "3 2\n2 ...
p03048 diverta 2019 Programming Contest - RGB Boxes
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g gre...
{ "input": [], "output": [] }
{ "input": [ "1 2 3 4", "13 1 4 3000" ], "output": [ "4", "87058" ] }
{ "input": [ "1 2 3 1", "13 1 4 540", "1 2 3 2", "17 1 4 540", "13 2 4 3000", "13 1 4 97", "18 1 4 540", "13 2 1 3000", "13 1 4 62", "13 1 4 92", "13 1 4 163", "13 1 8 163", "13 1 14 163", "13 1 6 163", "13 1 10 163", "13 1 10 115", "8 1 10 115", ...
p03189 AtCoder Grand Contest 030 - Inversion Sum
You are given an integer sequence of length N: A_1,A_2,...,A_N. Let us perform Q operations in order. The i-th operation is described by two integers X_i and Y_i. In this operation, we will choose one of the following two actions and perform it: * Swap the values of A_{X_i} and A_{Y_i} * Do nothing There are 2^Q wa...
{ "input": [], "output": [] }
{ "input": [ "3 2\n1\n2\n3\n1 2\n1 3", "5 3\n3\n2\n3\n1\n4\n1 5\n2 3\n4 2", "9 5\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3 5\n8 9\n7 9\n3 2\n3 8" ], "output": [ "6", "36", "425" ] }
{ "input": [ "3 2\n1\n2\n3\n1 3\n1 3", "5 3\n3\n2\n3\n2\n4\n1 5\n2 3\n4 2", "9 5\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3 5\n8 9\n7 9\n3 1\n3 8", "3 2\n1\n2\n1\n1 3\n1 3", "5 3\n3\n2\n6\n2\n4\n1 5\n2 3\n4 2", "9 5\n3\n1\n4\n1\n5\n9\n2\n8\n3\n3 5\n8 9\n7 9\n3 1\n3 8", "5 3\n3\n2\n11\n2\n4\n1 5\n2 1\n4...
p03336 AtCoder Grand Contest 025 - Addition and Andition
Takahashi and Aoki love calculating things, so they will play with numbers now. First, they came up with one positive integer each. Takahashi came up with X, and Aoki came up with Y. Then, they will enjoy themselves by repeating the following operation K times: * Compute the bitwise AND of the number currently kept b...
{ "input": [], "output": [] }
{ "input": [ "2 3 3\n11\n101", "10 10 10\n1100110011\n1011001101", "5 8 3\n10101\n10101001" ], "output": [ "10000\n10010", "10000100000010001000\n10000100000000100010", "100000\n10110100" ] }
{ "input": [ "5 8 3\n00101\n10101001", "5 8 3\n00101\n10100001", "5 8 5\n00101\n10110001", "5 8 5\n00101\n10110011", "5 8 3\n10101\n10100001", "5 8 3\n00100\n10101001", "5 8 5\n00101\n10000001", "5 8 5\n10101\n10110001", "10 10 14\n1100110011\n1011001101", "5 8 3\n10101\n101110...
p03497 AtCoder Regular Contest 086 - Not so Diverse
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. Constraints * 1 \leq K \leq N...
{ "input": [], "output": [] }
{ "input": [ "4 4\n1 1 2 2", "5 2\n1 1 2 2 5", "10 3\n5 1 3 2 4 1 1 2 3 4" ], "output": [ "0", "1", "3" ] }
{ "input": [ "4 4\n0 1 2 2", "10 3\n5 1 3 2 4 1 2 2 3 4", "10 3\n5 1 3 4 8 1 2 2 3 4", "10 3\n3 2 3 4 8 1 2 2 3 4", "5 2\n2 1 4 2 1", "10 1\n5 1 3 2 4 1 2 2 3 8", "10 1\n5 2 3 2 4 1 2 2 3 8", "4 4\n0 1 2 4", "4 4\n-1 1 2 4", "4 4\n-2 1 2 4", "4 6\n-2 1 2 4", "4 6\n-2 1 ...
p03657 AtCoder Beginner Contest 067 - Sharing Cookies
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them ca...
{ "input": [], "output": [] }
{ "input": [ "4 5", "1 1" ], "output": [ "Possible", "Impossible" ] }
{ "input": [ "4 0", "-1 2", "1 2", "7 0", "0 2", "7 -1", "7 -2", "-1 4", "7 -4", "-1 8", "5 -4", "-1 14", "8 -4", "-1 28", "5 0", "-2 28", "5 -1", "-2 40", "0 -1", "-3 40", "-1 -1", "-3 57", "-1 -2", "-2 57", "-2 -2", ...
p03813 AtCoder Beginner Contest 053 - ABC/ARC
Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise. You are given Smeke's current rating, x. Print `ABC` if Smeke will participate in ABC, and print `ARC` otherwise. Constraints * 1 ≦ x ≦ 3{,}000 * x i...
{ "input": [], "output": [] }
{ "input": [ "1000", "2000" ], "output": [ "ABC", "ARC" ] }
{ "input": [ "0000", "2936", "0100", "1432", "1100", "146", "1101", "242", "0110", "171", "0010", "313", "1010", "372", "1011", "288", "1111", "434", "0111", "664", "1110", "211", "0001", "123", "0011", "116", ...
p03982 Kyoto University Programming Contest 2016 - WAAAAAAAAAAAAALL
Kyoto University decided to build a straight wall on the west side of the university to protect against gorillas that attack the university from the west every night. Since it is difficult to protect the university at some points along the wall where gorillas attack violently, reinforcement materials are also built at ...
{ "input": [], "output": [] }
{ "input": [ "2\n1 5\n3 1", "5\n1 2 3 4 5\n3 3 1 1 1", "27\n46 3 4 2 10 2 5 2 6 7 20 13 9 49 3 8 4 3 19 9 3 5 4 13 9 5 7\n10 2 5 6 2 6 3 2 2 5 3 11 13 2 2 7 7 3 9 5 13 4 17 2 2 2 4", "2\n1 99999999999\n1234567891 1", "18\n3878348 423911 8031742 1035156 24256 10344593 19379 3867285 4481365 1475384 ...
{ "input": [ "5\n1 4 3 4 5\n3 3 1 1 1", "27\n46 3 4 2 10 2 5 2 6 7 20 13 9 49 3 8 4 3 19 9 3 5 4 13 9 5 7\n10 2 5 6 2 6 3 2 2 5 3 11 13 2 2 7 7 3 9 5 26 4 17 2 2 2 4", "2\n1 99999999999\n1549099265 1", "18\n3878348 423911 8031742 1035156 24256 10344593 19379 3867285 4481365 1475384 1959412 1383457 164...
p00070 Combination of Number Sequences
Consider a sequence of n numbers using integers from 0 to 9 k1, k2, ..., kn. Read the positive integers n and s, k1 + 2 x k2 + 3 x k3 + ... + n x kn = s Create a program that outputs how many rows of n numbers such as. However, the same number does not appear more than once in one "n sequence of numbers". Input T...
{ "input": [], "output": [] }
{ "input": [ "3 10\n3 1" ], "output": [ "8\n0" ] }
{ "input": [ "4 10\n3 1", "6 10\n3 1", "2 14\n3 1", "2 25\n10 0", "2 4\n10 0", "3 10\n0 1", "3 14\n10 3", "3 10\n2 1", "2 9\n3 1", "2 14\n2 1", "3 22\n10 3", "3 20\n3 1", "2 20\n2 1", "5 23\n3 2", "2 0\n2 1", "2 1\n2 1", "5 33\n3 1", "0 13\n2 2",...
p00202 At Boss's Expense
Taro Aizu's company has a boss who hates being indivisible. When Taro goes out to eat with his boss, he pays by splitting the bill, but when the payment amount is not divisible by the number of participants, his boss always pays for it. One day, Taro became the secretary of the dinner party. Mr. Taro, who has little m...
{ "input": [], "output": [] }
{ "input": [ "4 15000\n305\n260\n129\n500\n3 400\n10\n20\n30\n3 200909\n5\n9\n12\n0 0" ], "output": [ "14983\nNA\n200909" ] }
{ "input": [ "4 15000\n305\n260\n129\n500\n3 400\n10\n20\n30\n3 337371\n5\n9\n12\n0 0", "4 15000\n305\n124\n129\n500\n3 400\n10\n20\n30\n3 200909\n5\n9\n12\n0 0", "4 15000\n305\n260\n136\n500\n3 400\n10\n1\n30\n3 337371\n5\n1\n12\n0 0", "4 11033\n305\n24\n129\n177\n3 547\n6\n20\n30\n3 200909\n5\n9\n32...
p00357 Trampoline
A plurality of trampolines are arranged in a line at 10 m intervals. Each trampoline has its own maximum horizontal distance within which the jumper can jump safely. Starting from the left-most trampoline, the jumper jumps to another trampoline within the allowed jumping range. The jumper wants to repeat jumping until ...
{ "input": [], "output": [] }
{ "input": [ "4\n20\n30\n1\n20", "4\n20\n5\n10\n1", "3\n10\n5\n10" ], "output": [ "yes", "no", "no" ] }
{ "input": [ "4\n20\n51\n1\n20", "4\n20\n5\n17\n1", "3\n12\n5\n10", "4\n37\n51\n1\n20", "4\n20\n5\n5\n1", "3\n20\n5\n10", "4\n54\n51\n1\n20", "4\n35\n5\n5\n1", "3\n20\n5\n5", "4\n84\n51\n1\n20", "4\n29\n5\n5\n1", "3\n7\n5\n10", "4\n84\n51\n2\n20", "4\n29\n5\n5\n...
p00563 Rope
JOI is a baby playing with a rope. The rope has length $N$, and it is placed as a straight line from left to right. The rope consists of $N$ cords. The cords are connected as a straight line. Each cord has length 1 and thickness 1. In total, $M$ colors are used for the rope. The color of the $i$-th cord from left is $C...
{ "input": [], "output": [] }
{ "input": [ "5 3\n1 2 3 3 2" ], "output": [ "2\n1\n1" ] }
{ "input": [ "5 3\n1 2 3 1 2", "4 3\n1 2 3 1 2", "5 3\n1 2 2 3 2", "5 3\n1 2 2 3 3", "5 3\n1 3 2 3 3", "4 4\n1 2 3 4 2", "4 2\n2 2 2 1 4", "4 3\n1 2 3 2 2", "4 3\n1 2 3 2 4", "5 3\n1 2 3 1 1", "5 3\n1 2 3 2 2", "4 3\n1 3 3 2 4", "5 3\n2 2 3 1 1", "4 3\n1 3 2 2 4...
p00716 Ohgas' Fortune
The Ohgas are a prestigious family based on Hachioji. The head of the family, Mr. Nemochi Ohga, a famous wealthy man, wishes to increase his fortune by depositing his money to an operation company. You are asked to help Mr. Ohga maximize his profit by operating the given money during a specified period. From a given l...
{ "input": [], "output": [] }
{ "input": [ "4\n1000000\n5\n2\n0 0.03125 3000\n1 0.03125 3000\n6620000\n7\n2\n0 0.0732421875 42307\n1 0.0740966796875 40942\n39677000\n4\n4\n0 0.0709228515625 30754\n1 0.00634765625 26165\n0 0.03662109375 79468\n0 0.0679931640625 10932\n10585000\n6\n4\n1 0.0054931640625 59759\n1 0.12353515625 56464\n0 0.04968261...
{ "input": [ "4\n1000000\n5\n2\n0 0.03125 3000\n1 0.03125 3000\n6620000\n7\n2\n0 0.0732421875 42307\n0 0.0740966796875 40942\n39677000\n4\n4\n0 0.0709228515625 30754\n1 0.00634765625 26165\n0 0.03662109375 79468\n0 0.0679931640625 10932\n10585000\n6\n4\n1 0.0054931640625 59759\n1 0.12353515625 56464\n0 0.04968261...
p00856 Minimal Backgammon
Here is a very simple variation of the game backgammon, named “Minimal Backgammon”. The game is played by only one player, using only one of the dice and only one checker (the token used by the player). The game board is a line of (N + 1) squares labeled as 0 (the start) to N (the goal). At the beginning, the checker ...
{ "input": [], "output": [] }
{ "input": [ "6 1 0 0\n7 1 0 0\n7 2 0 0\n6 6 1 1\n2\n5\n7 10 0 6\n1\n2\n3\n4\n5\n6\n0 0 0 0" ], "output": [ "0.166667\n0.000000\n0.166667\n0.619642\n0.000000" ] }
{ "input": [ "6 1 0 0\n7 1 0 0\n7 2 0 0\n6 6 1 1\n2\n5\n7 10 0 6\n2\n2\n3\n4\n5\n6\n0 0 0 0", "6 1 0 0\n7 1 0 0\n7 2 0 0\n6 6 1 1\n2\n5\n7 5 0 6\n1\n2\n3\n4\n5\n6\n0 0 0 0", "6 2 0 0\n7 1 0 0\n7 2 0 0\n6 6 1 1\n2\n5\n7 10 0 6\n2\n2\n3\n4\n5\n6\n0 0 0 0", "6 1 0 0\n7 1 0 0\n7 2 0 0\n6 3 1 1\n2\n5\n7 10...
p00987 One-Way Conveyors
One-Way Conveyors You are working at a factory manufacturing many different products. Products have to be processed on a number of different machine tools. Machine shops with these machines are connected with conveyor lines to exchange unfinished products. Each unfinished product is transferred from a machine shop to ...
{ "input": [], "output": [] }
{ "input": [ "3 2\n1 2\n2 3\n3\n1 2\n1 3\n2 3" ], "output": [ "Yes\n1 2\n2 3" ] }
{ "input": [ "6 2\n1 2\n2 3\n3\n1 2\n1 3\n2 3", "3 0\n0 2\n2 3\n3\n1 2\n1 3\n2 3", "3 2\n1 2\n2 3\n3\n1 2\n1 2\n2 3", "3 0\n0 2\n2 3\n3\n1 0\n1 3\n2 3", "3 0\n0 2\n2 3\n3\n1 0\n1 3\n3 3", "3 0\n0 2\n2 3\n5\n1 0\n1 3\n3 3", "3 0\n0 2\n2 3\n5\n1 0\n1 2\n3 3", "3 0\n0 2\n2 3\n5\n1 0\n1 0\...
p01119 Balance Scale
<!-- Problem C --> Balance Scale You, an experimental chemist, have a balance scale and a kit of weights for measuring weights of powder chemicals. For work efficiency, a single use of the balance scale should be enough for measurement of each amount. You can use any number of weights at a time, placing them eithe...
{ "input": [], "output": [] }
{ "input": [ "4 2\n9 2 7 11\n2 9\n6 2\n7 3 6 12 16 9\n2 9\n5 2\n7 3 6 12 17\n2 9\n7 5\n15 21 33 48 51 75 111\n36 54 57 93 113\n0 0" ], "output": [ "0\n5\n-1\n5" ] }
{ "input": [ "4 2\n9 2 7 11\n2 9\n6 2\n7 3 6 12 16 9\n2 9\n5 2\n7 3 6 12 17\n2 9\n7 5\n15 21 57 48 51 75 111\n36 54 57 93 113\n0 0", "4 2\n9 2 7 11\n2 9\n6 2\n7 3 6 12 16 9\n2 9\n5 2\n7 3 6 12 17\n2 9\n7 5\n15 21 57 48 51 75 111\n36 54 57 93 102\n0 0", "4 2\n9 2 7 11\n2 9\n6 2\n7 3 6 12 16 9\n2 9\n5 2\n7 ...
p01257 Vending Machine
There has been marketing warfare among beverage vendors, and they have been working hard for in- crease of their sales. The Kola-Coqua Company is one of the most successful vendors among those: their impressive advertisements toward the world has brought the overwhelming market share of their representative product cal...
{ "input": [], "output": [] }
{ "input": [ "6 330\n1 5 10 50 100 500\n7 127\n1 2 4 8 16 32 64\n2 10000\n1000 2000\n0 0" ], "output": [ "2\n1\n4" ] }
{ "input": [ "6 330\n1 5 10 50 100 500\n7 127\n1 2 4 8 29 32 64\n2 10000\n1000 2000\n0 0", "6 330\n1 5 10 50 100 500\n7 127\n1 2 4 8 16 32 64\n2 10000\n1000 1446\n0 0", "6 330\n1 5 10 50 100 500\n7 127\n1 2 0 8 16 32 64\n2 10000\n1000 1446\n0 0", "6 330\n1 5 10 50 100 500\n7 127\n1 2 0 8 16 32 64\n2 1...
p01418 Sleeping Time
Miki is a high school student. She has a part time job, so she cannot take enough sleep on weekdays. She wants to take good sleep on holidays, but she doesn't know the best length of sleeping time for her. She is now trying to figure that out with the following algorithm: 1. Begin with the numbers K, R and L. 2. She t...
{ "input": [], "output": [] }
{ "input": [ "3 0 2\n0.10000000000\n0.00000100000\n0.37500000000", "3 0 2\n0.10000000000\n0.37499999977\n1.00000000000", "3 0 2\n0.10000000000\n0.50000000000\n1.00000000000", "3 0 2\n0.20000000000\n0.00000100000\n0.37500000000" ], "output": [ "0.729000", "0.810000", "0.900000", "0....
{ "input": [ "3 0 2\n0.4085591484323763\n0.00000100000\n0.37500000000", "3 0 2\n0.14744802999270293\n0.37499999977\n1.00000000000", "4 0 2\n0.10000000000\n0.50000000000\n1.00000000000", "3 0 3\n0.20000000000\n0.00000100000\n0.37500000000", "3 0 2\n0.14744802999270293\n1.1414476119385046\n1.0000000...
p01572 Artistic Art Museum
Mr. Knight is a chief architect of the project to build a new art museum. One day, he was struggling to determine the design of the building. He believed that a brilliant art museum must have an artistic building, so he started to search for a good motif of his building. The art museum has one big theme: "nature and hu...
{ "input": [], "output": [] }
{ "input": [ "2\n8 -1 2 1 2 1 -3 2 -3 2 3 -2 3 -2 -3 -1 -3" ], "output": [ "22.6303" ] }
{ "input": [ "2\n8 -1 2 1 2 1 -3 1 -3 2 3 -2 3 -2 -3 -1 -3", "2\n8 -1 2 1 2 1 -6 1 -3 2 3 -2 3 -2 -3 -1 -3", "2\n8 -1 2 1 2 1 -3 2 -5 2 3 -2 3 -2 -3 -1 -3", "2\n8 -1 2 1 2 1 -3 2 -5 2 3 -2 3 -2 -3 -1 0", "2\n8 -1 2 1 2 1 -3 2 -3 2 3 -2 3 -2 -4 -1 -3", "2\n3 -1 2 1 2 1 -6 1 -3 2 3 -2 3 -2 -3 -1...
p01734 Removing Magical Tiles
Ayimok is a wizard. His daily task is to arrange magical tiles in a line, and then cast a magic spell. Magical tiles and their arrangement follow the rules below: * Each magical tile has the shape of a trapezoid with a height of 1. * Some magical tiles may overlap with other magical tiles. * Magical tiles are arrang...
{ "input": [], "output": [] }
{ "input": [ "3\n26 29 9 12\n6 10 15 16\n8 17 18 19" ], "output": [ "1" ] }
{ "input": [ "3\n26 17 9 12\n6 10 15 16\n8 17 18 19", "3\n26 29 9 12\n6 10 15 16\n11 17 18 19", "3\n26 29 11 12\n6 10 15 16\n8 17 18 19", "3\n26 17 9 12\n6 10 27 16\n8 17 18 19", "3\n26 29 1 12\n6 10 15 16\n8 17 18 19", "3\n26 24 9 12\n6 10 27 16\n8 17 18 19", "3\n26 29 1 12\n6 10 15 16\n8...
p01873 Periodic Sequence
B: Periodic Sequence- problem Dr. Period, a professor at H University, is studying a property called the cycle that is supposed to be hidden in all things. As a generally known basic cycle, a cycle hidden in a sequence may be considered. That is, if the sequence S = S_1, S_2, ..., S_N of length N satisfies the follow...
{ "input": [], "output": [] }
{ "input": [ "6\n1 2 3 1 2 3" ], "output": [ "2" ] }
{ "input": [ "6\n1 2 3 1 1 3", "6\n1 2 3 1 0 3", "6\n2 2 3 1 0 3", "6\n2 2 3 2 0 3", "6\n4 2 3 2 0 3", "6\n4 2 3 2 0 4", "6\n4 4 3 2 0 4", "6\n7 4 3 2 0 4", "6\n7 4 3 2 1 4", "6\n7 4 3 2 2 4", "6\n7 0 3 2 2 4", "6\n7 -1 3 2 2 4", "6\n6 -1 3 2 2 4", "6\n6 -1 1 2 ...
p02010 Additions
You are given an integer $N$ and a string consisting of '+' and digits. You are asked to transform the string into a valid formula whose calculation result is smaller than or equal to $N$ by modifying some characters. Here, you replace one character with another character any number of times, and the converted string s...
{ "input": [], "output": [] }
{ "input": [ "2000\n1234++7890", "1\n+123", "100\n+123", "10\n++1+", "10\n+123" ], "output": [ "2", "-1", "2", "2", "4" ] }
{ "input": [ "2000\n0234++7890", "1\n46", "100\n66", "10\n239", "10\n151", "10\n3363", "10\n++0+", "2000\n0987++4320", "1\n83", "100\n61", "10\n437", "2000\n0947++8320", "1\n27", "100\n25", "2000\n0947++3820", "1\n54", "100\n45", "10\n64", "2...
p02153 Don't Burn Kotatsu Turtle
Problem Kotatsu turtle is a turtle with a kotatsu shell. As soon as Kotatsu was pokita (getting up), he was trapped in a stage divided into grid-like sections. There is only one exit on this stage. The parcel is either a road, a fence or a bomb, and the kotatsu can move up, down, left and right to enter the parcel o...
{ "input": [], "output": [] }
{ "input": [ "2 4 1 1\ng\ns###", "4 4 1 1\ng#..\n...\n.*..\n...s", "3 3 10 1\ng..\n.\ns..", "4 4 1 1\ng#..\n*..\n....\n...s", "4 4 1 1\ng#..\n#...\n.*..\n...s", "3 3 1 10\ng..\n.\ns.." ], "output": [ "6", "7", "21", "INF", "7", "6" ] }
{ "input": [ "4 4 1 1\ng#..\n+..\n....\n...s", "5 4 1 1\ng#..\n#...\n.*..\n...s", "3 3 1 10\n..g\n.\ns..", "4 4 0 1\n.#g.\n+..\n....\n...s", "4 4 1 1\n.g#.\n+..\n....\n...s", "3 3 10 2\ng..\n.\ns..", "3 3 1 10\ng..\n/\ns..", "6 4 2 2\n.g#.\n+..\n....\ns./.", "3 3 7 2\ng..\n.\ns..",...
p02294 Intersection
For given two segments s1 and s2, print "1" if they are intersect, "0" otherwise. s1 is formed by end points p0 and p1, and s2 is formed by end points p2 and p3. Constraints * 1 ≤ q ≤ 1000 * -10000 ≤ xpi, ypi ≤ 10000 * p0 ≠ p1 and p2 ≠ p3. Input The entire input looks like: q (the number of queries) 1st query 2n...
{ "input": [], "output": [] }
{ "input": [ "3\n0 0 3 0 1 1 2 -1\n0 0 3 0 3 1 3 -1\n0 0 3 0 3 -2 5 0" ], "output": [ "1\n1\n0" ] }
{ "input": [ "3\n0 0 3 0 1 1 2 -1\n0 0 3 0 3 1 3 -1\n0 0 6 0 3 -2 5 0", "3\n0 0 3 0 1 1 2 -1\n0 0 0 0 3 1 3 -1\n0 0 6 0 1 -2 5 0", "3\n-1 0 3 0 1 1 4 -1\n1 0 0 0 3 1 3 -1\n0 0 6 1 1 -2 5 0", "3\n-1 0 3 0 1 1 4 0\n1 0 0 0 3 1 3 -1\n0 -1 6 1 1 -2 5 0", "3\n-1 0 0 -1 2 1 4 -2\n1 0 0 0 4 1 6 -1\n0 -1 ...
p02441 Count
For a given sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$, perform the following operations. * count($b, e, k$): print the number of the specific values $k$ in $a_b, a_{b+1}, ..., a_{e-1}$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i, k_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 ...
{ "input": [], "output": [] }
{ "input": [ "9\n1 4 1 4 2 1 3 5 6\n3\n0 9 1\n1 6 1\n3 7 5" ], "output": [ "3\n2\n0" ] }
{ "input": [ "9\n1 4 1 4 2 0 3 5 6\n3\n0 9 1\n1 6 1\n3 7 5", "9\n1 4 1 4 4 -1 3 5 6\n3\n0 9 1\n0 6 1\n3 7 5", "9\n1 4 1 4 4 -1 3 5 6\n3\n0 9 1\n0 6 2\n2 7 5", "9\n1 4 0 4 4 -1 3 5 6\n3\n0 9 1\n0 6 2\n2 7 5", "9\n2 4 0 4 4 -1 7 5 6\n3\n0 9 1\n0 6 2\n0 17 9", "9\n1 4 1 4 2 1 3 5 6\n3\n0 9 1\n1 9...
axr1p2
Given this sequence….. 1^(1!)+2^(2!)+3^(3!)+4^(4!)+……………………..N^(N!). Your job is to write a program such that given N any time, you have to find out the unit place digit of the sum of the above sequence. Input Enter the number N to calculate the unit place digit of the sum of the above sequence 1 < N < 1000. ...
{ "input": [], "output": [] }
{ "input": [ "71\n#" ], "output": [ "8\n" ] }
{ "input": [], "output": [] }
cmb01
Reversed number is a number written in arabic numerals but the order of digits is reversed. The first digit becomes last and vice versa. For example, if the number is 1245,it will become 5421 .Note that all the leading zeros are omitted. That means if the number ends with a zero, the zero is lost by reversing (e.g....
{ "input": [], "output": [] }
{ "input": [ "1\n24 1" ], "output": [ "34\n" ] }
{ "input": [ "1\n24 2", "1\n34 2", "1\n15 1", "1\n68 1", "1\n20 1", "1\n34 3", "1\n68 2", "1\n9 1", "1\n124 2", "1\n9 2", "1\n9 4", "1\n5 4", "1\n5 2", "1\n2 2", "1\n1 4", "1\n4 2", "1\n31 1", "1\n48 1", "1\n66 2", "1\n15 4", "1\n22 3...
flow011
In a company an emplopyee is paid as under: If his basic salary is less than Rs. 1500, then HRA = 10% of base salary and DA = 90% of basic salary. If his salary is either equal to or above Rs. 1500, then HRA = Rs. 500 and DA = 98% of basic salary. If the Employee's salary is input, write a program to find his gross sa...
{ "input": [], "output": [] }
{ "input": [ "3 \n1203\n10042\n1312" ], "output": [ "2406\n20383.2\n2624\n" ] }
{ "input": [ "3 \n1203\n6117\n1312", "3 \n1203\n4359\n1312", "3 \n530\n4359\n1312", "3 \n530\n4670\n1312", "3 \n530\n4670\n1914", "3 \n530\n729\n1914", "3 \n37\n729\n1914", "3 \n68\n729\n1914", "3 \n133\n729\n1914", "3 \n133\n1025\n1914", "3 \n257\n1025\n1914", "3 \n154...
lemusic
The Little Elephant from the Zoo of Lviv likes listening to music. There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers Bi and Li - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going to list...
{ "input": [], "output": [] }
{ "input": [ "2\n3\n1 2\n2 2\n3 2\n3\n2 3\n1 2\n2 4" ], "output": [ "12\n16\n" ] }
{ "input": [ "2\n3\n1 2\n2 2\n3 2\n3\n2 3\n1 2\n2 8", "2\n3\n1 2\n2 2\n3 2\n3\n2 3\n1 2\n2 2", "2\n3\n1 1\n2 2\n3 2\n3\n2 3\n1 2\n2 2", "2\n3\n1 2\n2 2\n4 2\n3\n2 3\n1 2\n2 4", "2\n3\n1 1\n2 2\n3 2\n3\n2 3\n1 2\n2 8", "2\n3\n1 2\n2 2\n3 2\n3\n2 3\n1 2\n2 3", "2\n3\n1 1\n2 2\n1 2\n3\n2 3\n1...
ppxor
Polo, the Penguin, likes the XOR operation. Please read NOTE if you are not familiar with XOR operation. XOR-sum of a list of numbers is the result of XOR-ing all of them. XOR-sum of (A[1] XOR A[2] XOR ... XOR A[N]) is defined as A[1] XOR (A[2] XOR (A[3] XOR ( ... XOR A[N]))). He has an array A consisting of N integer...
{ "input": [], "output": [] }
{ "input": [ "1\n2\n1 2" ], "output": [ "6" ] }
{ "input": [], "output": [] }
sumtrian
Let's consider a triangle of numbers in which a number appears in the first line, two numbers appear in the second line, three in the third line, etc. Develop a program which will compute the largest of the sums of numbers that appear on the paths starting from the top towards the base, so that: on each path the next ...
{ "input": [], "output": [] }
{ "input": [ "2\n3\n1\n2 1\n1 2 3\n4 \n1 \n1 2 \n4 1 2\n2 3 1 1" ], "output": [ "5\n9\n" ] }
{ "input": [ "2\n3\n1\n2 1\n1 2 3\n4 \n1 \n1 2 \n4 1 2\n2 0 1 1", "2\n3\n1\n2 1\n2 2 3\n4 \n1 \n1 2 \n4 1 2\n2 3 1 1", "2\n3\n1\n3 1\n2 2 3\n4 \n1 \n1 2 \n4 1 2\n2 3 1 1", "2\n3\n1\n2 1\n1 2 3\n4 \n1 \n1 2 \n4 1 2\n1 0 1 1", "2\n3\n1\n0 1\n1 2 2\n4 \n2 \n1 2 \n4 1 2\n2 0 1 1", "2\n3\n1\n3 1\n4...
100_J. Interval Coloring
Aryo has got a lot of intervals for his 2418th birthday. He is really excited and decided to color all these intervals with some colors. He has a simple rule for himself. He calls a coloring nice if there exists no three intervals a, b and c such that the following conditions are satisfied simultaneously: * a, b an...
{ "input": [], "output": [] }
{ "input": [ "2\n[1,2)\n(3,4]\n", "3\n[1,3]\n[2,6]\n(5,7)\n" ], "output": [ "1\n", "2\n" ] }
{ "input": [], "output": [] }
1223_B. Strings Equalization
You are given two strings of equal length s and t consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings. During each operation you choose two adjacent characters in any string and assign the value of the first character to the value of the second or vice versa. ...
{ "input": [], "output": [] }
{ "input": [ "3\nxabb\naabx\ntechnocup\ntechnocup\na\nz\n" ], "output": [ "YES\nYES\nNO\n" ] }
{ "input": [ "3\nxabb\naabx\nteohnccup\ntechnocup\na\nz\n", "3\nbcbw\nxaaa\ntdohncbup\npvconhcet\nb\nz\n", "3\nxabb\naabx\ntdohnccup\ntechnocup\na\nz\n", "3\nxabb\nxbaa\ntdohnccup\ntechnocup\na\nz\n", "3\nxacb\nxbaa\ntdohnccup\ntechnocup\na\nz\n", "3\nxabb\naabx\ntechnncup\ntechnocup\na\nz\n",...
130_E. Tribonacci numbers
Tribonacci numbers are a sequence of numbers, defined as follows: * t0 = t1 = 0, * t2 = 1, * ti = ti - 1 + ti - 2 + ti - 3. You are given n; calculate n-th tribonacci number modulo 26. Input The only line of input contains an integer n (1 ≤ n ≤ 1000). Output Output n-th tribonacci number modulo 26. Examp...
{ "input": [], "output": [] }
{ "input": [ "4\n", "9\n" ], "output": [ "2\n", "18\n" ] }
{ "input": [], "output": [] }
1331_H. It's showtime
You are given a mysterious language (codenamed "UnknownX") available in "Custom Test" tab. Find out what this language is, and use it to solve the following problem. You are given an integer input = 1000 * n + mod (1 ≤ n, mod ≤ 999). Calculate [double factorial](https://en.wikipedia.org/wiki/Double_factorial) of n mod...
{ "input": [], "output": [] }
{ "input": [ "6100\n", "9900\n", "100002\n", "123456\n" ], "output": [ "\n48\n", "\n45\n", "\n0\n", "\n171\n" ] }
{ "input": [], "output": [] }
375_D. Tree and Queries
You have a rooted tree consisting of n vertices. Each vertex of the tree has some color. We will assume that the tree vertices are numbered by integers from 1 to n. Then we represent the color of vertex v as cv. The tree root is a vertex with number 1. In this problem you need to answer to m queries. Each query is des...
{ "input": [], "output": [] }
{ "input": [ "8 5\n1 2 2 3 3 2 3 3\n1 2\n1 5\n2 3\n2 4\n5 6\n5 7\n5 8\n1 2\n1 3\n1 4\n2 3\n5 3\n", "4 1\n1 2 3 4\n1 2\n2 3\n3 4\n1 1\n" ], "output": [ "2\n2\n1\n0\n1\n", "4\n" ] }
{ "input": [ "4 1\n1 4 3 4\n1 2\n2 3\n3 4\n1 1\n", "4 1\n1 4 6 7\n1 2\n2 3\n3 4\n1 1\n", "8 5\n1 2 2 3 3 2 3 3\n1 2\n1 5\n2 3\n2 4\n5 6\n5 7\n5 8\n1 3\n1 3\n1 4\n2 3\n5 3\n", "8 5\n1 2 2 3 3 3 3 3\n1 2\n1 5\n2 3\n2 4\n5 6\n5 7\n5 8\n1 2\n1 3\n1 4\n2 3\n5 3\n", "4 1\n1 4 3 4\n1 2\n2 3\n3 4\n1 2\n",...
683_G. The Fraction
Periodic decimal fraction is usually written as: [entire_part.non-periodic_part (period)]. Any simple fraction can be represented as a periodic decimal fraction and vice versa. For example, the decimal fraction 0.2(45) corresponds to a fraction 27 / 110. Your task is to convert the periodic fraction to a simple periodi...
{ "input": [], "output": [] }
{ "input": [ "0.2(45)\n", "0.75(0)\n" ], "output": [ "27/110\n", "3/4\n" ] }
{ "input": [], "output": [] }
72_B. INI-file
The INI file format is a de facto standard for configuration files. INI files are simple text files with a basic structure. They are commonly associated with Microsoft Windows, but are also used on other platforms. Each line in INI-file stands for key-value mapping or defines new section. A key-value line has a format...
{ "input": [], "output": [] }
{ "input": [ "11\na= 1\nb=a\na = 2\n ; comment\n[z]\n1=2\n[y]\n2=3\n[z]\n2=1\n[w]\n" ], "output": [ "a=2\nb=a\n[w]\n[y]\n2=3\n[z]\n1=2\n2=1\n" ] }
{ "input": [], "output": [] }
amazing-race-3
It is the final leg of the most famous amazing race. The top 'n' competitors have made it to the final. The final race has just begun. The race has 'm' checkpoints. Each team can reach any of the 'm' checkpoint but after a team reaches a particular checkpoint that checkpoint gets closed and is not open to any other tea...
{ "input": [], "output": [] }
{ "input": [ "2 3 1\n0 1\n0 0\n0 10\n27 29\n458 9651\n5 3\n\nSAMPLE" ], "output": [ "4" ] }
{ "input": [ "2 3 1\n0 1\n0 0\n0 10\n27 29\n458 9651\n5 3\n\nS@MPLE", "2 3 0\n0 1\n0 0\n0 10\n41 29\n458 4196\n5 2\n\nS@MPLE", "2 3 1\n0 0\n0 2\n2 10\n41 26\n458 7943\n5 4\n\nS@NPLE", "2 3 2\n0 1\n0 2\n2 10\n41 26\n381 7943\n5 4\n\nS@NPLE", "2 2 1\n0 1\n0 2\n2 10\n41 29\n458 6028\n5 4\n\nS@NPLE", ...
candy-1
Daenerys Targaryen set her eyes on The Kingdom of The North which is ruled by the House Stark. There is a huge market in the Castle of Winterfell that sells products of all prices starting from 1 coin i.e. there are products worth Rs 1, 2, 3 . . . 10^17 . Ned Stark is the Lord of Winterfell. He gives Daenerys some co...
{ "input": [], "output": [] }
{ "input": [ "2\n10\n1 2 4 8 16 32 64 128 256 512\n5\n1 3 4 5 7\n\nSAMPLE" ], "output": [ "1024\n2" ] }
{ "input": [ "2\n10\n1 2 4 8 16 32 64 128 256 512\n5\n0 3 4 5 7\n\nSAMPLE", "2\n10\n1 2 0 8 16 32 64 128 256 512\n5\n1 3 4 5 7\n\nSAMPLE", "2\n10\n1 2 4 8 11 32 64 128 256 512\n6\n0 3 4 5 0\n\nSAMPLE", "2\n11\n1 2 6 8 11 32 64 128 256 512\n6\n0 3 4 5 0\n\nSAMPLE", "2\n10\n1 2 1 8 16 32 64 128 611 ...
kth-shortest-path
You are given a cost matrix of dimensions m X n. The problem of finding the minimal path from top-left corner to some cell in the matrix is well studied. Here, we are gonna add a little twist. To refresh your memory, the total cost of a path is sum total of cost of all cells visited in the path. Only 2 moves are all...
{ "input": [], "output": [] }
{ "input": [ "2\n2 2\n1 2\n3 4\n2\n1 1 1\n1 1 2\n2 2\n1 2\n## 4\n3\n1 1 1\n1 1 2\n1 0 1\n\nSAMPLE" ], "output": [ "7\n8\n7\nNot so many paths\nObstacle" ] }
{ "input": [ "2\n2 2\n0 2\n3 4\n2\n1 1 1\n1 1 2\n2 2\n1 2\n## 4\n3\n1 1 1\n1 1 2\n1 0 1\n\nSAMPLE", "2\n2 2\n0 2\n3 4\n2\n1 1 2\n1 1 2\n2 2\n1 2\n## 4\n3\n1 1 1\n1 1 2\n1 0 1\n\nSAMPLE", "2\n2 2\n0 2\n3 4\n2\n1 1 1\n1 1 2\n2 2\n1 2\n## 4\n3\n1 1 1\n1 1 1\n1 0 1\n\nSAMPLE", "2\n2 2\n0 2\n3 4\n2\n1 1 2\...
passing-the-parcel
Have you ever been a part of the exciting game Passing the Parcel ? Sid is on a school picnic with his classmates. The teacher decides to make the whole class play the game of Passing the Parcel. Since the winner of the game gets lots of chocolates and ice cream as his/her prize, all the students are over-excited abo...
{ "input": [], "output": [] }
{ "input": [ "6\nabba\n\nSAMPLE" ], "output": [ "5\n" ] }
{ "input": [ "6\nbbba\n\nSAMPLE", "6\nabaa\n\nSAMPLE", "6\nabba\n\nELPMAS", "6\nbabb\n\nRAMPLE", "6\nbaab\n\nRAMPLE", "6\nbbba\n\nRAMPLE", "6\nbbba\n\nELPMAS", "6\nbbba\n\nDLPMAS", "6\nabba\n\nFLPMAS", "6\nbbba\n\nSAMPLD", "6\nabba\n\nFKPMAS", "6\nbbba\n\nS@MPLD", "...
roy-and-counting-sorted-substrings-1
Roy has a string S of length N. String S is made of lower case English alphabets. He likes sorted strings. So he wonders how many substrings of S are sorted. Given the string S, your task is to count the number of sorted substrings of S. A string s is lexicographically sorted if si ≤ si+1 where 1 ≤ i ≤ N-1 (con...
{ "input": [], "output": [] }
{ "input": [ "4\n3\nabc\n3\nbba\n4\nabac\n3\nzyxSAMPLE" ], "output": [ "6\n4\n6\n3\n" ] }
{ "input": [ "4\n3\nabc\n3\nbba\n4\ncaba\n3\nzyxSAMPLE", "4\n3\nabc\n3\nbba\n4\naabc\n3\nzyxSAMPLE", "4\n3\nabc\n3\nbba\n4\ncaba\n3\nzzxSAMPLE", "4\n3\nabc\n3\nbba\n4\naabc\n3\nzxxSAMPLE", "4\n3\nabd\n3\nbba\n4\naabc\n2\nzyxSAMLPE", "4\n3\ncba\n3\naba\n4\ndbaa\n3\nzyxSAMPLE", "4\n3\ncba\n3...
string-query-22
Given a string s and m queries. For each query delete the K-th occurence of a character x. Input: The first line contains the string s followed by an integer m. The string consists of lowercase letters. After that m lines follow each line containing the integer K and the character x. Output: Print the string after al...
{ "input": [], "output": [] }
{ "input": [ "abcdbcaab\n5\n2 a\n1 c\n1 d\n3 b\n2 a\n\nSAMPLE" ], "output": [ "abbc\n" ] }
{ "input": [ "abcdbcaab\n5\n2 a\n1 c\n1 c\n3 b\n2 a\n\nSAMPLE", "abcdbcaab\n0\n2 a\n1 c\n1 d\n5 b\n2 a\n\nSAMPLE", "abcdbcaab\n5\n2 a\n1 c\n1 c\n1 b\n2 a\n\nSAMPLE", "abcdbcaab\n1\n2 a\n1 c\n1 d\n5 b\n2 a\n\nSAMPLE", "abcdbcaab\n5\n2 a\n1 c\n1 c\n1 b\n1 a\n\nELPMAS", "abcdbcaab\n5\n2 a\n1 c\n1...
p02596 AtCoder Beginner Contest 174 - Repsept
Takahashi loves the number 7 and multiples of K. Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.) If the sequence contains no multiples of K, print `-1` instead. Constraints * 1 \leq K \leq 10^6 * K is an integer. Input Input is giv...
{ "input": [], "output": [] }
{ "input": [ "2", "999983", "101" ], "output": [ "-1", "999982", "4" ] }
{ "input": [ "3", "1803846", "1", "1041437", "958033", "9", "172483", "2243343", "187013", "27", "62967", "57", "23239", "42117", "55133", "5041", "30689", "2849", "7083", "1929", "1533", "751", "3031", "6451", "4869",...
p02727 AtCoder Beginner Contest 160 - Red and Green Apples
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red o...
{ "input": [], "output": [] }
{ "input": [ "2 2 2 2 2\n8 6\n9 1\n2 1", "1 2 2 2 1\n2 4\n5 1\n3", "2 2 4 4 4\n11 12 13 14\n21 22 23 24\n1 2 3 4" ], "output": [ "25", "12", "74" ] }
{ "input": [ "2 2 2 2 3\n8 6\n9 1\n2 1", "1 2 2 2 1\n3 4\n5 1\n3", "2 2 4 4 4\n11 12 13 14\n21 22 23 22\n1 2 3 4", "2 2 2 2 3\n8 1\n9 1\n2 1", "0 2 2 2 3\n8 1\n9 1\n2 1", "2 1 4 4 4\n11 12 13 14\n21 22 23 22\n0 2 3 4", "1 2 2 4 1\n3 3\n1 1\n3", "2 1 4 4 4\n11 12 13 14\n21 25 23 22\n0 1...
p02858 DISCO Presents Discovery Channel Code Contest 2020 Qual - DISCOSMOS
In 2937, DISCO creates a new universe called DISCOSMOS to celebrate its 1000-th anniversary. DISCOSMOS can be described as an H \times W grid. Let (i, j) (1 \leq i \leq H, 1 \leq j \leq W) denote the square at the i-th row from the top and the j-th column from the left. At time 0, one robot will be placed onto each s...
{ "input": [], "output": [] }
{ "input": [ "869 120 1001", "2 2 1" ], "output": [ "672919729", "9" ] }
{ "input": [ "869 80 1001", "328 80 1001", "328 102 1011", "328 102 1111", "279 102 1111", "25 102 1111", "25 122 1111", "25 63 1111", "25 89 1111", "1486 120 1001", "869 80 1101", "328 117 1011", "40 102 1111", "328 60 1111", "117 102 1111", "24 102 111...
p02994 AtCoder Beginner Contest 131 - Bite Eating
You have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative. You can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used. You planned to make an apple pie using all of the apples, ...
{ "input": [], "output": [] }
{ "input": [ "5 2", "30 -50", "3 -1" ], "output": [ "18", "-1044", "0" ] }
{ "input": [ "5 4", "13 -50", "3 -2", "5 7", "16 -50", "5 -2", "5 9", "23 -50", "4 -2", "8 9", "5 -50", "4 -1", "8 11", "5 -29", "5 -1", "8 7", "10 -2", "15 7", "15 13", "15 2", "13 -8", "15 4", "8 -4", "15 8", "8 -1",...
p03135 AtCoder Beginner Contest 117 - Entrance Examination
In order to pass the entrance examination tomorrow, Taro has to study for T more hours. Fortunately, he can leap to World B where time passes X times as fast as it does in our world (World A). While (X \times t) hours pass in World B, t hours pass in World A. How many hours will pass in World A while Taro studies fo...
{ "input": [], "output": [] }
{ "input": [ "1 100", "99 1", "8 3" ], "output": [ "0.0100000000", "99.0000000000", "2.6666666667" ] }
{ "input": [ "8 2", "8 4", "8 6", "8 9", "14 9", "14 4", "14 5", "13 5", "13 9", "13 18", "4 18", "4 5", "4 8", "4 13", "4 26", "8 5", "16 5", "16 6", "11 5", "18 5", "9 5", "1 5", "1 8", "1 10", "1 3", "1 9", ...
p03280 AtCoder Beginner Contest 106 - Garden
There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) What is the area of this yard excluding the roads? Find it. Constraints * A is an ...
{ "input": [], "output": [] }
{ "input": [ "5 7", "2 2" ], "output": [ "24", "1" ] }
{ "input": [ "6 7", "2 1", "6 12", "0 2", "0 4", "9 2", "2 4", "-1 2", "-1 4", "-1 5", "0 0", "7 2", "0 -1", "-1 -1", "-2 -2", "0 -11", "-11 2", "-11 3", "-11 4", "2 -4", "-22 4", "2 -6", "-21 4", "0 -6", "-21 8", ...
p03435 AtCoder Beginner Contest 088 - Takahashi's Information
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is...
{ "input": [], "output": [] }
{ "input": [ "1 0 1\n2 1 2\n1 0 1", "1 8 6\n2 9 7\n0 7 7", "0 8 8\n0 8 8\n0 8 8", "2 2 2\n2 1 2\n2 2 2" ], "output": [ "Yes", "No", "Yes", "No" ] }
{ "input": [ "1 0 1\n4 1 2\n1 0 1", "1 8 6\n2 9 7\n1 7 7", "0 8 8\n0 8 8\n0 0 8", "2 2 2\n2 1 0\n2 2 2", "1 0 1\n4 1 2\n0 0 1", "1 8 6\n4 9 7\n1 7 7", "0 8 2\n0 8 8\n0 0 8", "2 2 2\n2 1 -1\n2 2 2", "1 0 1\n4 1 4\n0 0 1", "1 8 6\n6 9 7\n1 7 7", "-1 8 2\n0 8 8\n0 0 8", "2...
p03594 CODE FESTIVAL 2017 qual A - Four Coloring
We have a grid with H rows and W columns of squares. We will represent the square at the i-th row from the top and j-th column from the left as (i,\ j). Also, we will define the distance between the squares (i_1,\ j_1) and (i_2,\ j_2) as |i_1 - i_2| + |j_1 - j_2|. Snuke is painting each square in red, yellow, green or...
{ "input": [], "output": [] }
{ "input": [ "2 2 1", "2 3 2" ], "output": [ "RY\nGR", "RYB\nRGB" ] }
{ "input": [ "3 3 2", "3 3 3", "3 2 3", "1 2 3", "1 4 3", "1 4 5", "1 6 5", "1 6 4", "1 8 4", "1 1 4", "3 2 1", "2 5 2", "6 3 2", "6 3 3", "3 2 6", "1 2 2", "1 3 3", "1 5 4", "3 3 1", "2 6 2", "6 3 6", "3 4 3", "1 2 1", "1...
p03751 square869120Contest #4 - Atcoder Handles
Mr.X, who the handle name is T, looked at the list which written N handle names, S_1, S_2, ..., S_N. But he couldn't see some parts of the list. Invisible part is denoted `?`. Please calculate all possible index of the handle name of Mr.X when you sort N+1 handle names (S_1, S_2, ..., S_N and T) in lexicographical ord...
{ "input": [], "output": [] }
{ "input": [ "2\ntourist\npetr\ne" ], "output": [ "1" ] }
{ "input": [ "2\ntourist\neptr\ne", "2\nssvuhnr\nerrs\nf", "2\nhupouvt\netor\ni", "2\nsourist\neptr\ne", "2\nsourist\neqtr\ne", "2\nsourist\netqr\ne", "2\nsourisu\netqr\ne", "2\nsourisu\netqr\nd", "2\nsourisu\netrr\nd", "2\nsourisu\nrrte\nd", "2\nsouuisr\nrrte\nd", "2\n...
p03915 CODE FESTIVAL 2016 Final - Zigzag MST
We have a graph with N vertices, numbered 0 through N-1. Edges are yet to be added. We will process Q queries to add edges. In the i-th (1≦i≦Q) query, three integers A_i, B_i and C_i will be given, and we will add infinitely many edges to the graph as follows: * The two vertices numbered A_i and B_i will be connected...
{ "input": [], "output": [] }
{ "input": [ "7 1\n5 2 1", "2 1\n0 0 1000000000", "5 3\n0 1 10\n0 2 10\n0 4 10" ], "output": [ "21", "1000000001", "42" ] }
{ "input": [ "7 1\n6 2 1", "2 1\n0 0 1000000010", "5 3\n0 0 10\n0 2 10\n0 4 10", "9 1\n6 2 1", "5 3\n0 0 10\n0 3 10\n0 4 10", "9 1\n7 2 1", "9 1\n5 2 1", "7 1\n5 4 1", "2 1\n0 0 0000000000", "5 3\n0 1 10\n1 2 10\n0 4 10", "2 1\n1 0 1000000010", "9 1\n6 2 0", "2 1\n0...
p00017 Caesar Cipher
In cryptography, Caesar cipher is one of the simplest and most widely known encryption method. Caesar cipher is a type of substitution cipher in which each letter in the text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, 'a' would be replaced by 'b', 'b' would...
{ "input": [], "output": [] }
{ "input": [ "xlmw mw xli tmgxyvi xlex m xsso mr xli xvmt." ], "output": [ "this is the picture that i took in the trip." ] }
{ "input": [ "xlmw mw xli tmgxyvi xlex m xsso mr ilx xvmt.", "xlmw mw xli tmgxyvi xlex m ossx mr ilx xvmt.", "xlmw mw xli tmgxyvi xlex m ossx mr ilx xwmt.", "xlmw mw xli tmgxyvi xlex m orsx mr ilx xwmt.", "xlmw mw xli tmgxyvi xlex l orsx mr ilx xwmt.", "wmlx mw xli tmgxyvi xlex l orsx mr ilx x...
p00149 Eye Test
Create a program that inputs the test result data of the visual acuity test and outputs the number of people who apply to each judgment based on the following visual acuity judgment table for each of the left and right eyesight. Judgment | Sight --- | --- A | 1.1 or above B | 0.6 or more and less than 1.1 C | 0.2 or m...
{ "input": [], "output": [] }
{ "input": [ "1.0 1.2\n0.8 1.5\n1.2 0.7\n2.0 2.0" ], "output": [ "2 3\n2 1\n0 0\n0 0" ] }
{ "input": [ "1.0 1.2\n0.8 1.5\n1.2 0.7\n2.0 2.1903643288076555", "1.0 1.6960573379527397\n1.4596389610615816 1.5471720124202895\n1.2 0.7\n2.751284804693524 2.1903643288076555", "1.4450818768746183 1.6960573379527397\n2.61268179406582 1.5471720124202895\n2.573217216239934 0.7\n4.9346769267643475 2.1903643...
p00301 Symmetric Ternary Number
It is known that each weight of 1 gram, 3 gram, 9 gram, and 27 gram can be weighed from 1 gram to 40 gram in 1 gram increments using a balance. For example, if you put a weight of 3 grams and a weight you want to weigh on one plate of the balance and a weight of 27 grams and 1 gram on the other plate, the weight of the...
{ "input": [], "output": [] }
{ "input": [ "25" ], "output": [ "+0-+" ] }
{ "input": [ "15", "9", "30", "24", "20", "34", "49", "14", "10", "13", "11", "1", "2", "3", "5", "7", "22", "19", "4", "16", "27", "45", "33", "54", "40", "37", "17", "6", "8", "21", "23", ...
p00470 Commute routes
problem A city in Canada where JOI lives is divided into a grid pattern by w roads that extend straight in the north-south direction and h roads that extend straight in the east-west direction. The w roads in the north-south direction are numbered 1, 2, ..., w in order from the west. In addition, h roads in the east-...
{ "input": [], "output": [] }
{ "input": [ "3 4\n15 15\n0 0" ], "output": [ "5\n43688" ] }
{ "input": [ "3 4\n15 20\n0 0", "3 4\n15 24\n0 0", "3 4\n15 34\n0 0", "4 4\n15 34\n0 0", "3 4\n15 16\n0 0", "3 5\n15 34\n0 0", "4 4\n12 34\n0 0", "1 4\n15 16\n0 0", "2 4\n12 34\n0 0", "2 1\n12 34\n0 0", "4 2\n22 34\n0 0", "4 3\n22 34\n0 0", "4 3\n13 34\n0 0", "6...
p00662 The Great Summer Contest
Currently, people's entertainment is limited to programming contests. The activity of the entertainment club of a junior high school to which she belongs is to plan and run a programming contest. Her job is not to create problems. It's a behind-the-scenes job of soliciting issues from many, organizing referees, and pro...
{ "input": [], "output": [] }
{ "input": [ "1 1 1 1 1 1\n1 1 1 0 0 0\n1 0 0 0 1 1\n3 0 0 3 0 0\n3 1 0 1 3 1\n1 2 0 2 0 1\n0 0 1 1 0 3\n1 0 0 1 1 0\n0 0 0 0 0 0" ], "output": [ "2\n1\n1\n2\n3\n1\n1\n0" ] }
{ "input": [ "1 1 1 1 1 1\n1 1 1 0 0 0\n1 0 0 0 1 0\n3 0 0 3 0 0\n3 1 0 1 3 1\n1 2 0 2 0 1\n0 0 1 1 0 3\n1 0 0 1 1 0\n0 0 0 0 0 0", "1 1 1 1 1 1\n1 1 1 0 0 0\n1 0 0 0 1 0\n3 0 0 0 0 0\n3 1 0 1 3 1\n1 2 0 2 0 1\n0 0 1 1 0 3\n1 0 0 1 1 0\n0 0 0 0 0 0", "1 1 1 1 1 1\n1 1 1 0 0 0\n1 0 0 0 1 1\n2 0 0 3 0 0\n3 ...
p00805 Fishnet
A fisherman named Etadokah awoke in a very small island. He could see calm, beautiful and blue sea around the island. The previous night he had encountered a terrible storm and had reached this uninhabited island. Some wrecks of his ship were spread around him. He found a square wood-frame and a long thread among the w...
{ "input": [], "output": [] }
{ "input": [ "2\n0.2000000 0.6000000\n0.3000000 0.8000000\n0.3000000 0.5000000\n0.5000000 0.6000000\n2\n0.3333330 0.6666670\n0.3333330 0.6666670\n0.3333330 0.6666670\n0.3333330 0.6666670\n4\n0.2000000 0.4000000 0.6000000 0.8000000\n0.1000000 0.5000000 0.6000000 0.9000000\n0.2000000 0.4000000 0.6000000 0.8000000\n...
{ "input": [ "2\n0.2000000 0.6000000\n0.3000000 0.8000000\n0.3000000 0.5000000\n0.5000000 0.6000000\n2\n0.3333330 0.6666670\n0.3333330 0.6666670\n0.3333330 0.6666670\n0.3333330 0.6666670\n4\n0.2000000 0.4000000 0.6000000 0.8000000\n0.1000000 0.5000000 0.6000000 0.9000000\n0.2000000 0.4000000 0.6000000 0.8000000\n...
p00936 Squeeze the Cylinders
Example Input 2 10 10 Output 40.00000000
{ "input": [], "output": [] }
{ "input": [ "2\n10 10" ], "output": [ "40.00000000" ] }
{ "input": [ "2\n10 4", "2\n3 4", "2\n3 1", "2\n4 1", "2\n4 2", "2\n7 2", "2\n1 2", "2\n1 0", "2\n2 0", "2\n4 0", "2\n0 0", "2\n3 0", "2\n3 2", "2\n6 2", "2\n8 2", "2\n8 4", "2\n4 4", "2\n2 12", "2\n2 20", "2\n0 22", "2\n14 10", "...
p01069 Sum of Sequences
Problem Given a sequence A with n elements, a sequence B with m elements, q queries each consisting of an integer c. For each query The absolute value of the difference between the sum of all [la, ra] in sequence A and the sum of all [lb, rb] in sequence B is c. La, ra, lb, rb (0 ≤ la ≤ ra ≤ ra ≤ Find the number of co...
{ "input": [], "output": [] }
{ "input": [ "3 3 1\n1 2 3\n3 1 2\n3", "5 4 2\n1 2 3 4 5\n2 2 2 2\n11\n12" ], "output": [ "6", "3\n4" ] }
{ "input": [ "5 4 2\n1 2 3 4 9\n2 2 2 2\n11\n12", "5 4 2\n1 2 3 0 9\n2 2 2 2\n11\n12", "3 3 1\n1 2 3\n5 1 2\n3", "5 4 2\n1 2 3 4 5\n2 2 2 4\n11\n12", "5 4 2\n1 2 3 3 9\n2 2 2 2\n11\n12", "5 4 2\n1 2 3 0 9\n3 2 2 2\n11\n16", "3 4 1\n1 2 3\n5 1 2\n3", "5 4 2\n1 2 4 4 5\n2 2 2 4\n11\n12",...
p01203 Compress Files
Your computer is a little old-fashioned. Its CPU is slow, its memory is not enough, and its hard drive is near to running out of space. It is natural for you to hunger for a new computer, but sadly you are not so rich. You have to live with the aged computer for a while. At present, you have a trouble that requires a ...
{ "input": [], "output": [] }
{ "input": [ "6 1\n2 1\n2 1\n2 1\n2 1\n2 1\n5 1\n1 1\n4 2\n0 0" ], "output": [ "2\nImpossible" ] }
{ "input": [ "6 1\n2 1\n2 1\n2 1\n2 1\n2 1\n5 0\n1 1\n4 2\n0 0", "8 1\n2 1\n2 1\n2 1\n2 1\n2 1\n5 1\n1 1\n4 2\n0 0", "8 1\n3 1\n3 2\n2 1\n3 1\n2 1\n8 0\n1 1\n6 3\n0 0", "6 1\n2 1\n2 1\n2 1\n2 1\n2 0\n5 0\n1 1\n4 1\n0 0", "3 1\n2 1\n2 1\n2 1\n2 1\n2 0\n8 0\n1 1\n4 2\n0 0", "6 0\n4 2\n2 1\n2 1\n...
p01339 Alien's Counting
Natsuki and her friends were taken to the space by an alien and made friends with a lot of aliens. During the space travel, she discovered that aliens’ hands were often very different from humans’. Generally speaking, in a kind of aliens, there are N fingers and M bend rules on a hand. Each bend rule describes that a f...
{ "input": [], "output": [] }
{ "input": [ "5 4\n2 3\n3 4\n4 3\n5 4", "5 0", "5 5\n1 2\n2 3\n3 4\n4 5\n5 1" ], "output": [ "10", "32", "2" ] }
{ "input": [ "6 0", "5 5\n1 2\n2 3\n3 1\n4 5\n5 1", "7 0", "6 4\n2 3\n3 4\n4 3\n5 4", "4 0", "8 0", "1 0", "11 0", "13 0", "6 4\n2 3\n3 5\n4 3\n5 4", "3 0", "5 5\n1 2\n2 3\n3 4\n4 5\n5 2", "6 4\n2 2\n3 4\n4 3\n5 4", "17 0", "6 4\n2 3\n1 5\n4 3\n5 4", "29...
p01506 Digit
For a positive integer a, let S(a) be the sum of the digits in base l. Also let L(a) be the minimum k such that S^k(a) is less than or equal to l-1. Find the minimum a such that L(a) = N for a given N, and print a modulo m. Input The input contains several test cases, followed by a line containing "0 0 0". Each tes...
{ "input": [], "output": [] }
{ "input": [ "0 1000 10\n1 1000 10\n0 0 0" ], "output": [ "Case 1: 1\nCase 2: 10" ] }
{ "input": [ "0 1000 4\n1 1000 10\n0 0 0", "0 1000 4\n1 1000 17\n0 0 0", "0 1000 4\n1 1000 33\n0 0 0", "0 1000 4\n0 1000 17\n0 0 0", "0 1000 4\n2 1100 10\n0 0 0", "1 1000 10\n1 1000 10\n0 0 0", "1 1000 4\n1 1000 17\n0 0 0", "0 1000 4\n2 1000 33\n0 0 0", "1 1000 12\n1 1000 10\n0 0 0...
p01677 Broken Audio Signal
Problem Statement Nathan O. Davis is a student at the department of integrated systems. Today's agenda in the class is audio signal processing. Nathan was given a lot of homework out. One of the homework was to write a program to process an audio signal. He copied the given audio signal to his USB memory and brought ...
{ "input": [], "output": [] }
{ "input": [ "5\n1 x 2 4 x\n2\nx x\n2\n1 2\n2\n2 1\n2\n1000000000 x\n4\nx 2 1 x\n0" ], "output": [ "3\nnone\nambiguous\nnone\nambiguous\nnone" ] }
{ "input": [ "5\n0 x 2 4 x\n2\nx x\n2\n1 2\n2\n2 1\n2\n1000000000 x\n4\nx 2 1 x\n0", "5\n1 x 2 0 x\n2\nx x\n2\n1 2\n2\n2 1\n2\n1000000000 x\n4\nx 2 1 x\n0", "5\n0 x 2 4 x\n2\nx x\n2\n1 2\n2\n0 1\n2\n1000000000 x\n4\nx 2 1 x\n0", "5\n0 x 3 4 x\n2\nx x\n2\n1 2\n2\n0 1\n2\n1000000000 x\n4\nx 2 1 x\n0", ...
p01821 Identity Function
Example Input 3 Output 1
{ "input": [], "output": [] }
{ "input": [ "3" ], "output": [ "1" ] }
{ "input": [ "4", "2", "15", "133", "33", "69", "635", "407", "329", "249", "321", "789", "447", "5663", "667", "141", "391", "177", "2283", "717", "591", "295", "1253", "913", "515", "1203", "815", "20093"...
p01956 Window
In the building of Jewelry Art Gallery (JAG), there is a long corridor in the east-west direction. There is a window on the north side of the corridor, and $N$ windowpanes are attached to this window. The width of each windowpane is $W$, and the height is $H$. The $i$-th windowpane from the west covers the horizontal r...
{ "input": [], "output": [] }
{ "input": [ "4 3 3\n1 1 2 3", "4 1 4\n3 3 2 2", "6 2 2\n0 2 2 2 2 0", "8 7 15\n5 0 9 14 0 4 4 15", "8 10 18\n2 12 16 14 18 4 17 16" ], "output": [ "9", "6", "8", "189", "370" ] }
{ "input": [ "4 1 4\n3 2 2 2", "6 2 2\n1 2 2 2 2 0", "8 7 15\n5 0 9 14 0 4 0 15", "8 10 18\n2 12 16 14 18 4 17 10", "2 1 4\n3 2 2 2", "8 7 15\n5 0 1 14 0 4 0 15", "8 10 18\n2 12 16 14 18 6 17 10", "8 7 15\n5 -1 1 14 0 4 0 15", "8 10 18\n2 12 5 14 18 6 17 10", "8 10 18\n2 12 5 1...
p02103 Great Devil Sakanikia
Problem The great devil Sacagna was still attacked by her natural enemy cat today. I bought a secret weapon because I couldn't do it all the time. This secret weapon can block the cat's path of movement by creating huge rocks that keep cats away from you. Now, Sacagna and one cat are in a rectangular closed section ...
{ "input": [], "output": [] }
{ "input": [ "5 5 3\n0 2\n2 2\n4 1", "3 5 2\n0 2\n2 2" ], "output": [ "2", "1" ] }
{ "input": [ "3 5 2\n1 2\n2 2", "3 5 2\n0 2\n0 2", "1 5 1\n0 2\n2 0", "3 5 2\n0 2\n2 0", "3 5 2\n2 2\n2 2", "5 5 3\n0 2\n2 2\n4 0", "3 5 0\n1 2\n2 2", "3 5 2\n0 3\n2 0", "3 5 1\n2 2\n2 2", "3 5 0\n1 2\n0 2", "3 5 0\n2 2\n2 2", "3 5 0\n1 2\n1 2", "2 5 0\n2 2\n2 2", ...
p02243 Single Source Shortest Path II
For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$. Constraints * $1 \leq n \leq 10,000$ * $0 \leq c_i \leq 100,000$ * $|E| < 500,000$ * All vertices are reachable from vertex $0...
{ "input": [], "output": [] }
{ "input": [ "5\n0 3 2 3 3 1 1 2\n1 2 0 2 3 4\n2 3 0 3 3 1 4 1\n3 4 2 1 0 1 1 4 4 3\n4 2 2 1 3 3" ], "output": [ "0 0\n1 2\n2 2\n3 1\n4 3" ] }
{ "input": [ "5\n0 3 2 3 3 1 1 1\n1 2 0 2 3 4\n2 3 0 3 3 1 4 1\n3 4 2 1 0 1 1 4 4 3\n4 2 2 1 3 3", "5\n0 3 2 3 3 1 1 2\n1 2 0 2 3 4\n2 3 0 3 3 1 4 1\n3 4 2 1 0 1 1 1 4 3\n4 2 2 1 3 3", "5\n0 3 2 3 3 2 1 1\n1 2 0 2 4 4\n2 3 0 3 0 2 4 1\n3 4 2 1 0 0 1 4 4 3\n4 2 2 1 3 3", "5\n0 3 2 3 3 1 1 1\n1 2 0 2 0 ...
p02389 Rectangle
Write a program which calculates the area and perimeter of a given rectangle. Constraints * 1 ≤ a, b ≤ 100 Input The length a and breadth b of the rectangle are given in a line separated by a single space. Output Print the area and perimeter of the rectangle in a line. The two integers should be separated by a si...
{ "input": [], "output": [] }
{ "input": [ "3 5" ], "output": [ "15 16" ] }
{ "input": [ "0 5", "1 5", "1 3", "0 3", "0 1", "0 2", "0 4", "1 4", "2 4", "2 7", "2 13", "2 23", "2 14", "4 14", "4 23", "3 23", "1 23", "1 21", "1 37", "2 37", "2 41", "0 41", "0 52", "0 57", "1 57", "1 11", ...
cb05
A regular octagon with vertices X1, X2,..., X8 is provided. A frog starts jumping from the vertex X1. It may jump to any of the two adjacent vertices in one jump except from X5. When it reaches X5, it stops and stays there. Let P(n) be the number of distinct paths of exactly n jumps ending at X5. Given the value of n, ...
{ "input": [], "output": [] }
{ "input": [ "3\n1\n2\n4" ], "output": [ "0\n0\n2" ] }
{ "input": [ "3\n1\n2\n5", "3\n2\n1\n4", "3\n4\n1\n4", "3\n4\n1\n7", "3\n2\n4\n3", "3\n1\n2\n6", "3\n8\n1\n7", "3\n2\n6\n3", "3\n4\n1\n8", "3\n8\n1\n4", "3\n6\n2\n4", "3\n2\n1\n8", "3\n6\n1\n6", "3\n3\n10\n4", "3\n2\n4\n6", "3\n4\n2\n6", "3\n6\n1\n5"...
crz02
In the University College of JNTUK Vizianagaram external lab examinations were being conducted. Management has decided to strictly prohibit the mal practices for that the management has decided to arrange cardboards of size nx2 to place in between two successive systems. The construction of cardboard can be done only b...
{ "input": [], "output": [] }
{ "input": [ "3\n1\n2\n3" ], "output": [ "1\n2\n3" ] }
{ "input": [], "output": [] }
harry
Problem description Nineteen years after the conclusion of events of Harry Potter and the Deathly Hallows, Harry Potter is now a Ministry of Magic employee. His youngest son Albus Severus Potter struggle with the weight of a family legacy he never wanted. As past and present fuse ominously, both father and son learn th...
{ "input": [], "output": [] }
{ "input": [ "3\nabccde\n2\nacd\nbc\nabccde\n2\nad\nbce\nmnopq\n3\namn\nopsp\nqrwas" ], "output": [ "NO\nNO\nYES" ] }
{ "input": [], "output": [] }
mgcrnk
Everybody loves magic, especially magicians who compete for glory on the Byteland Magic Tournament. Magician Cyael is one such magician. Cyael has been having some issues with her last performances and today she’ll have to perform for an audience of some judges, who will change her tournament ranking, possibly increasi...
{ "input": [], "output": [] }
{ "input": [ "2\n2\n0 -4\n8 0\n2\n0 -45\n-3 0" ], "output": [ "8.000000\nBad Judges\n" ] }
{ "input": [ "2\n2\n0 -4\n8 0\n2\n0 -45\n-2 0", "2\n2\n0 -4\n6 0\n2\n0 -45\n-2 1", "2\n2\n0 -8\n10 0\n2\n0 -17\n-3 -1", "2\n2\n0 -8\n7 0\n2\n0 -45\n-3 -1", "2\n2\n0 -8\n2 0\n2\n0 -19\n-2 0", "2\n2\n0 -4\n8 0\n2\n0 -87\n0 0", "2\n2\n0 -8\n2 0\n2\n0 -19\n0 0", "2\n2\n0 -4\n6 0\n1\...
recipe
The chef has a recipe he wishes to use for his guests, but the recipe will make far more food than he can serve to the guests. The chef therefore would like to make a reduced version of the recipe which has the same ratios of ingredients, but makes less food. The chef, however, does not like fractions. The original rec...
{ "input": [], "output": [] }
{ "input": [ "3\n2 4 4\n3 2 3 4\n4 3 15 9 6" ], "output": [ "1 1\n2 3 4\n1 5 3 2\n" ] }
{ "input": [ "3\n2 4 4\n3 2 3 4\n4 3 20 9 6", "3\n2 4 4\n3 2 1 4\n4 3 15 9 6", "3\n2 4 4\n3 2 3 4\n4 3 20 9 8", "3\n2 4 7\n3 2 1 4\n4 3 15 9 6", "3\n2 4 4\n3 2 3 6\n4 3 20 9 8", "3\n2 4 4\n3 2 3 8\n4 3 15 9 6", "3\n2 4 8\n3 2 3 4\n4 3 20 9 6", "3\n2 4 8\n3 2 1 4\n4 3 15 9 6", "3\n2...
tree
Let's define a good tree: It is a tree with k * n nodes labeled from 0 to k * n - 1 Node i and node j are not adjacent, for all 0 <= i, j < k * n such that i div k = j div k (here div means integer division. E.g. 7 div 2 = 3) Given n and k, how many different good trees are there? Input Two integers n(1 <= n <= 10...
{ "input": [], "output": [] }
{ "input": [ "1 2", "2 2", "4 1" ], "output": [ "0\n", "4\n", "16\n" ] }
{ "input": [ "1 3", "1 1", "2 3", "2 5", "3 3", "2 6", "6 3", "2 8", "6 4", "3 6", "6 8", "3 8", "4 8", "4 2", "4 3", "4 5", "4 7", "5 7", "3 7", "2 7", "2 4", "4 4", "4 10", "6 10", "6 13", "2 13", "3 13", ...
1251_E2. Voting (Hard Version)
The only difference between easy and hard versions is constraints. Now elections are held in Berland and you want to win them. More precisely, you want everyone to vote for you. There are n voters, and two ways to convince each of them to vote for you. The first way to convince the i-th voter is to pay him p_i coins....
{ "input": [], "output": [] }
{ "input": [ "3\n3\n1 5\n2 10\n2 8\n7\n0 1\n3 1\n1 1\n6 1\n1 1\n4 1\n4 1\n6\n2 6\n2 3\n2 8\n2 7\n4 4\n5 5\n" ], "output": [ "8\n0\n7\n" ] }
{ "input": [ "3\n3\n1 5\n2 10\n2 8\n7\n0 1\n3 1\n1 1\n6 0\n1 1\n4 1\n4 1\n6\n2 6\n2 3\n2 8\n2 7\n4 4\n5 5\n", "3\n3\n1 5\n1 10\n2 8\n7\n0 1\n3 1\n1 1\n6 0\n1 1\n4 1\n4 1\n6\n2 6\n2 3\n2 8\n2 7\n4 4\n5 5\n", "3\n3\n1 5\n2 10\n2 8\n7\n0 1\n3 1\n1 1\n6 0\n1 1\n4 1\n4 1\n6\n2 6\n2 3\n2 8\n2 7\n1 4\n5 5\n", ...
1443_B. Saving the City
Bertown is a city with n buildings in a straight line. The city's security service discovered that some buildings were mined. A map was compiled, which is a string of length n, where the i-th character is "1" if there is a mine under the building number i and "0" otherwise. Bertown's best sapper knows how to activate...
{ "input": [], "output": [] }
{ "input": [ "2\n1 1\n01000010\n5 1\n01101110\n" ], "output": [ "2\n6\n" ] }
{ "input": [ "2\n1 1\n01000110\n5 1\n01101110\n", "2\n2 1\n01000110\n5 1\n01101110\n", "2\n2 1\n01000110\n5 1\n01101101\n", "2\n2 1\n11000111\n5 1\n01101001\n", "2\n1 1\n01000010\n10 1\n01101110\n", "2\n1 1\n01000110\n5 2\n01101110\n", "2\n1 1\n11000111\n5 1\n01101001\n", "2\n0 1\n1100...
1468_K. The Robot
There is a robot on a checkered field that is endless in all directions. Initially, the robot is located in the cell with coordinates (0, 0). He will execute commands which are described by a string of capital Latin letters 'L', 'R', 'D', 'U'. When a command is executed, the robot simply moves in the corresponding dire...
{ "input": [], "output": [] }
{ "input": [ "4\nL\nRUUDL\nLLUU\nDDDUUUUU\n" ], "output": [ "\n-1 0\n1 2\n0 0\n0 1\n" ] }
{ "input": [ "4\nL\nLUUDR\nLLUU\nDDDUUUUU\n", "4\nL\nUURDL\nLLUU\nDDDUUUUU\n", "4\nL\nUURDL\nLLUU\nUUUUUDDD\n", "4\nL\nLUUDR\nLLUU\nUUUUUDDD\n", "4\nL\nRUUDL\nLLUU\nUUUUUDDD\n", "4\nL\nUULDR\nLLUU\nUDUUUDDU\n", "4\nL\nRDUUL\nUULL\nUUUUUDDD\n", "4\nL\nRUUDL\nLLUU\nUUUUDDDU\n", "4\nL...
little-vaishnavi-and-plywood-1
Little Vaishnavi is bored during the vacation which is going on. Being the only little girl in the neighbourhood she did not have any one else to play with. Her parents are so strict that they will not let her out of the house even to see what the kids from the other houses are playing. So she decided to make a game o...
{ "input": [], "output": [] }
{ "input": [ "2\n2 3\n1 0\n\nSAMPLE" ], "output": [ "15\n0\n" ] }
{ "input": [ "2\n3 3\n1 0\n\nSAMPLE", "2\n3 3\n1 1\n\nSAMPLE", "2\n3 0\n1 1\n\nSAMPLE", "2\n5 0\n1 1\n\nSAMPLE", "2\n5 0\n1 2\n\nSAMPLE", "2\n5 0\n2 1\n\nSMAPLE", "2\n5 -1\n2 1\n\nSMAPLE", "2\n5 -1\n1 1\n\nSMAPLE", "2\n2 -1\n1 1\n\nSMAPLE", "2\n2 -2\n1 1\n\nSMAPLE", "2\n2 0...
will-rick-survive-or-not-2
After Governor's attack on prison, Rick found himself surrounded by walkers. They are coming towards him from all sides. Now, suppose Rick have infinite number of bullets with him. Suppose Rick need 1 bullet to kill each walker (yeah he is good in killing walkers. They need to be shot at head. See, how good he is). Now...
{ "input": [], "output": [] }
{ "input": [ "2\n5\n2 4 2 5 6\n4\n2 2 2 2\n\nSAMPLE" ], "output": [ "Rick now go and save Carl and Judas\nGoodbye Rick\n2\n" ] }
{ "input": [ "2\n5\n2 4 2 5 6\n4\n4 2 2 2\n\nSAMPLE", "2\n5\n2 4 2 5 6\n4\n4 3 2 2\n\nSAMPLE", "2\n5\n0 4 2 5 6\n4\n4 3 2 2\n\nSAMPLE", "2\n5\n0 4 0 5 6\n4\n4 0 2 2\n\nSAMPLE", "2\n0\n0 7 1 1 37\n6\n-1 -2 0 -2\n\nSFLPLA", "2\n21\n1 7 1 1 17\n8\n-1 1 0 0\n\nSFLPLA", "2\n5\n2 2 2 5 6\n1\n3 2...
p02631 AtCoder Beginner Contest 171 - Red Scarf
There are N Snuke Cats numbered 1, 2, \ldots, N, where N is even. Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written. Recently, they learned the operation called xor (exclusive OR). What is xor? For n non-negative integers x_1, x_2, \ldots, x_n, their xor, x_1~\textrm{xor}~x_2~\...
{ "input": [], "output": [] }
{ "input": [ "4\n20 11 9 24" ], "output": [ "26 5 7 22" ] }
{ "input": [ "4\n5 11 9 24", "4\n5 11 10 24", "4\n0 11 10 24", "4\n1 11 10 24", "4\n1 11 10 29", "4\n1 11 0 29", "4\n1 11 0 49", "4\n1 2 0 49", "4\n2 2 0 49", "4\n2 0 0 49", "4\n2 0 1 49", "4\n0 0 1 49", "4\n1 0 1 49", "4\n1 0 2 49", "4\n1 0 3 49", "4\n1...
p02762 AtCoder Beginner Contest 157 - Friend Suggestions
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M friendships and K blockships. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User C_i...
{ "input": [], "output": [] }
{ "input": [ "4 4 1\n2 1\n1 3\n3 2\n3 4\n4 1", "5 10 0\n1 2\n1 3\n1 4\n1 5\n3 2\n2 4\n2 5\n4 3\n5 3\n4 5", "10 9 3\n10 1\n6 7\n8 2\n2 5\n8 4\n7 3\n10 9\n6 4\n5 8\n2 6\n7 5\n3 1" ], "output": [ "0 1 0 1", "0 0 0 0 0", "1 3 5 4 3 3 3 3 1 0" ] }
{ "input": [ "5 10 0\n1 2\n1 3\n1 4\n1 5\n3 2\n2 4\n2 5\n4 3\n1 3\n4 5", "5 10 0\n1 2\n1 3\n2 4\n1 5\n3 2\n2 4\n2 5\n4 3\n1 3\n4 5", "5 10 0\n1 2\n1 3\n2 4\n1 5\n3 2\n2 4\n2 5\n4 1\n1 3\n4 5", "5 10 0\n1 2\n1 3\n2 5\n1 5\n3 2\n2 4\n2 5\n4 1\n1 3\n4 5", "5 10 0\n1 2\n1 3\n2 5\n1 5\n3 2\n2 4\n2 3\n4...
p02897 AtCoder Beginner Contest 142 - Odds of Oddness
Given is an integer N. Takahashi chooses an integer a from the positive integers not greater than N with equal probability. Find the probability that a is odd. Constraints * 1 \leq N \leq 100 Input Input is given from Standard Input in the following format: N Output Print the probability that a is odd. Your ...
{ "input": [], "output": [] }
{ "input": [ "4", "1", "5" ], "output": [ "0.5000000000", "1.0000000000", "0.6000000000" ] }
{ "input": [ "8", "11", "19", "21", "3", "9", "39", "-1", "53", "33", "-3", "47", "69", "17", "-11", "25", "-13", "-25", "57", "-9", "37", "23", "-5", "-7", "45", "15", "87", "29", "13", "7", "1...
p03032 AtCoder Beginner Contest 128 - equeue
Your friend gave you a dequeue D as a birthday present. D is a horizontal cylinder that contains a row of N jewels. The values of the jewels are V_1, V_2, ..., V_N from left to right. There may be jewels with negative values. In the beginning, you have no jewel in your hands. You can perform at most K operations on...
{ "input": [], "output": [] }
{ "input": [ "6 4\n-10 8 2 1 2 6", "6 4\n-6 -100 50 -2 -5 -3", "6 3\n-6 -100 50 -2 -5 -3" ], "output": [ "14", "44", "0" ] }
{ "input": [ "6 4\n-10 8 2 0 2 6", "6 4\n-1 -100 50 -2 -5 -3", "6 3\n-6 -100 50 -2 -9 -3", "6 4\n-10 3 2 0 2 6", "6 4\n-1 -100 78 -2 -5 -3", "6 4\n-10 3 2 0 2 12", "6 4\n-10 3 3 0 2 12", "6 7\n-1 -100 78 0 -5 -3", "6 4\n-15 3 0 0 2 12", "6 7\n-1 -100 54 0 -1 -3", "6 9\n-1 -...
p03173 Educational DP Contest - Slimes
There are N slimes lining up in a row. Initially, the i-th slime from the left has a size of a_i. Taro is trying to combine all the slimes into a larger slime. He will perform the following operation repeatedly until there is only one slime: * Choose two adjacent slimes, and combine them into a new slime. The new sli...
{ "input": [], "output": [] }
{ "input": [ "6\n7 6 8 6 1 1", "5\n10 10 10 10 10", "3\n1000000000 1000000000 1000000000", "4\n10 20 30 40" ], "output": [ "68", "120", "5000000000", "190" ] }
{ "input": [ "6\n7 9 8 6 1 1", "5\n10 8 10 10 10", "3\n1001000000 1000000000 1000000000", "4\n10 20 30 46", "6\n7 9 13 6 1 1", "5\n19 8 10 10 10", "3\n1001000000 1000000001 1000000000", "4\n10 5 30 46", "6\n7 9 13 6 1 2", "5\n19 8 10 10 1", "3\n1001000000 1010000001 1000000...
p03321 AtCoder Regular Contest 099 - Independence
In the State of Takahashi in AtCoderian Federation, there are N cities, numbered 1, 2, ..., N. M bidirectional roads connect these cities. The i-th road connects City A_i and City B_i. Every road connects two distinct cities. Also, for any two cities, there is at most one road that directly connects them. One day, it ...
{ "input": [], "output": [] }
{ "input": [ "5 5\n1 2\n1 3\n3 4\n3 5\n4 5", "5 1\n1 2", "10 39\n7 2\n7 1\n5 6\n5 8\n9 10\n2 8\n8 7\n3 10\n10 1\n8 10\n2 3\n7 4\n3 9\n4 10\n3 4\n6 1\n6 7\n9 5\n9 7\n6 9\n9 4\n4 6\n7 5\n8 3\n2 5\n9 2\n10 7\n8 6\n8 9\n7 3\n5 3\n4 5\n6 3\n2 10\n5 10\n4 2\n6 2\n8 4\n10 6", "4 3\n1 2\n1 3\n2 3" ], "out...
{ "input": [ "5 0\n1 2", "1 0\n1 2", "5 5\n1 2\n2 3\n3 4\n3 5\n4 5", "4 3\n1 2\n1 4\n2 3", "3 1\n2 1", "8 3\n1 2\n1 3\n2 3", "5 0\n1 0", "8 5\n1 2\n1 3\n3 4\n3 5\n4 5", "9 1\n1 2", "5 0\n1 -1", "9 1\n1 4", "1 0\n1 4", "1 0\n0 4", "7 1\n1 2", "8 0\n1 2", ...