info
stringlengths
120
50k
question
stringlengths
504
10.4k
avg@8_qwen3_4b_instruct_2507
float64
0
0.88
{"tests": "{\"inputs\": [\"5\\n100 200 300 400 500\", \"3\\n1 2 3\", \"5\\n100 325 300 400 500\", \"3\\n1 4 3\", \"5\\n101 325 300 400 500\", \"3\\n2 4 3\", \"5\\n101 325 404 400 500\", \"3\\n3 4 3\", \"5\\n101 608 404 400 500\", \"3\\n4 4 3\", \"5\\n101 608 404 772 500\", \"3\\n4 4 1\", \"5\\n101 608 404 1494 500\", \...
Problem Define a function $ f $ that starts with $ 1 $ and takes a sequence of finite lengths as an argument as follows. $ \ displaystyle f (\\ {a_1, a_2, \ ldots, a_n \\}) = \ sum_ {i = 1} ^ n {a_i} ^ i $ Given a sequence of length $ N $, $ X = \\ {x_1, x_2, \ ldots, x_N \\} $, $ f (X) for all subsequences $ X'$ ex...
0
{"tests": "{\"inputs\": [\"10\\n0 blue 6\\n0 red 1\\n0 blue 4\\n0 white 5\\n1 red\\n1 blue\\n2 red\\n1 black\\n1 red\\n3 w z\", \"10\\n0 blue 6\\n0 red 1\\n0 blue 4\\n0 white 5\\n1 red\\n2 blue\\n2 red\\n1 black\\n1 red\\n3 w z\", \"10\\n0 blue 6\\n0 red 1\\n0 blue 4\\n0 white 10\\n1 red\\n1 blue\\n2 red\\n1 black\\n1 ...
For a dictionary $M$ that stores elements formed by a pair of a string key and an integer value, perform a sequence of the following operations. Note that multiple elements can have equivalent keys. * insert($key$, $x$): Insert an element formed by a pair of $key$ and $x$ to $M$. * get($key$): Print all values with th...
0
{"tests": "{\"inputs\": [\"3 2\\n1 0 1\\n\", \"4 4\\n2 8 4 1\\n\", \"3 2\\n3 2 1\\n\", \"5 1\\n1000000000 1000000000 1000000000 1000000000 1000000000\\n\", \"3 10\\n5 5 0\\n\", \"1 1\\n1\\n\", \"4 4\\n3 6 2 3\\n\", \"1 10\\n1\\n\", \"185 2\\n0 14 2 11 5 17 9 11 8 12 8 17 17 0 4 15 4 17 8 1 2 10 8 0 8 16 1 7 10 4 0 18 2...
Enough is enough. Too many times it happened that Vasya forgot to dispose of garbage and his apartment stank afterwards. Now he wants to create a garbage disposal plan and stick to it. For each of next n days Vasya knows a_i — number of units of garbage he will produce on the i-th day. Each unit of garbage must be dis...
0
{"tests": "{\"inputs\": [\"6 8 2\\n\", \"5 4 3\\n\", \"5000000000000 6000000000000 10000000000000\\n\", \"2778787205 1763925790 48326734\\n\", \"582426543750017 789023129080207 4395672028302\\n\", \"0 0 1\\n\", \"1000000000000000000 999999999999999999 3\\n\", \"7 14 5\\n\", \"1 0 1\\n\", \"132940 345844 5\\n\", \"20021...
Soon after the Chunga-Changa island was discovered, it started to acquire some forms of civilization and even market economy. A new currency arose, colloquially called "chizhik". One has to pay in chizhiks to buy a coconut now. Sasha and Masha are about to buy some coconuts which are sold at price z chizhiks per cocon...
0.375
{"tests": "{\"inputs\": [\"4\\n5\\n231\\n7\\n2323\\n6\\n333\\n24\\n133321333\\n\", \"9\\n1500\\n1212\\n1500\\n1221\\n1500\\n122\\n1500\\n12121\\n1500\\n22\\n1500\\n1111112111111112\\n1500\\n1111111111221111111\\n1500\\n111111122\\n1500\\n11111121111121111111\\n\", \"1\\n1000000\\n22\\n\", \"1\\n941759\\n1223231111\\n\"...
We start with a string s consisting only of the digits 1, 2, or 3. The length of s is denoted by |s|. For each i from 1 to |s|, the i-th character of s is denoted by s_i. There is one cursor. The cursor's location ℓ is denoted by an integer in \{0, …, |s|\}, with the following meaning: * If ℓ = 0, then the cursor...
0
{"tests": "{\"inputs\": [\"3 3\\n.#.\\n###\\n##.\\n\", \"4 5\\n....#\\n####.\\n.###.\\n.#...\\n\", \"4 2\\n##\\n.#\\n.#\\n##\\n\", \"3 5\\n.....\\n.....\\n.....\\n\", \"2 1\\n.\\n#\\n\", \"19 19\\n##############.....\\n.#############.....\\n.###########.......\\n.###########.......\\n.....#######.......\\n.....###........
A monopole magnet is a magnet that only has one pole, either north or south. They don't actually exist since real magnets have two poles, but this is a programming contest problem, so we don't care. There is an n× m grid. Initially, you may place some north magnets and some south magnets into the cells. You are allowe...
0
{"tests": "{\"inputs\": [\"1 4\\n19\\n\", \"3 6\\n5 3 1\\n\", \"10 23\\n343 984 238 758983 231 74 231 548 893 543\\n\", \"1 1\\n1\\n\", \"29 99047\\n206580 305496 61753 908376 272137 803885 675070 665109 995787 667887 164508 634877 994427 270698 931765 721679 518973 65009 804367 608526 535640 117656 342804 398273 36920...
There are some rabbits in Singapore Zoo. To feed them, Zookeeper bought n carrots with lengths a_1, a_2, a_3, …, a_n. However, rabbits are very fertile and multiply very quickly. Zookeeper now has k rabbits and does not have enough carrots to feed all of them. To solve this problem, Zookeeper decided to cut the carrots...
0
{"tests": "{\"inputs\": [\"3 5\\n1 4 4 3 4\\n1 4 1 4 2\\n1 4 4 4 3\\n\", \"1 1\\n1\\n\", \"1 1\\n2\\n\", \"3 1\\n1\\n1\\n1\\n\", \"3 1\\n1\\n1\\n2\\n\", \"3 5\\n1 4 4 3 4\\n1 4 2 4 2\\n1 4 4 4 3\\n\", \"3 5\\n1 4 4 3 4\\n1 4 2 4 2\\n1 3 4 4 3\\n\", \"3 5\\n1 4 4 3 4\\n1 4 2 4 2\\n1 3 4 4 4\\n\", \"3 5\\n1 4 4 3 4\\n1 1...
Monocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands. Monocarp's empire has n cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur, he builds exactly one Monum...
0
{"tests": "{\"inputs\": [\"1\\n1\\n\", \"3\\n1 4 2\\n\", \"6\\n258 877 696 425 663 934\\n\", \"37\\n280 281 169 68 249 389 977 101 360 43 448 447 368 496 125 507 747 392 338 270 916 150 929 428 118 266 589 470 774 852 263 644 187 817 808 58 637\\n\", \"100\\n469 399 735 925 62 153 707 723 819 529 200 624 57 708 245 384...
One day, as Sherlock Holmes was tracking down one very important criminal, he found a wonderful painting on the wall. This wall could be represented as a plane. The painting had several concentric circles that divided the wall into several parts. Some parts were painted red and all the other were painted blue. Besides,...
0.625
{"tests": "{\"inputs\": [\"1\\n1\\n5\\n1 2\\n1 10\\n1 10\\n1 10\\n1 10\\n\", \"3\\n1 2 3\\n2\\n1 1\\n3 1\\n\", \"5\\n1 2 3 6 6\\n4\\n1 1\\n3 1\\n1 1\\n4 3\\n\", \"2\\n1 6\\n5\\n2 6\\n1 2\\n1 1\\n1 2\\n1 7\\n\", \"3\\n2 10 15\\n1\\n1 830\\n\", \"3\\n1 6 8\\n5\\n3 4\\n3 9\\n3 3\\n1 2\\n1 6\\n\", \"7\\n8 13 19 21 25 30 32...
Dima's got a staircase that consists of n stairs. The first stair is at height a1, the second one is at a2, the last one is at an (1 ≤ a1 ≤ a2 ≤ ... ≤ an). Dima decided to play with the staircase, so he is throwing rectangular boxes at the staircase from above. The i-th box has width wi and height hi. Dima throws eac...
0.375
{"tests": "{\"inputs\": [\"5\\n1 2 3 4 5\\n5 4 3 2 0\\n\", \"6\\n1 2 3 10 20 30\\n6 5 4 3 2 0\\n\", \"6\\n2 2 3 10 20 30\\n6 5 4 3 2 0\\n\", \"5\\n1 4 3 4 5\\n5 4 3 2 0\\n\", \"6\\n1 2 3 10 20 25\\n6 5 4 3 2 0\\n\", \"6\\n1 1 2 10 20 25\\n6 5 4 3 2 0\\n\", \"5\\n1 2 3 4 5\\n9 4 3 2 0\\n\", \"5\\n1 2 3 4 5\\n6 4 3 2 0\\...
Kalila and Dimna are two jackals living in a huge jungle. One day they decided to join a logging factory in order to make money. The manager of logging factory wants them to go to the jungle and cut n trees with heights a1, a2, ..., an. They bought a chain saw from a shop. Each time they use the chain saw on the tree...
0
{"tests": "{\"inputs\": [\"3 4\\n2 5 6\\n1 3 6 8\\n\", \"3 3\\n1 2 3\\n1 2 3\\n\", \"1 2\\n165\\n142 200\\n\", \"10 11\\n1 909090909 1818181817 2727272725 3636363633 4545454541 5454545449 6363636357 7272727265 8181818173\\n454545455 1363636363 2272727271 3181818179 4090909087 4999999995 5909090903 6818181811 7727272719...
Mad scientist Mike does not use slow hard disks. His modification of a hard drive has not one, but n different heads that can read data in parallel. When viewed from the side, Mike's hard drive is an endless array of tracks. The tracks of the array are numbered from left to right with integers, starting with 1. In the...
0
{"tests": "{\"inputs\": [\"4 6 5 7\\n3 1 2 2 3 1\\n3 2 2 2 5 5\\n4 2 2 2 5 3\\n3 2 2 1 4 3\\n2 3 1 4 1 5 1\\n\", \"4 4 9 5\\n4 7 9 5\\n1 2 1 7\\n8 3 4 9\\n5 7 7 2\\n7 1 9 2 5\\n\", \"10 1 9 5\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n1\\n1 1 9 2 3\\n\", \"11 11 9 11\\n1 1 1 1 1 1 1 1 1 1 1\\n1 1 1 1 1 1 1 1 2 2 1\\n1 1 1 1...
Dima loves Inna very much. He decided to write a song for her. Dima has a magic guitar with n strings and m frets. Dima makes the guitar produce sounds like that: to play a note, he needs to hold one of the strings on one of the frets and then pull the string. When Dima pulls the i-th string holding it on the j-th fret...
0.875
{"tests": "{\"inputs\": [\"3 3 4 7\\n\", \"1 0 1 2\\n\", \"1 0 1 1\\n\", \"99085 7738 98097 -6487\\n\", \"1 2 2 1\\n\", \"93430 5720 93581 -2371\\n\", \"97530 -7728 92184 -755\\n\", \"93564 -4520 99118 -52061\\n\", \"100000 100 100000 70000\\n\", \"98405 -62879 99461 -33688\\n\", \"5 4 3 -2\\n\", \"93564 8371 99118 640...
Last year the world's largest square was built in Berland. It is known that the square can be represented as an infinite plane with an introduced Cartesian system of coordinates. On that square two sets of concentric circles were painted. Let's call the set of concentric circles with radii 1, 2, ..., K and the center i...
0
{"tests": "{\"inputs\": [\"7 8\\n40 20 10 30 20 50 40\\n1 2\\n2 3\\n3 4\\n4 5\\n5 6\\n6 7\\n1 4\\n5 7\\n\", \"3 3\\n10 20 30\\n1 2\\n2 3\\n3 1\\n\", \"4 3\\n10 20 30 40\\n1 3\\n2 3\\n4 3\\n\", \"10 19\\n13637 26970 19043 3616 12880 19387 12539 25190 2452 1261\\n1 2\\n1 3\\n1 4\\n2 5\\n3 6\\n6 7\\n3 8\\n5 9\\n3 10\\n4 1...
Of course our child likes walking in a zoo. The zoo has n areas, that are numbered from 1 to n. The i-th area contains ai animals in it. Also there are m roads in the zoo, and each road connects two distinct areas. Naturally the zoo is connected, so you can reach any area of the zoo from any other area using the roads....
0.25
{"tests": "{\"inputs\": [\"4 3\\n3 1 4 2\\n\", \"100 10000000\\n1 2 2 1 2 2 1 1 2 2 1 2 1 1 1 1 1 2 2 2 1 2 1 2 1 2 1 2 1 1 2 1 1 1 2 2 2 1 1 2 2 1 1 2 2 2 2 2 2 1 1 2 2 1 1 2 1 1 2 1 2 1 1 2 1 2 2 2 1 1 2 2 1 2 1 1 2 2 1 1 1 2 1 2 1 1 1 2 1 1 1 1 1 1 1 1 2 1 1 1\\n\", \"99 10000000\\n96 97 98 93 94 95 90 91 92 87 88 8...
You are given an array of positive integers a1, a2, ..., an × T of length n × T. We know that for any i > n it is true that ai = ai - n. Find the length of the longest non-decreasing sequence of the given array. Input The first line contains two space-separated integers: n, T (1 ≤ n ≤ 100, 1 ≤ T ≤ 107). The second li...
0
{"tests": "{\"inputs\": [\"2\\n1 2\\n\", \"4\\n1 1 2 2\\n\", \"4\\n1 2 3 12\\n\", \"21\\n999999 999998 999996 999992 999984 999968 999936 999872 999744 999488 998976 997952 995904 991808 983616 967232 934464 868928 737856 475712 1000000\\n\", \"1\\n412237\\n\", \"3\\n76427 184396 963319\\n\", \"5\\n741304 281944 258539...
Define the simple skewness of a collection of numbers to be the collection's mean minus its median. You are given a list of n (not necessarily distinct) integers. Find the non-empty subset (with repetition) with the maximum simple skewness. The mean of a collection is the average of its elements. The median of a colle...
0
{"tests": "{\"inputs\": [\"6\\n1 2\\n2 3\\n2 4\\n4 5\\n1 6\\n\", \"7\\n1 2\\n1 3\\n3 4\\n1 5\\n5 6\\n6 7\\n\", \"10\\n4 2\\n7 4\\n2 6\\n2 5\\n4 8\\n10 3\\n2 9\\n9 1\\n5 10\\n\", \"10\\n5 10\\n7 8\\n8 3\\n2 6\\n3 2\\n9 7\\n4 5\\n10 1\\n6 4\\n\", \"4\\n4 1\\n4 3\\n4 2\\n\", \"3\\n3 1\\n1 2\\n\", \"9\\n1 2\\n1 3\\n1 4\\n1...
Vanya wants to minimize a tree. He can perform the following operation multiple times: choose a vertex v, and two disjoint (except for v) paths of equal length a0 = v, a1, ..., ak, and b0 = v, b1, ..., bk. Additionally, vertices a1, ..., ak, b1, ..., bk must not have any neighbours in the tree other than adjacent verti...
0
{"tests": "{\"inputs\": [\"123 1 2143435 4\\n123 11 -5453 141245\\n\", \"3 2 30 4\\n6 14 25 48\\n\", \"123 1 2143435 4\\n54343 -13 6 124\\n\", \"-100 0 50 1\\n0\\n\", \"-1000 0 10 1\\n5\\n\", \"-3 1 100 1\\n3\\n\", \"1000000000 100000 1000000000 4\\n5433 13 6 0\\n\", \"5 1 5 5\\n1 2 3 4 0\\n\", \"2 -1 6 1\\n2\\n\", \"3...
Masha really loves algebra. On the last lesson, her strict teacher Dvastan gave she new exercise. You are given geometric progression b defined by two integers b1 and q. Remind that a geometric progression is a sequence of integers b1, b2, b3, ..., where for each i > 1 the respective term satisfies the condition bi = ...
0
{"tests": "{\"inputs\": [\"6\\n\", \"100\\n\", \"3\\n\", \"56\\n\", \"1\\n\", \"46\\n\", \"63478\\n\", \"7578\\n\", \"56056\\n\", \"78\\n\", \"66873\\n\", \"8149\\n\", \"35708\\n\", \"81207\\n\", \"41385\\n\", \"37317\\n\", \"74424\\n\", \"67817\\n\", \"684\\n\", \"15\\n\", \"96992\\n\", \"38798\\n\", \"19715\\n\", \"6...
Two best friends Serozha and Gena play a game. Initially there is one pile consisting of n stones on the table. During one move one pile should be taken and divided into an arbitrary number of piles consisting of a1 > a2 > ... > ak > 0 stones. The piles should meet the condition a1 - a2 = a2 - a3 = ... = ak - 1 - ak =...
0
{"tests": "{\"inputs\": [\"5 4\\nabcd\\ndcba\\nacbd\\ndbca\\nzzzz\\n\", \"3 4\\nabac\\ncaab\\nacba\\n\", \"3 4\\nkbbu\\nkbub\\nubkb\\n\", \"3 4\\nkbub\\nkbbu\\nubkb\\n\", \"5 5\\nzbibx\\nzbbix\\nzbibx\\nxbibz\\nxbibz\\n\", \"100 2\\nqz\\nqz\\nqz\\nqz\\nqz\\nqz\\nqz\\nqz\\nqz\\nqz\\nqz\\nqz\\nqz\\nqz\\nqz\\nqz\\nqz\\nqz...
We had a string s consisting of n lowercase Latin letters. We made k copies of this string, thus obtaining k identical strings s1, s2, ..., sk. After that, in each of these strings we swapped exactly two characters (the characters we swapped could be identical, but they had different indices in the string). You are gi...
0
{"tests": "{\"inputs\": [\"1\\n4\\n1 2 1 2\\n\\nSAMPLE\", \"1\\n4\\n1 2 1 2\\n\\nTAMPLE\", \"1\\n0\\n1 3 1 2\\n\\nTAMPLE\", \"1\\n0\\n1 3 0 3\\n\\nTAMPLE\", \"1\\n-3\\n-1 -1 -1 -1\\n\\nANMDPL\", \"1\\n0\\n1 2 1 2\\n\\nTAMPLE\", \"1\\n0\\n1 3 1 3\\n\\nTAMPLE\", \"1\\n0\\n1 3 -1 3\\n\\nTAMPLE\", \"1\\n0\\n1 6 -1 3\\n\\nT...
** Problem Statement is Updated ** Xenny had N colors with him, all arranged in a straight line. He was interested in picking up a particular subarray of colors. A pre-set is a set that contains all subarrays of colors that start from the first color and do not contain the last color. An end-set is a set that contai...
0
{"tests": "{\"inputs\": [\"1\\n5\\n1 10 20 40 60\\n\\nSAMPLE\", \"5\\n1\\n100\\n2\\n100 1\\n2\\n1 2\\n3\\n1 100 2\\n3\\n1 2 3\\n3\\n1 5 6\\n3\\n1 7 8\\n3\\n8 7 1\\n3\\n7 8 1\\n3\\n7 1 8\", \"5\\n1\\n100\\n2\\n100 1\\n2\\n1 2\\n3\\n1 100 2\\n3\\n1 2 3\\n3\\n1 5 6\\n3\\n1 7 8\\n3\\n8 7 1\\n3\\n7 8 2\\n3\\n7 1 8\", \"5\\n...
Given an array A. Delete an single element from the array such that sum of the differences of adjacent elements should be minimum. For more clarification Sum for an array A having N element is defined as : abs( A[0] - A[1] ) + abs( A[1] - A[2] ) + abs( A[2] - A[3] ) +............ + abs( A[N-2] - A[N-1] ) Inp...
0.5
{"tests": "{\"inputs\": [\"3 2\\n3 2\", \"856 16\\n399 263 665 432 206 61 784 548 422 313 848 478 827 26 398 63\", \"3 2\\n1 2\", \"856 16\\n399 491 665 432 206 61 784 548 422 313 848 478 827 26 398 63\", \"4 2\\n1 2\", \"856 16\\n399 491 665 432 206 0 784 548 422 313 848 478 827 26 398 63\", \"2 2\\n1 2\", \"856 16\\n...
There are N children, numbered 1,2,\ldots,N. In the next K days, we will give them some cookies. In the i-th day, we will choose a_i children among the N with equal probability, and give one cookie to each child chosen. (We make these K choices independently.) Let us define the happiness of the children as c_1 \times ...
0
{"tests": "{\"inputs\": [\"3\\n1\\n2\\n1\", \"8\\n4\\n4\\n4\\n1\\n1\\n1\\n2\\n2\", \"6\\n1\\n1\\n6\\n2\\n2\\n2\", \"5\\n3\\n1\\n4\\n1\\n5\", \"8\\n4\\n4\\n4\\n1\\n2\\n1\\n2\\n2\", \"5\\n3\\n1\\n4\\n2\\n5\", \"6\\n4\\n1\\n1\\n2\\n2\\n4\", \"6\\n1\\n1\\n1\\n2\\n2\\n2\", \"6\\n1\\n1\\n1\\n2\\n2\\n1\", \"6\\n1\\n1\\n1\\n1\...
You are given a sequence of N integers: A_1,A_2,...,A_N. Find the number of permutations p_1,p_2,...,p_N of 1,2,...,N that can be changed to A_1,A_2,...,A_N by performing the following operation some number of times (possibly zero), modulo 998244353: * For each 1\leq i\leq N, let q_i=min(p_{i-1},p_{i}), where p_0=p_N...
0.125
{"tests": "{\"inputs\": [\"15 10000000000\\n400000000 1000000000\\n800000000 1000000000\\n1900000000 1000000000\\n2400000000 1000000000\\n2900000000 1000000000\\n3300000000 1000000000\\n3700000000 1000000000\\n3800000000 1000000000\\n4000000000 1000000000\\n4100000000 1000000000\\n5200000000 1000000000\\n6600000000 100...
"Teishi-zushi", a Japanese restaurant, is a plain restaurant with only one round counter. The outer circumference of the counter is C meters. Customers cannot go inside the counter. Nakahashi entered Teishi-zushi, and he was guided to the counter. Now, there are N pieces of sushi (vinegared rice with seafood and so on...
0
{"tests": "{\"inputs\": [\"9\\n1 3 6 13 15 18 19 29 31\\n10\\n4\\n1 8\\n7 3\\n6 7\\n8 5\", \"9\\n1 3 6 13 15 18 19 29 31\\n10\\n2\\n1 8\\n7 3\\n6 7\\n8 5\", \"9\\n1 6 6 13 23 18 19 29 31\\n10\\n3\\n1 8\\n7 3\\n6 7\\n8 10\", \"9\\n1 3 6 13 23 18 19 29 31\\n10\\n2\\n1 8\\n7 5\\n6 7\\n8 5\", \"9\\n1 3 6 13 23 18 19 29 31\...
N hotels are located on a straight line. The coordinate of the i-th hotel (1 \leq i \leq N) is x_i. Tak the traveler has the following two personal principles: * He never travels a distance of more than L in a single day. * He never sleeps in the open. That is, he must stay at a hotel at the end of a day. You are ...
0.625
{"tests": "{\"inputs\": [\"3 3\\n100 10 10\\n-100 -20 -100\\n-100 -20 -100\\n-100 -20 -100\\n3 3\\n100 10 10\\n-100 -20 -100\\n-100 -20 -20\\n-100 -60 -20\\n3 3\\n100 10 3\\n-100 -20 -100\\n-20 -20 -20\\n-20 -100 -20\\n3 3\\n100 3 3\\n-100 -20 -30\\n-100 -20 2\\n-100 -20 -20\\n4 5\\n1500 5 4\\n-10 -380 -250 -250\\n-90 ...
Aizu has an ancient legend of buried treasure. You have finally found the place where the buried treasure is buried. Since we know the depth of the buried treasure and the condition of the strata to be dug, we can reach the buried treasure at the lowest cost with careful planning. So you decided to create a program tha...
0
{"tests": "{\"inputs\": [\"4\\n24 99\\n15 68\\n12 90\\n95 79\", \"3\\n2 46\\n94 8\\n46 57\", \"4\\n24 99\\n15 68\\n12 90\\n95 66\", \"3\\n0 46\\n94 8\\n46 57\", \"4\\n24 99\\n15 44\\n12 90\\n95 66\", \"3\\n0 46\\n9 8\\n46 57\", \"4\\n18 99\\n15 44\\n12 90\\n95 66\", \"3\\n1 46\\n9 8\\n46 57\", \"4\\n18 99\\n15 44\\n3 9...
Playing with Stones Koshiro and Ukiko are playing a game with black and white stones. The rules of the game are as follows: 1. Before starting the game, they define some small areas and place "one or more black stones and one or more white stones" in each of the areas. 2. Koshiro and Ukiko alternately select an area ...
0
{"tests": "{\"inputs\": [\"4 5\\n..33\\n..33\\n2222\\n..1.\\n.111\\n5 7\\n....1\\n.1..1\\n.1..1\\n11..1\\n.2222\\n..111\\n...1.\\n3 6\\n.3.\\n233\\n23.\\n22.\\n.11\\n.11\\n4 3\\n2222\\n..11\\n..11\\n4 5\\n.3..\\n33..\\n322.\\n2211\\n.11.\\n3 3\\n222\\n2.1\\n111\\n3 4\\n11.\\n11.\\n.2.\\n222\\n3 4\\n.11\\n.11\\n.2.\\n22...
You are working for an administration office of the International Center for Picassonian Cubism (ICPC), which plans to build a new art gallery for young artists. The center is organizing an architectural design competition to find the best design for the new building. Submitted designs will look like a screenshot of a...
0
{"tests": "{\"inputs\": [\"10 2\\n2 3 1\\n3 5 1\", \"1 0\", \"10 3\\n2 2 1\\n4 2 1\\n8 1 1\", \"10 2\\n2 3 1\\n1 5 1\", \"10 2\\n2 3 1\\n1 5 0\", \"10 0\\n2 3 1\\n1 5 1\", \"18 0\\n2 3 1\\n1 5 1\", \"0 0\\n2 -1 1\\n0 1 1\", \"1 0\\n2 0 2\\n1 2 1\", \"2 1\\n1 0 7\\n4 -1 0\", \"10 3\\n2 0 1\\n4 2 1\\n8 1 1\", \"34 0\\n2 ...
Problem Aizu Magic School is a school where people who can use magic gather. Haruka, one of the students of that school, can use the magic of warp on the magic team. From her house to the school, there is a straight road of length L. There are also magic circles on this road. She uses this road every day to go to sch...
0.875
{"tests": "{\"inputs\": [\"2 2\\nQE\\nEA\\n3 1\\nQAE\\n3 1\\nAQE\\n5 5\\n..E..\\n.###.\\nA###Q\\n.###.\\n..E..\\n5 1\\nA.E.Q\\n5 5\\nA....\\n.\\n..E..\\n.####\\n....Q\\n0 0\", \"2 2\\nQE\\nEA\\n3 1\\nQAE\\n3 1\\nAQE\\n5 5\\n..E..\\n.###.\\nA###Q\\n.###.\\n..E..\\n5 1\\nA.E.Q\\n5 5\\nA....\\n####.\\n..E..\\n.####\\n.......
A small country called Maltius was governed by a queen. The queen was known as an oppressive ruler. People in the country suffered from heavy taxes and forced labor. So some young people decided to form a revolutionary army and fight against the queen. Now, they besieged the palace and have just rushed into the entranc...
0
{"tests": "{\"inputs\": [\"3 3 1\\nS#.\\n...\\n.#G\", \"3 3 1\\nS#G\\n...\\n.#.\", \"3 3 2\\nS#.\\n...\\n.#G\", \"4 3 2\\nS..\\n...\\n..#\\n.#G\", \"1 3 1\\nS#G\\n...\\n.#.\", \"3 3 2\\nS#.\\n...\\n/#G\", \"4 3 2\\nS..\\n...\\n..#\\nG#.\", \"3 3 2\\nS#.\\n...\\n.$G\", \"1 3 2\\nS#G\\n...\\n.#.\", \"5 3 2\\nS#.\\n...\\n...
There is an evil creature in a square on N-by-M grid (2 \leq N, M \leq 100), and you want to kill it using a laser generator located in a different square. Since the location and direction of the laser generator are fixed, you may need to use several mirrors to reflect laser beams. There are some obstacles on the grid ...
0
{"tests": "{\"inputs\": [\"2 0\", \"2 1\", \"2 2\", \"2 4\", \"0 4\", \"-1 4\", \"-1 0\", \"1 -1\", \"-1 2\", \"-1 -4\", \"-2 -7\", \"-1 -7\", \"-1 -5\", \"1 -6\", \"2 -6\", \"2 -8\", \"5 -10\", \"5 -8\", \"9 -8\", \"9 -14\", \"9 -25\", \"9 -20\", \"18 -20\", \"18 -36\", \"18 -33\", \"18 -27\", \"33 -27\", \"33 -33\", ...
problem AOR Ika and you came to the tournament-style table tennis tournament singles section for reconnaissance. For AOR Ika-chan, who wants to record all the games, you decide to ask for the number of games that will be played in this tournament. There are $ N $ players in the tournament, each with a uniform number ...
0.25
{"tests": "{\"inputs\": [\"20\\n\", \"5184\\n\", \"2\\n\", \"328509\\n\", \"279936\\n\", \"341\\n\", \"605000\\n\", \"11\\n\", \"4\\n\", \"786432\\n\", \"982081\\n\", \"52488\\n\", \"6444\\n\", \"12\\n\", \"1105\\n\", \"49\\n\", \"252601\\n\", \"1000000\\n\", \"162000\\n\", \"29341\\n\", \"1729\\n\", \"30492\\n\", \"99...
JATC's math teacher always gives the class some interesting math problems so that they don't get bored. Today the problem is as follows. Given an integer n, you can perform the following operations zero or more times: * mul x: multiplies n by x (where x is an arbitrary positive integer). * sqrt: replaces n with √...
0
{"tests": "{\"inputs\": [\"4 2\\n4478\\n\", \"7 4\\n4727447\\n\", \"7 74\\n4777774\\n\", \"3 99\\n447\\n\", \"47 7\\n77774477747474477477477774747747447447774777474\\n\", \"74 1000000000\\n77474447774774747474777447474777777477474444477747444777447444474744744444\\n\", \"10 200\\n6860544593\\n\", \"100 1000000000\\n584...
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya has a number consisting of n digits without leading zeroes. He represented it as an array of d...
0.375
{"tests": "{\"inputs\": [\"3\\n5\\n1 3\\n1 2\\n3 3\\n5 5\\n4 3\\n2\\n1 0\\n0 1\\n1\\n4 3\\n\", \"2\\n1\\n1 1\\n1\\n1 1\\n\", \"2\\n1\\n1 2\\n1\\n1 1\\n\", \"2\\n1\\n1 2\\n1\\n2 1\\n\", \"2\\n1\\n1 2\\n1\\n1 2\\n\", \"2\\n1\\n1 3\\n1\\n2 1\\n\", \"2\\n1\\n1 0\\n1\\n1 2\\n\", \"2\\n1\\n1 3\\n1\\n1 1\\n\", \"2\\n1\\n1 0\\...
There is a robot in a warehouse and n packages he wants to collect. The warehouse can be represented as a coordinate grid. Initially, the robot stays at the point (0, 0). The i-th package is at the point (x_i, y_i). It is guaranteed that there are no two packages at the same point. It is also guaranteed that the point ...
0.875
{"tests": "{\"inputs\": [\"6 7\\n11 45 14 9 19 81\\n\", \"4 4\\n3 5 8 14\\n\", \"30 30\\n65536 536870912 2097152 512 32768 16384 8388608 16777216 524288 4194304 1 1048576 2048 262144 64 4096 8192 256 131072 2 268435456 33554432 32 16 134217728 8 67108864 128 4 1024\\n\", \"6 35\\n23601314651 29074846252 10638992479 327...
This is the easy version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved. Chiori loves dolls and now she is going to decorate her bedroom! <image> As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati...
0
{"tests": "{\"inputs\": [\"4 2\\n1 2\\n2 2\\n\", \"3 2\\n1 1\\n2 2\\n\", \"6 2\\n2 3\\n4 1\\n\", \"25 2\\n1 23\\n3 1\\n\", \"178279081 0\\n\", \"999999999 1\\n100 1000000000\\n\", \"1 1\\n1 1\\n\", \"1001 1\\n60 10001\\n\", \"10 4\\n4 1\\n6 5\\n7 1\\n8 3\\n\", \"999999999 1\\n999999999 999999999\\n\", \"1000 1\\n1 1000...
A famous gang of pirates, Sea Dogs, has come back to their hideout from one of their extravagant plunders. They want to split their treasure fairly amongst themselves, that is why You, their trusted financial advisor, devised a game to help them: All of them take a sit at their round table, some of them with the golde...
0
{"tests": "{\"inputs\": [\"6 10\\n10 40\\n20 10\\n25 30\\n30 15\\n50 15\\n65 30\\n\", \"2 10000\\n0 10000\\n400000 0\\n\", \"9 5\\n0 0\\n5 10\\n15 10\\n20 0\\n25 11\\n30 0\\n35 10\\n50 10\\n60 5\\n\", \"4 6\\n0 0\\n2 4\\n7 5\\n10 0\\n\", \"5 2\\n1 3\\n4 4\\n5 7\\n7 5\\n10 4\\n\", \"5 2\\n1 3\\n4 4\\n5 1\\n7 5\\n10 4\\n...
The hobbits Frodo and Sam are carrying the One Ring to Mordor. In order not to be spotted by orcs, they decided to go through the mountains. The mountain relief can be represented as a polyline with n points (x_i, y_i), numbered from 1 to n (x_i < x_{i + 1} for 1 ≤ i ≤ n - 1). Hobbits start their journey at the point ...
0
{"tests": "{\"inputs\": [\"4 5\\n1 2 1\\n2 3 1\\n3 1 2\\n1 4 1\\n4 3 2\\n2\\n1 2 4\\n4 3 5\\n\", \"4 4\\n1 2 1\\n2 3 1\\n3 1 2\\n1 4 3\\n3\\n1 1 3\\n1 2 4\\n4 0 1\\n\", \"2 1\\n2 1 1\\n1\\n2 1 2\\n\", \"4 5\\n1 2 1\\n2 3 1\\n3 1 2\\n1 4 1\\n4 3 2\\n2\\n1 2 4\\n3 3 5\\n\", \"3 1\\n2 1 1\\n1\\n2 1 2\\n\", \"3 1\\n2 1 1\\...
In Fire City, there are n intersections and m one-way roads. The i-th road goes from intersection a_i to b_i and has length l_i miles. There are q cars that may only drive along those roads. The i-th car starts at intersection v_i and has an odometer that begins at s_i, increments for each mile driven, and resets to ...
0
{"tests": "{\"inputs\": [\"7 4\\n1&gt;3&gt;22&lt;\\n1 3\\n4 7\\n7 7\\n1 7\\n\", \"5 1\\n1>3><\\n4 5\\n\", \"4 1\\n34><\\n1 4\\n\", \"3 10\\n<<<\\n2 3\\n3 3\\n2 3\\n3 3\\n1 3\\n1 1\\n1 2\\n3 3\\n1 1\\n2 2\\n\", \"7 4\\n1>3>22<\\n1 3\\n4 7\\n7 7\\n1 7\\n\", \"1 1\\n0\\n1 1\\n\", \"10 30\\n306<<>4>04\\n2 2\\n6 6\\n1 10\\n...
There is a programming language in which every program is a non-empty sequence of "<" and ">" signs and digits. Let's explain how the interpreter of this programming language works. A program is interpreted using movement of instruction pointer (IP) which consists of two parts. * Current character pointer (CP); *...
0
{"tests": "{\"inputs\": [\"4 3\\n\", \"8 4\\n\", \"5 5\\n\", \"1000000000000000000 1000000000\\n\", \"525 34\\n\", \"1000000000 999999999\\n\", \"1 1000000000\\n\", \"223265034477 726990\\n\", \"499999998500000000 1000000000\\n\", \"499999999500000000 1000000000\\n\", \"499999998500000001 1000000000\\n\", \"462498979 2...
Vova, the Ultimate Thule new shaman, wants to build a pipeline. As there are exactly n houses in Ultimate Thule, Vova wants the city to have exactly n pipes, each such pipe should be connected to the water supply. A pipe can be connected to the water supply if there's water flowing out of it. Initially Vova has only on...
0.375
{"tests": "{\"inputs\": [\"1 2 1 2\\n\", \"719 735 626 990\\n\", \"1 3 1 3\\n\", \"64 704 148 603\\n\", \"486 868 929 999\\n\", \"533 773 823 998\\n\", \"897 957 92 898\\n\", \"933 977 266 450\\n\", \"518 816 243 359\\n\", \"3 4 3 4\\n\", \"699 925 441 928\\n\", \"450 885 755 836\\n\", \"882 962 311 811\\n\", \"1 3 2 3...
SmallR is an archer. SmallR is taking a match of archer with Zanoes. They try to shoot in the target in turns, and SmallR shoots first. The probability of shooting the target each time is <image> for SmallR while <image> for Zanoes. The one who shoots in the target first should be the winner. Output the probability th...
0.625
{"tests": "{\"inputs\": [\"2\\nAG\\n\", \"3\\nTTT\\n\", \"1\\nC\\n\", \"20\\nTAAGCGACCAGGTGCTTTAC\\n\", \"15\\nAGCGAATCCCATTGT\\n\", \"4\\nGACT\\n\", \"1\\nT\\n\", \"3\\nGCA\\n\", \"318\\nTATCAATCGGTACGTGCGCATCATTGTCAATCGGGCTTCATGGCTTGCGGGCGCTACCCGAGGGGAAGCTGCGGACAGGTAGGTAAGATACACACGAACCAAACGGAGTTATGTTGGATAAATTGGCTGGAA...
Vasya became interested in bioinformatics. He's going to write an article about similar cyclic DNA sequences, so he invented a new method for determining the similarity of cyclic sequences. Let's assume that strings s and t have the same length n, then the function h(s, t) is defined as the number of positions in whic...
0.5
{"tests": "{\"inputs\": [\"5\\n2 0\\n0 0\\n1 0\\n1 1\\n0 1\\n0 -1 -2 1 0\\n\", \"3\\n1 0\\n0 0\\n2 0\\n0 1 2\\n\", \"1\\n0 0\\n-9876\\n\", \"9\\n0 0\\n1 0\\n2 0\\n0 1\\n1 1\\n2 1\\n1 2\\n2 2\\n0 2\\n0 0 0 -1 -1 -2 1 1 2\\n\", \"40\\n0 0\\n0 1\\n0 2\\n0 3\\n0 4\\n0 5\\n0 6\\n0 7\\n0 8\\n0 9\\n0 10\\n0 11\\n0 12\\n1 0\\n...
Wilbur is playing with a set of n points on the coordinate plane. All points have non-negative integer coordinates. Moreover, if some point (x, y) belongs to the set, then all points (x', y'), such that 0 ≤ x' ≤ x and 0 ≤ y' ≤ y also belong to this set. Now Wilbur wants to number the points in the set he has, that is ...
0.375
{"tests": "{\"inputs\": [\"3\\nbcd\\nab\\ncdef\\n\", \"4\\nx\\ny\\nz\\nw\\n\", \"4\\nrz\\nvu\\nxy\\npg\\n\", \"70\\nxv\\nlu\\ntb\\njx\\nseh\\nc\\nm\\ntbr\\ntb\\ndl\\ne\\nd\\nt\\np\\nn\\nse\\nna\\neh\\nw\\np\\nzkj\\nr\\nk\\nrw\\nqf\\ndl\\ndl\\ns\\nat\\nkjx\\na\\nz\\nmig\\nu\\nse\\npse\\nd\\ng\\nc\\nxv\\nv\\ngo\\nps\\ncd...
Berland scientists face a very important task - given the parts of short DNA fragments, restore the dinosaur DNA! The genome of a berland dinosaur has noting in common with the genome that we've used to: it can have 26 distinct nucleotide types, a nucleotide of each type can occur at most once. If we assign distinct En...
0
{"tests": "{\"inputs\": [\"ABABBBACFEYUKOTT\\n\", \"AAA\\n\", \"HDDRZDKCHHHEDKHZMXQSNQGSGNNSCCPVJFGXGNCEKJMRKSGKAPQWPCWXXWHLSMRGSJWEHWQCSJJSGLQJXGVTBYALWMLKTTJMFPFS\\n\", \"AABBYYYYYYYY\\n\", \"XXFPZDRPXLNHGDVCBDKJMKLGUQZXLLWYLOKFZVGXVNPJWZZZNRMQBRJCZTSDRHSNCVDMHKVXCXPCRBWSJCJWDRDPVZZLCZRTDRYA\\n\", \"SGDDFCDRDWGPNNFBB...
One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump ability he should have in order to be able to reach the far end of the string, jumping only on vowels of the English alphabet. Jump ability is the maximum possible length of ...
0
{"tests": "{\"inputs\": [\"4 3\\nULR\\nDLR\\nLRU\\nLRD\\nULR\\nDUU\\nUDD\\nDLR\", \"2 3\\nULR\\nDLR\\nLRU\\nLRD\\n\", \"34 5\\nLRUUU\\nUUDDD\\nDDULR\\nLRDUU\\nULRDD\\nDULRU\\nUDLRD\\nDULRU\\nUDLRD\\nDLRUU\\nULRDD\\nDLRLR\\nLRUUU\\nLRDDD\\nUUULR\\nDDDLR\\nLRULR\\nLRDLR\\nLRLRU\\nULRUD\\nDLRDU\\nLRLRD\\nULRUU\\nDUUDD\\nU...
Peter decided to lay a parquet in the room of size n × m, the parquet consists of tiles of size 1 × 2. When the workers laid the parquet, it became clear that the tiles pattern looks not like Peter likes, and workers will have to re-lay it. The workers decided that removing entire parquet and then laying it again is v...
0
{"tests": "{\"inputs\": [\"4 20\\n10 3 6 3\\n\", \"3 3\\n2 1 9\\n\", \"1 2\\n9\\n\", \"7 6\\n4 20 16 14 3 17 4\\n\", \"1 1\\n1000000000\\n\", \"4 2\\n45 44 35 38\\n\", \"2 1\\n4 1000000000\\n\", \"2 1\\n1 4\\n\", \"100 10\\n246 286 693 607 87 612 909 312 621 37 801 558 504 914 416 762 187 974 976 123 635 488 416 659 98...
Makes solves problems on Decoforces and lots of other different online judges. Each problem is denoted by its difficulty — a positive integer number. Difficulties are measured the same across all the judges (the problem with difficulty d on Decoforces is as hard as the problem with difficulty d on any other judge). M...
0
{"tests": "{\"inputs\": [\"2 3\\n1 2 4 5\\n1 2 1 3 2 3\\n\", \"2 2\\n1 2 3 4\\n1 5 3 4\\n\", \"2 2\\n1 2 3 4\\n1 5 6 4\\n\", \"2 3\\n1 2 1 3\\n1 2 1 3 2 3\\n\", \"3 7\\n8 2 7 9 8 1\\n3 1 8 1 2 7 4 7 4 2 1 4 4 6\\n\", \"1 10\\n3 9\\n3 2 3 4 5 3 5 7 8 6 2 5 7 8 2 4 1 7 5 1\\n\", \"12 1\\n6 2 6 4 8 6 6 9 5 6 6 1 9 1 1 3 3...
Two participants are each given a pair of distinct numbers from 1 to 9 such that there's exactly one number that is present in both pairs. They want to figure out the number that matches by using a communication channel you have access to without revealing it to you. Both participants communicated to each other a set ...
0
{"tests": "{\"inputs\": [\"2\\n31\\n4 1\\n160\\n9 2\\n\\nSAMPLE\", \"2\\n31\\n4 1\\n98\\n9 2\\n\\nSAMPLE\", \"2\\n31\\n7 1\\n98\\n17 2\\n\\nSAMOLE\", \"2\\n6\\n7 1\\n98\\n17 2\\n\\nSAMOLE\", \"2\\n6\\n4 2\\n98\\n24 3\\n\\nSAMOLE\", \"2\\n6\\n4 2\\n152\\n24 3\\n\\nSAMOLE\", \"2\\n12\\n4 1\\n152\\n24 3\\n\\nSAMOLE\", \"2...
Gudi enters the castle, and moves along the main path. Suddenly, a block in the ground opens and she falls into it! Gudi slides down and lands in a dark room. A mysterious voice announces: Intruders are not allowed inside the castle. To proceed, you must solve my puzzle. Here is a string S indexed from 1 to N, cons...
0
{"tests": "{\"inputs\": [\"3\\n1 3\\n1 4\\n8 10\\n\\nSAMPLE\", \"3\\n1 3\\n1 4\\n8 10\", \"10\\n10 15\\n1 100\\n2 100\\n100 100\\n15 15\\n99 99\\n50 51\\n2 3\\n3 4\\n4 5\", \"3\\n1 3\\n1 3\\n8 10\", \"10\\n10 15\\n1 110\\n2 100\\n100 100\\n15 15\\n99 99\\n50 51\\n2 3\\n3 4\\n4 5\", \"3\\n1 3\\n2 4\\n8 10\\n\\nSAMPLE\",...
Little Shino loves to play with numbers. She just came to know about Fibonacci Series. Fibonacci Series is a series of number such that Fib(1) = 0 Fib(2) = 1 Fib(x) = Fib(x-1) + Fib(x-2)\;where\;2 < x Soon Little Shino realized that Fibonacci series grows very fast. So she just wants the sum of last 4 digits of the F...
0.125
{"tests": "{\"inputs\": [\"3 4\\n0\\n1\\n3\", \"10 100\\n2\\n11\\n35\\n42\\n54\\n69\\n89\\n91\\n93\\n99\", \"4 8\\n1\\n3\\n5\\n6\", \"10 100\\n2\\n10\\n35\\n42\\n54\\n69\\n89\\n91\\n93\\n99\", \"4 8\\n1\\n5\\n5\\n6\", \"10 100\\n2\\n10\\n35\\n42\\n54\\n69\\n87\\n91\\n93\\n99\", \"4 8\\n1\\n2\\n5\\n6\", \"4 8\\n1\\n2\\n...
Given are N points on the circumference of a circle centered at (0,0) in an xy-plane. The coordinates of the i-th point are (\cos(\frac{2\pi T_i}{L}),\sin(\frac{2\pi T_i}{L})). Three distinct points will be chosen uniformly at random from these N points. Find the expected x- and y-coordinates of the center of the circ...
0
{"tests": "{\"inputs\": [\"2\\n..\\n..\", \"2\\n#.\\n.#\", \"2\", \"3\\n.#.\\n\\n.#.\", \"3\\n...\\n.#.\\n...\", \"2\\n.\\n.#\", \"2\\n/.\\n..\", \"2\\n#.\\n#.\", \"3\\n.#.\\n\\n.$.\", \"3\\n...\\n.#.\\n/..\", \"2\\n.\\n#.\", \"2\\n#.\\n-#\", \"0\", \"2\\n./\\n..\", \"2\\n#.\\n#-\", \"3\\n.\\\".\\n\\n.$.\", \"3\\n...\\...
There is a square-shaped grid with N vertical rows and N horizontal columns. We will denote the square at the i-th row from the top and the j-th column from the left as (i,\ j). Initially, each square is either white or black. The initial color of the grid is given to you as characters a_{ij}, arranged in a square sha...
0
{"tests": "{\"inputs\": [\"3 11\\n0 2 5\\n0 1 5\\n0 3 4\\n1 1\\n1 2\\n1 3\\n0 3 2\\n1 1\\n0 2 1\\n1 2\\n1 3\", \"5 2\\n1 1\\n1 2\", \"3 11\\n0 2 5\\n0 1 5\\n0 3 6\\n1 1\\n1 2\\n1 3\\n0 3 2\\n1 1\\n0 2 1\\n1 2\\n1 3\", \"3 11\\n0 2 5\\n0 1 5\\n0 3 8\\n1 1\\n1 2\\n1 3\\n0 3 2\\n1 1\\n0 2 1\\n1 2\\n1 3\", \"3 10\\n0 2 5\\...
White Tiger University holds a programming contest every year. The contest starts with a score of 0 for all teams, and points are added according to the answer status. In this contest, rankings will be made in descending order of score. When the total number of teams is N, each team is assigned a number from 1 to N. If...
0.75
{"tests": "{\"inputs\": [\"2 1 1\\n1\\n50\\n2 1 2\\n1\\n50\\n1\\n60\\n2 1 2\\n2\\n60 61\\n1\\n70\\n4 2 3\\n3\\n60 61 62\\n1\\n70\\n2\\n80 81\\n3 1 2\\n3\\n60 61 62\\n2\\n70 60\\n1 2 5\\n2\\n87 95\\n3\\n96 71 35\\n2\\n68 2\\n3\\n3 18 93\\n2\\n57 2\\n2 2 1\\n5\\n1 2 1 3 1\\n0 0 0\", \"2 1 1\\n1\\n50\\n2 2 2\\n1\\n50\\n1\...
The deadline of Prof. Hachioji’s assignment is tomorrow. To complete the task, students have to copy pages of many reference books in the library. All the reference books are in a storeroom and only the librarian is allowed to enter it. To obtain a copy of a reference book’s page, a student should ask the librarian to...
0
{"tests": "{\"inputs\": [\"4 4\\nA B G\\nA B 40 3\\nB C 80 0\\nA G 40 0\\nB G 80 0\\n5 6\\nKusatsu Tokyo Aizu\\nTokyo Nagoya 120 3\\nKusatsu Nagoya 40 0\\nKusatsu Kanazawa 40 0\\nKanazawa Aizu 40 0\\nTokyo Kanazawa 40 0\\nTokyo Aizu 80 4\\n0 0\", \"4 4\\nA B G\\nA B 40 3\\nB C 80 0\\nA G 40 0\\nB G 80 0\\n5 6\\nKusatsu...
Problem C: Seishun 18 Kippu A student at R University, sirokurostone, was about to attend a training camp at Atsu University. Other members plan to use the Shinkansen, but sirokurostone was going to use the Seishun 18 Ticket. Similarly, a person who likes 2D with a youth 18 ticket was also trying to participate in the...
0.75
{"tests": "{\"inputs\": [\"3\\n-\\nU\\nD\", \"10\\nU\\nD\\nU\\nD\\nU\\nD\\nU\\nD\\nU\\nD\", \"8\\nU\\nD\\nD\\nD\\nD\\nD\\nD\\nD\", \"2\\nD\\nU\", \"5\\nU\\nU\\n-\\nD\\nD\", \"2\\nD\\nT\", \"2\\nE\\nU\", \"2\\nF\\nU\", \"2\\nD\\nS\", \"2\\nC\\nU\", \"2\\nB\\nU\", \"2\\nD\\nV\", \"2\\nD\\nR\", \"2\\nA\\nU\", \"2\\nD\\nW\...
Hakone Ekiden is one of the Japanese New Year's traditions. In Hakone Ekiden, 10 runners from each team aim for the goal while connecting the sashes at each relay station. In the TV broadcast, the ranking change from the previous relay station is displayed along with the passing order of each team at the relay station....
0
{"tests": "{\"inputs\": [\"2 15\\n2 3 3 7 2\\n2 7 1 1 4\", \"2 15\\n2 3 3 7 2\\n1 7 1 1 4\", \"2 15\\n2 3 5 7 2\\n0 7 1 1 4\", \"2 15\\n2 5 5 8 2\\n1 7 1 1 4\", \"2 4\\n2 3 3 7 1\\n0 7 1 1 6\", \"2 25\\n2 3 3 7 2\\n2 7 1 1 4\", \"2 0\\n2 3 5 7 2\\n1 7 1 1 4\", \"2 4\\n2 1 3 7 1\\n0 7 1 1 6\", \"2 15\\n2 2 5 7 3\\n0 11 ...
Problem statement Here are N mysteriously shaped vases. The i-th jar is a shape in which K_i right-sided cylinders are vertically connected in order from the bottom. The order in which they are connected cannot be changed. Mr. A has a volume of water of M. Pour this water into each jar in any amount you like. It does ...
0
{"tests": "{\"inputs\": [\"13\", \"8\", \"9\", \"5\", \"7\", \"3\", \"2\", \"1\", \"10\", \"0\", \"4\", \"-1\", \"-2\", \"14\", \"-3\", \"-4\", \"-6\", \"-8\", \"-10\", \"-12\", \"-18\", \"-9\", \"-27\", \"6\", \"12\", \"-5\", \"16\", \"-7\", \"24\", \"-17\", \"19\", \"-23\", \"33\", \"-15\", \"55\", \"-16\", \"84\", \...
Given a non-negative decimal integer $x$, convert it to binary representation $b$ of 32 bits. Then, print the result of the following operations to $b$ respecitvely. * Inversion: change the state of each bit to the opposite state * Logical left shift: shift left by 1 * Logical right shift: shift right by 1 Constraint...
0
{"tests": "{\"inputs\": [\"2 4 4 2\\n1 3\\n2 3\\n1 4\\n1 2\\n3 4\\n1 4\\n1 2\\n3 4\\n\", \"2 4 4 2\\n1 3\\n2 4\\n1 2\\n1 2\\n3 4\\n3 4\\n1 2\\n3 4\\n\", \"10 15 50 10\\n6 8\\n10 15\\n9 12\\n1 8\\n4 8\\n1 12\\n14 15\\n4 7\\n5 9\\n7 11\\n7 50\\n4 41\\n10 50\\n5 33\\n10 26\\n14 42\\n8 37\\n4 45\\n5 48\\n1 27\\n1 8\\n4 25\...
In addition to complaints about lighting, a lot of complaints about insufficient radio signal covering has been received by Bertown city hall recently. n complaints were sent to the mayor, all of which are suspiciosly similar to each other: in the i-th complaint, one of the radio fans has mentioned that the signals of ...
0
{"tests": "{\"inputs\": [\"2 3\\n\", \"2 1\\n\", \"3 6\\n\", \"2 5\\n\", \"1 2\\n\", \"100000 100000\\n\", \"1 3\\n\", \"1 100000\\n\", \"91697 91697\\n\", \"1 99999\\n\", \"100000 1\\n\", \"91248 82914\\n\", \"1 1\\n\", \"52702 64157\\n\", \"99998 1\\n\", \"99411 90913\\n\", \"99999 1\\n\", \"3 1\\n\", \"1 99998\\n\",...
Recently Ivan the Fool decided to become smarter and study the probability theory. He thinks that he understands the subject fairly well, and so he began to behave like he already got PhD in that area. To prove his skills, Ivan decided to demonstrate his friends a concept of random picture. A picture is a field of n r...
0
{"tests": "{\"inputs\": [\"1\\n13\\n\", \"4\\n4 0 11 6\\n\", \"5\\n108499762 843249791 917433490 622172778 725664656\\n\", \"6\\n787704054 796688644 754725914 561572949 573891604 312543334\\n\", \"4\\n433189692 522048869 125182076 157942182\\n\", \"5\\n809571641 29322377 935888946 833709370 2457463\\n\", \"2\\n15128270...
Anu has created her own function f: f(x, y) = (x | y) - y where | denotes the [bitwise OR operation](https://en.wikipedia.org/wiki/Bitwise_operation#OR). For example, f(11, 6) = (11|6) - 6 = 15 - 6 = 9. It can be proved that for any nonnegative numbers x and y value of f(x, y) is also nonnegative. She would like to r...
0.125
{"tests": "{\"inputs\": [\"6\\n1 1\\n.\\n1 2\\nG.\\n2 2\\n#B\\nG.\\n2 3\\nG.#\\nB#.\\n3 3\\n#B.\\n#..\\nGG.\\n2 2\\n#B\\nB.\\n\", \"5\\n2 5\\nB.GGG\\n.B.G.\\n3 6\\nBB#.GG\\nB.#B.G\\n.#.#G.\\n3 2\\n..\\n..\\n..\\n1 4\\nBBB.\\n4 9\\n###B##.B#\\n.####.##G\\n##.###.#.\\n...B#.B#.\\n\", \"1\\n1 1\\n.\\n\", \"4\\n1 2\\nG.\\n...
Vivek has encountered a problem. He has a maze that can be represented as an n × m grid. Each of the grid cells may represent the following: * Empty — '.' * Wall — '#' * Good person — 'G' * Bad person — 'B' The only escape from the maze is at cell (n, m). A person can move to a cell only if it shares a...
0
{"tests": "{\"inputs\": [\"2 4 3\\n1 1 1\\n1 2 2\\n2 1 3\\n2 2 7\\n\", \"2 4 7\\n1 1 1\\n1 2 2\\n2 1 3\\n2 2 7\\n\", \"4 16 105\\n2 4 15\\n1 1 16\\n2 2 57\\n3 4 31\\n1 2 47\\n2 3 28\\n1 3 70\\n4 2 50\\n3 1 10\\n4 1 11\\n4 4 27\\n1 4 56\\n3 3 28\\n3 2 28\\n2 1 33\\n4 3 63\\n\", \"5 15 90\\n2 3 71\\n5 1 72\\n3 2 29\\n2 5...
The Smart Beaver from ABBYY was offered a job of a screenwriter for the ongoing TV series. In particular, he needs to automate the hard decision: which main characters will get married by the end of the series. There are n single men and n single women among the main characters. An opinion poll showed that viewers lik...
0
{"tests": "{\"inputs\": [\"2 2 4 100\\n\", \"3 1 3 5\\n\", \"1 4 4 7\\n\", \"5 5 2 10\\n\", \"1000000 1000000 1 1\\n\", \"5 5 2 1\\n\", \"1 1 2 2\\n\", \"1 1 1000000 1\\n\", \"2 1 371319 775111\\n\", \"1000000 1 1 1\\n\", \"5 2 68 144841\\n\", \"702841 39 622448 218727\\n\", \"1 1 1 1\\n\", \"1 1 100 2\\n\", \"1 1 1000...
Qwerty the Ranger took up a government job and arrived on planet Mars. He should stay in the secret lab and conduct some experiments on bacteria that have funny and abnormal properties. The job isn't difficult, but the salary is high. At the beginning of the first experiment there is a single bacterium in the test tub...
0
{"tests": "{\"inputs\": [\"1 1\\n\", \"2 1\\n\", \"1 2\\n\", \"5 3\\n\", \"1526002 6904227\\n\", \"4 1\\n\", \"674098 1358794\\n\", \"5 5\\n\", \"100 87\\n\", \"10000000 8660255\\n\", \"100 199\\n\", \"100 49\\n\", \"2 6904227\\n\", \"6552194 8371814\\n\", \"10000000 866254\\n\", \"2 2\\n\", \"5 10\\n\", \"3983458 7761...
A girl named Xenia has a cupboard that looks like an arc from ahead. The arc is made of a semicircle with radius r (the cupboard's top) and two walls of height h (the cupboard's sides). The cupboard's depth is r, that is, it looks like a rectangle with base r and height h + r from the sides. The figure below shows what...
0
{"tests": "{\"inputs\": [\"3\\n1 2\\n2 3\\n3 4\\n\", \"2\\n1 3\\n1 3\\n\", \"10\\n1 1\\n8 10\\n1 7\\n6 8\\n5 7\\n1 9\\n8 8\\n6 10\\n1 4\\n3 4\\n\", \"10\\n1 4\\n1 12\\n5 7\\n5 5\\n2 5\\n1 7\\n1 10\\n7 9\\n8 9\\n9 11\\n\", \"10\\n6 7\\n5 11\\n5 10\\n9 10\\n11 12\\n6 12\\n7 11\\n1 1\\n5 9\\n2 8\\n\", \"10\\n6 9\\n1 8\\n6...
On a history lesson the teacher asked Vasya to name the dates when n famous events took place. He doesn't remembers the exact dates but he remembers a segment of days [li, ri] (inclusive) on which the event could have taken place. However Vasya also remembers that there was at most one event in one day. Help him choose...
0
{"tests": "{\"inputs\": [\"2 2\\n99 100\\n\", \"2 4\\n7 9\\n\", \"3 8\\n17 15 19\\n\", \"100 9455943\\n44 8 21 71 7 29 40 65 91 70 48 19 77 48 16 22 54 4 29 34 9 22 73 34 47 41 5 83 32 91 52 6 74 64 18 23 9 4 36 78 98 20 20 3 69 86 41 67 54 76 87 84 47 6 52 87 61 100 98 80 14 14 24 99 90 73 97 79 22 65 65 51 29 44 15 6...
Petya loves computer games. Finally a game that he's been waiting for so long came out! The main character of this game has n different skills, each of which is characterized by an integer ai from 0 to 100. The higher the number ai is, the higher is the i-th skill of the character. The total rating of the character is...
0.125
{"tests": "{\"inputs\": [\"4 6\\n2S 3S 4S 7S 8S AS\\n5H 6H 7H 5S TC AC\\n8H 9H TH 7C 8C 9C\\n2D 2C 3C 4C 5C 6C\\n\", \"4 6\\n2S 3S 4S 7S 8S AS\\n5H 6H 7H QC TC AC\\n8H 9H TH 7C 8C 9C\\n2D 2C 3C 4C 5C 6C\\n\", \"4 6\\n2S 3S 4S 7S 8S AS\\n5H 6H 7H J1 TC AC\\n8H 9H TH 7C 8C 9C\\n2D 2C 3C 4C 5C 6C\\n\", \"7 7\\n6C 8C KH 8S...
Vasya has a pack of 54 cards (52 standard cards and 2 distinct jokers). That is all he has at the moment. Not to die from boredom, Vasya plays Solitaire with them. Vasya lays out nm cards as a rectangle n × m. If there are jokers among them, then Vasya should change them with some of the rest of 54 - nm cards (which a...
0
{"tests": "{\"inputs\": [\"4\\n2 1 4 3\\n\", \"4\\n4 4 4 4\\n\", \"4\\n2 3 1 4\\n\", \"100\\n99 7 60 94 9 96 38 44 77 12 75 88 47 42 88 95 59 4 12 96 36 16 71 6 26 19 88 63 25 53 90 18 95 82 63 74 6 60 84 88 80 95 66 50 21 8 61 74 61 38 31 19 28 76 94 48 23 80 83 58 62 6 64 7 72 100 94 90 12 63 44 92 32 12 6 66 49 80 7...
As you have noticed, there are lovely girls in Arpa’s land. People in Arpa's land are numbered from 1 to n. Everyone has exactly one crush, i-th person's crush is person with the number crushi. <image> Someday Arpa shouted Owf loudly from the top of the palace and a funny game started in Arpa's land. The rules are a...
0.25
{"tests": "{\"inputs\": [\"17 5\\n0 2 4 13 15\\n\", \"5 3\\n1 2 3\\n\", \"17 5\\n0 2 4 13 14\\n\", \"17 2\\n8 3\\n\", \"239 100\\n178 74 144 43 201 189 40 175 51 31 202 114 12 17 86 78 53 196 235 158 95 224 143 198 170 117 79 81 23 197 73 165 133 166 21 50 148 34 121 223 184 45 54 228 9 238 187 19 218 169 104 62 106 46...
Little Timofey likes integers a lot. Unfortunately, he is very young and can't work with very big integers, so he does all the operations modulo his favorite prime m. Also, Timofey likes to look for arithmetical progressions everywhere. One of his birthday presents was a sequence of distinct integers a1, a2, ..., an. ...
0
{"tests": "{\"inputs\": [\"5 1\\nAABBB\\n\", \"5 1\\nABABB\\n\", \"433 3\\nFZDDHMJGBZCHFUXBBPIEBBEFDWOMXXEPOMDGSMPIUZOMRZQNSJAVNATGIWPDFISKFQXJNVFXPHOZDAEZFDAHDXXQKZMGNSGKQNWGNGJGJZVVITKNFLVCPMZSDMCHBTVAWYVZLIXXIADXNYILEYNIQHKMOGMVOCWGHCWIYMPEPADSJAAKEGTUSEDWAHMNYJDIHBKHVUHLYGNGZDBULRXLSAJHPCMNWCEAAPYMHDTYWPADOTJTXTXUK...
<image> It's the end of July – the time when a festive evening is held at Jelly Castle! Guests from all over the kingdom gather here to discuss new trends in the world of confectionery. Yet some of the things discussed here are not supposed to be disclosed to the general public: the information can cause discord in th...
0.75
{"tests": "{\"inputs\": [\"3\\n&amp; 1\\n&amp; 3\\n&amp; 5\\n\", \"3\\n^ 1\\n^ 2\\n^ 3\\n\", \"3\\n| 3\\n^ 2\\n| 1\\n\", \"1\\n& 0\\n\", \"1\\n^ 123\\n\", \"10\\n^ 218\\n& 150\\n| 935\\n& 61\\n| 588\\n& 897\\n| 411\\n| 584\\n^ 800\\n| 704\\n\", \"3\\n& 1\\n& 3\\n& 5\\n\", \"1\\n| 123\\n\", \"1\\n^ 0\\n\", \"1\\n| 1023\...
Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well. In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an...
0
{"tests": "{\"inputs\": [\"5 6 1 1 3\\n2\\n5\\n3\\n1 1 5 6\\n1 3 5 4\\n3 3 5 3\\n\", \"2 10 1 1 1\\n1\\n10\\n1\\n1 5 1 8\\n\", \"4 4 1 0 1\\n1\\n\\n1\\n1 2 1 4\\n\", \"2 5 1 0 1\\n2\\n\\n1\\n1 4 1 5\\n\", \"10 10 1 8 4\\n10\\n2 3 4 5 6 7 8 9\\n10\\n1 1 3 1\\n2 1 7 1\\n1 1 9 1\\n7 1 4 1\\n10 1 7 1\\n2 1 7 1\\n3 1 2 1\\n...
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
0
{"tests": "{\"inputs\": [\"<span class=\\\"tex-font-style-tt\\\">-o---o-</span>\\n\", \"<span class=\\\"tex-font-style-tt\\\">-o-o--</span>\", \"ooo\\n\", \"<span class=\\\"tex-font-style-tt\\\">-o---</span>\\n\", \"-oo-oo------\\n\", \"-----------------------------------o---------------------o-------------------------...
A necklace can be described as a string of links ('-') and pearls ('o'), with the last link or pearl connected to the first one. <image> You can remove a link or a pearl and insert it between two other existing links or pearls (or between a link and a pearl) on the necklace. This process can be repeated as many times...
0
{"tests": "{\"inputs\": [\"616 4\\n305 250\\n558 43\\n182 37\\n297 138\", \"60 5\\n60 28\\n32 38\\n31 44\\n48 30\\n14 34\", \"7 6\\n5 5\\n1 5\\n4 5\\n3 6\\n1 5\\n3 3\", \"938 4\\n305 250\\n558 43\\n182 37\\n297 138\", \"60 5\\n60 28\\n32 38\\n31 44\\n48 30\\n14 4\", \"7 6\\n5 5\\n1 5\\n4 5\\n3 6\\n1 0\\n3 3\", \"938 4\...
Problem: N boxes are arranged systematically in a circle and numbered from 1 to N in increasing order in clockwise direction. There will be Q queries asking you whether boxes i and j can be connected by a straight rod such that this rod does not intersect ( criss - cross as seen from top view ) with any of the other r...
0.25
{"tests": "{\"inputs\": [\"4\\n2 5 2 5\", \"2\\n4 3\", \"4\\n2 5 2 8\", \"2\\n4 4\", \"4\\n2 9 3 8\", \"4\\n0 9 3 8\", \"2\\n3 8\", \"2\\n4 1\", \"4\\n2 1 3 1\", \"2\\n24 8\", \"2\\n5 8\", \"2\\n15 11\", \"2\\n7 8\", \"4\\n3 12 6 4\", \"2\\n10 16\", \"4\\n2 5 3 8\", \"2\\n4 7\", \"2\\n4 8\", \"4\\n0 1 3 8\", \"4\\n0 1 ...
Niwango-kun has \\(N\\) chickens as his pets. The chickens are identified by numbers \\(1\\) to \\(N\\), and the size of the \\(i\\)-th chicken is a positive integer \\(a_i\\). \\(N\\) chickens decided to take each other's hand (wing) and form some cycles. The way to make cycles is represented by a permutation \\(p\\)...
0
{"tests": "{\"inputs\": [\"20 17\", \"2 2\", \"36 17\", \"4 2\", \"36 18\", \"4 3\", \"36 22\", \"59 22\", \"3 2\", \"49 17\", \"4 0\", \"36 9\", \"4 1\", \"29 22\", \"59 35\", \"6 1\", \"62 9\", \"8 1\", \"72 35\", \"12 1\", \"88 9\", \"72 32\", \"5 1\", \"3 3\", \"41 17\", \"2 1\", \"36 12\", \"13 1\", \"59 39\", \"3...
Consider the following game: * The game is played using a row of N squares and many stones. * First, a_i stones are put in Square i\ (1 \leq i \leq N). * A player can perform the following operation as many time as desired: "Select an integer i such that Square i contains exactly i stones. Remove all the stones from S...
0
{"tests": "{\"inputs\": [\"3\\n0\\n5\\n1\\n1\\n0\\n-1\", \"3\\n0\\n5\\n1\\n1\\n1\\n-1\", \"3\\n0\\n9\\n1\\n1\\n0\\n-1\", \"3\\n0\\n5\\n1\\n1\\n2\\n-1\", \"3\\n1\\n9\\n1\\n1\\n0\\n-1\", \"3\\n0\\n6\\n1\\n1\\n2\\n-1\", \"3\\n1\\n9\\n0\\n1\\n0\\n-1\", \"3\\n0\\n5\\n0\\n1\\n0\\n-1\", \"3\\n1\\n5\\n1\\n1\\n0\\n-1\", \"3\\n0...
The screen that displays digital numbers that you often see on calculators is called a "7-segment display" because the digital numbers consist of seven parts (segments). The new product to be launched by Wakamatsu will incorporate a 7-segment display into the product, and as an employee, you will create a program to d...
0
{"tests": "{\"inputs\": [\"1\\nE A C\\n1\\nE B C\\n2\\nE A B\\n0\", \"1\\nD A C\\n1\\nE B C\\n2\\nE A B\\n0\", \"1\\nD A C\\n1\\nE B C\\n2\\nF A B\\n0\", \"1\\nD A C\\n0\\nE B C\\n2\\nF A B\\n0\", \"1\\nC A C\\n0\\nE B C\\n2\\nF A B\\n0\", \"1\\nE A B\\n1\\nE B C\\n2\\nE A B\\n0\", \"1\\nD A C\\n1\\nE A D\\n2\\nF A B\\...
Dr. Asimov, a robotics researcher, loves to research, but hates houseworks and his house were really dirty. So, he has developed a cleaning robot. As shown in the following figure, his house has 9 rooms, where each room is identified by an alphabet: <image> The robot he developed operates as follows: * If the bat...
0.25
{"tests": "{\"inputs\": [\"2 0\\n1 2\\n5 4\\n1 5\\n1 2 1 1\\n2 3 2 2\\n3 4 2 2\\n4 5 1 1\\n6 6\\n1 6\\n1 2 2 1\\n2 3 2 1\\n3 6 2 1\\n1 4 2 30\\n4 5 3 30\\n5 6 2 30\\n6 7\\n1 6\\n1 2 1 30\\n2 3 1 30\\n3 1 1 30\\n3 4 100 30\\n4 5 1 30\\n5 6 1 30\\n6 4 1 30\\n0 0\", \"2 0\\n1 2\\n5 4\\n1 5\\n1 2 1 1\\n2 3 2 2\\n3 4 2 2\\n...
Consider car trips in a country where there is no friction. Cars in this country do not have engines. Once a car started to move at a speed, it keeps moving at the same speed. There are acceleration devices on some points on the road, where a car can increase or decrease its speed by 1. It can also keep its speed there...
0
{"tests": "{\"inputs\": [\"2 1 0 1 0 1\\n0 1 2\\n3 1 1 2 0 1\\n2\\n0 2 1\\n1 2 1\\n3 2 1 2 0 1\\n2\\n0 2 1\\n1 2 1\\n4 4 1 4 1 3\\n2\\n0 1 2\\n1 2 4\\n0 2 1\\n3 0 3\\n5 3 2 6 0 3\\n1 2\\n2 1 2\\n1 0 1\\n3 4 1\\n2 4 1\\n4 1 2\\n2 0 2\\n5 4 2 6 0 3\\n1 2\\n4 2 4\\n2 1 2\\n4 3 1\\n0 1 5\\n1 4 2\\n2 0 3\\n0 0 0 0 0 0\", \"...
Princess in Danger Princess crisis English text is not available in this practice contest. A brave princess in a poor country's tomboy is married to another country for a political marriage. However, a villain who was trying to kill the princess attacked him on the way to his wife, and the princess was seriously inj...
0.125
{"tests": "{\"inputs\": [\"6\\n2 5 2 5 2 1\", \"6\\n2 5 2 6 2 1\", \"6\\n1 25 1 10 1 3\", \"6\\n0 5 0 11 2 2\", \"6\\n0 3 0 9 0 0\", \"6\\n2 5 0 6 2 1\", \"6\\n2 9 0 6 2 1\", \"6\\n2 9 1 6 2 1\", \"6\\n0 9 1 6 2 1\", \"6\\n0 9 1 6 2 2\", \"6\\n0 9 1 6 2 3\", \"6\\n0 9 1 5 2 3\", \"6\\n0 9 1 3 2 3\", \"6\\n0 10 1 3 2 3\...
C: Mod! Mod! story That's right! I'm looking for eyewitness testimony! A phantom thief has appeared in Aizu! Everyone's horse stick was stolen! Who is the culprit! ?? Unravel! Mod! Mod! Problem statement "Eyes" ... it's a miracle bud that swells in the hearts of the chosen ones ... You can steal anything with the s...
0
{"tests": "{\"inputs\": [\"5\\n-127.0.0.4/31\\n+127.0.0.8\\n+127.0.0.0/30\\n-195.82.146.208/29\\n-127.0.0.6/31\\n\", \"4\\n-149.154.167.99\\n+149.154.167.100/30\\n+149.154.167.128/25\\n-149.154.167.120/29\\n\", \"2\\n+127.0.0.1/32\\n-127.0.0.1\\n\", \"1\\n-149.154.167.99\\n\", \"11\\n-0.0.0.15/32\\n-0.0.0.12/31\\n-0.0....
Berkomnadzor — Federal Service for Supervision of Communications, Information Technology and Mass Media — is a Berland federal executive body that protects ordinary residents of Berland from the threats of modern internet. Berkomnadzor maintains a list of prohibited IPv4 subnets (blacklist) and a list of allowed IPv4 ...
0
{"tests": "{\"inputs\": [\"2\\n1 2\\nWL\\n\", \"3\\n10 10 10\\nGLW\\n\", \"2\\n10 10\\nWL\\n\", \"1\\n10\\nG\\n\", \"4\\n1 1 1 1\\nWGWL\\n\", \"2\\n2 10\\nGL\\n\", \"3\\n10 10 50\\nWGL\\n\", \"2\\n100 100\\nWG\\n\", \"10\\n324839129156 133475576222 987711341463 185514358673 88712073883 243757012712 950854402304 2194706...
Bob is a duck. He wants to get to Alice's nest, so that those two can duck! <image> Duck is the ultimate animal! (Image courtesy of See Bang) The journey can be represented as a straight line, consisting of n segments. Bob is located to the left of the first segment, while Alice's nest is on the right of the last seg...
0
{"tests": "{\"inputs\": [\"0 0 1000000 1000000\\n0 0 499999 1000000\\n500000 0 1000000 1000000\\n\", \"3 3 7 5\\n0 0 4 6\\n0 0 7 4\\n\", \"5 2 10 5\\n3 1 7 6\\n8 1 11 7\\n\", \"2 2 4 4\\n1 1 3 5\\n3 1 5 5\\n\", \"7 1 8 3\\n0 0 4 2\\n2 1 18 21\\n\", \"5 2 10 5\\n8 1 11 7\\n3 1 7 6\\n\", \"3 3 4 4\\n0 0 1 1\\n3 3 4 4\\n\...
There is a white sheet of paper lying on a rectangle table. The sheet is a rectangle with its sides parallel to the sides of the table. If you will take a look from above and assume that the bottom left corner of the table has coordinates (0, 0), and coordinate axes are left and bottom sides of the table, then the bott...
0.125
{"tests": "{\"inputs\": [\"4\\n3 4\\n1 1\\n2 2\\n3 3\\n1 3\\n\\n3 7\\n1 1\\n1 2\\n1 3\\n2 2\\n3 1\\n3 2\\n3 3\\n\\n1 1\\n1 1\\n\\n2 4\\n1 1\\n1 2\\n2 1\\n2 2\\n\", \"5\\n4 6\\n1 1\\n3 3\\n1 2\\n2 2\\n4 4\\n4 2\\n\\n4 6\\n2 4\\n2 2\\n3 2\\n1 1\\n3 3\\n4 4\\n\\n4 8\\n1 1\\n3 1\\n2 2\\n3 3\\n3 2\\n1 2\\n4 4\\n2 4\\n\\n5 8...
In the Catowice city next weekend the cat contest will be held. However, the jury members and the contestants haven't been selected yet. There are n residents and n cats in the Catowice, and each resident has exactly one cat living in his house. The residents and cats are numbered with integers from 1 to n, where the i...
0
{"tests": "{\"inputs\": [\"4\\n3 17 6 0\\n\", \"3\\n1 2 3\\n\", \"2\\n7 2\\n\", \"3\\n43 12 12\\n\", \"2\\n105953580 334230288\\n\", \"2\\n1073709056 32767\\n\", \"10\\n22 27 7 14 10 9 10 15 13 0\\n\", \"10\\n22 15 29 8 5 17 27 27 2 10\\n\", \"100\\n784 784 784 784 784 784 784 784 784 784 784 784 784 784 784 784 784 78...
Let's call two numbers similar if their binary representations contain the same number of digits equal to 1. For example: * 2 and 4 are similar (binary representations are 10 and 100); * 1337 and 4213 are similar (binary representations are 10100111001 and 1000001110101); * 3 and 2 are not similar (binary repr...
0
{"tests": "{\"inputs\": [\"5\\n6\\n3 2 5 6\\n2 4 6\\n3 1 3 4\\n2 1 3\\n4 1 2 4 6\\n5\\n2 2 3\\n2 1 2\\n2 1 4\\n2 4 5\\n7\\n3 1 2 6\\n4 1 3 5 6\\n2 1 2\\n3 4 5 7\\n6 1 2 3 4 5 6\\n3 1 3 6\\n2\\n2 1 2\\n5\\n2 2 5\\n3 2 3 5\\n4 2 3 4 5\\n5 1 2 3 4 5\\n\", \"1\\n6\\n4 2 3 4 5\\n2 1 2\\n2 3 5\\n2 2 5\\n6 1 2 3 4 5 6\\n\", \...
We guessed a permutation p consisting of n integers. The permutation of length n is the array of length n where each element from 1 to n appears exactly once. This permutation is a secret for you. For each position r from 2 to n we chose some other index l (l < r) and gave you the segment p_l, p_{l + 1}, ..., p_r in s...
0
{"tests": "{\"inputs\": [\"4\\n3 3\\nabc\\nbcd\\n4 2\\nabba\\nazza\\n2 1\\nzz\\naa\\n6 2\\naaabba\\nddddcc\\n\", \"4\\n1 3\\nabc\\nbcd\\n4 2\\nabba\\nazza\\n2 1\\nzz\\naa\\n6 2\\naaabba\\nddddcc\\n\", \"4\\n3 3\\nabc\\nbcd\\n4 2\\nabba\\nazza\\n2 1\\nzz\\naa\\n6 2\\naaabba\\nedddcc\\n\", \"4\\n3 3\\nabb\\nacd\\n4 2\\na...
Ashish has two strings a and b, each of length n, and an integer k. The strings only contain lowercase English letters. He wants to convert string a into string b by performing some (possibly zero) operations on a. In one move, he can either * choose an index i (1 ≤ i≤ n-1) and swap a_i and a_{i+1}, or * choos...
0
{"tests": "{\"inputs\": [\"5\\n7 12\\n1 2 3 4 9 10 11\\nR R L L R R R\\n2 10\\n1 6\\nR R\\n2 10\\n1 3\\nL L\\n1 10\\n5\\nR\\n7 8\\n6 1 7 2 3 5 4\\nR L R L L L L\\n\", \"1\\n20 50\\n4 6 8 9 10 13 14 16 18 20 23 25 30 32 33 38 42 43 45 46\\nL L L L L L L L L L R R R L L R R L R R\\n\", \"1\\n10 20\\n2 3 7 9 10 13 14 16 1...
There are n robots driving along an OX axis. There are also two walls: one is at coordinate 0 and one is at coordinate m. The i-th robot starts at an integer coordinate x_i~(0 < x_i < m) and moves either left (towards the 0) or right with the speed of 1 unit per second. No two robots start at the same coordinate. Whe...
0
{"tests": "{\"inputs\": [\"abc\\nba\\n\", \"abacaba\\naba\\n\", \"abab\\nab\\n\", \"abcdadbcd\\nabcd\\n\", \"cctckkhatkgrhktihcgififfgfctctkrgiakrifazzggfzczfkkahhafhcfgacccfakkarcatkfiktczkficahgiriakccfiztkhkgrfkrimgamighhtamrhxftaadwxgfggytwjccgkdpyyatctfdygxggkyycpjyfxyfdwtgytcacawjddjdctyfgddkfkypyxftxxtaddcxxpgfg...
A subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is a string x = sk1sk2... sk|x| (1 ≤ k1 < k2 < ... < k|x| ≤ |s|). You've got two strings — s and t. Let's consider all subsequences of string s, coinciding with string t. Is it true that each character of string s occurs in at...
0.375
{"tests": "{\"inputs\": [\"1\\n\", \"01\\n\", \"11\\n\", \"0111001111110010000001111100110100111110001100100001111111110000010010111010010010010111000110001111\\n\", \"10110\\n\", \"0110011110111000001101001010101000011011101001001101000000111101010101111101010011101001111010111001\\n\", \"100111100\\n\", \"0\\n\", \"0...
As a tradition, every year before IOI all the members of Natalia Fan Club are invited to Malek Dance Club to have a fun night together. Malek Dance Club has 2n members and coincidentally Natalia Fan Club also has 2n members. Each member of MDC is assigned a unique id i from 0 to 2n - 1. The same holds for each member o...
0
{"tests": "{\"inputs\": [\"5 3\\n4 4 4 4 4\\n2 2 2 2 2\\n\", \"3 2\\n10 8 1\\n2 7 1\\n\", \"1 1\\n1\\n2\\n\", \"19 2\\n68 24 95 24 94 82 37 87 68 67 59 28 68 5 70 53 80 46 61\\n60 74 46 9 40 45 58 51 96 4 42 33 12 40 34 9 58 84 91\\n\", \"2 1\\n75 65\\n16 60\\n\", \"21 8\\n50 39 28 27 58 46 95 46 50 8 28 94 61 58 57 7 ...
Dima, Inna and Seryozha have gathered in a room. That's right, someone's got to go. To cheer Seryozha up and inspire him to have a walk, Inna decided to cook something. Dima and Seryozha have n fruits in the fridge. Each fruit has two parameters: the taste and the number of calories. Inna decided to make a fruit sala...
0.375
{"tests": "{\"inputs\": [\"-2 1\\n\", \"4 3\\n\", \"2 1\\n\", \"-12 -35\\n\", \"-215 -996\\n\", \"-96 -556\\n\", \"-1000 0\\n\", \"20 -21\\n\", \"0 0\\n\", \"207 -224\\n\", \"-668 970\\n\", \"-496 -644\\n\", \"253 -204\\n\", \"-129 489\\n\", \"15 -8\\n\", \"-589 952\\n\", \"0 2\\n\", \"-216 -90\\n\", \"-72 -646\\n\", \...
Not so long ago as a result of combat operations the main Berland place of interest — the magic clock — was damaged. The cannon's balls made several holes in the clock, that's why the residents are concerned about the repair. The magic clock can be represented as an infinite Cartesian plane, where the origin correspond...
0
{"tests": "{\"inputs\": [\"11 2 3\\n\", \"11 11 5\\n\", \"18 11 21\\n\", \"6 5 7\\n\", \"9 8 17\\n\", \"6 7 4\\n\", \"10 20 2\\n\", \"11 8 23\\n\", \"10 11 5\\n\", \"11 15 2\\n\", \"10 2 82\\n\", \"4 0 2\\n\", \"5 6 3\\n\", \"10 1 11\\n\", \"10 11 11\\n\", \"5 11 1\\n\", \"11 25 0\\n\", \"11 10 19\\n\", \"12938621 1928...
Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly k points, the score is reset and a new set begins. Across all the sets Misha scored a points ...
0
{"tests": "{\"inputs\": [\"04:30\\n\", \"08:17\\n\", \"12:00\\n\", \"17:48\\n\", \"08:31\\n\", \"23:01\\n\", \"06:36\\n\", \"10:54\\n\", \"00:24\\n\", \"12:30\\n\", \"11:32\\n\", \"23:58\\n\", \"07:20\\n\", \"19:55\\n\", \"23:00\\n\", \"00:01\\n\", \"20:45\\n\", \"23:45\\n\", \"11:59\\n\", \"20:12\\n\", \"04:11\\n\", \...
Do you remember a kind cartoon "Beauty and the Beast"? No, no, there was no firing from machine guns or radiation mutants time-travels! There was a beauty named Belle. Once she had violated the Beast's order and visited the West Wing. After that she was banished from the castle... Everybody was upset. The beautiful ...
0.875
{"tests": "{\"inputs\": [\"2 12\\n1 3\\n10 15\\n\", \"2 100\\n3 10\\n50 150\\n\", \"3 9\\n5 5 30\\n6 6 10\\n\", \"1 1000000\\n1000000\\n1000000\\n\", \"1 200\\n1000000\\n100\\n\", \"1 1\\n1000000\\n1\\n\", \"20 30\\n70 97 14 31 83 22 83 56 19 87 59 7 7 89 24 82 34 40 6 24\\n10 4 47 46 11 18 32 55 16 32 53 37 43 32 41 4...
Consider a system of n water taps all pouring water into the same container. The i-th water tap can be set to deliver any amount of water from 0 to ai ml per second (this amount may be a real number). The water delivered by i-th tap has temperature ti. If for every <image> you set i-th tap to deliver exactly xi ml of ...
0