question
large_stringlengths
265
13.2k
Solve the programming task below in a Python markdown code block. A soldier wants to buy w bananas in the shop. He has to pay k dollars for the first banana, 2k dollars for the second one and so on (in other words, he has to pay iΒ·k dollars for the i-th banana). He has n dollars. How many dollars does he have to bor...
Solve the programming task below in a Python markdown code block. In the official contest this problem has a different statement, for which jury's solution was working incorrectly, and for this reason it was excluded from the contest. This mistake have been fixed and the current given problem statement and model solut...
Solve the programming task below in a Python markdown code block. Ayrat has number n, represented as it's prime factorization pi of size m, i.e. n = p1Β·p2Β·...Β·pm. Ayrat got secret information that that the product of all divisors of n taken modulo 109 + 7 is the password to the secret data base. Now he wants to calcul...
Solve the programming task below in a Python markdown code block. Paul is at the orchestra. The string section is arranged in an r Γ— c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can tak...
Solve the programming task below in a Python markdown code block. Pari has a friend who loves palindrome numbers. A palindrome number is a number that reads the same forward or backward. For example 12321, 100001 and 1 are palindrome numbers, while 112 and 1021 are not. Pari is trying to love them too, but only very ...
Solve the programming task below in a Python markdown code block. The only king stands on the standard chess board. You are given his position in format "cd", where c is the column from 'a' to 'h' and d is the row from '1' to '8'. Find the number of moves permitted for the king. Check the king's moves here https://en...
Solve the programming task below in a Python markdown code block. Grigoriy, like the hero of one famous comedy film, found a job as a night security guard at the museum. At first night he received embosser and was to take stock of the whole exposition. Embosser is a special devise that allows to "print" the text of a...
Solve the programming task below in a Python markdown code block. PolandBall lives in a forest with his family. There are some trees in the forest. Trees are undirected acyclic graphs with k vertices and k - 1 edges, where k is some integer. Note that one vertex is a valid tree. There is exactly one relative living i...
Solve the programming task below in a Python markdown code block. Moriarty has trapped n people in n distinct rooms in a hotel. Some rooms are locked, others are unlocked. But, there is a condition that the people in the hotel can only escape when all the doors are unlocked at the same time. There are m switches. Each...
Solve the programming task below in a Python markdown code block. Most C/C++ programmers know about excellent opportunities that preprocessor #define directives give; but many know as well about the problems that can arise because of their careless use. In this problem we consider the following model of #define const...
Solve the programming task below in a Python markdown code block. Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees. Consider the point (x, y) in the 2D plane such that x and y are integers and 0 ≀ x, y. There is a tree in such a point, and ...
Solve the programming task below in a Python markdown code block. Ivan has an array consisting of n different integers. He decided to reorder all elements in increasing order. Ivan loves merge sort so he decided to represent his array with one or several increasing sequences which he then plans to merge into one sorte...
Solve the programming task below in a Python markdown code block. You are given n strings s1, s2, ..., sn consisting of characters 0 and 1. m operations are performed, on each of them you concatenate two existing strings into a new one. On the i-th operation the concatenation saisbi is saved into a new string sn + i (...
Solve the programming task below in a Python markdown code block. "QAQ" is a word to denote an expression of crying. Imagine "Q" as eyes with tears and "A" as a mouth. Now Diamond has given Bort a string consisting of only uppercase English letters of length n. There is a great number of "QAQ" in the string (Diamond ...
Solve the programming task below in a Python markdown code block. You are given a [directed graph](https://en.wikipedia.org/wiki/Directed_graph) consisting of n vertices and m edges (each edge is directed, so it can be traversed in only one direction). You are allowed to remove at most one edge from it. Can you make ...
Solve the programming task below in a Python markdown code block. You are given an array a of length n. We define fa the following way: * Initially fa = 0, M = 1; * for every 2 ≀ i ≀ n if aM < ai then we set fa = fa + aM and then set M = i. Calculate the sum of fa over all n! permutations of the array a modu...
Solve the programming task below in a Python markdown code block. Each student eagerly awaits the day he would pass the exams successfully. Thus, Vasya was ready to celebrate, but, alas, he didn't pass it. However, many of Vasya's fellow students from the same group were more successful and celebrated after the exam. ...
Solve the programming task below in a Python markdown code block. Given an array A of size N. Given Q operations, each operation contains an integer D. In each operation you have to divide all the elements of the array by D. For example, for each operation with a given D, the new array A would be: A[0] / D, A[1] / D...
Solve the programming task below in a Python markdown code block. Little Deepu loves positive things in life, positive girlfriends, positive marks. He's, in general a lover of positive things, so for obvious reasons he loves an array which contains positive elements. Anyway, Little Deepu also thinks that not every va...
Solve the programming task below in a Python markdown code block. An intergallactic war is on. Aliens are throwing fire-balls at our planet and this fire is so deadly that whichever nation it hits, it will wipe out not only that nation, but also spreads to any other nation which lies adjacent to it. Given an NxM map...
Solve the programming task below in a Python markdown code block. Given are N integers A_1,\ldots,A_N. We will choose exactly K of these elements. Find the maximum possible product of the chosen elements. Then, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive). Constraints...
Solve the programming task below in a Python markdown code block. A Hitachi string is a concatenation of one or more copies of the string `hi`. For example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not. Given a string S, determine whether S is a Hitachi string. Constraints * The length of S is...
Solve the programming task below in a Python markdown code block. Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.) We will pour x~\mathrm{cm}^3 of water into the bottle, and ...
Solve the programming task below in a Python markdown code block. There is a grid with H rows and W columns, where each square is painted black or white. You are given H strings S_1, S_2, ..., S_H, each of length W. If the square at the i-th row from the top and the j-th column from the left is painted black, the j-t...
Solve the programming task below in a Python markdown code block. In the city of Nevermore, there are 10^8 streets and 10^8 avenues, both numbered from 0 to 10^8-1. All streets run straight from west to east, and all avenues run straight from south to north. The distance between neighboring streets and between neighbo...
Solve the programming task below in a Python markdown code block. Two deer, AtCoDeer and TopCoDeer, are playing a game called Honest or Dishonest. In this game, an honest player always tells the truth, and an dishonest player always tell lies. You are given two characters a and b as the input. Each of them is either `...
Solve the programming task below in a Python markdown code block. There are N towns located in a line, conveniently numbered 1 through N. Takahashi the merchant is going on a travel from town 1 to town N, buying and selling apples. Takahashi will begin the travel at town 1, with no apple in his possession. The action...
Solve the programming task below in a Python markdown code block. Create a program that reads poker hand data and outputs the role for each. However, this issue follows the rules below. * Poker is a competition with 5 playing cards. * No more than 5 cards with the same number. * There is no joker. * Suppose you only ...
Solve the programming task below in a Python markdown code block. I bought food at the store to make a lunch box to eat at lunch. At the store, I only got an elongated bag to put food in, so I had to stack all the food vertically and put it in the bag. I want to pack the bag with the heavy ones down so that it won't f...
Solve the programming task below in a Python markdown code block. You are working on the development of the unique operating system "Unsgune 15" and are struggling to design a scheduler that determines performance. A scheduler is a program that expresses the processes to be executed in units called tasks and determine...
Solve the programming task below in a Python markdown code block. A text editor is a useful software tool that can help people in various situations including writing and programming. Your job in this problem is to construct an offline text editor, i.e., to write a program that first reads a given text and a sequence ...
Solve the programming task below in a Python markdown code block. You are appointed director of a famous concert hall, to save it from bankruptcy. The hall is very popular, and receives many requests to use its two fine rooms, but unfortunately the previous director was not very efficient, and it has been losing money...
Solve the programming task below in a Python markdown code block. Your friend recently came up with a card game called UT-Rummy. The cards used in this game are numbered red, green, or blue and any number from 1 to 9. Each player in this game has 9 cards in his or her hand, chooses one from his or her hand, discards ...
Solve the programming task below in a Python markdown code block. As many of you know, we have two major calendar systems used in Japan today. One of them is Gregorian calendar which is widely used across the world. It is also known as β€œWestern calendar” in Japan. The other calendar system is era-based calendar, or s...
Solve the programming task below in a Python markdown code block. One-day pass Mr. D, a university student living in a certain country, is a big fan of Mr. A, a national guitarist, and is thinking of going to a live concert in the city center this summer. However, since Mr. D lives in a remote area, he was very worri...
Solve the programming task below in a Python markdown code block. C --Misawa's rooted tree Problem Statement You noticed that your best friend Misawa's birthday was near, and decided to give him a rooted binary tree as a gift. Here, the rooted binary tree has the following graph structure. (Figure 1) * Each vertex ...
Solve the programming task below in a Python markdown code block. Notes Template in C Constraints 2 ≀ the number of operands in the expression ≀ 100 1 ≀ the number of operators in the expression ≀ 99 -1 Γ— 109 ≀ values in the stack ≀ 109 Input An expression is given in a line. Two consequtive symbols (operand or o...
Solve the programming task below in a Python markdown code block. Write a program which reads a list of student test scores and evaluates the performance for each student. The test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examinat...
Solve the programming task below in a Python markdown code block. John Smith knows that his son, Thomas Smith, is among the best students in his class and even in his school. After the students of the school took the exams in English, German, Math, and History, a table of results was formed. There are n students, eac...
Solve the programming task below in a Python markdown code block. There are two bus stops denoted A and B, and there n buses that go from A to B every day. The shortest path from A to B takes t units of time but some buses might take longer paths. Moreover, buses are allowed to overtake each other during the route. A...
Solve the programming task below in a Python markdown code block. Today is tuesday, that means there is a dispute in JOHNNY SOLVING team again: they try to understand who is Johnny and who is Solving. That's why guys asked Umnik to help them. Umnik gave guys a connected graph with n vertices without loops and multiedg...
Solve the programming task below in a Python markdown code block. Given two integers n and x, construct an array that satisfies the following conditions: * for any element a_i in the array, 1 ≀ a_i<2^n; * there is no non-empty subsegment with [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) eq...
Solve the programming task below in a Python markdown code block. Marcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other. Let's focus on the students. They are indexed with intege...
Solve the programming task below in a Python markdown code block. Recently you have bought a snow walking robot and brought it home. Suppose your home is a cell (0, 0) on an infinite grid. You also have the sequence of instructions of this robot. It is written as the string s consisting of characters 'L', 'R', 'U' an...
Solve the programming task below in a Python markdown code block. You are given two strings s and t consisting of lowercase Latin letters. Also you have a string z which is initially empty. You want string z to be equal to string t. You can perform the following operation to achieve this: append any subsequence of s a...
Solve the programming task below in a Python markdown code block. It is Professor R's last class of his teaching career. Every time Professor R taught a class, he gave a special problem for the students to solve. You being his favourite student, put your heart into solving it one last time. You are given two polynomi...
Solve the programming task below in a Python markdown code block. Kaavi, the mysterious fortune teller, deeply believes that one's fate is inevitable and unavoidable. Of course, she makes her living by predicting others' future. While doing divination, Kaavi believes that magic spells can provide great power for her t...
Solve the programming task below in a Python markdown code block. Little Petya very much likes playing with little Masha. Recently he has received a game called "Zero-One" as a gift from his mother. Petya immediately offered Masha to play the game with him. Before the very beginning of the game several cards are lain...
Solve the programming task below in a Python markdown code block. A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters + and 1 into this sequence. For example, sequences (())(), () and (()(())) are regular, while )(, (() and (()))( are not. Let's call a...
Solve the programming task below in a Python markdown code block. You are playing a game similar to Sokoban on an infinite number line. The game is discrete, so you only consider integer positions on the line. You start on a position 0. There are n boxes, the i-th box is on a position a_i. All positions of the boxes ...
Solve the programming task below in a Python markdown code block. AquaMoon has n friends. They stand in a row from left to right, and the i-th friend from the left wears a T-shirt with a number a_i written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. Aqu...
Solve the programming task below in a Python markdown code block. <image> Input The input contains two integers a, b (1 ≀ a ≀ 10, 0 ≀ b ≀ 22Β·a - 1) separated by a single space. Output Output two integers separated by a single space. Examples Input 1 0 Output 0 0 Input 2 15 Output 3 0 Input 4 160 O...
Solve the programming task below in a Python markdown code block. As you very well know, this year's funkiest numbers are so called triangular numbers (that is, integers that are representable as <image>, where k is some positive integer), and the coolest numbers are those that are representable as a sum of two triang...
Solve the programming task below in a Python markdown code block. Several ages ago Berland was a kingdom. The King of Berland adored math. That's why, when he first visited one of his many palaces, he first of all paid attention to the floor in one hall. The floor was tiled with hexagonal tiles. The hall also turned ...
Solve the programming task below in a Python markdown code block. You're given a string of lower-case Latin letters. Your task is to find the length of its longest substring that can be met in the string at least twice. These occurrences can overlap (see sample test 2). Input The first input line contains the string...
Solve the programming task below in a Python markdown code block. Vasily the bear has a favorite rectangle, it has one vertex at point (0, 0), and the opposite vertex at point (x, y). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes. Vasya also loves triangles, if the triangles ...
Solve the programming task below in a Python markdown code block. A permutation p is an ordered group of numbers p1, p2, ..., pn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1, p2, ..., pn. Simon has a positive integer n and a non-negative in...
Solve the programming task below in a Python markdown code block. Ksenia has ordinary pan scales and several weights of an equal mass. Ksenia has already put some weights on the scales, while other weights are untouched. Ksenia is now wondering whether it is possible to put all the remaining weights on the scales so t...
Solve the programming task below in a Python markdown code block. Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them i...
Solve the programming task below in a Python markdown code block. You have k pieces of laundry, each of which you want to wash, dry and fold. You are at a laundromat that has n1 washing machines, n2 drying machines and n3 folding machines. Each machine can process only one piece of laundry at a time. You can't dry a p...
Solve the programming task below in a Python markdown code block. Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) Γ— (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one way. This means in each horizontal street, the traffic ...
Solve the programming task below in a Python markdown code block. You have a new professor of graph theory and he speaks very quickly. You come up with the following plan to keep up with his lecture and make notes. You know two languages, and the professor is giving the lecture in the first one. The words in both lan...
Solve the programming task below in a Python markdown code block. Polycarp is flying in the airplane. Finally, it is his favorite time β€” the lunchtime. The BerAvia company stewardess is giving food consecutively to all the passengers from the 1-th one to the last one. Polycarp is sitting on seat m, that means, he will...
Solve the programming task below in a Python markdown code block. Berlanders like to eat cones after a hard day. Misha Square and Sasha Circle are local authorities of Berland. Each of them controls its points of cone trade. Misha has n points, Sasha β€” m. Since their subordinates constantly had conflicts with each oth...
Solve the programming task below in a Python markdown code block. You are given a string s and should process m queries. Each query is described by two 1-based indices li, ri and integer ki. It means that you should cyclically shift the substring s[li... ri] ki times. The queries should be processed one after another ...
Solve the programming task below in a Python markdown code block. <image> As some of you know, cubism is a trend in art, where the problem of constructing volumetrical shape on a plane with a combination of three-dimensional geometric shapes comes to the fore. A famous sculptor Cicasso, whose self-portrait you can ...
Solve the programming task below in a Python markdown code block. Recently Anton found a box with digits in his room. There are k2 digits 2, k3 digits 3, k5 digits 5 and k6 digits 6. Anton's favorite integers are 32 and 256. He decided to compose this integers from digits he has. He wants to make the sum of these int...
Solve the programming task below in a Python markdown code block. Nothing is eternal in the world, Kostya understood it on the 7-th of January when he saw partially dead four-color garland. Now he has a goal to replace dead light bulbs, however he doesn't know how many light bulbs for each color are required. It is g...
Solve the programming task below in a Python markdown code block. The marmots need to prepare k problems for HC2 over n days. Each problem, once prepared, also has to be printed. The preparation of a problem on day i (at most one per day) costs ai CHF, and the printing of a problem on day i (also at most one per day)...
Solve the programming task below in a Python markdown code block. We often go to supermarkets to buy some fruits or vegetables, and on the tag there prints the price for a kilo. But in some supermarkets, when asked how much the items are, the clerk will say that a yuan for b kilos (You don't need to care about what "y...
Solve the programming task below in a Python markdown code block. Petya loves hockey very much. One day, as he was watching a hockey match, he fell asleep. Petya dreamt of being appointed to change a hockey team's name. Thus, Petya was given the original team name w and the collection of forbidden substrings s1, s2, ....
Solve the programming task below in a Python markdown code block. You are given two squares, one with sides parallel to the coordinate axes, and another one with sides at 45 degrees to the coordinate axes. Find whether the two squares intersect. The interior of the square is considered to be part of the square, i.e. ...
Solve the programming task below in a Python markdown code block. Steve Jobs' ghost has come down to BITS Pilani Hyderabad Campus, since he has heard a lot about the coding culture here. Hoping to recruit talented people to work on top-secret Apple software, he keeps a strict coding test. Apple is currently working o...
Solve the programming task below in a Python markdown code block. Given is an integer N. Find the number of digits that N has in base K. Constraints * All values in input are integers. * 1 \leq N \leq 10^9 * 2 \leq K \leq 10 Input Input is given from Standard Input in the following format: N K Output Print th...
Solve the programming task below in a Python markdown code block. We have N locked treasure boxes, numbered 1 to N. A shop sells M keys. The i-th key is sold for a_i yen (the currency of Japan), and it can unlock b_i of the boxes: Box c_{i1}, c_{i2}, ..., c_{i{b_i}}. Each key purchased can be used any number of times...
Solve the programming task below in a Python markdown code block. The development of algae in a pond is as follows. Let the total weight of the algae at the beginning of the year i be x_i gram. For iβ‰₯2000, the following formula holds: * x_{i+1} = rx_i - D You are given r, D and x_{2000}. Calculate x_{2001}, ..., ...
Solve the programming task below in a Python markdown code block. As AtCoder Beginner Contest 100 is taking place, the office of AtCoder, Inc. is decorated with a sequence of length N, a = {a_1, a_2, a_3, ..., a_N}. Snuke, an employee, would like to play with this sequence. Specifically, he would like to repeat the f...
Solve the programming task below in a Python markdown code block. As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple ...
Solve the programming task below in a Python markdown code block. Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times ...
Solve the programming task below in a Python markdown code block. Snuke loves flags. Snuke is placing N flags on a line. The i-th flag can be placed at either coordinate x_i or coordinate y_i. Snuke thinks that the flags look nicer when the smallest distance between two of them, d, is larger. Find the maximum possi...
Solve the programming task below in a Python markdown code block. CODE FESTIVAL 2016 is going to be held. For the occasion, Mr. Takahashi decided to make a signboard. He intended to write `CODEFESTIVAL2016` on it, but he mistakenly wrote a different string S. Fortunately, the string he wrote was the correct length. ...
Solve the programming task below in a Python markdown code block. Taro is very good at 8 puzzles and always has his friends sort them out during breaks. At that time, my friend asked me, "Can you solve more complicated puzzles?", But I have never done other puzzles. Apparently the friend made 11 puzzles by himself. Th...
Solve the programming task below in a Python markdown code block. Of the real numbers, those with a circular decimal part and those with a finite number of digits can be expressed as fractions. Given a real number that can be represented by a fraction, write a program that outputs an irreducible fraction equal to ...
Solve the programming task below in a Python markdown code block. The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange...
Solve the programming task below in a Python markdown code block. It was the last day of the summer camp you strayed into the labyrinth on the way to Komaba Campus, the University of Tokyo. The contest has just begun. Your teammates must impatiently wait for you. So you have to escape from this labyrinth as soon as po...
Solve the programming task below in a Python markdown code block. There are N towers in the town where Ikta lives. Each tower is given a different number from 0 to N-1, and the tower with number i is called tower i. Curious Ikta was interested in the height of the N towers and decided to make a table T showing the mag...
Solve the programming task below in a Python markdown code block. problem $ M $ students will be tested in a classroom with $ N $ seats in a straight line. Seats are numbered $ 1 \ dots N $ from the front, and $ 1 $ per seat can seat $ 1 $ students. Now each student is sitting in the $ A_1, \ dots, A_M $ seats. To ...
Solve the programming task below in a Python markdown code block. Search trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue. Binary search tree is one of fundamental search trees. The key...
Solve the programming task below in a Python markdown code block. Print all combinations which can be made by $k$ different elements from $0, 1, ..., n-1$. Note that we represent $0, 1, ... n-1$ as 00...0001, 00...0010, 00...0100, ..., 10...0000 in binary respectively and the integer representation of a combination is...
Solve the programming task below in a Python markdown code block. As you might remember, the collector of Siruseri had ordered a complete revision of the Voters List. He knew that constructing the list of voters is a difficult task, prone to errors. Some voters may have been away on vacation, others may have moved dur...
Solve the programming task below in a Python markdown code block. Little boy Gerald studies at school which is quite far from his house. That's why he has to go there by bus every day. The way from home to school is represented by a segment of a straight line; the segment contains exactly n + 1 bus stops. All of them ...
Solve the programming task below in a Python markdown code block. Consider some set of distinct characters A and some string S, consisting of exactly n characters, where each character is present in A. You are given an array of m integers b (b_1 < b_2 < ... < b_m). You are allowed to perform the following move on t...
Solve the programming task below in a Python markdown code block. You're given an array a of length n. You can perform the following operations on it: * choose an index i (1 ≀ i ≀ n), an integer x (0 ≀ x ≀ 10^6), and replace a_j with a_j+x for all (1 ≀ j ≀ i), which means add x to all the elements in the prefix end...
Solve the programming task below in a Python markdown code block. You are playing a new famous fighting game: Kortal Mombat XII. You have to perform a brutality on your opponent's character. You are playing the game on the new generation console so your gamepad have 26 buttons. Each button has a single lowercase Lati...
Solve the programming task below in a Python markdown code block. Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices A and B are given, each of them has size n Γ— m. Nastya can perform the following operation to matrix A unlimit...
Solve the programming task below in a Python markdown code block. You are given an array a consisting of n integers a_1, a_2, ..., a_n. Your problem is to find such pair of indices i, j (1 ≀ i < j ≀ n) that lcm(a_i, a_j) is minimum possible. lcm(x, y) is the least common multiple of x and y (minimum positive number ...
Solve the programming task below in a Python markdown code block. The mayor of the Central Town wants to modernize Central Street, represented in this problem by the (Ox) axis. On this street, there are n antennas, numbered from 1 to n. The i-th antenna lies on the position x_i and has an initial scope of s_i: it cov...
Solve the programming task below in a Python markdown code block. Polycarp has n different binary words. A word called binary if it contains only characters '0' and '1'. For example, these words are binary: "0001", "11", "0" and "0011100". Polycarp wants to offer his set of n binary words to play a game "words". In t...
Solve the programming task below in a Python markdown code block. INTERCAL is the oldest of esoteric programming languages. One of its many weird features is the method of character-based output, known as Turing Tape method. It converts an array of unsigned 8-bit integers into a sequence of characters to print, using ...
Solve the programming task below in a Python markdown code block. You are given an array a of length 2^n. You should process q queries on it. Each query has one of the following 4 types: 1. Replace(x, k) β€” change a_x to k; 2. Reverse(k) β€” reverse each subarray [(i-1) β‹… 2^k+1, i β‹… 2^k] for all i (i β‰₯ 1); 3. S...