Data Analyst
Once, a Yandex Ads anti-fraud intern joined the team. While the fraudster group was active, which simulated traffic on their sites through bot visits, and thus received money for ad impressions by bots, the intern's task was to find all such fraudulent sites with fake traffic. Interestingly, all traffic on these sites was generated with IP substitution, making it seem as if a bot was visiting from city A, but in reality, the device was in a completely different location. A lot of time passed, and the intern tried to cover this entire fraud group, even managing to catch some sites in parts. But the whole network could not be caught. After some time, he noticed a news report: in city A, on 02.08.2025, mobile internet was completely absent. However, wired (home) internet continued to work. Given this, how can the intern find all fake sites? You have logs of sites in a table format for the period from 30.07.2025 to 10.08.2025: timestamp | site_id | city_id Each record corresponds to a visit to a site by one device. It is known that bot traffic changes significantly less than real traffic per day. Your task is to find all sites whose traffic was mainly composed of bots that faked their region to city A. Note The table containing the data is called logs. Example of a table record: timestamp | site_id | city_id [phone]:13:53 | 6e84d9b71ca44aea | A
Afanasy had been working for 2 weeks on writing code capable of solving Japanese crossword puzzles with support for nine colors, when at a team meeting, a colleague told him that he could handle the task faster himself, and there was no point in the program anymore. But Afanasy, being an optimist, decided to continue practicing this task and do the following — estimate how well his colleague handles crosswords. For this assessment, he chose an analog of the IoU metric — the calculation will be similar to the classic Intersection Over Union, but by colors. It works as follows: each matching cell in the original and the solution by color adds 1 to the numerator, and in the denominator, 1 is added for each cell in the original and the solution (for matching cells, only one is added). After that, averaging is performed over the number of colors in the original image, rounded to two decimal places; zero is not considered a color, so the metric should not be calculated for cells of this color. Input starts with a line containing the number of rows n and columns m (in that order). Then, 2n lines follow, containing m numbers separated by spaces — the first n lines relate to the submitted crossword, and the next n — to the original image. It is assumed that each line, starting from the second, contains exactly m numbers. As an answer, output a number rounded to two decimal places, as in the examples. Here are some examples: 1. First example [phone] -> 1.0 Explanation: the contribution of matching and non-matching cells (1.0 + 1.0 + 1.0 + 1.0) / number of colors (4) 2. Second example [phone] -> 0.08 Explanation: the contribution of matching and non-matching cells (0.25 + 0.0 + 0.0) / number of colors (3); zeros are not counted, neither as cells in representations nor in the number of colors. 3. Third example [phone] where the submitted image starts [phone] — where the submitted image ends 0 1 2 — where the original image begins [phone] -> 0.47 Explanation: the contribution of matching and non-matching cells (0.4 + 0.5 + 0.5) / number of colors (3); zeros are not counted as cells in representations nor in the number of colors. 4. Fourth example [phone] -> 0.0 Explanation: the contribution of matching and non-matching cells (0.0) / number of colors (1); zeros are not counted as cells in representations nor in the number of colors.
B. Prefixes and Suffixes Given a sorted array of n zeros. At each step, you can choose an arbitrary number of the first or last elements of this array, and add one to all selected elements. Is it possible to reach the specified state of the array after some number of such operations? Input format The first line contains an integer 1 ≤ n ≤ 100000 — the number of elements in the array. The second line contains n non-negative integers a1, a2, ..., an separated by spaces, where ai ≤ 10^18 — the desired final elements. Output format Print "YES" if such a state is achievable, and "NO" if it is not. Example Input [phone] Output YES Note The states [phone] can be reached as follows: add one to the first three elements, resulting in [phone] add one to the last four elements, resulting in [phone] add one to the last element, resulting in [phone]
D. Chinese fireworks Vladimir bought a set of 3 Chinese fireworks. They look exactly the same and are mixed in a box, but according to the instructions, they have different reliability: 1. "Elite" — defect rate 10% (success probability 0.9). 2. "Standard" — defect rate 20% (success probability 0.8). 3. "Economy" — defect rate 40% (success probability 0.6). Vladimir randomly takes the first firework, lights it, and it successfully fires. Happy, Vladimir decides to launch the remaining two fireworks one after another. What is the probability that both the second and third fireworks will also successfully fire — without defect? Round the answer to three decimal places. Output format A decimal number rounded to 3 decimal places. For example, 0.98 or 0.999
Would the proposed solution work for SQLite?
A. The Best Scientific Laboratory In a certain city, several scientific laboratories are researching bacterial cultures. They study a sequence of samples, where each sample belongs to a specific strain (type of bacteria). The chief biological research university announced a contest: to find the maximum number of consecutive samples that can be analyzed considering the restriction. Specifically: in any continuous segment of the sequence, there should be no more than K different strains. Our laboratory strives to become the best in the city. To win the contest, we need to find exactly such a maximum length of a segment that satisfies the strict condition. We are counting on you, because in case of victory, the laboratory will receive a grant that will open new horizons for our research. Input format The first line contains two numbers: N — the length of the sample sequence and K — the restriction on the number of different strains. The second line contains N numbers — the elements of the sequence. Output format The program should output the number of the maximum length of a segment of the sample sequence. Example 1 Input [phone] Output 3
D. Valera and vending machines In a business center, there are 10 externally identical vending machines with chocolates. Each machine dispenses a chocolate with its own fixed probability, which is initially unknown and may differ between machines. Sweet-tooth Valera wants to get as many chocolates as possible, but his budget is limited to 200 tugrik. Each purchase attempt (using any machine once) costs exactly 1 tugrik — payment is made regardless of whether the machine dispenses a chocolate or not. Valera, trying to learn the probabilities of the machines, met security guard Alexei, who shared an important piece of information. The guard told him that 2/5 of the machines have probabilities drawn from a uniform distribution on [0.2, 0.3], 2/5 from [0.4, 0.5], and the rest from [0.85, 1]. Your task is to devise an algorithm that helps Valera get as many chocolates as possible. Interaction protocol This is an interactive task. Your program should first output the number of the machine — a number from 0 to 9. Then the system (interactor) will return the result: 1 if a chocolate was dispensed, or 0 if not. Your program can read this value (for example, via input()) to use in further calculations. Scoring system In each test, the percentage of successful attempts to get chocolates will be evaluated. If this percentage exceeds 75%, the test is considered passed. Note It is recommended to use Python 3.8 (Handbook DS) as the compiler.