info stringlengths 120 50k | question stringlengths 504 10.4k | avg@8_qwen3_4b_instruct_2507 float64 0 0.88 |
|---|---|---|
{"tests": "{\"inputs\": [\"39 14\", \"3 2\", \"39 23\", \"3 0\", \"31 14\", \"6 2\", \"47 12\", \"31 12\", \"5 2\", \"47 22\", \"27 12\", \"12 2\", \"3 4\", \"39 16\", \"4 4\", \"31 2\", \"5 12\", \"39 2\", \"44 16\", \"9 2\", \"10 12\", \"19 2\", \"12 4\", \"44 26\", \"33 2\", \"19 4\", \"20 26\", \"37 2\", \"11 2\", ... | Let us define the oddness of a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n} as \sum_{i = 1}^n |i - p_i|.
Find the number of permutations of {1,\ 2,\ ...,\ n} of oddness k, modulo 10^9+7.
Constraints
* All values in input are integers.
* 1 \leq n \leq 50
* 0 \leq k \leq n^2
Input
Input is given from... | 0 |
{"tests": "{\"inputs\": [\"10\\n2 10 5 7 3 6 4 9 8 1\", \"5\\n5 4 3 2 1\", \"5\\n3 5 1 2 4\", \"5\\n5 4 3 2 2\", \"5\\n5 8 3 2 1\", \"10\\n2 10 5 2 3 6 4 9 8 1\", \"10\\n2 10 5 7 2 6 4 9 8 1\", \"5\\n5 2 3 3 1\", \"10\\n2 10 5 7 2 8 4 9 16 1\", \"10\\n2 10 5 7 4 6 4 7 8 1\", \"5\\n2 5 1 2 4\", \"5\\n5 5 3 2 2\", \"5\\n... | Takahashi loves sorting.
He has a permutation (p_1,p_2,...,p_N) of the integers from 1 through N. Now, he will repeat the following operation until the permutation becomes (1,2,...,N):
* First, we will define high and low elements in the permutation, as follows. The i-th element in the permutation is high if the maxi... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 1\\n1 1\\n2 1\", \"3\\n1 0\\n1 1\\n2 1\", \"3\\n1 0\\n2 1\\n2 1\", \"3\\n1 0\\n2 1\\n1 0\", \"3\\n1 0\\n2 1\\n2 0\", \"3\\n1 2\\n1 1\\n2 1\", \"3\\n2 0\\n1 1\\n2 1\", \"3\\n1 0\\n2 1\\n2 2\", \"3\\n1 1\\n2 1\\n1 1\", \"3\\n1 0\\n0 1\\n2 0\", \"3\\n2 0\\n1 1\\n3 1\", \"3\\n2 1\\n2 1\\n1 ... | Snuke is having another barbeque party.
This time, he will make one serving of Skewer Meal.
He has a stock of N Skewer Meal Packs. The i-th Skewer Meal Pack contains one skewer, A_i pieces of beef and B_i pieces of green pepper. All skewers in these packs are different and distinguishable, while all pieces of beef an... | 0.375 |
{"tests": "{\"inputs\": [\"4\\na->e->c->b->d\\nb\", \"4\\na->e->c->b->d\\nb<-c<-a<-d<-e\\nb->a->c<-a->c->d<-c<-a<-b->a->c->d->e<-d\\na->e<-a<-d->a->e<-a<-d<-c->d->a<-d<-c<-b->c->d<-c\", \"4\\na->f->c->b->d\\nb\", \"4\\na->e->c->b->d\\na\", \"4\\na->f->c->b->d\\na\", \"4\\na->f->c->b->d\\n`\", \"4\\na->e->c->b->d\\nc\",... | There are trains with 26 cars or less. Each vehicle has an identification code from lowercase a to z. No vehicle has the same symbol. However, the order in which the vehicles are connected is arbitrary. The conductor patrols the train. The conductor patrolls back and forth in the train, so he may pass through the same ... | 0 |
{"tests": "{\"inputs\": [\"8\\n00000000\\n80000000\\n00000080\\n00000040\\n000000c0\\n00000100\\n80000780\\n80000f70\", \"8\\n00000000\\n80000000\\n00000080\\n00000040\\n000000c0\\n00000100\\n15330257\\n80000f70\", \"8\\n00000000\\n80000000\\n00000080\\n00000040\\n000000c0\\n00000100\\n21251916\\n80000f70\", \"8\\n0000... | Consider a 32-bit real type with 7 bits from the right as the decimal part, the following 24 bits as the integer part, and the leftmost 1 bit as the sign part as shown below (b1, ..., b32). Represents 0 or 1).
<image>
To translate this format into a decimal representation that is easy for humans to understand, inter... | 0 |
{"tests": "{\"inputs\": [\"8\\n1\\n0\\n1\\n1\\n0\\n0\\n0\\n0\\n8\\n1\\n0\\n1\\n1\\n0\\n0\\n0\\n1\\n0\", \"8\\n1\\n1\\n1\\n1\\n0\\n0\\n0\\n0\\n8\\n1\\n0\\n1\\n1\\n0\\n0\\n0\\n1\\n0\", \"8\\n1\\n1\\n1\\n1\\n0\\n0\\n0\\n0\\n8\\n1\\n0\\n0\\n1\\n0\\n0\\n0\\n1\\n0\", \"8\\n1\\n0\\n1\\n1\\n0\\n0\\n0\\n0\\n4\\n1\\n0\\n1\\n1\\n... | problem
Play by arranging white and black stones on the table. First, place the stones on the left edge of the table. Then place the stones in the second place from the left. Repeat this n times to arrange n stones in a horizontal row. However, when placing a new i-th go stone, replace the go stone on the table accord... | 0 |
{"tests": "{\"inputs\": [\"0ig3he12fz99\", \"1122334455\", \"0ig3hd12fz99\", \"0hg3hd12fz99\", \"833453334\", \"2336078995\", \"1437005866\", \"4037065\", \"15423151\", \"8181\", \"111\", \"0hg3hd13fz99\", \"90\", \"2\", \"1496009822\", \"0hf3hd12fz99\", \"1173329527\", \"99zf21dh3fh0\", \"0hfdh312fz99\", \"1810014501\... | Problem
Given the string S, which consists of lowercase letters and numbers. Follow the steps below to compress the length of string S.
1. Change the order of the characters in the character string to any order.
Example: "0ig3he12fz99"-> "efghiz012399"
2. Perform the following operations any number of times.
* Sele... | 0 |
{"tests": "{\"inputs\": [\"1 1 100\\n50 200 20 40 0\\n1\\n2 4 100\\n7 4 1 4 1\\n19 5 1 4 0\\n5\\n3\\n7\\n9\\n1 2 3\\n1 1 1 1 0\\n1\\n3\\n1 2 10\\n5 10 1 1 1\\n2\\n3\\n0 0 0\", \"1 1 100\\n50 200 20 40 0\\n1\\n2 4 101\\n7 4 1 4 1\\n19 5 1 4 0\\n5\\n3\\n7\\n9\\n1 2 3\\n1 1 1 1 0\\n1\\n3\\n1 2 10\\n5 10 1 1 1\\n2\\n3\\n0 ... | ACM countries have rivers that flow from east to west in the center. This river flows from the neighboring country in the west through the neighboring country in ACM to the neighboring country in the east, and the total length in ACM is K km. It is planned to install several locks on this river and use it as a canal.
... | 0 |
{"tests": "{\"inputs\": [\"3 1 2 3\\n1 2 3\\n1 3\", \"3 1 2 3\\n1 2 2\\n1 3\", \"3 1 2 3\\n1 0 1\\n2 3\", \"3 1 1 3\\n1 2 3\\n1 3\", \"3 1 1 3\\n1 2 0\\n1 3\", \"3 1 2 3\\n1 2 5\\n1 3\", \"3 1 2 3\\n1 0 4\\n1 3\", \"3 1 2 3\\n1 1 6\\n1 3\", \"3 1 2 3\\n1 2 8\\n1 3\", \"3 1 2 3\\n1 2 7\\n1 3\", \"3 1 2 3\\n0 -1 10\\n1 3... | problem
Dimension exists from $ 1 $ dimension to $ N $ dimension. AOR Ika can move between dimensions. Specifically, when AOR Ika is in the $ i $ dimension, she can move freely to the $ j $ dimension ($ i> j $), but in the $ k $ dimension ($ i <k $). You need to use magic to move to.
AOR Ika can use $ M $ types of ma... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 2\\n1 3\\n1 4\\n\", \"4\\n1 2\\n2 3\\n3 4\\n\", \"10\\n2 3\\n3 9\\n6 3\\n9 8\\n9 10\\n4 8\\n3 1\\n3 5\\n7 1\\n\", \"3\\n2 1\\n3 2\\n\", \"2\\n2 1\\n\", \"4\\n1 2\\n1 3\\n3 4\\n\", \"10\\n2 3\\n3 9\\n6 3\\n9 8\\n9 10\\n4 5\\n3 1\\n3 5\\n7 1\\n\", \"10\\n2 3\\n3 9\\n6 4\\n9 8\\n9 10\\n4 8... | Sergey Semyonovich is a mayor of a county city N and he used to spend his days and nights in thoughts of further improvements of Nkers' lives. Unfortunately for him, anything and everything has been done already, and there are no more possible improvements he can think of during the day (he now prefers to sleep at nigh... | 0.125 |
{"tests": "{\"inputs\": [\"5 2\\n1 -1\\n1 -5\\n2 -1\\n2 -1\\n1 -10\\n\", \"6 3\\n2 6\\n3 6\\n2 5\\n3 5\\n1 9\\n3 1\\n\", \"5 3\\n2 6\\n3 6\\n2 5\\n3 5\\n1 11\\n\", \"15 9\\n9 0\\n5 3\\n2 -1\\n2 -1\\n6 -1\\n9 -2\\n6 0\\n6 2\\n1 -2\\n1 2\\n2 -1\\n7 -2\\n1 1\\n6 -2\\n2 -2\\n\", \"8 4\\n2 0\\n3 9\\n3 5\\n1 0\\n2 8\\n1 -2\\... | A multi-subject competition is coming! The competition has m different subjects participants can choose from. That's why Alex (the coach) should form a competition delegation among his students.
He has n candidates. For the i-th person he knows subject s_i the candidate specializes in and r_i — a skill level in his s... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 2\\n2 3\\n\", \"5\\n1 2\\n1 3\\n1 4\\n3 5\\n\", \"10\\n9 5\\n9 3\\n8 1\\n4 5\\n8 2\\n7 2\\n7 5\\n3 6\\n10 5\\n\", \"10\\n4 5\\n9 7\\n1 6\\n2 5\\n7 4\\n6 10\\n8 3\\n4 3\\n6 7\\n\", \"10\\n10 8\\n9 2\\n3 2\\n10 6\\n1 3\\n10 4\\n5 9\\n7 8\\n10 2\\n\", \"10\\n1 10\\n7 1\\n6 2\\n1 3\\n8 4\\n... | [INSPION FullBand Master - INSPION](https://www.youtube.com/watch?v=kwsciXm_7sA)
[INSPION - IOLITE-SUNSTONE](https://www.youtube.com/watch?v=kwsciXm_7sA)
On another floor of the A.R.C. Markland-N, the young man Simon "Xenon" Jackson, takes a break after finishing his project early (as always). Having a lot of free ti... | 0 |
{"tests": "{\"inputs\": [\"100000 200000\\n\", \"3 4\\n\", \"3 5\\n\", \"42 1337\\n\", \"3 3\\n\", \"20 20\\n\", \"3 200000\\n\", \"2 2\\n\", \"150000 200000\\n\", \"200000 200000\\n\", \"1000 200000\\n\", \"2 3\\n\", \"7 14\\n\", \"2 10\\n\", \"3 6\\n\", \"6 200000\\n\", \"2 1\\n\", \"113870 200000\\n\", \"42 2283\\n\... | Your task is to calculate the number of arrays such that:
* each array contains n elements;
* each element is an integer from 1 to m;
* for each array, there is exactly one pair of equal elements;
* for each array a, there exists an index i such that the array is strictly ascending before the i-th element a... | 0 |
{"tests": "{\"inputs\": [\"6\\n1 5\\n0 10\\n1 -5\\n0 5\\n1 11\\n0 -10\\n\", \"6\\n1 5\\n0 10\\n1 -5\\n1 5\\n1 11\\n0 -10\\n\", \"6\\n1 5\\n0 10\\n1 -5\\n0 5\\n1 11\\n0 -5\\n\", \"6\\n1 5\\n0 10\\n1 -5\\n0 5\\n1 3\\n0 -10\\n\", \"6\\n1 5\\n0 10\\n1 -5\\n1 7\\n1 11\\n0 -10\\n\", \"6\\n1 5\\n0 10\\n1 -5\\n1 5\\n1 18\\n0 -... | Polycarp plays a computer game (yet again). In this game, he fights monsters using magic spells.
There are two types of spells: fire spell of power x deals x damage to the monster, and lightning spell of power y deals y damage to the monster and doubles the damage of the next spell Polycarp casts. Each spell can be ca... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 4\\n3 6\\n1 6\\n6 2\\n5 5\\n\", \"5\\n1 4\\n3 7\\n1 6\\n6 2\\n5 5\\n\", \"5\\n1 5\\n3 6\\n1 6\\n6 2\\n5 5\\n\", \"5\\n1 5\\n3 6\\n1 6\\n6 2\\n4 5\\n\", \"5\\n1 2\\n3 7\\n2 6\\n3 2\\n6 5\\n\", \"5\\n1 3\\n3 7\\n2 6\\n3 2\\n6 5\\n\", \"5\\n1 3\\n3 7\\n2 3\\n1 2\\n6 5\\n\", \"5\\n1 4\\n3 6... | There is a new attraction in Singapore Zoo: The Infinite Zoo.
The Infinite Zoo can be represented by a graph with an infinite number of vertices labeled 1,2,3,…. There is a directed edge from vertex u to vertex u+v if and only if u\&v=v, where \& denotes the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwis... | 0 |
{"tests": "{\"inputs\": [\"0 0 10\\n\", \"-1 8 3\\n\", \"1 16 5\\n\", \"2 18 2\\n\", \"1 1 4\\n\", \"4 972 4\\n\", \"1 512 9\\n\", \"1 961 2\\n\", \"0 3 6\\n\", \"-3 -768 8\\n\", \"1 625 4\\n\", \"4 972 1\\n\", \"1 1000 1\\n\", \"3 0 4\\n\", \"7 175 1\\n\", \"-4 0 1\\n\", \"-5 3 4\\n\", \"10 0 6\\n\", \"-5 -5 6\\n\", \... | A long time ago in some far country lived king Copa. After the recent king's reform, he got so large powers that started to keep the books by himself.
The total income A of his kingdom during 0-th year is known, as well as the total income B during n-th year (these numbers can be negative — it means that there was a l... | 0.25 |
{"tests": "{\"inputs\": [\"a8\\nh1\\n\", \"g8\\na8\\n\", \"h1\\nb2\\n\", \"d4\\nh2\\n\", \"g6\\nf2\\n\", \"e6\\nb6\\n\", \"f8\\nf8\\n\", \"h4\\nd1\\n\", \"e7\\nb1\\n\", \"g2\\na6\\n\", \"d2\\nf1\\n\", \"d1\\nb7\\n\", \"a7\\ne5\\n\", \"c5\\na2\\n\", \"f5\\nd2\\n\", \"h8\\nf1\\n\", \"b3\\na5\\n\", \"f1\\nc5\\n\", \"a6\\n... | The king is left alone on the chessboard. In spite of this loneliness, he doesn't lose heart, because he has business of national importance. For example, he has to pay an official visit to square t. As the king is not in habit of wasting his time, he wants to get from his current position s to square t in the least nu... | 0.625 |
{"tests": "{\"inputs\": [\"4\\n1 3 3 1\\n\", \"5\\n2 4 1 4 8\\n\", \"1\\n1\\n\", \"7\\n766 766 1477 766 107 1774 990\\n\", \"6\\n3 8 3 9 3 10\\n\", \"11\\n1552 1010 1552 1248 1550 388 1541 1010 613 1821 388\\n\", \"6\\n5 1 2 5 2 4\\n\", \"19\\n895 1302 724 952 340 952 939 1302 724 952 939 340 340 1844 770 976 435 1302 ... | It's time polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got down to business. In total, there are n tasks for the day and each animal should do each of these tasks. For each task, they have evaluated its difficulty. Also animals decided to do the tasks in order... | 0 |
{"tests": "{\"inputs\": [\"4\\n31\\n23\\n**\\n31\\n23\\n**\\n13\\n32\\n**\\n32\\n13\\n\", \"4\\n51\\n26\\n**\\n54\\n35\\n**\\n25\\n61\\n**\\n45\\n53\\n\", \"4\\n36\\n44\\n**\\n32\\n46\\n**\\n66\\n41\\n**\\n64\\n34\\n\", \"3\\n14\\n54\\n**\\n45\\n41\\n**\\n12\\n22\\n\", \"7\\n21\\n33\\n**\\n33\\n12\\n**\\n32\\n31\\n**\\... | Cheaterius is a famous in all the Berland astrologist, magician and wizard, and he also is a liar and a cheater. One of his latest inventions is Cheaterius' amulets! They bring luck and wealth, but are rather expensive. Cheaterius makes them himself. The technology of their making is kept secret. But we know that throu... | 0 |
{"tests": "{\"inputs\": [\"2 1 2\\n1 10\\n5 9\\n\", \"5 9 2\\n15 18\\n13 15\\n9 16\\n5 21\\n10 11\\n\", \"3 1 1\\n1 2\\n1 1000000000\\n999999999 1000000000\\n\", \"3 1000000000 1000000000\\n1 2\\n1 1000000000\\n999999999 1000000000\\n\", \"1 9 2\\n8 11\\n\", \"3 1 1000000000\\n1 2\\n1 1000000000\\n999999999 1000000000\... | For months Maxim has been coming to work on his favorite bicycle. And quite recently he decided that he is ready to take part in a cyclists' competitions.
He knows that this year n competitions will take place. During the i-th competition the participant must as quickly as possible complete a ride along a straight lin... | 0 |
{"tests": "{\"inputs\": [\"7\\n\", \"3\\n\", \"26\\n\", \"851838979\\n\", \"24\\n\", \"533568904697339792\\n\", \"27\\n\", \"780694167817136918\\n\", \"249781780\\n\", \"138919367769131403\\n\", \"196006607922989510\\n\", \"973034514\\n\", \"30\\n\", \"565840809656836956\\n\", \"109561818187625921\\n\", \"2282969219676... | Ayrat is looking for the perfect code. He decided to start his search from an infinite field tiled by hexagons. For convenience the coordinate system is introduced, take a look at the picture to see how the coordinates of hexagon are defined:
<image> <image> Ayrat is searching through the field. He started at point (... | 0 |
{"tests": "{\"inputs\": [\"7 1\\n\", \"10 2\\n\", \"955067149029 42\\n\", \"340506728610 27\\n\", \"261777837818 43\\n\", \"96000000673 3\\n\", \"641 2000\\n\", \"937746931140 51\\n\", \"289393192315 4\\n\", \"23566875403 21584772251\\n\", \"549755813888 100000\\n\", \"331725641503 251068357277\\n\", \"999999999937 100... | The Holmes children are fighting over who amongst them is the cleverest.
Mycroft asked Sherlock and Eurus to find value of f(n), where f(1) = 1 and for n ≥ 2, f(n) is the number of distinct ordered positive integer pairs (x, y) that satisfy x + y = n and gcd(x, y) = 1. The integer gcd(a, b) is the greatest common divi... | 0 |
{"tests": "{\"inputs\": [\"7\\nadd 3\\nadd 2\\nadd 1\\nremove\\nadd 4\\nremove\\nremove\\nremove\\nadd 6\\nadd 7\\nadd 5\\nremove\\nremove\\nremove\\n\", \"3\\nadd 1\\nremove\\nadd 2\\nadd 3\\nremove\\nremove\\n\", \"2\\nadd 2\\nadd 1\\nremove\\nremove\\n\", \"4\\nadd 1\\nadd 2\\nremove\\nremove\\nadd 4\\nadd 3\\nremov... | Okabe and Super Hacker Daru are stacking and removing boxes. There are n boxes numbered from 1 to n. Initially there are no boxes on the stack.
Okabe, being a control freak, gives Daru 2n commands: n of which are to add a box to the top of the stack, and n of which are to remove a box from the top of the stack and thr... | 0 |
{"tests": "{\"inputs\": [\"2\\n2\\n1548\\n\\nSAMPLE\", \"100\\n826555\\n29937\\n82698\\n346981\\n490420\\n801306\\n142167\\n948126\\n190048\\n472464\\n365458\\n533781\\n651062\\n950909\\n890012\\n952976\\n974090\\n791611\\n937512\\n738134\\n846008\\n922994\\n490878\\n750703\\n484277\\n83339\\n29296\\n849174\\n670039\\n... | Little Deepu and Little Kuldeep are the two best warriors in the realm of Westeros. But, their priorities and their loyalties are very much divided. Little Kuldeep fights for the right, just while Little Deepu fights for the wrong reasons, and supports the wrong ones in the kingdom. Everyone's scared of these two warr... | 0.375 |
{"tests": "{\"inputs\": [\"2\\n5 3\\n1 2\\n3 4\\n2 5\\n4 3\\n1 2\\n1 3\\n1 4\\n\\nSAMPLE\", \"2\\n5 3\\n1 2\\n3 4\\n2 5\\n4 1\\n1 2\\n1 3\\n1 4\\n\\nSAMPLE\", \"2\\n5 3\\n1 2\\n3 3\\n2 5\\n4 3\\n1 2\\n1 3\\n1 4\\n\\nSAMPLE\", \"2\\n5 3\\n1 2\\n3 4\\n2 5\\n4 3\\n1 2\\n1 4\\n1 4\\n\\nSAMPLE\", \"2\\n5 3\\n1 2\\n3 3\\n2 5... | There is a sale in the market on clothes , so as usual N girls gathered there to grab great deals.But due to huge popularity of sale crowd has gone uncontrollable. You being head of management team of the mall has been assigned the task to make them form a queue so that everyone can shop turn-wise.
Since queue is going... | 0 |
{"tests": "{\"inputs\": [\"2\\n5\\nabcdef\\n4\\nabcdefSAMPLE\", \"2\\n6\\nabcdef\\n4\\nabcdefSAMPLE\", \"2\\n10\\nabcdef\\n4\\nabcdefLAMPSE\", \"2\\n10\\nabbdef\\n4\\nabcdefKAMPSE\", \"2\\n6\\nabcdef\\n3\\nabcdefSAMPLE\", \"2\\n6\\nabcdeg\\n3\\nabcdefSAMPLE\", \"2\\n1\\nabcdef\\n8\\nabcdefLAMPSE\", \"2\\n8\\nabcdeg\\n3... | Given a string S which contains only lowercase characters ['a'-'z'] and an integer K you have to find number of substrings having weight equal to K.
Weight of characters is defined as :
Weight['a']=1
Weight['b']=2
Weight['c']=3
Weight['d']=4
Weight['e']=5
Weight['f']=6
Weight['g']=7
Weight['h']=8
Weight['i']=9
W... | 0 |
{"tests": "{\"inputs\": [\"3 8\\n4 2 1\\n2 3 1\", \"3 5\\n4 2 1\\n2 3 1\", \"11 14\\n3 1 4 1 5 9 2 6 5 3 5\\n8 9 7 9 3 2 3 8 4 6 2\", \"3 1\\n4 2 1\\n2 3 1\", \"3 6\\n4 2 1\\n2 3 1\", \"11 14\\n3 1 4 1 5 9 2 6 5 3 5\\n8 9 7 9 3 1 3 8 4 6 2\", \"3 1\\n8 2 1\\n2 3 1\", \"11 14\\n3 1 4 1 2 9 2 6 5 3 5\\n8 9 7 26 3 1 3 8 4... | Takahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The consumption coefficient of Member i is A_i.
In the contest, N foods numbered 1 through N will be presented, and the difficulty of ... | 0 |
{"tests": "{\"inputs\": [\"ABCACCBABCBCAABCB\", \"C\", \"ABCABC\", \"ABBACCBACCBCAABCB\", \"B\", \"ACBAACBCCABCCBBBA\", \"ABCAACBCAABCCBBBC\", \"ACCAAABCAABCCBBBC\", \"CBAABC\", \"ABBBCCBACCBCAABCB\", \"D\", \"DBAABC\", \"ABBBCCBACCBCAABCA\", \"E\", \"DBAAAC\", \"F\", \"DAAAAC\", \"ACBAACBCAABCCBBBC\", \"A\", \"AAADAC\... | You are given a string s consisting of `A`, `B` and `C`.
Snuke wants to perform the following operation on s as many times as possible:
* Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.
Find the maximum possible number of operations.
Constraints
* 1 \leq |s| \leq 200000
* Each char... | 0.25 |
{"tests": "{\"inputs\": [\"3 2 6\", \"3 1 3\", \"5 10 1\", \"0 2 6\", \"3 1 0\", \"8 10 1\", \"1 2 6\", \"-2 0 0\", \"0 -1 4\", \"-1 -1 4\", \"-1 -1 7\", \"-1 -2 7\", \"0 0 7\", \"2 0 14\", \"2 1 14\", \"0 1 14\", \"1 2 18\", \"0 2 16\", \"0 1 24\", \"0 1 18\", \"0 1 36\", \"0 0 36\", \"2 0 36\", \"0 0 61\", \"0 -1 61\... | AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the ho... | 0.875 |
{"tests": "{\"inputs\": [\"(1-10*i)+00007+(3+10*i)\\n3+4*i*(4+10*i)\\n(102+10*i)*(99+10*i)\\n2*i+3+9999*i+4\", \"(1-10*i)+00007+(3+10*i)\\n3+5*i*(4+10*i)\\n(102+10*i)*(99+10*i)\\n2*i+3+9999*i+4\", \"(1-10*i)+00007+(3+10*i)\\n3+5*i*(4+10*i)\\n(102*10*i)*(99+10*i)\\n2*i+3+9999*i+4\", \"(1-10*i)+00007+(3+10*i)\\n3+5*i*(4+... | Write a program to calculate values of arithmetic expressions which may involve complex numbers. Details of the expressions are described below.
In this problem, basic elements of expressions are non-negative integer numbers and the special symbol "`i`". Integer numbers are sequences of digits of arbitrary length and ... | 0.125 |
{"tests": "{\"inputs\": [\"8\\n-7 9 6 9\\n-5 5 6 5\\n-10 -5 10 -5\\n-6 9 -9 -6\\n6 9 9 -6\\n-1 -2 -3 10\\n1 -2 3 10\\n-2 -3 2 -3\\n8\\n-7 9 5 7\\n-5 5 6 5\\n-10 -5 10 -5\\n-6 9 -9 -6\\n6 9 9 -6\\n-1 -2 -3 10\\n1 -2 3 10\\n-2 -3 2 -3\\n0\", \"8\\n-7 9 6 9\\n-5 5 6 5\\n-10 -5 10 -5\\n-6 9 -9 -1\\n6 9 9 -6\\n-1 -2 -3 10\\... | Once upon a time when people still believed in magic, there was a great wizard Aranyaka Gondlir. After twenty years of hard training in a deep forest, he had finally mastered ultimate magic, and decided to leave the forest for his home.
Arriving at his home village, Aranyaka was very surprised at the extraordinary des... | 0 |
{"tests": "{\"inputs\": [\"5 3\", \"5 4\", \"2 4\", \"4 4\", \"7 4\", \"7 3\", \"11 3\", \"7 2\", \"17 3\", \"31 3\", \"25 3\", \"25 2\", \"25 4\", \"6 2\", \"6 3\", \"10 3\", \"4 5\", \"12 8\", \"24 3\", \"31 4\", \"30 3\", \"27 2\", \"17 8\", \"48 3\", \"30 2\", \"30 8\", \"37 3\", \"14 2\", \"13 5\", \"30 10\", \"37... | Problem A Secret of Chocolate Poles
Wendy, the master of a chocolate shop, is thinking of displaying poles of chocolate disks in the showcase. She can use three kinds of chocolate disks: white thin disks, dark thin disks, and dark thick disks. The thin disks are $1$ cm thick, and the thick disks are $k$ cm thick. Disk... | 0.125 |
{"tests": "{\"inputs\": [\"4 5 2\\n1 2 2 A\\n1 3 2 A\\n1 4 2 A\\n2 3 1 B\\n3 4 1 B\\n5 8 2\\n1 2 1 A\\n2 3 1 A\\n3 4 3 A\\n4 5 3 A\\n1 2 5 B\\n2 3 5 B\\n3 4 8 B\\n4 5 8 B\\n5 5 1\\n1 2 1 A\\n2 3 1 A\\n3 4 1 A\\n4 5 1 B\\n3 5 1 B\\n4 5 3\\n1 2 2 A\\n2 4 3 B\\n3 4 4 B\\n2 3 5 A\\n3 1 6 A\\n0 0 0\", \"4 5 2\\n1 2 2 A\\n1 ... | Bridge Construction Planning
There is a city consisting of many small islands, and the citizens live in these islands. Citizens feel inconvenience in requiring ferry rides between these islands. The city mayor decided to build bridges connecting all the islands.
The city has two construction companies, A and B. The m... | 0.25 |
{"tests": "{\"inputs\": [\"4\\n4 6\\n*.*..*\\n*.....\\n..-...\\n^.*#..\\n10\\nSRSSRRUSSR\\n2 2\\n<.\\n..\\n12\\nDDSRRSUUSLLS\\n3 5\\n>-#**\\n.-*#*\\n.-**#\\n15\\nSSSDRSSSDRSSSUU\\n5 5\\nv****\\n*****\\n*****\\n*****\\n*****\\n44\\nSSSSDDRSDRSRDSULUURSSSSRRRRDSSSSDDLSDLSDLSSD\", \"4\\n4 6\\n*.*..*\\n*.....\\n...-..\\n^.... | You decide to develop a game with your friends. The title of the game is "Battle Town". This is a game with the theme of urban warfare with tanks. As the first step in game development, we decided to develop the following prototype.
In this prototype, the only tanks that appear are the player's tanks, not the enemy ta... | 0.125 |
{"tests": "{\"inputs\": [\"1\\n12\\n123\\n369\\n6748\\n4247219123\\n1232123212321232\", \"1\\n12\\n123\\n369\\n6748\\n4247219123\\n1232123212321232\\n#\", \"1\\n2\\n123\\n369\\n6748\\n4247219123\\n1232123212321232\", \"1\\n12\\n123\\n369\\n2355\\n868736334\\n1232123212321232\\n#\", \"1\\n12\\n154\\n369\\n6748\\n4247219... | Japanese video game company has developed the music video game called Step Step Evolution. The gameplay of Step Step Evolution is very simple. Players stand on the dance platform, and step on panels on it according to a sequence of arrows shown in the front screen.
There are eight types of direction arrows in the Step... | 0 |
{"tests": "{\"inputs\": [\"0.0\", \"(1.1)\", \"...\", \"0-1.\", \"000\", \"0.010621136904092388\", \"0.1.\", \"100\", \".01.\", \"101\", \".10.\", \"010\", \".00.\", \"110\", \"011\", \"001\", \".0.0\", \".1.0\", \"..00\", \"(.11)\", \"0.504714885606491\", \"(.1)1\", \"1.3688811760808033\", \"(-1)1\", \"1)1-(\", \"1-1)... | The time was 3xxx, and the highly developed civilization was in a stagnation period. Historians decided to learn the wisdom of the past in an attempt to overcome this situation. What I paid attention to was the material left by the genius of the early days of computers. The calculation formula is written in this materi... | 0 |
{"tests": "{\"inputs\": [\"2 2\\n100 -1\\n200 300\", \"2 2\\n100 -1\\n200 62\", \"2 2\\n110 -1\\n200 62\", \"2 2\\n111 -1\\n200 62\", \"2 2\\n100 -1\\n200 398\", \"2 2\\n100 -1\\n200 37\", \"2 2\\n110 -1\\n200 85\", \"2 2\\n111 -1\\n42 62\", \"2 1\\n100 -1\\n200 37\", \"2 2\\n100 -1\\n200 85\", \"2 1\\n101 -1\\n200 37\... | D --Invisible
Problem Statement
You are trying to play a card game called "Invisible" with your friends. This card game uses two types of cards, a "scoring card" and a "jamming card". A positive value is written on each score card. The rules of this card game are as follows.
* The game is played by two players, play... | 0 |
{"tests": "{\"inputs\": [\"4\\n6 5\\n16 13\\n61690850361 24777622630\\n34 33\\n\", \"1\\n5484081721 5484081720\\n\", \"1\\n5 4\\n\", \"5\\n529 169\\n232 231\\n283 282\\n217 216\\n34310969148 14703433301\\n\", \"1\\n3121 3120\\n\", \"1\\n25 24\\n\", \"5\\n45925060463 34682596536\\n34161192623 19459231506\\n74417875602 2... | Alice has a lovely piece of cloth. It has the shape of a square with a side of length a centimeters. Bob also wants such piece of cloth. He would prefer a square with a side of length b centimeters (where b < a). Alice wanted to make Bob happy, so she cut the needed square out of the corner of her piece and gave it to ... | 0.875 |
{"tests": "{\"inputs\": [\"3 1 -9\\n0 3 3 -1\\n\", \"1 1 -3\\n0 3 3 0\\n\", \"10 4 8\\n2 8 -10 9\\n\", \"3 0 -324925900\\n-97093162 612988987 134443035 599513203\\n\", \"0 2 -866705865\\n394485460 465723932 89788653 -50040527\\n\", \"3 0 407398974\\n-665920261 551867422 -837723488 503663817\\n\", \"664808710 -309024147... | In this problem we consider a very simplified model of Barcelona city.
Barcelona can be represented as a plane with streets of kind x = c and y = c for every integer c (that is, the rectangular grid). However, there is a detail which makes Barcelona different from Manhattan. There is an avenue called Avinguda Diagonal... | 0 |
{"tests": "{\"inputs\": [\"7 4\\n1 3 1 2 2 4 3\\n\", \"3 3\\n2 3 1\\n\", \"8 8\\n6 2 1 8 5 7 3 4\\n\", \"4 7\\n3 6 2 4\\n\", \"3 3\\n3 1 3\\n\", \"10 10\\n5 1 6 2 8 3 4 10 9 7\\n\", \"5 3\\n2 1 2 2 2\\n\", \"2 3\\n3 2\\n\", \"9 8\\n6 1 7 4 3 4 1 8 3\\n\", \"2 18\\n7 13\\n\", \"2 20\\n1 8\\n\", \"10 5\\n5 1 2 2 3 3 4 4 ... | You are given an array consisting of n integers a_1, a_2, ... , a_n and an integer x. It is guaranteed that for every i, 1 ≤ a_i ≤ x.
Let's denote a function f(l, r) which erases all values such that l ≤ a_i ≤ r from the array a and returns the resulting array. For example, if a = [4, 1, 1, 4, 5, 2, 4, 3], then f(2, 4... | 0 |
{"tests": "{\"inputs\": [\"2 2\\n\", \"2 0\\n\", \"0 2\\n\", \"2000 2000\\n\", \"1994 1981\\n\", \"2000 0\\n\", \"976 1698\\n\", \"756 1061\\n\", \"1028 1040\\n\", \"27 16\\n\", \"1991 1992\\n\", \"983 666\\n\", \"60 59\\n\", \"5 13\\n\", \"872 1313\\n\", \"1935 856\\n\", \"1915 1915\\n\", \"45 1323\\n\", \"11 2\\n\", ... | Natasha's favourite numbers are n and 1, and Sasha's favourite numbers are m and -1. One day Natasha and Sasha met and wrote down every possible array of length n+m such that some n of its elements are equal to 1 and another m elements are equal to -1. For each such array they counted its maximal prefix sum, probably a... | 0 |
{"tests": "{\"inputs\": [\"2\\n2 3\\n5\\n2 1 1\\n2 2 1\\n1 1 1\\n2 1 2\\n2 2 0\\n\", \"3\\n3 1 1\\n6\\n1 1 1\\n1 2 1\\n1 2 2\\n1 1 2\\n1 1 3\\n1 2 3\\n\", \"2\\n2 2\\n5\\n1 1 2\\n1 1 0\\n1 1 1\\n1 1 0\\n1 1 2\\n\", \"2\\n4 4\\n9\\n1 1 1\\n1 2 1\\n1 3 1\\n2 1 2\\n2 2 2\\n2 3 2\\n2 3 1\\n2 2 1\\n2 1 1\\n\", \"1\\n30\\n1\... | Bob is playing a game of Spaceship Solitaire. The goal of this game is to build a spaceship. In order to do this, he first needs to accumulate enough resources for the construction. There are n types of resources, numbered 1 through n. Bob needs at least a_i pieces of the i-th resource to build the spaceship. The numbe... | 0 |
{"tests": "{\"inputs\": [\"6\\n2 2 1 2\\n0 100 0 1\\n12 13 25 1\\n27 83 14 25\\n0 0 1 0\\n1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000\\n\", \"1\\n0 0 0 1\\n\", \"1\\n1 0 0 1\\n\", \"6\\n2 2 1 2\\n0 100 0 1\\n11 13 25 1\\n27 83 14 25\\n0 0 1 0\\n1000000000000000000 1000000000000000000... | Anna is a girl so brave that she is loved by everyone in the city and citizens love her cookies. She is planning to hold a party with cookies. Now she has a vanilla cookies and b chocolate cookies for the party.
She invited n guests of the first type and m guests of the second type to the party. They will come to the ... | 0.25 |
{"tests": "{\"inputs\": [\"3\\n1 1\\n3 1 2\\n\", \"3\\n1 1\\n3 1 3\\n\", \"2\\n1\\n293175439 964211398\\n\", \"50\\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49\\n82 30 98 3 92 42 28 41 90 67 83 5 2 77 38 39 96 22 18 37 88 42 9... | Bandits appeared in the city! One of them is trying to catch as many citizens as he can.
The city consists of n squares connected by n-1 roads in such a way that it is possible to reach any square from any other square. The square number 1 is the main square.
After Sunday walk all the roads were changed to one-way ro... | 0 |
{"tests": "{\"inputs\": [\"4\\n2 3\\n.*.\\n***\\n2 3\\n.*.\\n**.\\n4 5\\n.***.\\n*****\\n*****\\n*.*.*\\n5 7\\n..*.*..\\n.*****.\\n*******\\n.*****.\\n..*.*..\\n\", \"6\\n4 7\\n...*...\\n..***..\\n.****..\\n*******\\n6 10\\n....*.*...\\n...*****..\\n..*******.\\n.********.\\n********.*\\n**********\\n5 5\\n*...*\\n**.*... | Holidays are coming up really soon. Rick realized that it's time to think about buying a traditional spruce tree. But Rick doesn't want real trees to get hurt so he decided to find some in an n × m matrix consisting of "*" and ".".
<image>
To find every spruce first let's define what a spruce in the matrix is. A set ... | 0.75 |
{"tests": "{\"inputs\": [\"4\\n3 4\\n0000\\n00#0\\n0000\\n2 1\\n#\\n#\\n1 2\\n##\\n6 29\\n#############################\\n#000##0###0##0#0####0####000#\\n#0#0##00#00##00####0#0###0#0#\\n#0#0##0#0#0##00###00000##00##\\n#000##0###0##0#0##0###0##0#0#\\n#############################\\n\", \"1\\n12 12\\n#000#0#0##00\\n0####... | Omkar's most recent follower, Ajit, has entered the Holy Forest. Ajit realizes that Omkar's forest is an n by m grid (1 ≤ n, m ≤ 2000) of some non-negative integers. Since the forest is blessed by Omkar, it satisfies some special conditions:
1. For any two adjacent (sharing a side) cells, the absolute value of the d... | 0 |
{"tests": "{\"inputs\": [\"7 39\\n.......................................\\n.###..###..#..###.....###..###..#..###.\\n...#..#.#..#..#.........#..#.#..#..#...\\n.###..#.#..#..###.....###..#.#..#..###.\\n.#....#.#..#....#.....#....#.#..#..#.#.\\n.###..###..#..###.....###..###..#..###.\\n..................................... | They say "years are like dominoes, tumbling one after the other". But would a year fit into a grid? I don't think so.
Limak is a little polar bear who loves to play. He has recently got a rectangular grid with h rows and w columns. Each cell is a square, either empty (denoted by '.') or forbidden (denoted by '#'). Row... | 0 |
{"tests": "{\"inputs\": [\"1\\n1 2 3\\n4 5 6\\n20 10\\n1 2 3\\n\", \"4\\n0 0 0\\n0 10 0\\n10 10 0\\n10 0 0\\n0 0 0\\n1 1\\n5 5 50\\n\", \"4\\n0 0 0\\n0 10 0\\n10 10 0\\n10 0 0\\n0 0 0\\n1 1\\n5 5 25\\n\", \"20\\n26 47 23\\n1 -2 17\\n-14 -22 46\\n19 34 -18\\n22 -10 -34\\n15 14 -48\\n-30 -12 -12\\n-23 40 -48\\n-50 -41 -3... | Brothers Fred and George Weasley once got into the sporting goods store and opened a box of Quidditch balls. After long and painful experiments they found out that the Golden Snitch is not enchanted at all. It is simply a programmed device. It always moves along the same trajectory, which is a polyline with vertices at... | 0 |
{"tests": "{\"inputs\": [\"2 1 0\\n1 2\\n2 2\\n\", \"2 0 0\\n1 2\\n2 3\\n\", \"2 5 7\\n3 4\\n14 4\\n\", \"1 5 7\\n1\\n2\\n\", \"10 300 517\\n-6 -2 6 5 -3 8 9 -10 8 6\\n5 -9 -2 6 1 4 6 -2 5 -3\\n\", \"2 1 3\\n2 2\\n2 2\\n\", \"2 0 1\\n1 2\\n2 2\\n\", \"1 1 2\\n0\\n8\\n\", \"3 1 4\\n0 0 0\\n1 5 6\\n\", \"1 0 6\\n0\\n0\\n... | You are given two arrays A and B, each of size n. The error, E, between these two arrays is defined <image>. You have to perform exactly k1 operations on array A and exactly k2 operations on array B. In one operation, you have to choose one element of the array and increase or decrease it by 1.
Output the minimum poss... | 0.25 |
{"tests": "{\"inputs\": [\"2\\n1 2\", \"3\\n2 3 1 4\", \"5\\n6 14 15 7 12 16 5 4 11 9 3 10 8 2 13 1\", \"2\\n2 3\", \"2\\n2 4\", \"2\\n2 1\", \"2\\n2 7\", \"2\\n3 4\", \"2\\n5 1\", \"2\\n6 3\", \"2\\n5 3\", \"3\\n7 3 1 4\", \"2\\n6 4\", \"2\\n6 1\", \"2\\n11 4\", \"2\\n2 8\", \"2\\n6 5\", \"2\\n12 1\", \"2\\n11 3\", \"... | Inspired by the tv series Stranger Things, bear Limak is going for a walk between two mirror worlds.
There are two perfect binary trees of height H, each with the standard numeration of vertices from 1 to 2^H-1. The root is 1 and the children of x are 2 \cdot x and 2 \cdot x + 1.
Let L denote the number of leaves in ... | 0 |
{"tests": "{\"inputs\": [\"5 6\\n1 3\\n1 4\\n2 3\\n1 5\\n3 5\\n2 4\", \"7 8\\n1 2\\n2 3\\n3 4\\n4 5\\n5 6\\n6 7\\n3 5\\n2 6\", \"7 8\\n1 4\\n2 3\\n3 4\\n4 5\\n5 6\\n6 7\\n3 5\\n2 6\", \"5 6\\n1 3\\n1 4\\n2 3\\n1 5\\n3 5\\n3 4\", \"7 8\\n1 4\\n2 4\\n3 4\\n4 5\\n5 6\\n6 7\\n3 5\\n2 6\", \"7 8\\n1 4\\n2 3\\n3 4\\n4 1\\n5 ... | You are given a connected undirected simple graph, which has N vertices and M edges. The vertices are numbered 1 through N, and the edges are numbered 1 through M. Edge i connects vertices A_i and B_i. Your task is to find a path that satisfies the following conditions:
* The path traverses two or more vertices.
* The... | 0 |
{"tests": "{\"inputs\": [\"7\\n1 4 2 5 4 3\\n2 1 5\\n3 1 6\\n4 1 7\\n5 2 7 6\\n6 1 1\\n7 0\\n6\\n1 2 2\\n1 5 3\\n1 2 1\\n5 1 3\\n6 3 3\\n1 7 4\", \"7\\n1 4 2 5 4 3\\n2 1 5\\n3 1 6\\n4 1 7\\n5 2 7 6\\n6 1 1\\n7 0\\n6\\n1 2 2\\n1 5 3\\n1 2 0\\n5 1 3\\n6 3 3\\n1 7 4\", \"7\\n1 4 2 5 4 6\\n2 1 5\\n3 1 6\\n4 1 7\\n5 2 7 6\\... | On the Internet, data is divided into packets, and each packet is transferred to a destination via a relay device called a router. Each router determines the next router to forward from the destination described in the packet. In addition, a value called TTL (Time To Live) is added to the packet to prevent it from bein... | 0 |
{"tests": "{\"inputs\": [\"5\\n2 2 1 2\\n9 5\\n1 17\\n3 2 2 1\\n6 1 20\\n8 18 3\\n8\\n5 4 1 3\\n5 5 4 5 5\\n8 2 1 9 7\\n1 1 3 5 1\\n7 2 7 1 3\\n6 5 6 2\\n2 3 5 8 2 7\\n1 6 9 4 5 1\\n2 4 5 4 2 2\\n5 4 2 5 3 3\\n7 1 5 1 5 6\\n6\\n3 3 2 2\\n2 9 2\\n9 1 9\\n2 9 2\\n2 2 1 1\\n1 3\\n5 7\\n0\", \"5\\n2 2 1 2\\n9 5\\n1 17\\n3 ... | problem
Do you know Just Odd Inventions? The business of this company is to "just odd inventions". Here we call it JOI for short.
JOI has two offices, each of which has square rooms of the same size arranged in a grid pattern. All the rooms that are in contact with each other have an ID card authentication function. ... | 0 |
{"tests": "{\"inputs\": [\"abcabcaxcabc\\n4\\n1 9 3\\n8 12 3\\n1 4 2\\n2 3 2\", \"abcabcaxcabc\\n2\\n1 9 3\\n8 12 3\\n1 4 2\\n2 3 2\", \"abcabcaxcabc\\n2\\n0 9 3\\n8 12 3\\n0 0 1\\n4 5 1\", \"abcabcaxcabc\\n4\\n1 15 3\\n8 12 3\\n1 4 2\\n2 3 2\", \"abcabcaxcabc\\n2\\n0 9 3\\n8 12 2\\n0 0 1\\n4 5 1\", \"abcabcaxcabc\\n4\... | Almost periodic string
Given the string S. Answer Q queries for this string S. In the i-th query, determine if S [l_i, \ r_i] can be a string of period t_i when you can change from S [l_i, \ r_i] to one character. S [l, \ r] represents the substring of the string S from the lth to the rth.
If the character string W i... | 0 |
{"tests": "{\"inputs\": [\"20\\n350\", \"10\\n20\", \"20\\n594\", \"10\\n26\", \"20\\n704\", \"10\\n27\", \"20\\n41\", \"10\\n15\", \"20\\n2\", \"10\\n29\", \"20\\n0\", \"10\\n52\", \"20\\n1\", \"10\\n86\", \"20\\n-1\", \"10\\n55\", \"20\\n-2\", \"10\\n80\", \"20\\n-4\", \"10\\n45\", \"20\\n-7\", \"10\\n83\", \"20\\n-1... | Problem
Find the angle between the two given angles θ1 and θ2. Here, the angle between them is defined as "θ1 & plus; t'when t'is the one with the smallest absolute value among the t satisfying θ1 & plus; t = θ2 − t" as shown in the figure below.
A image of angles
Constraints
The input satisfies the following condi... | 0.125 |
{"tests": "{\"inputs\": [\"3\\n1 10\\n2 12\\n100 10000\", \"3\\n1 10\\n1 12\\n100 10000\", \"3\\n1 20\\n1 12\\n100 10010\", \"3\\n1 20\\n1 11\\n100 10110\", \"3\\n1 10\\n2 12\\n100 10010\", \"3\\n1 20\\n2 12\\n100 10000\", \"3\\n2 20\\n1 12\\n100 10010\", \"3\\n1 20\\n1 11\\n100 11110\", \"3\\n1 10\\n2 3\\n100 10010\",... | The electrical resistance is the opposition to the passage of electric current. If two resistors with resistance R1 and R2 are connected to each other, the resultant resistance R depends on how their ends are connected. If they are connected in Series, they simply add up to give R = R1 + R2. If they are connected in Pa... | 0.125 |
{"tests": "{\"inputs\": [\"5 5\\n2 4 3 2 1\", \"5 5\\n2 4 9 2 5\", \"5 8\\n2 4 3 2 1\", \"5 5\\n2 4 3 4 1\", \"5 8\\n2 4 5 3 1\", \"4 5\\n2 4 3 3 1\", \"3 5\\n2 4 9 2 5\", \"5 8\\n2 4 3 3 1\", \"3 4\\n2 4 9 2 5\", \"5 8\\n2 4 4 3 1\", \"5 4\\n2 4 9 2 5\", \"5 8\\n2 4 4 3 0\", \"5 8\\n2 4 4 2 0\", \"5 8\\n1 4 4 2 0\", \... | In Chef's house there are N apples lying in a row on the floor. These apples are numbered from 1 (left most one) to N (right most one). The types of apples are also numbered by positive integers, and the type of apple i is Ti.
Chef has recently brought two trained dogs. Both of the dogs are too intelligent to know the ... | 0.375 |
{"tests": "{\"inputs\": [\"3 4\\n0 0\\n0 2\\n2 0\\n0 2\\n2 2\\n2 0\\n1 1\\n\", \"3 4\\n0 0\\n0 2\\n2 0\\n0 2\\n2 2\\n2 0\\n0 0\\n\", \"3 3\\n1 1\\n2 2\\n3 3\\n1 1\\n1 2\\n1 3\\n\", \"5 5\\n2 0\\n0 4\\n4 8\\n8 4\\n10 0\\n0 2\\n2 6\\n6 10\\n10 6\\n8 2\\n\", \"6 3\\n0 0\\n1 1\\n2 2\\n3 3\\n4 4\\n5 5\\n0 6\\n3 3\\n6 0\\n\"... | After the war, the supersonic rocket became the most common public transportation.
Each supersonic rocket consists of two "engines". Each engine is a set of "power sources". The first engine has n power sources, and the second one has m power sources. A power source can be described as a point (x_i, y_i) on a 2-D plan... | 0 |
{"tests": "{\"inputs\": [\"4 2 6 4\\n\", \"1000000000000000000 1000000000000000000 999999866000004473 999999822000007597\\n\", \"14 16 7 22\\n\", \"17 15 5 3\\n\", \"500 500 1000000000000000000 1\\n\", \"281474976710656 1 1 281474976710656\\n\", \"100 81 10 9\\n\", \"100000 1 3 2\\n\", \"3 3 2 4\\n\", \"1043706193704 1... | Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV sets with a certain aspect ratio: formally, if the width of the screen is w, an... | 0.75 |
{"tests": "{\"inputs\": [\"3 3 2\\n1 1\\n1..\\n...\\n..2\\n\", \"3 4 4\\n1 1 1 1\\n....\\n#...\\n1234\\n\", \"4 4 2\\n5 1\\n1#.2\\n.#..\\n.##.\\n....\\n\", \"2 3 2\\n1 2\\n...\\n21.\\n\", \"3 8 3\\n1 1 1\\n.222.321\\n2.##3.31\\n2#1.2131\\n\", \"3 3 2\\n4 1\\n1#2\\n.#.\\n...\\n\", \"3 7 1\\n1\\n###11..\\n1...11.\\n.1#1#... | Kilani is playing a game with his friends. This game can be represented as a grid of size n × m, where each cell is either empty or blocked, and every player has one or more castles in some cells (there are no two castles in one cell).
The game is played in rounds. In each round players expand turn by turn: firstly, t... | 0.125 |
{"tests": "{\"inputs\": [\"6\\n(?????\\n\", \"10\\n(???(???(?\\n\", \"30\\n((??)?)???(????(????)???????((\\n\", \"6\\n))??((\\n\", \"4\\n??(?\\n\", \"6\\n((?())\\n\", \"300\\n)?)???????(?????????)??)??)?)??)??()???)??)??????????(?)???(?????)????????????????????)?????)???(???????)?????)?)??????????????))????(?)??????)??... | Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | 0 |
{"tests": "{\"inputs\": [\"3\\n3 1\\n4 2\\n69 6\\n\", \"1\\n241139 1\\n\", \"1\\n2441139 10\\n\", \"1\\n2452199 2\\n\", \"1\\n244139 1\\n\", \"1\\n2451199 2\\n\", \"1\\n244119 1\\n\", \"1\\n2441139 12\\n\", \"1\\n2441139 2\\n\", \"2\\n1000000000 1\\n1000000000 500000000\\n\", \"1\\n2441139 1\\n\", \"1\\n402805 1\\n\", ... | You have a list of numbers from 1 to n written from left to right on the blackboard.
You perform an algorithm consisting of several steps (steps are 1-indexed). On the i-th step you wipe the i-th number (considering only remaining numbers). You wipe the whole number (not one digit).
<image>
When there are less than ... | 0.75 |
{"tests": "{\"inputs\": [\")\\n)))\\n\", \"())\\n(()(()(()(\\n\", \")\\n((\\n\", \"(())(()\\n()))()\\n\", \"()))()))))())(()))))))))()()()(()))()((()()()(()))()()()()((((())))))()))))(((())(()))())(())((()(((\\n)\\n\", \")(()(((((()))(()))((()((((((()(())))((()()))()(())))(()))))()(()((((()(())))((()((((())(()))((())))... | You are given two bracket sequences (not necessarily regular) s and t consisting only of characters '(' and ')'. You want to construct the shortest regular bracket sequence that contains both given bracket sequences as subsequences (not necessarily contiguous).
Recall what is the regular bracket sequence:
* () is t... | 0 |
{"tests": "{\"inputs\": [\"3\\n101110\\n2\\n01\\n1\\n110\\n1\\n\", \"3\\n100110\\n2\\n01\\n1\\n110\\n1\\n\", \"3\\n100110\\n2\\n01\\n1\\n111\\n1\\n\", \"3\\n100110\\n2\\n01\\n2\\n011\\n1\\n\", \"3\\n000110\\n2\\n01\\n2\\n011\\n1\\n\", \"3\\n001110\\n2\\n01\\n2\\n111\\n1\\n\", \"3\\n001110\\n2\\n01\\n2\\n101\\n1\\n\", \... | Consider the following process. You have a binary string (a string where each character is either 0 or 1) w of length n and an integer x. You build a new binary string s consisting of n characters. The i-th character of s is chosen as follows:
* if the character w_{i-x} exists and is equal to 1, then s_i is 1 (forma... | 0.25 |
{"tests": "{\"inputs\": [\"2\\n2\\n1 1\\n2\\n1 1\\n\\n2\\n1 2\\n2\\n3 3\\n\", \"2\\n4\\n1 1 1 1\\n4\\n1 1 1 1\\n\\n3\\n2 1 1\\n3\\n2 1 1\\n\", \"2\\n4\\n1 4 1 2\\n4\\n3 4 5 12\\n\\n4\\n1 2 3 6\\n2\\n1 3\\n\", \"1\\n4\\n4 4 3 5\\n4\\n3 3 3 3\\n\", \"12\\n4\\n3 4 4 5\\n4\\n3 3 3 3\\n\\n4\\n3 4 5 4\\n4\\n3 3 3 3\\n\\n4\\n... | One drew a closed polyline on a plane, that consisted only of vertical and horizontal segments (parallel to the coordinate axes). The segments alternated between horizontal and vertical ones (a horizontal segment was always followed by a vertical one, and vice versa). The polyline did not contain strict self-intersecti... | 0 |
{"tests": "{\"inputs\": [\"7\\n4 2\\n0110\\n4 2\\n1001\\n9 3\\n010001110\\n9 3\\n101110001\\n10 3\\n0101110001\\n10 10\\n1111111111\\n11 10\\n11111111110\\n\", \"2\\n64 32\\n0000000001111111111111111111111011111111111111111111111111111111\\n66 33\\n000000000111111111111111111111110111111111111111111111111111111111\\n\"... | Let's call two strings a and b (both of length k) a bit similar if they have the same character in some position, i. e. there exists at least one i ∈ [1, k] such that a_i = b_i.
You are given a binary string s of length n (a string of n characters 0 and/or 1) and an integer k. Let's denote the string s[i..j] as the su... | 0 |
{"tests": "{\"inputs\": [\"3\\n2\\n0 1\\n1 0\\n0 -1\\n-2 0\\n4\\n1 0\\n3 0\\n-5 0\\n6 0\\n0 3\\n0 1\\n0 2\\n0 4\\n5\\n3 0\\n0 4\\n0 -3\\n4 0\\n2 0\\n1 0\\n-3 0\\n0 -10\\n0 -2\\n0 -10\\n\", \"3\\n2\\n0 1\\n1 0\\n0 -1\\n-2 0\\n4\\n1 0\\n3 0\\n-5 0\\n6 0\\n0 4\\n0 1\\n0 2\\n0 4\\n5\\n3 0\\n0 4\\n0 -3\\n4 0\\n2 0\\n1 0\\n-... | Diamond Miner is a game that is similar to Gold Miner, but there are n miners instead of 1 in this game.
The mining area can be described as a plane. The n miners can be regarded as n points on the y-axis. There are n diamond mines in the mining area. We can regard them as n points on the x-axis. For some reason, no m... | 0.125 |
{"tests": "{\"inputs\": [\"4 3\\n0 0\\n1 0\\n1 1\\n0 1\\n0 0 1 1\\n0 0 0 1\\n0 0 1 -1\\n\", \"4 9\\n0 0\\n0 1\\n1 1\\n1 0\\n0 0 1 1\\n1 1 0 0\\n0 0 1 0\\n0 0 0.5 0\\n0 0.5 1 0.5\\n0 1 1 1\\n1 1 1 0\\n0.75 0.75 0.75 0.25\\n0 0.25 1 0.75\\n\", \"3 1\\n2 2\\n100000 100000\\n-99999.99 -100000\\n100000 100000 -99999.99 -100... | Given simple (without self-intersections) n-gon. It is not necessary convex. Also you are given m lines. For each line find the length of common part of the line and the n-gon.
The boundary of n-gon belongs to polygon. It is possible that n-gon contains 180-degree angles.
Input
The first line contains integers n and... | 0 |
{"tests": "{\"inputs\": [\"3 1 10\\n\", \"3 3 10\\n\", \"1 1 10\\n\", \"2 6 9\\n\", \"3 100 1000000\\n\", \"19 1 10000000\\n\", \"10 100 1000000\\n\", \"7 1 5000000\\n\", \"5 1 5000000\\n\", \"18 1 10000000\\n\", \"8 100 1000000\\n\", \"10000000 1 1\\n\", \"5 25 845\\n\", \"6 100 1000000\\n\", \"13 100 1000000\\n\", \"... | For given n, l and r find the number of distinct geometrical progression, each of which contains n distinct integers not less than l and not greater than r. In other words, for each progression the following must hold: l ≤ ai ≤ r and ai ≠ aj , where a1, a2, ..., an is the geometrical progression, 1 ≤ i, j ≤ n and i ≠ j... | 0 |
{"tests": "{\"inputs\": [\"2 2 2\\n1 3\\n\", \"3 3 2\\n3 5 1\\n\", \"7 7 2\\n7 3 4 1 6 5 2\\n\", \"5 10 3\\n12 8 18 25 1\\n\", \"13 10 4\\n5 28 67 70 68 3 84 4 30 82 96 37 49\\n\", \"15 20 15\\n8 18 12 15 1 9 4 21 23 3 24 5 2 25 14\\n\", \"10 7 2\\n30 9 1 40 34 4 35 27 11 3\\n\", \"20 30 10\\n37 220 115 125 266 821 642... | Every evening Vitalya sets n alarm clocks to wake up tomorrow. Every alarm clock rings during exactly one minute and is characterized by one integer ai — number of minute after midnight in which it rings. Every alarm clock begins ringing at the beginning of the minute and rings during whole minute.
Vitalya will defin... | 0 |
{"tests": "{\"inputs\": [\"4 6 7 13\\n\", \"233 233 10007 1\\n\", \"2 3 5 8\\n\", \"66634 64950 66889 215112576953\\n\", \"339138 549930 999883 962863668031\\n\", \"699601 39672 1000003 1\\n\", \"28361 465012 1000003 12693229\\n\", \"533806 514846 1000003 999999999999\\n\", \"620328 378284 999983 189501757723\\n\", \"4... | Given an integer x. Your task is to find out how many positive integers n (1 ≤ n ≤ x) satisfy $$$n ⋅ a^n ≡ b (mod\;p), where a, b, p$$$ are all known constants.
Input
The only line contains four integers a,b,p,x (2 ≤ p ≤ 10^6+3, 1 ≤ a,b < p, 1 ≤ x ≤ 10^{12}). It is guaranteed that p is a prime.
Output
Print a sin... | 0.25 |
{"tests": "{\"inputs\": [\"0 1 1 0 0 0 0 0 0 7 0 0 0 0\\n\", \"5 1 1 1 1 0 0 0 0 0 0 0 0 0\\n\", \"787 393 649 463 803 365 81 961 989 531 303 407 579 915\\n\", \"10001 10001 10001 10001 10001 10001 10001 10001 10001 10001 10001 10001 10001 1\\n\", \"8789651 4466447 1218733 6728667 1796977 6198853 8263135 6309291 824290... | Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes.
<image>
Initially, each hole has a_i stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in th... | 0 |
{"tests": "{\"inputs\": [\"2\\naba\\nbaba\\nxy\\nzw\\n\\nSAMPLE\", \"2\\naba\\nbaba\\nxy\\nzw\\n\\nELPMAS\", \"2\\naba\\nbaaa\\nxy\\nwz\\n\\nELPMAS\", \"2\\naca\\nbaab\\nwy\\nyw\\n\\nSQAMLE\", \"2\\naba\\nbaba\\nxy\\nwz\\n\\nELPMAS\", \"2\\naba\\nbaaa\\nxy\\nwz\\n\\nSAMPLE\", \"2\\naba\\nbaaa\\nxy\\nwy\\n\\nSAMPLE\", \... | Everyone knows that chotu likes palindromic strings. One day, he found 2 ordinary strings s1 and s2. Now he wonders if he could make a palindrome by concatenating s1 and s2 in any order. i.e if s1s2 or s2s1 is a palindrome.
Input
First line of input contains T, denoting number of test cases.
Each test case contains t... | 0.625 |
{"tests": "{\"inputs\": [\"3\\n0 0 1\\n3 1 1\\n6 0 9\\n\\nSAMPLE\", \"3\\n0 0 2\\n3 1 1\\n6 0 9\\n\\nSAMPLE\", \"3\\n0 0 2\\n3 1 2\\n6 0 9\\n\\nSAMPLE\", \"3\\n0 0 2\\n4 1 2\\n6 0 9\\n\\nSAMLPE\", \"3\\n0 0 2\\n5 1 2\\n6 0 9\\n\\nSAMLPE\", \"3\\n0 0 2\\n5 0 2\\n6 0 9\\n\\nSAMLPE\", \"3\\n0 0 2\\n5 0 2\\n6 0 4\\n\\nSAML... | Hasan has finally finished his final exams and he decided to go in a trip among cities in Syria.
There are N cities in Syria and they are numbered from 1 to N, each city has coordinates on plane, i-th city is in (Xi, Yi).
Hasan is in first city and he wants to visit some cities by his car in the trip but the final de... | 0 |
{"tests": "{\"inputs\": [\"3 1\\n3 1 4\\n5 3 2\", \"7 3\\n27 18 28 18 28 46 1000000000\\n1000000000 1 7\\n1000000000 2 10\\n1000000000 3 12\", \"3 1\\n2 1 4\\n5 3 2\", \"7 3\\n27 18 28 18 28 46 1000000000\\n1000000010 1 7\\n1000000000 2 10\\n1000000000 3 12\", \"7 3\\n27 18 28 18 28 46 1000000000\\n1000000010 1 7\\n100... | We have a sequence of k numbers: d_0,d_1,...,d_{k - 1}.
Process the following q queries in order:
* The i-th query contains three integers n_i, x_i, and m_i. Let a_0,a_1,...,a_{n_i - 1} be the following sequence of n_i numbers: \begin{eqnarray} a_j = \begin{cases} x_i & ( j = 0 ) \\\ a_{j - 1} + d_{(j - 1)~\textrm{mo... | 0 |
{"tests": "{\"inputs\": [\"3\\n2 4 6\", \"8\\n1 2 3 4 6 8 12 12\", \"10\\n356822 296174 484500 710640 518322 888250 259161 609120 592348 713644\", \"3\\n1 4 6\", \"8\\n1 4 3 4 6 8 12 12\", \"10\\n356822 296174 484500 710640 610703 888250 259161 609120 592348 713644\", \"3\\n2 3 6\", \"8\\n1 8 3 4 6 8 12 12\", \"10\\n35... | We have an integer sequence of length N: A_0,A_1,\cdots,A_{N-1}.
Find the following sum (\mathrm{lcm}(a, b) denotes the least common multiple of a and b):
* \sum_{i=0}^{N-2} \sum_{j=i+1}^{N-1} \mathrm{lcm}(A_i,A_j)
Since the answer may be enormous, compute it modulo 998244353.
Constraints
* 1 \leq N \leq 200000
... | 0 |
{"tests": "{\"inputs\": [\"1593 4311\\n4321 2155\\n1256 6421\\n5310 1455\\n2152 5421\\n1549 3386\\n4528 3719\\n1234 4321\\n3330 3109\\n2739 2199\\n0 0\", \"1593 4311\\n4321 2155\\n1256 6421\\n5310 1455\\n2152 5421\\n1549 3386\\n4528 1578\\n1234 4321\\n3330 3109\\n2739 2199\\n0 0\", \"1593 4311\\n4321 2155\\n1256 6421\\... | In Aizuwakamatsu City, there is a first city called "Tokaichi" on January 10th every year. This Tokaichi has a history of about 600 years and is the largest first city in the Aizu region. It is also well known that Okiagari-koboshi, a familiar lucky charm, is sold in the Aizu region. Okiagari-koboshi is a papier-mâché ... | 0 |
{"tests": "{\"inputs\": [\"5 5 3\\n-8 1\\n-4 2\\n-2 2\\n4 2\\n10 1\\n1\\n3\\n5\", \"5 5 3\\n-8 1\\n-4 2\\n-2 2\\n4 0\\n10 1\\n1\\n3\\n5\", \"5 8 3\\n-8 1\\n-4 2\\n-2 2\\n4 1\\n10 1\\n1\\n3\\n5\", \"5 5 1\\n-8 1\\n-4 2\\n-2 2\\n4 2\\n10 1\\n1\\n3\\n5\", \"5 5 3\\n-8 1\\n-4 2\\n-2 2\\n4 0\\n10 1\\n1\\n5\\n5\", \"5 8 3\\n... | problem
The JOI country has one long enough road running east to west. The royal palace of JOI country is along the road, and the position along the road in JOI country is represented by the integer A. When A = 0, it represents the position of the royal palace. When A> 0, it indicates the position A meters east of the... | 0 |
{"tests": "{\"inputs\": [\"5 4 2\\n1 1 10\\n5 4 3\", \"5 4 2\\n2 1 10\\n5 4 3\", \"5 5 2\\n1 1 10\\n5 4 3\", \"8 4 2\\n2 1 10\\n5 4 5\", \"5 6 2\\n2 2 1\\n2 4 3\", \"5 6 2\\n2 1 10\\n5 4 4\", \"8 5 2\\n2 1 7\\n5 4 3\", \"5 6 2\\n1 3 0\\n5 1 2\", \"5 7 2\\n1 3 0\\n5 1 2\", \"5 6 2\\n2 2 3\\n2 4 3\", \"8 4 2\\n2 1 10\\n6... | Estimating the Flood Risk
Mr. Boat is the owner of a vast extent of land. As many typhoons have struck Japan this year, he became concerned of flood risk of his estate and he wants to know the average altitude of his land. The land is too vast to measure the altitude at many spots. As no steep slopes are in the estate... | 0 |
{"tests": "{\"inputs\": [\"5\\n3\\n3 2\\n4 1\\n5 1\\n3\\n1\\n1 2\\n3\\n2\\n1 2\\n3 2\\n5\\n4\\n4 1\\n4 2\\n5 1\\n5 2\\n5\\n3\\n4 1\\n4 2\\n5 1\\n5\\n4\\n3 2\\n4 1\\n5 1\\n5 2\\n9\\n11\\n6 1\\n6 4\\n7 2\\n7 3\\n7 4\\n8 2\\n8 3\\n8 4\\n9 1\\n9 3\\n9 5\\n9\\n10\\n6 1\\n6 4\\n7 2\\n7 3\\n7 4\\n8 2\\n8 3\\n8 4\\n9 1\\n9 3\\... | Playoff by all the teams
The Minato Mirai Football Association hosts its annual championship as a single round-robin tournament, in which each team plays a single match against all the others. Unlike many other round-robin tournaments of football, matches never result in a draw in this tournament. When the regular tim... | 0 |
{"tests": "{\"inputs\": [\"9 4 3 2 3\\n2 1\\n7 3\", \"9 4 3 2 1\\n2 1\\n7 3\", \"9 4 4 2 3\\n2 1\\n7 3\", \"9 4 3 2 0\\n2 1\\n7 3\", \"9 4 4 2 3\\n1 1\\n7 2\", \"9 6 4 2 3\\n2 1\\n7 3\", \"9 4 4 2 3\\n1 1\\n9 3\", \"16 4 4 2 3\\n1 1\\n7 2\", \"9 6 4 2 3\\n3 1\\n7 3\", \"9 5 4 2 3\\n1 1\\n9 3\", \"16 6 4 2 3\\n1 1\\n7 2... | Training is indispensable for achieving good results at ICPC. Rabbit wants to win at ICPC, so he decided to practice today as well.
Today's training is to use the Amidakuji to improve luck by gaining the ability to read the future. Of course, not only relying on intuition, but also detailed probability calculation is ... | 0 |
{"tests": "{\"inputs\": [\"3\\n3\\n1 1\\n2 1\\n3 1\", \"3\\n3\\n1 1\\n2 0\\n3 1\", \"3\\n3\\n1 1\\n2 0\\n0 1\", \"3\\n3\\n1 1\\n3 0\\n0 1\", \"3\\n1\\n1 1\\n3 0\\n0 1\", \"3\\n1\\n1 0\\n3 0\\n0 1\", \"3\\n2\\n1 0\\n3 0\\n0 1\", \"3\\n2\\n1 0\\n3 1\\n-1 1\", \"3\\n2\\n1 0\\n3 2\\n-1 1\", \"3\\n2\\n1 -1\\n3 0\\n-1 1\", \... | Problem statement
Jota made a scale as shown in the figure below using a stick with a length of $ 2L $.
<image>
The rods are evenly spaced with $ 2L + 1 $ holes, from left to right: $ -L, -L + 1, \ cdots, -1, 0, 1, \ cdots, L-1, L $. It is numbered. And the place of the hole of No. $ 0 $ is hung from the ceiling wit... | 0 |
{"tests": "{\"inputs\": [\"3 13\\n0 0 1\\n0 0 2\\n0 0 3\\n0 1 -1\\n0 2 4\\n0 2 5\\n1 0\\n1 1\\n1 2\\n2 1\\n1 0\\n1 1\\n1 2\", \"3 13\\n0 0 1\\n0 0 3\\n0 0 3\\n0 1 -1\\n0 2 4\\n0 2 5\\n1 0\\n1 1\\n1 2\\n2 1\\n1 0\\n1 1\\n1 2\", \"3 13\\n0 0 1\\n0 0 2\\n0 0 3\\n0 1 0\\n0 2 4\\n0 2 5\\n1 0\\n1 1\\n1 2\\n2 1\\n1 0\\n1 1\\n... | For $n$ dynamic arrays $A_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations:
* pushBack($t$, $x$): Add element $x$ at the end of $A_t$.
* dump($t$): Print all elements in $A_t$.
* clear($t$): Clear $A_t$. If $A_t$ is empty, do nothing.
$A_i$ is a 0-origin array and it is empty in the initial... | 0 |
{"tests": "{\"inputs\": [\"3\\n2 2\\naa\\naA\\n3 3\\naba\\nbab\\naba\\n4 4\\naabb\\naabb\\nbbaa\\nbbaa\", \"3\\n2 2\\naa\\naA\\n3 0\\naba\\nbab\\naba\\n4 4\\naabb\\naabb\\nbbaa\\nbbaa\", \"3\\n2 2\\naa\\naA\\n3 -1\\naba\\nbab\\naba\\n4 4\\naabb\\naabb\\nbaaa\\nbbaa\", \"3\\n2 2\\naa\\naA\\n3 3\\naba\\nbab\\naba\\n4 4\\... | Chef has just finished the construction of his new garden. He has sown the garden with patches of the most beautiful carpet grass he could find. He has filled it with patches of different color and now he wants to evaluate how elegant his garden is.
Chef's garden looks like a rectangular grid of cells with N rows and M... | 0.75 |
{"tests": "{\"inputs\": [\"5\\n1 2 3 2 2\\n\", \"3\\n1 2 3\\n\", \"5\\n1 1 1 1 1\\n\", \"9\\n1 100 1 100 1 100 1 100 1\\n\", \"100\\n637 61 394 666 819 664 274 652 123 152 765 524 375 60 812 832 20 275 85 193 846 815 538 807 15 439 688 882 272 630 132 669 820 646 757 233 470 778 97 450 304 439 240 586 531 59 192 456 54... | Welcome to Innopolis city. Throughout the whole year, Innopolis citizens suffer from everlasting city construction.
From the window in your room, you see the sequence of n hills, where i-th of them has height ai. The Innopolis administration wants to build some houses on the hills. However, for the sake of city appea... | 0 |
{"tests": "{\"inputs\": [\"4\\n0101\\n0011\\n\", \"3\\n100\\n001\\n\", \"91\\n0010010000110001001011011011111001000110001000100111110010010001100110010111100111011111100\\n1101110110000100110000100011010110111101100000011011100111111000110000001101101111100100101\\n\", \"19\\n1111010011111010100\\n1010000110100110110\\... | You are given two binary strings a and b of the same length. You can perform the following two operations on the string a:
* Swap any two bits at indices i and j respectively (1 ≤ i, j ≤ n), the cost of this operation is |i - j|, that is, the absolute difference between i and j.
* Select any arbitrary index i (1 ... | 0 |
{"tests": "{\"inputs\": [\"6\\n5 11 44\\n\", \"6\\n314 1592 6535\\n\", \"2\\n9900\\n\", \"4\\n35 15\\n\", \"82\\n24 192 896 1568 2907 4840 7475 9775 11109 29939 22475 45951 46552 36859 66787 106329 85211 94423 65627 147436 143259 128699 139277 167743 178063 192167 150133 162719 177103 160732 139859 157301 176681 199291... | Chouti is working on a strange math problem.
There was a sequence of n positive integers x_1, x_2, …, x_n, where n is even. The sequence was very special, namely for every integer t from 1 to n, x_1+x_2+...+x_t is a square of some integer number (that is, a [perfect square](https://en.wikipedia.org/wiki/Square_number)... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 10 100 1000\\n\", \"5\\n1 2 3 4 4\\n\", \"3\\n2 4 3\\n\", \"3\\n13 8 5\\n\", \"4\\n4 2 2 3\\n\", \"27\\n496869708 6536632 139291 53540 27689600 72492314 189787341 364332 953704 2496779 10576485 307082368 85752 44802715 21328 10886 1543076 10000 17113116 32213 117295028 444 589373 803952... | You are given n numbers a_1, a_2, …, a_n. Is it possible to arrange them in a circle in such a way that every number is strictly less than the sum of its neighbors?
For example, for the array [1, 4, 5, 6, 7, 8], the arrangement on the left is valid, while arrangement on the right is not, as 5≥ 4 + 1 and 8> 1 + 6.
<im... | 0 |
{"tests": "{\"inputs\": [\"8\\n1 2 3\\n123 321 456\\n5 10 15\\n15 18 21\\n100 100 101\\n1 22 29\\n3 19 38\\n6 30 46\\n\", \"1\\n451 10000 10000\\n\", \"1\\n3533 3533 10000\\n\", \"2\\n256 4096 10000\\n2 749 1000\\n\", \"1\\n1429 1429 10000\\n\", \"1\\n73 73 10000\\n\", \"1\\n137 137 10000\\n\", \"1\\n1684 5052 10000\\n... | You are given three integers a ≤ b ≤ c.
In one move, you can add +1 or -1 to any of these integers (i.e. increase or decrease any number by one). You can perform such operation any (possibly, zero) number of times, you can even perform this operation several times with one number. Note that you cannot make non-positiv... | 0 |
{"tests": "{\"inputs\": [\"2\\n4\\n1 2 4 3\\n5\\n1 1 1 1 1\\n\", \"1\\n1\\n2\\n\", \"1\\n1\\n1\\n\", \"2\\n4\\n1 2 4 6\\n5\\n1 1 1 1 1\\n\", \"2\\n4\\n1 2 4 3\\n5\\n1 2 1 1 1\\n\", \"2\\n4\\n2 2 4 3\\n5\\n1 2 1 1 1\\n\", \"2\\n4\\n1 2 8 3\\n5\\n1 1 1 2 1\\n\", \"2\\n4\\n1 2 4 12\\n5\\n2 1 1 1 1\\n\", \"2\\n4\\n1 3 4 1\... | A championship is held in Berland, in which n players participate. The player with the number i has a_i (a_i ≥ 1) tokens.
The championship consists of n-1 games, which are played according to the following rules:
* in each game, two random players with non-zero tokens are selected;
* the player with more tokens ... | 0 |
{"tests": "{\"inputs\": [\"3\\n3\\n0 2 3\\n2\\n0 1000000000\\n1\\n0\\n\", \"3\\n1\\n0\\n3\\n0 2 3\\n2\\n0 1000000000\\n\", \"3\\n1\\n0\\n3\\n0 2 6\\n2\\n0 1000000000\\n\", \"3\\n1\\n0\\n3\\n0 2 1\\n2\\n0 1000000000\\n\", \"3\\n3\\n0 1 3\\n2\\n0 1000000000\\n1\\n0\\n\", \"3\\n1\\n0\\n3\\n0 1 3\\n2\\n0 1000000000\\n\", \... | Farmer John has a farm that consists of n pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that it is... | 0 |
{"tests": "{\"inputs\": [\"4\\n0.7 0.2 0.1 0.9\\n\", \"3\\n0.5 0.5 0.5\\n\", \"5\\n1 1 1 1 1\\n\", \"10\\n0.999453 0.999188 0.998398 0.999609 0.999113 0.999426 0.998026 0.999244 0.998842 0.999807\\n\", \"30\\n0.999453 0.998210 0.999812 0.998309 0.999333 0.999463 0.999490 0.998975 0.999248 0.999782 0.999233 0.999062 0.9... | You're playing a game called Osu! Here's a simplified version of it. There are n clicks in a game. For each click there are two outcomes: correct or bad. Let us denote correct as "O", bad as "X", then the whole play can be encoded as a sequence of n characters "O" and "X".
Using the play sequence you can calculate the... | 0 |
{"tests": "{\"inputs\": [\"abacaba\\nabaaba\\nx\\n\", \"ab\\nbc\\ncd\\n\", \"syvncqmfhautvxudqdhggz\\nhrpxzeghsocjpicuixskfuzupytsgjsdiyb\\nybcmnmnbpndbxlxbzhbfnqvwcffvrdhtickyqhupmcehls\\n\", \"iefouqzxoyuieqdzalfktehtvdbvjmeubju\\nocotspetkkhvwfgaqynhovjwjhciefouqzxoyuieqdzalfktehtvdbvjmeubjubcmnvpwgdpnchqhzjrchyrfpv... | Sometimes it is hard to prepare tests for programming problems. Now Bob is preparing tests to new problem about strings — input data to his problem is one string. Bob has 3 wrong solutions to this problem. The first gives the wrong answer if the input data contains the substring s1, the second enters an infinite loop i... | 0.5 |
{"tests": "{\"inputs\": [\"5 3\\n8 21 52 15 77\\n\", \"6 1\\n3 6 10 12 13 16\\n\", \"25 7\\n67 18 36 85 64 22 32 66 17 64 66 65 82 36 16 52 19 70 38 51 17 32 85 16 64\\n\", \"10 10\\n40141 53368 66538 64507 78114 34253 73242 42141 37430 6\\n\", \"18 9\\n85 29 29 15 17 71 46 69 48 80 44 73 40 55 61 57 22 68\\n\", \"1 1\... | Vasya's got a birthday coming up and his mom decided to give him an array of positive integers a of length n.
Vasya thinks that an array's beauty is the greatest common divisor of all its elements. His mom, of course, wants to give him as beautiful an array as possible (with largest possible beauty). Unfortunately, th... | 0.125 |
{"tests": "{\"inputs\": [\"3 4 1\\n1 0 0 1\\n0 1 1 0\\n1 0 0 1\\n\", \"5 5 2\\n1 1 1 1 1\\n1 1 1 1 1\\n1 1 0 1 1\\n1 1 1 1 1\\n1 1 1 1 1\\n\", \"3 4 1\\n1 0 0 0\\n0 1 1 1\\n1 1 1 0\\n\", \"2 2 1\\n1 1\\n1 0\\n\", \"5 5 5\\n0 1 1 1 1\\n1 0 1 1 1\\n1 1 0 1 1\\n1 1 1 0 1\\n1 1 1 1 0\\n\", \"9 9 10\\n0 0 0 0 0 0 1 0 0\\n1 ... | Sereja has an n × m rectangular table a, each cell of the table contains a zero or a number one. Sereja wants his table to meet the following requirement: each connected component of the same values forms a rectangle with sides parallel to the sides of the table. Rectangles should be filled with cells, that is, if a co... | 0 |
{"tests": "{\"inputs\": [\"4 2\\n..\\n..\\n..\\n..\\n\", \"4 5\\n#...#\\n#...#\\n###.#\\n###.#\\n\", \"3 3\\n...\\n..#\\n...\\n\", \"10 10\\n##........\\n#.#....#..\\n#.#...#..#\\n.........#\\n#..#......\\n......#..#\\n..#...#...\\n..#...#...\\n...#.....#\\n..........\\n\", \"9 37\\n.......#................#.##...#....... | On a certain meeting of a ruling party "A" minister Pavel suggested to improve the sewer system and to create a new pipe in the city.
The city is an n × m rectangular squared field. Each square of the field is either empty (then the pipe can go in it), or occupied (the pipe cannot go in such square). Empty squares are... | 0 |
{"tests": "{\"inputs\": [\"2 7\\n2 3\\n\", \"4 5\\n2 3 5 12\\n\", \"1 1\\n3\\n\", \"2 16\\n8 4\\n\", \"1 999983\\n1\\n\", \"3 16\\n2 4 8\\n\", \"2 8\\n4 12\\n\", \"2 27000\\n5400 4500\\n\", \"2 9\\n3 3\\n\", \"1 216000\\n648000\\n\", \"1 2\\n1\\n\", \"3 32\\n2 4 8\\n\", \"1 49\\n7\\n\", \"3 20\\n2 2 5\\n\", \"2 20998\\... | Today Pari and Arya are playing a game called Remainders.
Pari chooses two positive integer x and k, and tells Arya k but not x. Arya have to find the value <image>. There are n ancient numbers c1, c2, ..., cn and Pari has to tell Arya <image> if Arya wants. Given k and the ancient values, tell us if Arya has a winnin... | 0 |
{"tests": "{\"inputs\": [\"8 3\\n01010110\\n\", \"3 3\\n010\\n\", \"10 3\\n0111011010\\n\", \"4 4\\n0000\\n\", \"4 2\\n0010\\n\", \"4 4\\n0110\\n\", \"9 5\\n001100110\\n\", \"100 89\\n0011011110011111111010111101101100101111111111011011111111110111101111101111111101111011111011101110\\n\", \"100 81\\n011011101100001001... | Polycarp's workday lasts exactly n minutes. He loves chocolate bars and can eat one bar in one minute. Today Polycarp has k bars at the beginning of the workday.
In some minutes of the workday Polycarp has important things to do and in such minutes he is not able to eat a chocolate bar. In other minutes he can either ... | 0 |
{"tests": "{\"inputs\": [\"4 68\\n\", \"4 67\\n\", \"3 15\\n\", \"100000 148\\n\", \"68459 88\\n\", \"100000 143\\n\", \"100000 109\\n\", \"3 15\\n\", \"5 141\\n\", \"3 180\\n\", \"100000 49\\n\", \"5 111\\n\", \"100000 71\\n\", \"4 16\\n\", \"5 54\\n\", \"5 126\\n\", \"6 46\\n\", \"8509 139\\n\", \"100000 35\\n\", \"1... | On one quiet day all of sudden Mister B decided to draw angle a on his field. Aliens have already visited his field and left many different geometric figures on it. One of the figures is regular convex n-gon (regular convex polygon with n sides).
That's why Mister B decided to use this polygon. Now Mister B must find ... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n1 2\\n2 3\\n3 1\\n\\nSAMPLE\", \"5 2\\n5 3\\n5 2\", \"6 6\\n3 4\\n3 1\\n6 5\\n5 4\\n4 1\\n2 3\", \"47 30\\n41 12\\n6 28\\n23 29\\n44 32\\n20 36\\n31 36\\n11 19\\n41 4\\n43 21\\n20 16\\n38 23\\n18 29\\n19 38\\n10 6\\n30 35\\n16 30\\n22 16\\n42 35\\n7 22\\n36 27\\n35 33\\n37 21\\n29 5\\n2... | Little Monk is an extremely miser person. He hates spending money on things, be it for his own good or bad. But this time his friends have caught up with him, and are demanding a huge birthday treat. But, Monk is... well, Monk.
He figured out that there is no way for him to save himself and his money now. So, he deci... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.