tests dict | problem stringlengths 29 13k |
|---|---|
{
"inputs": [
"10\n1\n248618\n3\n12 10 8\n6\n100 11 15 9 7 8\n4\n0 1 1 0\n2\n0 0\n2\n0 1\n2\n1 0\n2\n1 1\n3\n0 1 0\n3\n1 0 1\n",
"10\n1\n248618\n3\n12 10 8\n6\n100 11 15 9 2 8\n4\n0 1 1 0\n2\n0 0\n2\n0 1\n2\n1 0\n2\n1 1\n3\n0 1 0\n3\n1 0 1\n",
"10\n1\n451008\n3\n12 10 8\n6\n000 11 15 9 2 8\n4\n0 1 1 0\n2\... | You're given an array a_1, …, a_n of n non-negative integers.
Let's call it sharpened if and only if there exists an integer 1 ≤ k ≤ n such that a_1 < a_2 < … < a_k and a_k > a_{k+1} > … > a_n. In particular, any strictly increasing or strictly decreasing array is sharpened. For example:
* The arrays [4], [0, 1], [... |
{
"inputs": [
"2\nxa\nay\n",
"2\nab\ncd\n",
"3\naab\nbcb\nbac\n",
"5\ncbbbb\nbcbbb\naacbb\naaacb\naaaac\n",
"20\nbifcabiabgfibfccdbgd\ncffaheagahcbacafbgeb\njagcacbadagcedbigaja\naaadicdbjdiibhihbgeb\nhiijbehdeaafdabiigha\nfiifibibgddjfbdafbif\nhdbgbcfjdgibadabfgaf\ngggdaijhfgbaidfajdaj\nfajhebaaa... | Given an n × n table T consisting of lowercase English letters. We'll consider some string s good if the table contains a correct path corresponding to the given string. In other words, good strings are all strings we can obtain by moving from the left upper cell of the table only to the right and down. Here's the form... |
{
"inputs": [
"3 3\n0 0\n3 0\n0 4\n1 2\n2 3\n3 1",
"6 6\n0 0\n0 1\n1 0\n30 0\n0 40\n30 40\n1 2\n2 3\n3 1\n4 5\n5 6\n6 4",
"4 3\n0 0\n-100 0\n100 0\n0 100\n1 2\n1 3\n1 4",
"6 7\n2 0\n6 0\n8 2\n6 3\n0 5\n1 7\n1 2\n2 3\n3 4\n4 1\n5 1\n5 4\n5 6",
"3 3\n0 0\n3 0\n0 4\n1 4\n2 3\n3 1",
"6 7\n2 0\n6 -... | Nicholas Y. Alford was a cat lover. He had a garden in a village and kept many cats in his garden. The cats were so cute that people in the village also loved them.
One day, an evil witch visited the village. She envied the cats for being loved by everyone. She drove magical piles in his garden and enclosed the cats w... |
{
"inputs": [
"2 2 7\n4 3\n",
"3 1 1\n1 1 1\n",
"2 2 30\n4 3\n",
"1 1 1\n1\n",
"23 2 5065472115\n428801639 184568779 477337858 18989778 249804431 579004904 679880522 901530462 200642926 941909941 377757672 300378484 103633484 503801915 910270476 13399319 214483686 671551510 986061470 346894110 521... | Anya loves to fold and stick. Today she decided to do just that.
Anya has n cubes lying in a line and numbered from 1 to n from left to right, with natural numbers written on them. She also has k stickers with exclamation marks. We know that the number of stickers does not exceed the number of cubes.
Anya can stick a... |
{
"inputs": [
"4 3\n",
"22 12\n",
"8 9\n",
"20 12\n",
"12 12\n",
"3 999279109\n",
"11 999286606\n",
"7 999228288\n",
"12 22\n",
"1000000000 1\n",
"20 6\n",
"8 3\n",
"999639051 3\n",
"14 10\n",
"1 12\n",
"1213 5\n",
"12 23\n",
"1 1\n",
"12 13\... | Holidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university of her dreams which is located in a town Pavlopolis. It's well known that universities provide students with dormitory for the period of university studies. Consequently Noora had to leave Vičkopolis and move to Pavlopo... |
{
"inputs": [
"ABACABA",
"ABBCABA",
"ABABBBA",
"@BABBBA",
"@BABCBA",
"AB@BCAB",
"BCABACB",
"ABCBACB",
"ABACBBA",
"ABBBABA",
"ABBB@BA",
"AB@BBBA",
"ABCBAB@",
"BABB@BA",
"@BABCBB",
"AB@BBAB",
"?BABCBB",
"BABBABA",
"BBCBAB?",
"BACBABA",
... | Mike likes strings. He is also interested in algorithms. A few days ago he discovered for himself a very nice problem:
You are given an AB-string S. You need to count the number of substrings of S, which have an equal number of 'A'-s and 'B'-s.
Do you know how to solve it? Good. Mike will make the problem a little ... |
{
"inputs": [
"1000 6\n-100 -200 -300 125 77 -4\n",
"10 4\n-3 -6 5 4\n",
"1000000000000 5\n-1 0 0 0 0\n",
"1 1\n-1000000\n",
"1000 13\n0 0 0 -3 -5 0 0 0 0 -1 -1 0 7\n",
"1000000000000 10\n8 10 3 0 -4 3 -7 -6 3 -6\n",
"100000 5\n0 0 0 0 0\n",
"6000 6\n-199 -19009 19009 -199 -199 -199\n"... | A superhero fights with a monster. The battle consists of rounds, each of which lasts exactly n minutes. After a round ends, the next round starts immediately. This is repeated over and over again.
Each round has the same scenario. It is described by a sequence of n numbers: d_1, d_2, ..., d_n (-10^6 ≤ d_i ≤ 10^6). Th... |
{
"inputs": [
"5\n00011\n00101\n01000\n10101\n00010\n8\n11000001\n10110111\n01100111\n01111010\n11111111\n01011010\n10100010\n10000001\n2\n01\n00\n3\n000\n000\n000\n0",
"5\n00011\n00101\n01000\n10101\n00010\n8\n11000001\n10110111\n01100111\n01111010\n11111111\n01001010\n10100010\n10000001\n2\n01\n00\n3\n000\n... | There is a n × n grid D where each cell contains either 1 or 0.
Your task is to create a program that takes the gird data as input and computes the greatest number of consecutive 1s in either vertical, horizontal, or diagonal direction.
For example, the consecutive 1s with greatest number in the figure below is circl... |
{
"inputs": [
"5\n1 2 3 4 5\n1000000000 1000000000 1000000000 1000000000 1000000000",
"4\n3 1 4 2\n10 20 30 40",
"1\n1\n10",
"9\n4 2 5 8 3 6 1 7 9\n6 8 8 4 6 3 5 7 5",
"5\n1 2 3 4 5\n1000000000 1000000010 1000000000 1000000000 1000000000",
"4\n3 1 4 2\n10 20 2 40",
"9\n4 2 5 8 3 6 1 7 9\n6... | There are N flowers arranged in a row. For each i (1 \leq i \leq N), the height and the beauty of the i-th flower from the left is h_i and a_i, respectively. Here, h_1, h_2, \ldots, h_N are all distinct.
Taro is pulling out some flowers so that the following condition is met:
* The heights of the remaining flowers ar... |
{
"inputs": [
"5 2 3\n3\n5\n1\n2\n3\n3 100 100\n3\n3\n4\n20 3 8\n3\n2\n6\n1\n9\n1\n8\n4\n2\n2\n8\n1\n8\n8\n2\n5\n3\n4\n3\n8\n7 2 2\n0\n2\n5\n2\n5\n2\n1\n0 0 0",
"5 2 3\n3\n5\n1\n2\n3\n3 100 100\n3\n3\n4\n20 3 8\n3\n2\n6\n1\n9\n1\n8\n4\n2\n2\n8\n1\n8\n8\n2\n6\n3\n4\n3\n8\n7 2 2\n0\n2\n5\n2\n5\n2\n1\n0 0 0",
... | coastline
Waves rush to the beach every second. There is data that observes and records how many meters the wave rushed beyond the reference point P every second for only T seconds. The data consists of T integers x1, ..., xT, and for each i (1 ≤ i ≤ T), a wave from point P to the point exactly xi m rushes in i second... |
{
"inputs": [
"8\n-10 0\n-6 6\n0 10\n6 6\n10 0\n6 -6\n0 -10\n-6 -6\n",
"5\n2 4\n2 7\n5 7\n5 4\n3 -2\n",
"4\n-1000000000 -5000000\n0 1234567\n1 1\n-5 -100000000\n",
"4\n-1000000000 1000000000\n1000000000 1000000000\n1000000000 -1000000000\n-1000000000 -1000000000\n",
"4\n-664436138 -678445515\n-664... | Limak is a little polar bear. According to some old traditions, his bear family prepared a New Year cake. And Limak likes cakes.
As you may know, a New Year cake is a strictly convex polygon with n vertices.
Parents won't allow Limak to eat more than half of a cake because he would get sick. After some thinking they ... |
{
"inputs": [
"2\n8\n8 2 12 6 4 24 16 3\n1\n2\n",
"25\n1\n19\n1\n2\n1\n4\n2\n2 4\n1\n5\n2\n2 5\n2\n4 5\n3\n5 2 4\n1\n10\n2\n2 10\n2\n10 4\n3\n2 10 4\n2\n10 5\n3\n2 5 10\n3\n10 4 5\n4\n2 5 10 4\n1\n20\n2\n20 2\n2\n4 20\n3\n4 2 20\n2\n5 20\n3\n2 20 5\n3\n5 20 4\n4\n4 2 5 20\n2\n20 10\n",
"25\n3\n12 3 2\n2\n... | We guessed some integer number x. You are given a list of almost all its divisors. Almost all means that there are all divisors except 1 and x in the list.
Your task is to find the minimum possible integer x that can be the guessed number, or say that the input data is contradictory and it is impossible to find such n... |
{
"inputs": [
"3\n21 4 0\n5 4 3\n22 7 10\n\nSAMPLE",
"3\n21 4 0\n5 4 3\n22 7 12\n\nSAMPLE",
"3\n21 4 0\n5 4 3\n22 7 3\n\nSAMPLE",
"3\n21 4 0\n5 4 3\n22 13 3\n\nSAMPLE",
"3\n21 5 0\n5 4 3\n22 13 3\n\nSAMPLE",
"3\n21 5 0\n5 4 3\n22 26 3\n\nSAMPLE",
"3\n21 5 0\n5 4 5\n22 26 3\n\nSAMPLE",
... | Tom is very weak at maths, his teacher gave him a simple problem of dividing two numbers but as usual Tom is having difficulty solving the problem. Can you help tom solve the problem ?
Teacher has given him 3 numbers a, b and c. The task is to divide a by b and write the answer upto c decimal places.
Input:
The firs... |
{
"inputs": [
"5\n10 100 20 200 1\n",
"6\n1 1 1 2 2 2\n",
"1\n100000\n",
"13\n1 1 1 2 2 2 3 3 3 4 4 4 5\n",
"7\n3 2 1 1 4 5 1\n",
"10\n30518 96518 74071 59971 50121 4862 43967 73607 19138 90754\n",
"10\n4 10 4 4 5 10 10 4 10 10\n",
"10\n63649 14562 779 31060 84730 3390 1402 70955 27426... | This problem is same as the previous one, but has larger constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.
For each of the n days since the day Shiro moved to th... |
{
"inputs": [
"3\n1 1 1\n2 2 1\n3 3 1\n",
"6\n1 1 5\n3 5 5\n1 2 5\n3 6 5\n2 3 5\n3 7 5\n",
"12\n1 9 1\n1 8 1\n1 7 1\n1 6 1\n1 1 1\n1 2 1\n1 3 1\n1 4 1\n2 5 1\n3 12 1\n3 14 2\n3 15 999999999\n",
"20\n1 1 1\n1 2 2\n1 3 3\n1 4 4\n1 5 5\n2 11 5\n2 12 4\n2 13 3\n2 14 2\n2 15 1\n3 6 1\n3 7 2\n3 8 3\n3 9 4\n... | Little Artem has invented a time machine! He could go anywhere in time, but all his thoughts of course are with computer science. He wants to apply this time machine to a well-known data structure: multiset.
Artem wants to create a basic multiset of integers. He wants these structure to support operations of three typ... |
{
"inputs": [
"ABAABBBAABABAAABBAA\nAABBBABBABBAAABABABAAB\nBABAABAABABABBAAAB\nAABABAAABBAABBBABAA\nAAAAAAAAAAA\nABBBBBBBBBB\n0",
"AABBAAABABAABBBAABA\nAABBBABBABBAAABABABAAB\nBABAABAABABABBAAAB\nAABABAAABBAABBBABAA\nAAAAAAAAAAA\nABBBBBBBBBB\n0",
"ABAABBBAABABAAABBAA\nAABBBABBABBAAABABABAAB\nBABAABAABABA... | It's been a while since I played with A, B, and C. Mr. A and Mr. B became players, and Mr. C became a referee and played a badminton singles game. The rules decided by the three people are as follows.
* 3 Play the game.
* The person who gets 11 points first wins the game.
* The first serve of the first game starts wit... |
{
"inputs": [
"5 5\n0 9 2 7 0\n9 0 3 0 5\n0 8 0 3 1\n6 7 4 3 9\n3 6 4 1 0\n",
"2 2\n1 2\n3 4\n",
"1 1\n1000000000\n",
"1 1\n651532387\n",
"5 5\n999999999 999999999 999999999 999999999 999999999\n999999999 999999999 999999999 999999999 999999999\n999999999 999999999 999999999 999999999 999999999\n9... | It is Bubble Cup finals season and farmer Johnny Bubbles must harvest his bubbles. The bubbles are in a rectangular bubblefield formed of N x M square parcels divided into N rows and M columns. The parcel in i^{th} row and j^{th} column yields A_{i,j} bubbles.
Johnny Bubbles has available a very special self-driving b... |
{
"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",
"2\naba\naaaa\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... |
{
"inputs": [
"5\n2\n2\n2\n2\n2\n",
"3\n2\n1\n1\n",
"2\n250000\n250000\n",
"10\n6\n1\n6\n10\n5\n7\n5\n6\n1\n1\n",
"2\n1\n1\n",
"3\n1\n250000\n1\n",
"5\n5\n4\n3\n2\n1\n",
"20\n10\n2\n7\n9\n8\n7\n2\n5\n6\n6\n1\n6\n4\n2\n5\n5\n5\n3\n2\n8\n",
"42\n9\n7\n22\n4\n22\n17\n7\n15\n15\n1\n7\n... | The Smart Beaver from ABBYY started cooperating with the Ministry of Defence. Now they train soldiers to move armoured columns. The training involves testing a new type of tanks that can transmit information. To test the new type of tanks, the training has a special exercise, its essence is as follows.
Initially, the ... |
{
"inputs": [
"5\n1 2 2\n2 3 4\n3 4 10\n3 5 18\n",
"6\n1 2 6\n1 3 8\n1 4 12\n2 5 2\n2 6 4\n",
"3\n1 2 1000\n2 3 100\n",
"2\n1 2 10000\n",
"2\n1 2 3182\n",
"6\n3 4 4772\n3 2 3920\n1 5 8416\n1 3 7736\n3 6 1540\n",
"2\n1 2 100\n",
"3\n2 3 4524\n2 1 6394\n",
"10\n8 2 3660\n5 6 4138\n1 ... | Note that this is the second problem of the two similar problems. You can hack this problem if you solve it. But you can hack the previous problem only if you solve both problems.
You are given a tree with n nodes. In the beginning, 0 is written on all edges. In one operation, you can choose any 2 distinct leaves u, v... |
{
"inputs": [
"2\n5\n10\n\nSAMPLE",
"2\n5\n10\n\nSAMPKE",
"2\n5\n18\n\nSAMPKE",
"2\n5\n20\n\nEKPLAS",
"2\n5\n28\n\nEKPLAS",
"2\n1\n38\n\nEKPLAS",
"2\n1\n64\n\nLKPEAS",
"2\n5\n13\n\nSAMPKE",
"2\n10\n18\n\nEKPLAS",
"2\n4\n18\n\nEKPLAS",
"2\n5\n34\n\nEKPLAS",
"2\n1\n40\n\n... | Alfi asked Roy to go for shopping with her. Witty Roy came up with a condition. He said, for each product of MRP (Maximum Retail Price) R, she'll have to pay minimum of all the prime factors of R and he himself will pay rest of the amount. Without giving it a second thought Alfi agreed.
Now they bought N number of pr... |
{
"inputs": [
"1",
"2",
"9",
"15485863\n",
"999983\n",
"9\n",
"29000087\n",
"29\n",
"27\n",
"31\n",
"7\n",
"2691939\n",
"452405440\n",
"1\n",
"13567\n",
"1000003\n",
"2\n",
"16\n",
"58376259\n",
"685146646\n",
"387420488\n",
"1000... | Fox Ciel wants to write a task for a programming contest. The task is: "You are given a simple undirected graph with n vertexes. Each its edge has unit length. You should calculate the number of shortest paths between vertex 1 and vertex 2."
Same with some writers, she wants to make an example with some certain output... |
{
"inputs": [
"2 2 2 2\n1 3\n2 4\n",
"2 2 5 2\n1 3\n2 4\n",
"5 5 20 100\n464 757 53 708 262\n753 769 189 38 796\n394 60 381 384 935\n882 877 501 615 464\n433 798 504 301 301\n",
"10 10 50 80\n529 349 889 455 946 983 482 179 590 907\n436 940 407 631 26 963 181 789 461 437\n367 505 888 521 449 741 900 9... | As we know, DZY loves playing games. One day DZY decided to play with a n × m matrix. To be more precise, he decided to modify the matrix with exactly k operations.
Each modification is one of the following:
1. Pick some row of the matrix and decrease each element of the row by p. This operation brings to DZY the v... |
{
"inputs": [
"40",
"66",
"9",
"28",
"76",
"17",
"15",
"117",
"14",
"5",
"107",
"25",
"187",
"29",
"140",
"180",
"324",
"77",
"47",
"30",
"54",
"6",
"65",
"12",
"11",
"10",
"13",
"16",
"138",
"4",
... | A bacteria lifespan is represented as follows:-
0th year- born
1st year- Does not reproduce only grows
2nd year- Gives birth to another Bacteria
3rd year- Gives birth to another Bacteria and then Dies
Initially in 0th year there is only 1 bacteria
Population in Nth year:-
year-population
0-1
1st year- 1
2nd y... |
{
"inputs": [
"4 4\n2 1 3 4\n3 4 2 1\nR 1\nL 2\nL 1\nL 5\n\nSAMPLE",
"4 3\n2 1 3 4\n3 4 2 1\nR 1\nL 2\nL 1\nL 5\n\nSAMPLE",
"4 3\n2 1 3 4\n3 4 2 1\nR 1\nL 0\nL 1\nL 5\n\nSAMPLE",
"4 4\n2 1 3 4\n3 4 2 1\nR 1\nL 2\nL 0\nL 5\n\nSAMELP",
"4 3\n2 1 3 4\n3 4 2 1\nR 2\nL 0\nL 1\nL 7\n\nSAMPLE",
"4 4\... | Kabra is a very good friend of JP. So JP has assigned him a task. Given an array, two operations can be performed on it. They are
1) L X : Rotate the array towards left by X.
2) R X : Rotate the array towards right by X.
Now you will be given 2 arrays containing N unique elements. The first one is the inital array(A) a... |
{
"inputs": [
"0",
"1",
"1234567894848",
"2",
"3",
"-1",
"4",
"2307894359683",
"8",
"-2",
"-4",
"-3",
"3500144313336",
"15",
"7",
"-7",
"-8",
"4048027520392",
"16",
"-6",
"-12",
"-11",
"2609800078127",
"6",
"-22",
... | We have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller.
* Determine the largest element in the sequence (if there is more than one, choose one). Decrease the value of this element... |
{
"inputs": [
"3 3\n.-.\n---\n--.",
"1 1\n.\n",
"2 2\n..\n..\n",
"8 35\n......................-............\n...-..........-........-...........\n...........-.......................\n-..................................\n...................................\n...........-............-.........-\n........... | DZY loves chessboard, and he enjoys playing with it.
He has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a chessman on it. Each chessman is either white or black. After putting all chessmen, DZY wants that no two chessmen with the sa... |
{
"inputs": [
"2 3\n-2 -1 3\n0 1 3\n2 3 3\n2 2\n-2 0 4\n0 2 3\n2 6\n-3 3 1\n-2 3 2\n-1 3 3\n0 3 4\n1 3 5\n2 3 6\n2 6\n-3 3 1\n-3 2 2\n-3 1 3\n-3 0 4\n-3 -1 5\n-3 -2 6\n0 0",
"2 3\n-3 -1 3\n0 1 3\n2 3 3\n2 2\n-2 0 4\n0 2 3\n2 6\n-3 3 1\n-2 3 2\n-1 3 3\n0 3 4\n1 3 5\n2 3 6\n2 6\n-3 3 1\n-3 2 2\n-3 1 3\n-3 0 4\n... | Vampire
Mr. C is a vampire. If he is exposed to the sunlight directly, he turns into ash. Nevertheless, last night, he attended to the meeting of Immortal and Corpse Programmers Circle, and he has to go home in the near dawn. Fortunately, there are many tall buildings around Mr. C's home, and while the sunlight is blo... |
{
"inputs": [
"2\n5\n0 1 2 3 4\n4\n-3 1 1 1\n",
"1\n10\n-3 -3 -3 -3 -3 -3 -3 -2 7 7\n",
"1\n10\n-9 1 -7 -6 2 2 1 1 5 1\n",
"1\n10\n-9 1 -1 -6 0 -4 4 4 8 2\n",
"1\n10\n-3 -3 -3 -3 0 -3 -3 -2 7 7\n",
"1\n10\n-9 1 -7 -6 0 2 1 1 5 1\n",
"1\n10\n-3 -3 -3 0 0 -3 -2 -2 7 7\n",
"1\n10\n-9 1 -1... | You are given n integers a_1, a_2, ..., a_n, such that for each 1≤ i ≤ n holds i-n≤ a_i≤ i-1.
Find some nonempty subset of these integers, whose sum is equal to 0. It can be shown that such a subset exists under given constraints. If there are several possible subsets with zero-sum, you can find any of them.
Input
E... |
{
"inputs": [
"4 4\n0 0\n6 0\n6 6\n0 6",
"4 2\n0 0\n6 0\n6 6\n0 6",
"4 1\n0 0\n6 0\n6 6\n0 6",
"4 1\n0 0\n6 0\n6 6\n0 9",
"4 1\n0 -1\n6 0\n6 6\n0 9",
"2 1\n0 -1\n6 0\n6 6\n0 9",
"4 4\n0 1\n6 0\n6 6\n0 6",
"4 2\n0 0\n6 0\n9 6\n0 6",
"4 1\n0 0\n6 1\n6 6\n0 6",
"4 4\n0 1\n6 -1\n6 ... | Example
Input
4 4
0 0
6 0
6 6
0 6
Output
35.759506 |
{
"inputs": [
"3\n1 2 0 0\n1 2 0 0",
"3\n1 2 0 0\n1 2 1 0",
"3\n1 2 0 0\n1 2 1 -1",
"3\n1 2 0 0\n2 2 1 0",
"3\n1 2 0 0\n2 2 2 0",
"3\n1 2 0 0\n2 2 0 0",
"3\n1 1 0 0\n2 2 0 0",
"3\n1 2 1 0\n2 2 0 0",
"3\n1 2 1 0\n3 2 0 0",
"3\n2 2 1 0\n3 2 0 0",
"3\n2 2 1 0\n3 2 0 1",
"3... | Problem statement
You and AOR Ika are preparing for a graph problem in competitive programming. Generating input cases is AOR Ika-chan's job. The input case for that problem is a directed graph of the $ N $ vertices. The vertices are numbered from $ 1 $ to $ N $. Edges may contain self-loops, but not multiple edges.
... |
{
"inputs": [
"3 3\nL T 1 1\nT R 3 1\nR B 3 3\nB L 1 3\nL R 2 2\nT B 2 2\n",
"3 4\nL T 1 3\nL B 2 2\nL B 3 3\nT R 1 2\nT B 2 1\nT R 4 1\nB R 4 3\n",
"4 8\nL T 1 1\nL B 2 1\nR T 1 2\nR B 2 2\nL T 3 3\nB R 3 3\nR T 4 4\nT B 5 4\nT B 6 5\nT B 7 6\nT B 8 7\nB L 8 4\n",
"1 1\nL T 1 1\nB R 1 1\n",
"1 1\... | Emuskald is an innovative musician and always tries to push the boundaries of music production. Now he has come up with an idea for a revolutionary musical instrument — a rectangular harp.
A rectangular harp is a rectangle n × m consisting of n rows and m columns. The rows are numbered 1 to n from top to bottom. Simil... |
{
"inputs": [
"3 3\n1 2 3",
"7 1\n1 0 1 0 1 0 1",
"5 10\n1 2 4 8 16",
"5 10\n1 2 5 8 16",
"5 10\n1 2 5 8 14",
"5 10\n1 2 5 14 14",
"8 10\n1 2 5 24 14",
"8 10\n1 2 5 24 11",
"8 10\n1 2 5 6 11",
"8 10\n0 2 5 6 11",
"8 10\n0 1 2 5 11",
"8 10\n0 1 2 5 9",
"8 10\n0 1 2 5... | Exclusive OR (XOR) is an operation on two binary numbers $ x $ and $ y $ (0 or 1) that produces 0 if $ x = y $ and $ 1 $ if $ x \ ne y $. This operation is represented by the symbol $ \ oplus $. From the definition: $ 0 \ oplus 0 = 0 $, $ 0 \ oplus 1 = 1 $, $ 1 \ oplus 0 = 1 $, $ 1 \ oplus 1 = 0 $.
Exclusive OR on two... |
{
"inputs": [
"3 3\n1 2 3\n5 6 1\n4 4 1\n",
"2 2\n1 3\n4 2\n",
"2 3\n4 8 8\n9 2 9\n",
"1 1\n99992\n",
"1 5\n14 14 8 14 14\n",
"3 3\n1 7 6\n4 6 2\n3 3 3\n",
"1 1\n14\n",
"6 5\n8 8 8 8 20\n13 8 16 13 9\n11 5 3 14 18\n13 8 6 18 6\n6 8 9 14 7\n2 14 14 9 3\n",
"8 5\n11 29 11 1 27\n24 16... | You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind you that a... |
{
"inputs": [
"2\n10 20 30 40 500\n1 2 3 4 5",
"2\n10 20 30 40 500\n1 2 0 4 5",
"2\n18 48 35 40 505\n1 0 -1 4 7",
"2\n16 37 1 29 55\n1 -1 -4 4 7",
"2\n8 1 0 -1 4\n-1 -1 1 2 0",
"2\n10 30 30 40 500\n1 2 0 4 5",
"2\n10 30 35 40 500\n1 2 0 4 5",
"2\n10 30 35 40 500\n1 4 0 4 5",
"2\n10... | Geek Sundaram is extremely anxious. He is in a hectic schedule. He has to study for his assessment the next day, watch FRIENDS tv show (in spite of watching every episode more than 5 times.. :P ), prepare questions for the programming contest and also complete his projects. So his friends try to calm him down by advisi... |
{
"inputs": [
"1 1\n2 2\n3 3\n2 2\n",
"3 3\n2 2\n1 1\n2 2\n",
"1 100\n100 1\n99 99\n99 99\n",
"21 22\n21 16\n32 14\n39 35\n",
"12 29\n44 8\n18 27\n43 19\n",
"10 3\n2 5\n1 10\n2 10\n",
"14 47\n47 42\n21 39\n40 7\n",
"6 3\n6 10\n2 5\n4 4\n",
"28 46\n50 27\n23 50\n21 45\n",
"46 33... | Kicker (table football) is a board game based on football, in which players control the footballers' figures mounted on rods by using bars to get the ball into the opponent's goal. When playing two on two, one player of each team controls the goalkeeper and the full-backs (plays defence), the other player controls the ... |
{
"inputs": [
"7\n3 3 4 5 4 5 3\n5 3 4 4 2 3 2",
"1\n2\n3",
"5\n3 2 2 4 1\n1 2 2 2 1",
"4\n1 1 1 1\n1 1 1 1",
"7\n3 3 4 5 4 5 3\n5 3 8 4 2 3 2",
"1\n2\n6",
"5\n3 2 2 4 1\n0 2 2 2 1",
"4\n1 1 0 1\n1 1 1 1",
"7\n3 3 4 5 4 5 3\n5 3 8 4 2 5 2",
"4\n1 1 0 1\n1 1 0 1",
"7\n3 3 4 ... | We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j).
You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down.
The square (i, j) contains A_{i, j} candies. You ... |
{
"inputs": [
"4\n8 2 5\n00110010\n8 1 1\n00110010\n9 100000000 100000000\n010101010\n2 5 1\n00\n",
"2\n2 3 5\n00\n12 4 7\n011101011100\n",
"2\n8 2 5\n01111110\n6 2 5\n001010\n",
"2\n2 3 8\n00\n12 4 7\n011101011100\n",
"2\n8 2 5\n01101110\n6 2 5\n001010\n",
"2\n8 2 5\n00101110\n6 2 5\n001010\n... | You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment [0, n] on OX axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval (x, x + 1) with integer x. So we can represent the road as a binary string consist... |
{
"inputs": [
"7 6\n4 5 2 5 3 6 6\n",
"6 4\n1 5 2 5 3 6\n",
"1 1\n1\n",
"7 6\n4 1 2 5 3 6 6\n",
"6 4\n1 5 2 5 2 6\n",
"6 4\n1 5 2 2 2 6\n",
"6 4\n1 5 2 5 2 0\n",
"6 4\n1 5 2 6 2 6\n",
"6 4\n1 0 2 6 2 6\n",
"7 6\n4 5 1 5 3 6 6\n",
"5 4\n1 5 2 2 2 6\n",
"7 3\n4 1 2 4 2 6 ... | For some array c, let's denote a greedy subsequence as a sequence of indices p_1, p_2, ..., p_l such that 1 ≤ p_1 < p_2 < ... < p_l ≤ |c|, and for each i ∈ [1, l - 1], p_{i + 1} is the minimum number such that p_{i + 1} > p_i and c[p_{i + 1}] > c[p_i].
You are given an array a_1, a_2, ..., a_n. For each its subsegment... |
{
"inputs": [
"6\n10 2 3 5 4 2\n",
"8\n7 6 5 4 3 2 2 3\n",
"4\n100 100 100 100\n",
"20\n6 8 14 8 9 4 7 9 7 6 9 10 14 14 11 7 12 6 11 6\n",
"10\n7 70 8 9 8 9 35 1 99 27\n",
"100\n17 23 71 25 50 71 85 46 78 72 89 26 23 70 40 59 23 43 86 81 70 89 92 98 85 88 16 10 26 91 61 58 23 13 75 39 48 15 73... | You are given a sequence of integers a_1, a_2, ..., a_n. You need to paint elements in colors, so that:
* If we consider any color, all elements of this color must be divisible by the minimal element of this color.
* The number of used colors must be minimized.
For example, it's fine to paint elements [40, 1... |
{
"inputs": [
"3 2\n",
"6 3\n",
"5 1\n",
"10 2\n",
"1000000 1000\n",
"38447 383\n",
"1000000000 1\n",
"1000000000 32170\n",
"5000000 12\n",
"1833 195\n",
"1000000000 999999999\n",
"999999999 500000000\n",
"599222887 298488\n",
"10 6\n",
"1 1\n",
"1000000... | n participants of the competition were split into m teams in some manner so that each team has at least one participant. After the competition each pair of participants from the same team became friends.
Your task is to write a program that will find the minimum and the maximum number of pairs of friends that could ha... |
{
"inputs": [
"1 1\n",
"2 3\n",
"782 19\n",
"1 2892\n",
"61 389\n",
"4830 1\n",
"6354 1\n",
"8 8\n",
"6 8\n",
"1249 19\n",
"1 3575\n",
"61 407\n",
"5803 1\n",
"6354 2\n",
"8 4\n",
"3 3\n",
"1122 19\n",
"1 6589\n",
"5803 2\n",
"6925 2\n",
... | This morning Tolik has understood that while he was sleeping he had invented an incredible problem which will be a perfect fit for Codeforces! But, as a "Discuss tasks" project hasn't been born yet (in English, well), he decides to test a problem and asks his uncle.
After a long time thinking, Tolik's uncle hasn't any... |
{
"inputs": [
"1000 1000000\n",
"4907 244618708\n",
"4054 287739817\n",
"1000 0\n",
"1000 1\n",
"1000 2\n",
"1587 1941728048\n",
"9030 982505993\n",
"10000 3\n",
"10000 2000000000\n",
"4907 248948704\n",
"4054 255445737\n",
"1010 0\n",
"1100 2\n",
"10001 3\n... | The city administration of IT City decided to fix up a symbol of scientific and technical progress in the city's main square, namely an indicator board that shows the effect of Moore's law in real time.
Moore's law is the observation that the number of transistors in a dense integrated circuit doubles approximately ev... |
{
"inputs": [
"3\n1 2 3",
"4\n1 2 4 8",
"3\n1 2 0",
"3\n3 2 1",
"4\n1 2 4 11",
"3\n0 2 0",
"4\n0 2 4 11",
"3\n0 1 0",
"4\n0 4 4 11",
"3\n0 1 -1",
"4\n0 4 4 20",
"3\n1 2 1",
"4\n0 4 1 20",
"3\n2 2 1",
"4\n0 4 1 33",
"4\n0 4 1 63",
"3\n3 4 1",
"4\n... | Snuke has N hats. The i-th hat has an integer a_i written on it.
There are N camels standing in a circle. Snuke will put one of his hats on each of these camels.
If there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print `Yes`; otherwise, print `No... |
{
"inputs": [
"8000\nNEW YORK BUSINESS LOANS FALL 222 MLN DLRS\nNEW YORK, March 26 - Commercial and industrial loans on the\nbooks of the 10 major New York banks, excluding acceptances,\nfell 222 mln dlrs to 64.05 billion in the week ended March 18,\nthe Federal Reserve Bank of New York said.\nIncluding acceptanc... | The Smart Beaver from ABBYY came up with another splendid problem for the ABBYY Cup participants! This time the Beaver invites the contest participants to check out a problem on sorting documents by their subjects. Let's describe the problem:
You've got some training set of documents. For each document you know its su... |
{
"inputs": [
"4\n2 1 3 4\n3 4 2 1\n",
"2\n1 2\n2 1\n",
"74\n52 59 25 35 69 1 54 20 26 12 53 44 24 51 66 16 57 15 7 10 60 31 70 42 61 55 41 33 67 46 28 17 32 13 9 39 43 36 6 38 48 3 29 45 56 64 65 34 21 4 73 74 27 50 5 2 22 68 49 8 71 19 14 40 62 37 72 11 30 58 18 47 63 23\n56 3 68 1 9 70 36 58 52 15 27 5... | The Little Elephant has two permutations a and b of length n, consisting of numbers from 1 to n, inclusive. Let's denote the i-th (1 ≤ i ≤ n) element of the permutation a as ai, the j-th (1 ≤ j ≤ n) element of the permutation b — as bj.
The distance between permutations a and b is the minimum absolute value of the dif... |
{
"inputs": [
"1098\n",
"10\n",
"97\n",
"36\n",
"855520\n",
"956126\n",
"439674440\n",
"990\n",
"30\n",
"69\n",
"38\n",
"196530\n",
"599785072\n",
"999999970\n",
"73180\n",
"920\n",
"21\n",
"9169813\n",
"40\n",
"83\n",
"962131\n",
... | Let's denote a function f(x) in such a way: we add 1 to x, then, while there is at least one trailing zero in the resulting number, we remove that zero. For example,
* f(599) = 6: 599 + 1 = 600 → 60 → 6;
* f(7) = 8: 7 + 1 = 8;
* f(9) = 1: 9 + 1 = 10 → 1;
* f(10099) = 101: 10099 + 1 = 10100 → 1010 → 101.
... |
{
"inputs": [
"3 3\n1\n2 2\n",
"3 3\n1\n1 1\n",
"3 3\n2\n1 1 3 3\n",
"2000 1\n10\n1058 1 1779 1 1995 1 1398 1 96 1 1599 1 1496 1 1659 1 385 1 1485 1\n",
"100 100\n4\n72 12 1 66 57 67 25 67\n",
"1 10\n9\n1 1 1 2 1 3 1 4 1 6 1 7 1 8 1 9 1 10\n",
"100 1\n10\n62 1 63 1 57 1 76 1 35 1 69 1 73 1... | After a terrifying forest fire in Berland a forest rebirth program was carried out. Due to it N rows with M trees each were planted and the rows were so neat that one could map it on a system of coordinates so that the j-th tree in the i-th row would have the coordinates of (i, j). However a terrible thing happened and... |
{
"inputs": [
"4\n10 10 10 10\n",
"6\n1 5 7 4 4 3\n",
"36\n1 10 61 43 27 49 55 33 7 30 45 78 69 34 38 19 36 49 55 11 30 63 46 24 16 68 71 18 11 52 72 24 60 68 8 41\n",
"12\n22 83 2 67 55 12 40 93 83 73 12 28\n",
"100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 ... | There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards will be ... |
{
"inputs": [
"3\n6\n0 3 0 0 1 3\n10\n0 0 0 1 0 5 0 0 0 2\n3\n0 0 0\n",
"3\n6\n0 3 0 0 1 3\n10\n0 0 0 1 0 5 0 0 0 4\n3\n0 0 0\n",
"3\n6\n0 3 0 0 1 3\n10\n1 0 0 1 0 5 0 0 0 4\n3\n0 0 0\n",
"3\n6\n0 3 0 0 1 3\n10\n0 0 0 1 0 5 0 0 0 3\n3\n0 0 0\n",
"3\n6\n0 3 1 0 1 3\n10\n1 0 0 1 0 5 0 0 0 4\n3\n0 0 ... | This week Arkady wanted to cook some pancakes (to follow ancient traditions) and make a problem about that. But then he remembered that one can't make a problem about stacking pancakes without working at a specific IT company, so he decided to bake the Napoleon cake instead.
To bake a Napoleon cake, one has to bake n ... |
{
"inputs": [
"5 4 2\n1 2\n2 3\n4 2\n4 1\n",
"6 5 3\n1 2\n1 3\n1 4\n1 5\n1 6\n",
"5 4 3\n5 1\n5 3\n3 1\n4 2\n",
"4 2 2\n1 2\n1 3\n",
"5 6 2\n3 5\n2 1\n2 5\n1 5\n1 3\n2 4\n",
"5 6 1\n3 1\n4 5\n3 5\n4 3\n1 2\n2 4\n",
"5 4 2\n2 1\n4 1\n4 2\n3 5\n",
"5 3 3\n5 4\n2 4\n2 1\n",
"2 1 1\n2 ... | A tree is a connected undirected graph consisting of n vertices and n - 1 edges. Vertices are numbered 1 through n.
Limak is a little polar bear. He once had a tree with n vertices but he lost it. He still remembers something about the lost tree though.
You are given m pairs of vertices (a1, b1), (a2, b2), ..., (am, ... |
{
"inputs": [
"3 5\n5 1 2 3 4 5\n2 1 2\n2 3 4\n",
"1 1\n0\n",
"1 1\n1 1\n",
"4 11\n10 1 11 4 6 9 2 3 10 5 8\n0\n1 3\n9 6 5 2 9 10 4 1 7 8\n",
"2 1\n0\n1 1\n",
"4 50\n9 26 13 12 16 39 37 42 11 18\n42 4 39 19 29 44 30 5 43 28 38 22 2 33 9 50 13 25 37 45 32 27 1 48 35 11 36 42 26 49 40 8 34 7 12 ... | Santa has prepared boxes with presents for n kids, one box for each kid. There are m kinds of presents: balloons, sweets, chocolate bars, toy cars... A child would be disappointed to receive two presents of the same kind, so all kinds of presents in one box are distinct.
Having packed all the presents, Santa realized ... |
{
"inputs": [
"1 1\n1 2\n",
"12 2\n4 1\n8 1\n",
"3 1\n1 1\n",
"10 4\n8 2\n2 2\n5 2\n7 2\n",
"30 4\n11 2\n8 2\n21 1\n23 1\n",
"18 4\n6 2\n10 2\n13 1\n12 1\n",
"97 15\n63 2\n35 2\n74 2\n20 2\n60 1\n31 2\n68 1\n21 2\n42 1\n29 1\n44 2\n79 1\n73 2\n53 1\n77 1\n",
"99 14\n17 2\n82 2\n85 2\n5... | In a far away land, there are two cities near a river. One day, the cities decide that they have too little space and would like to reclaim some of the river area into land.
The river area can be represented by a grid with r rows and exactly two columns — each cell represents a rectangular area. The rows are numbered ... |
{
"inputs": [
"4\n4 1 3 2 3 2 1 3\n",
"3\n5 8 5 5 7 5\n",
"2\n100000001 95312501 97600001 1\n",
"1\n1000000000 1000000000\n",
"2\n81475384 79354071 83089784 94987161\n",
"4\n4 1 3 2 3 11 1 3\n",
"2\n1 499999999 705032704 1000000000\n",
"2\n186213023 151398020 526707498 169652181\n",
... | Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes.
Strictly speaking, it makes a photo of all points with coordinates (x, y), such that x_1 ≤ x ≤ x_2 and y_1 ≤ y ≤ y_2, where (x_1, y_1) and (x... |
{
"inputs": [
"5 2\n5 2 3\n3 1 4 5 2\n3 5\n",
"4 4\n2 1 11\n1 3 2 4\n1 3 2 4\n",
"4 4\n5 1 4\n4 3 1 2\n2 4 3 1\n",
"4 4\n10 1 5\n1 2 3 4\n1 3 2 4\n",
"1 1\n2 1 2\n1\n1\n",
"5 2\n5 2 3\n3 1 4 2 5\n3 2\n",
"23 5\n10 3 4\n2 1 4 11 8 10 5 6 7 9 12 3 14 13 16 18 21 15 17 19 20 23 22\n4 6 3 18 2... | There are n warriors in a row. The power of the i-th warrior is a_i. All powers are pairwise distinct.
You have two types of spells which you may cast:
1. Fireball: you spend x mana and destroy exactly k consecutive warriors;
2. Berserk: you spend y mana, choose two consecutive warriors, and the warrior with gr... |
{
"inputs": [
"7\nRPS\nRSPP\n",
"5\nRRRRRRRR\nR\n",
"554858576\nP\nP\n",
"1\nRPSSPSRSPRSRSRRPPSRPRPSSRRRRRPPSPR\nS\n",
"1\nPSSSRPSRPRSPRP\nRRPSSPPSPRSSSSPPRSPSSRSSSRRPPSPPPSSPSRRRSRRSSRRPPRSSRRRPPSPRRPRRRPPSPSPPPPRSPPRPRRSRSSSSSPSRSSRPPRRPRRPRPRRRPPSSPPSRRSRPRPSSRSSSRPRPRP\n",
"1958778499\nSPS... | Nikephoros and Polycarpus play rock-paper-scissors. The loser gets pinched (not too severely!).
Let us remind you the rules of this game. Rock-paper-scissors is played by two players. In each round the players choose one of three items independently from each other. They show the items with their hands: a rock, scisso... |
{
"inputs": [
"3 \n30 30 20",
"3 \n12 20 12",
"3 \n30 30 7",
"3 \n12 20 16",
"3 \n30 40 7",
"3 \n12 5 16",
"3 \n30 31 7",
"3 \n7 5 16",
"3 \n30 51 3",
"3 \n7 8 16",
"3 \n30 26 0",
"3 \n30 22 0",
"3 \n7 6 2",
"3 \n30 8 1",
"3 \n7 4 3",
"3 \n30 16 1",
... | Mrityunjay is a high-school teacher, currently coaching students for JEE (Joint Entrance Exam). Mrityunjay every year gives prizes to the toppers of JEE in India. A lot of students give this exam in India and it is difficult for him to manually go through results and select two top students from them. So he asked for y... |
{
"inputs": [
"6 3\n1 2 3 4 5 6\n1 6\n2 5\n3 4\n",
"1 1\n1\n1 1\n",
"6 20\n10 21312 2314 214 1 322\n1 1\n1 2\n1 3\n1 4\n1 5\n1 6\n2 2\n2 3\n2 4\n2 5\n2 6\n3 4\n3 5\n3 6\n4 4\n4 5\n4 6\n5 5\n5 6\n6 6\n",
"5 10\n10 2 7 8 8\n2 5\n3 4\n5 5\n1 3\n3 4\n2 2\n2 5\n4 5\n5 5\n1 2\n",
"5 10\n10 4 7 8 8\n2 5\... | You are given an array with n integers ai and m queries. Each query is described by two integers (lj, rj).
Let's define the function <image>. The function is defined for only u ≤ v.
For each query print the maximal value of the function f(ax, ay) over all lj ≤ x, y ≤ rj, ax ≤ ay.
Input
The first line contains two i... |
{
"inputs": [
"6\n1 2\n2 3\n3 4\n2 5\n3 6\n",
"4\n1 2\n2 3\n3 4\n",
"5\n1 2\n1 3\n1 4\n1 5\n",
"9\n1 2\n1 3\n1 4\n1 5\n1 6\n6 7\n7 8\n7 9\n",
"8\n1 2\n1 3\n1 4\n1 8\n7 8\n6 8\n5 8\n",
"3\n2 3\n1 2\n",
"2\n1 2\n",
"9\n1 2\n2 3\n1 4\n1 5\n1 6\n6 7\n7 8\n7 9\n",
"3\n3 3\n1 2\n",
"... | Ramesses knows a lot about problems involving trees (undirected connected graphs without cycles)!
He created a new useful tree decomposition, but he does not know how to construct it, so he asked you for help!
The decomposition is the splitting the edges of the tree in some simple paths in such a way that each two pa... |
{
"inputs": [
"8\n0 0\n3 2\n6 2\n8 6\n6 5\n7 7\n0 4\n3 4\n8\n0 0\n5 3\n5 2\n4 1\n6 1\n8 6\n6 4\n2 4\n0",
"8\n0 -1\n3 2\n6 2\n8 6\n6 5\n7 7\n0 4\n3 4\n8\n0 0\n5 3\n5 2\n4 1\n6 1\n8 6\n6 4\n2 4\n0",
"8\n0 -1\n3 2\n6 2\n8 6\n6 5\n7 7\n0 4\n3 4\n8\n0 0\n5 3\n4 2\n4 1\n6 1\n8 6\n6 4\n2 4\n0",
"8\n0 -1\n3 3... | There was a large mansion surrounded by high walls. The owner of the mansion loved cats so much that he always prepared delicious food for the occasional cats. The hungry cats jumped over the high walls and rushed straight to the rice that was everywhere in the mansion.
One day the husband found some cats lying down i... |
{
"inputs": [
"5 7 2\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n1 5\n1 4\n2 5\n",
"8 11 4\n1 2\n2 3\n3 4\n4 5\n1 3\n1 6\n3 5\n3 7\n4 7\n5 7\n6 8\n1 5\n2 4\n6 7\n3 8\n",
"6 7 9\n5 6\n2 4\n3 4\n2 3\n2 6\n2 5\n1 6\n2 6\n2 4\n3 5\n2 5\n1 2\n3 5\n2 4\n2 5\n2 6\n",
"8 11 4\n1 2\n2 3\n3 4\n4 5\n1 3\n1 6\n3 5\n3 7\n4 7\n... | In an unspecified solar system, there are N planets. A space government company has recently hired space contractors to build M bidirectional Hyperspace™ highways, each connecting two different planets. The primary objective, which was to make sure that every planet can be reached from any other planet taking only Hype... |
{
"inputs": [
"2 3 1000 1000 1 1 1 2",
"10 10 1 11 3 3 7 7",
"10 10 1 10 3 3 7 7",
"2 3 1001 1000 1 1 1 2",
"16 10 1 10 3 3 7 7",
"2 3 1001 1000 1 2 1 2",
"16 10 1 10 3 3 2 7",
"2 3 1000 1000 1 2 1 2",
"2 3 1000 1000 1 2 0 2",
"2 3 1000 1010 1 2 0 2",
"16 10 0 7 3 3 2 8",
... | The fearless Ikta has finally hunted down the infamous Count Big Bridge! Count Bigbridge is now trapped in a rectangular room w meters wide and h meters deep, waiting for his end.
If you select a corner of the room and take the coordinate system so that the width direction is the x-axis and the depth direction is the ... |
{
"inputs": [
"5 3 3\n0 3 8 5 12\n1 2\n1 3\n2 5",
"5 3 3\n0 3 8 5 12\n1 2\n1 3\n1 5",
"5 3 3\n0 3 8 8 12\n1 3\n1 3\n2 5",
"5 3 3\n0 3 8 8 12\n1 2\n1 3\n2 5",
"5 6 3\n0 3 8 8 12\n1 2\n1 3\n2 5",
"5 3 1\n0 3 8 8 12\n1 3\n1 3\n2 5",
"5 3 3\n0 3 15 8 12\n1 2\n1 3\n3 5",
"5 3 3\n0 6 9 9 12\... | Nobody knows, but N frogs live in Chef's garden.
Now they are siting on the X-axis and want to speak to each other. One frog can send a message to another one if the distance between them is less or equal to K.
Chef knows all P pairs of frogs, which want to send messages. Help him to define can they or not!
Note : Mo... |
{
"inputs": [
"1\n3\n1 2\n1 3\n\n1 1\n\n2 3\n\n3 1\n\n3 1\n\nCorrect",
"1\n4\n2 4\n1 2\n2 4\n4 3\n",
"1\n3\n1 3\n1 2\n1 3\n",
"10\n3\n2 3\n2 3\n1 3\n6\n1 4\n3 4\n2 5\n2 1\n4 6\n2 3\n3\n3 2\n3 2\n1 2\n2\n1 2\n2 1\n3\n2 1\n3 1\n2 3\n2\n2 1\n2 1\n9\n5 7\n2 5\n3 4\n9 8\n1 5\n9 2\n8 4\n9 6\n7 3\n6\n6 3\n3 ... | Note that the only difference between the easy and hard version is the constraint on the number of queries. You can make hacks only if all versions of the problem are solved.
This is an interactive problem.
You are given a tree consisting of n nodes numbered with integers from 1 to n. Ayush and Ashish chose two secre... |
{
"inputs": [
"3 5\n1 2 3\n1 3 2 3 1\n",
"50 50\n75 71 23 37 28 23 69 75 5 62 3 11 96 100 13 50 57 51 8 90 4 6 84 27 11 89 95 81 10 62 48 52 69 87 97 95 30 74 21 42 36 64 31 80 81 50 56 53 33 99\n26 30 5 33 35 29 6 15 36 17 32 16 14 1 29 34 22 40 12 42 38 48 39 50 13 47 18 43 10 8 49 45 11 31 21 37 46 28 20 4... | New Year is coming, and Jaehyun decided to read many books during 2015, unlike this year. He has n books numbered by integers from 1 to n. The weight of the i-th (1 ≤ i ≤ n) book is wi.
As Jaehyun's house is not large enough to have a bookshelf, he keeps the n books by stacking them vertically. When he wants to read a... |
{
"inputs": [
"1 2\n",
"4 6\n",
"6 3\n",
"2 2\n",
"22248 608\n",
"999995 1000\n",
"5 5\n",
"999002 457\n",
"2 997\n",
"999883 200\n",
"1 1000\n",
"1000000 2\n",
"996004 999\n",
"9 8\n",
"810000 901\n",
"1593 66\n",
"199942 1000\n",
"1000000 1000\... | Vasya likes to solve equations. Today he wants to solve (x~div~k) ⋅ (x mod k) = n, where div and mod stand for integer division and modulo operations (refer to the Notes below for exact definition). In this equation, k and n are positive integer parameters, and x is a positive integer unknown. If there are several solu... |
{
"inputs": [
"4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n",
"10 3\n4 8\n9 4\n8 9\n",
"6 1\n2 5\n",
"6 0\n",
"6 15\n1 2\n1 3\n1 4\n1 5\n1 6\n2 3\n2 4\n2 5\n2 6\n3 4\n3 5\n3 6\n4 5\n4 6\n5 6\n",
"18 45\n1 2\n1 5\n1 12\n1 13\n2 3\n2 4\n2 11\n2 14\n2 15\n3 7\n3 16\n4 7\n4 8\n4 10\n4 18\n5 8\n5 10\n5 16\n... | Given a simple graph, output the number of simple cycles in it. A simple cycle is a cycle with no repeated vertices or edges.
Input
The first line of input contains two integers n and m (1 ≤ n ≤ 19, 0 ≤ m) – respectively the number of vertices and edges of the graph. Each of the subsequent m lines contains two intege... |
{
"inputs": [
"5 3\n",
"2 3\n",
"3 7\n",
"716249 716248\n",
"99087 99090\n",
"929061 929052\n",
"8 75\n",
"461363 256765\n",
"4982 2927\n",
"999983 999979\n",
"782250 782252\n",
"9886 8671\n",
"20393 86640\n",
"52 53\n",
"419 430\n",
"397 568\n",
"99... | Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other one's existence.
When Vasya has some free time, he goes to one of his girlfriends. He descends into the subway at some time,... |
{
"inputs": [
"3\n30 10 20 U\n10 10 10 U\n80 60 60 D\n\nSAMPLE",
"32\n10 5 5 U\n10 5 5 D\n10 3 3 D\n10 9 9 U\n10 10 10 U\n10 10 10 D\n100 80 20 U\n100 80 45 U\n100 80 46 U\n100 80 40 D\n100 80 0 D\n100 80 79 D\n100 100 3 U\n100 100 4 U\n100 100 5 U\n100 100 2 U\n100 100 1 D\n100 53 100 U\n100 52 100 U\n100 51... | Jack stays in a n-storey hostel. His dorm room is on the jth floor. Every morning, he is in so much hurry for classes that he cannot not decide whether to take Lift or Stairs to reach ground-floor. He asks you to help him choose either Stairs or Lift based on total time taken to reach ground-floor.
It takes him 10 sec... |
{
"inputs": [
"7 4\n9\n1 2 2 3\n2 3 3 2\n3 2 2 1\n2 1 1 2\n3 2 4 2\n4 2 5 3\n5 3 6 2\n6 2 5 1\n5 1 4 2\n2\n2 2 black\n2 2 red\n",
"5 5\n5\n1 1 2 2\n2 2 4 2\n4 2 4 4\n4 4 2 4\n2 4 2 2\n2\n3 3 black\n3 3 green\n",
"4 5\n6\n1 1 1 3\n1 3 3 3\n3 3 3 1\n3 1 1 1\n1 3 3 1\n1 1 3 3\n2\n2 1 red\n2 2 blue\n",
"1... | Anfisa the monkey got disappointed in word processors as they aren't good enough at reflecting all the range of her emotions, that's why she decided to switch to graphics editors. Having opened the BerPaint, she saw a white rectangle W × H in size which can be painted on. First Anfisa learnt to navigate the drawing too... |
{
"inputs": [
"00:01\n00:00\n",
"05:50\n05:44\n",
"00:00\n01:00\n",
"12:33\n23:33\n",
"10:05\n00:00\n",
"09:09\n00:00\n",
"13:04\n09:58\n",
"01:00\n00:00\n",
"03:48\n00:41\n",
"12:21\n21:12\n",
"12:44\n12:44\n",
"00:00\n00:01\n",
"12:59\n00:45\n",
"05:55\n07:12\... | George woke up and saw the current time s on the digital clock. Besides, George knows that he has slept for time t.
Help George! Write a program that will, given time s and t, determine the time p when George went to bed. Note that George could have gone to bed yesterday relatively to the current time (see the second... |
{
"inputs": [
"3\n0 4 1 0 0 9 8 3\n",
"10\n1 2 3 4 5 6 7 8\n",
"0\n0 0 0 0 0 0 0 0\n",
"51\n13 0 8 0 0 11 5 2\n",
"48\n4 0 2 4 0 3 0 8\n",
"25\n0 0 0 0 2 0 6 0\n",
"34\n4 0 0 0 1 0 0 4\n",
"39402932710920212\n0 0 0 7036655838029546 0 2597660979346835 0 0\n",
"18\n0 0 0 0 0 0 0 4\n"... | You have a set of items, each having some integer weight not greater than 8. You denote that a subset of items is good if total weight of items in the subset does not exceed W.
You want to calculate the maximum possible weight of a good subset of items. Note that you have to consider the empty set and the original set... |
{
"inputs": [
"4\n02:15\n06:01\n11:55\n10:40",
"4\n02:15\n05:01\n11:55\n10:40",
"4\n02:15\n05:01\n11:54\n10:40",
"4\n12:15\n05:01\n11:54\n10:40",
"4\n02:15\n05:01\n11:55\n11:40",
"4\n12:05\n05:01\n11:44\n00:41",
"4\n02:15\n10:50\n11:54\n10:40",
"4\n03:05\n06:11\n11:55\n10:41",
"4\n... | A mischievous notice has arrived from the primitive slow-life organization "Akaruda". Akaruda is famous for mischief such as throwing a pie at the face of a VIP, but recently it has become more radical, such as using gunpowder to sprinkle rat fireworks at the reception venue. The notice is the following text.
--- Per... |
{
"inputs": [
"4\nDivye\nRohit\nAkshat\nParth\nScorpio\nBMW\nFord\nChevrolet\n1 BMW\n1 Ford\n2 Scorpio Chevrolet\n1 Ford"
],
"outputs": [
"No"
]
} | A set of N dignitaries have arrived in close succession at Delhi and are awaiting transportation to Roorkee to participate in the inaugural ceremony of Cognizance. Being big sponsors of Cognizance, it has been deemed unsuitable by the organizing team to arrange for more than one dignitary to travel in a single vehicle.... |
{
"inputs": [
"4 5\n....#\n####.\n.###.\n.#...\n",
"3 5\n.....\n.....\n.....\n",
"3 3\n.#.\n###\n##.\n",
"2 1\n.\n#\n",
"4 2\n##\n.#\n.#\n##\n",
"10 10\n.#..#....#\n#..##...##\n.....##.#.\n.#....#..#\n##.##.###.\n####.##...\n..##.#..##\n..##..#.#.\n..#######.\n####...#.#\n",
"5 5\n.#...\n.... | A monopole magnet is a magnet that only has one pole, either north or south. They don't actually exist since real magnets have two poles, but this is a programming contest problem, so we don't care.
There is an n× m grid. Initially, you may place some north magnets and some south magnets into the cells. You are allowe... |
{
"inputs": [
"10\n",
"31\n",
"255\n",
"4848\n",
"41\n",
"13\n",
"2521\n",
"4444\n",
"28\n",
"1500\n",
"53\n",
"30\n",
"15\n",
"777\n",
"11\n",
"2001\n",
"666\n",
"32\n",
"1984\n",
"511\n",
"20\n",
"5000\n",
"2013\n",
"87\... | We'll call a set of positive integers a beautiful if the following condition fulfills: for any prime p, if <image>, then <image>. In other words, if one number from the set is divisible by prime p, then at least half of numbers from the set is divisible by p.
Your task is to find any beautiful set, where the number of... |
{
"inputs": [
"2\n10\n3\n",
"1\n2\n3\n",
"2\n1\n2\n",
"5\n6\n1\n",
"10\n10\n10\n",
"8\n9\n7\n",
"9\n2\n1\n",
"6\n7\n1\n",
"1\n2\n1\n",
"9\n7\n2\n",
"1\n9\n1\n",
"10\n1\n1\n",
"1\n3\n1\n",
"2\n6\n1\n",
"2\n8\n3\n",
"1\n10\n1\n",
"4\n2\n10\n",
"3\n... | Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last class the teacher wrote three positive integers a, b, c on the blackboard. The task was to insert signs of operations '+' and '*', and probably brackets between the numbers so that the value of the resulting e... |
{
"inputs": [
"100 8 5\n5 2 1 2 1\n",
"100 100 7\n1 2 3 4 5 6 7\n",
"100 100 5\n5 2 1 2 1\n",
"1000000000000 1000000000000 10\n99991 99992 99993 99994 99995 99996 99997 99998 99999 31000000000\n",
"991234567890 927215128595 5\n6 11 8 3 2000000014\n",
"54275126675 128566125 50\n1 1 3 1 1 3 7 1 ... | Consider a table G of size n × m such that G(i, j) = GCD(i, j) for all 1 ≤ i ≤ n, 1 ≤ j ≤ m. GCD(a, b) is the greatest common divisor of numbers a and b.
You have a sequence of positive integer numbers a1, a2, ..., ak. We say that this sequence occurs in table G if it coincides with consecutive elements in some row, s... |
{
"inputs": [
"4\n0 0 x\n2 0 x\n0 1 x\n2 1 x\n4\n1 0 x\n0 1 x\n2 1 x\n1 2 x\n4\n0 0 x\n2 0 y\n0 1 y\n1 2 x\n0",
"4\n0 0 x\n2 0 x\n0 1 x\n2 1 x\n4\n1 0 x\n0 1 x\n2 1 x\n1 2 x\n4\n0 0 x\n2 0 y\n1 1 y\n1 2 x\n0",
"4\n0 0 x\n2 0 x\n0 1 x\n2 1 x\n4\n1 0 w\n0 1 x\n2 1 x\n1 2 x\n4\n0 0 x\n2 0 y\n0 1 y\n1 2 x\n0"... | The sales department of Japanese Ancient Giant Corp. is visiting a hot spring resort for their recreational trip. For deepening their friendships, they are staying in one large room of a Japanese-style hotel called a ryokan.
In the ryokan, people sleep in Japanese-style beds called futons. They all have put their futo... |
{
"inputs": [
"4\n0 1 2 3\n",
"5\n0 1 2 1 2\n",
"61\n17 19 8 53 10 38 59 60 46 25 49 28 46 15 25 56 53 60 60 54 18 49 10 53 29 19 11 61 24 11 17 52 32 54 29 55 0 1 14 56 25 14 33 53 47 56 8 6 53 55 16 46 47 9 24 37 3 52 25 37 26\n",
"61\n45 48 30 23 15 47 8 3 35 56 54 35 17 47 35 56 32 42 14 37 36 44 ... | You are given a tree (a graph with n vertices and n - 1 edges in which it's possible to reach any vertex from any other vertex using only its edges).
A vertex can be destroyed if this vertex has even degree. If you destroy a vertex, all edges connected to it are also deleted.
Destroy all vertices in the given tree or... |
{
"inputs": [
"4\n5\n4 3 1 4 5\n4\n4 4 4 4\n3\n1 1 1\n5\n5 5 1 1 5\n",
"10\n1\n1\n2\n2 1\n3\n3 1 2\n3\n2 2 2\n4\n4 1 4 1\n5\n5 4 3 2 1\n5\n1 2 3 4 5\n6\n3 2 1 6 2 2\n10\n4 5 2 9 6 10 3 7 1 8\n10\n1 3 2 2 2 9 10 10 9 7\n",
"4\n5\n2 3 1 4 5\n4\n4 4 4 4\n3\n1 1 1\n5\n5 5 1 1 5\n",
"10\n1\n1\n2\n2 1\n3\n3... | Ujan decided to make a new wooden roof for the house. He has n rectangular planks numbered from 1 to n. The i-th plank has size a_i × 1 (that is, the width is 1 and the height is a_i).
Now, Ujan wants to make a square roof. He will first choose some of the planks and place them side by side in some order. Then he will... |
{
"inputs": [
"5\nyou\nate\nmy\nhum\ntoast",
"7\nshe\nsells\nsea\nshells\nby\nthe\nseashore",
"7\nshf\nsells\nsea\nshells\nby\nthe\nseashore",
"7\nshf\nsells\nsea\nshells\nby\nteh\nseashore",
"7\nshf\nsells\nsea\nshells\nby\nthd\nseashore",
"7\nshf\nsells\nsea\nshells\nbx\nthd\nseashore",
... | Problem
Here is a list of strings. Let's take a break and play with shiritori. Shiritori is performed according to the following rules.
1. First of all, select one of your favorite strings from the list and exclude that string from the list.
2. Next, select one character string from the list in which the last charact... |
{
"inputs": [
"7 4\n1>3>22<\n1 3\n4 7\n7 7\n1 7\n",
"5 1\n1>3><\n4 5\n",
"4 1\n34><\n1 4\n",
"3 10\n<<<\n2 3\n3 3\n2 3\n3 3\n1 3\n1 1\n1 2\n3 3\n1 1\n2 2\n",
"7 4\n1>3>22<\n1 3\n4 7\n7 7\n1 7\n",
"1 1\n0\n1 1\n",
"10 30\n306<<>4>04\n2 2\n6 6\n1 10\n1 8\n2 4\n9 10\n2 8\n3 5\n7 7\n2... | There is a programming language in which every program is a non-empty sequence of "<" and ">" signs and digits. Let's explain how the interpreter of this programming language works. A program is interpreted using movement of instruction pointer (IP) which consists of two parts.
* Current character pointer (CP);
*... |
{
"inputs": [
"6\naabddc\n",
"3\nabc\n",
"3\njjj\n",
"4\nabcc\n",
"6\nabcdee\n",
"3\nzza\n",
"3\ngcw\n",
"27\nabcdefghijklmnopqrstuvwxyza\n",
"27\nmnpsweykjdvaxyiqtgcuzhbfrlo\n",
"5\naabcd\n",
"2\nba\n",
"7\nkssssss\n",
"1\ne\n",
"5\nfnfvn\n",
"3\naba\n",
... | Panic is rising in the committee for doggo standardization — the puppies of the new brood have been born multi-colored! In total there are 26 possible colors of puppies in the nature and they are denoted by letters from 'a' to 'z' inclusive.
The committee rules strictly prohibit even the smallest diversity between dog... |
{
"inputs": [
"2 5\n2 6\n\nSAMPLE",
"2 5\n3 6",
"4 5\n3 6",
"4 5\n2 6\n\nSAMPLE",
"4 5\n4 6\n\nSAMPLE",
"4 0\n3 6",
"4 0\n4 6",
"7 7\n4 6\n\nSAMPLE",
"4 0\n1 6",
"7 7\n4 10\n\nSAMPLE",
"4 0\n0 6",
"4 0\n0 0",
"0 7\n4 10\n\nSALPME",
"0 1\n4 10\n\nSAMPME",
"6 ... | Sona is in-charge of inviting the guest. She don't know how much far they are from her place. She knows the guest house co-ordinates (gx,gy)and the co-ordinates of the place where she is standing(sx,sy). Help her to calculate the distance between the guest house and her place.
Input
First line contains guest house c... |
{
"inputs": [
"1 1\n4 10 0 0 10 0 10 10 0 10\n-5 -20 30 15\n135 45\n0 -15 15 0\n0 0",
"1 1\n4 10 0 0 9 0 10 10 0 10\n-5 -20 30 15\n135 45\n0 -15 15 0\n0 0",
"1 1\n4 10 0 0 9 0 10 10 0 10\n-5 -20 30 15\n238 45\n0 -15 15 0\n0 0",
"1 1\n4 10 0 0 9 0 10 10 0 10\n-5 -20 30 15\n135 24\n0 -15 15 0\n0 0",
... | Edward R. Nelson is visiting a strange town for some task today. This city is built on a two-dimensional flat ground with several vertical buildings each of which forms a convex polygon when seen from above on it (that is to say, the buidlings are convex polygon columns). Edward needs to move from the point S to the po... |
{
"inputs": [
"6 2\n1 2\n1 3\n2 4\n3 6\n2 5\n1 10\n1 10",
"4 3\n1 2\n2 3\n2 4\n2 10\n1 100\n3 1",
"4 3\n1 2\n2 3\n1 4\n2 10\n1 100\n3 1",
"4 3\n1 2\n2 3\n1 4\n2 10\n1 000\n3 1",
"4 3\n1 2\n2 3\n2 4\n2 19\n1 100\n3 1",
"2 3\n1 2\n2 3\n1 4\n2 10\n1 100\n3 1",
"4 3\n1 2\n2 3\n2 4\n4 10\n1 100... | Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i.
Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0.
Now, the following Q operations will be performed:
* Operation... |
{
"inputs": [
"7\n1 3\n2 3\n3 4\n4 5\n4 6\n6 7",
"7\n1 3\n2 3\n3 4\n4 5\n4 6\n3 7",
"7\n1 3\n2 3\n3 4\n7 5\n4 6\n6 7",
"7\n1 2\n2 3\n3 4\n4 5\n4 6\n6 7",
"7\n1 5\n2 3\n3 4\n1 5\n4 6\n6 4",
"7\n1 3\n2 3\n3 4\n4 5\n4 6\n6 4",
"7\n1 3\n2 3\n3 4\n7 5\n4 6\n3 7",
"7\n1 5\n2 3\n3 4\n4 5\n4 6... | Problem statement
Modulo is very good at drawing trees.
Over the years, Modulo has drawn a picture of a tree with $ N $ vertices. The vertices of this tree are numbered from $ 1 $ to $ N $, and the vertices $ a_i $ and $ b_i $$ (1 \ leq i \ leq N-1) $ are directly connected by edges. All vertices are not yet painted.... |
{
"inputs": [
"2\n5 3\n1 1 1 1 1\n2 1\n3 4",
"2\n5 6\n1 1 1 1 1\n2 1\n3 4",
"2\n5 6\n1 2 1 1 0\n2 1\n2 4",
"2\n5 3\n1 1 1 0 1\n2 1\n3 4",
"2\n5 6\n1 2 1 1 0\n2 1\n1 4",
"2\n8 6\n2 2 0 1 1\n2 2\n2 4",
"2\n11 4\n2 3 -3 1 1\n0 2\n2 4",
"2\n14 1\n2 11 0 1 2\n3 1\n2 7",
"2\n14 1\n2 11 0... | You have a list of N numbers. You are deleting D numbers from the list. Print the minimum sum that can be obtained by adding the remaining numbers after deleting exactly D numbers from the list.
Input
The first line will contain an integer T representing the number of test cases. Each test case will begin with two s... |
{
"inputs": [
"2\n4 10\n7 6\n\nSAMPLE",
"1000\n17 277\n35 390\n37 682\n12 133\n43 991\n37 381\n29 865\n32 1084\n23 352\n7 210\n16 245\n54 558\n57 1062\n5 451\n2 233\n17 445\n69 691\n38 823\n103 1071\n62 976\n28 955\n2 136\n51 670\n18 578\n40 984\n14 398\n11 447\n10 753\n51 573\n16 239\n37 632\n94 1070\n20 569... | Manu is a very bright student and had learned c++ Programming on her own.She has covered loops and if/else.She is a very inquisitive child and always love to discover new things.Same applies to programming she learns various syntax.One day while reading the documentation of a cstdlib library she came across a function ... |
{
"inputs": [
"15",
"100000",
"22",
"37",
"36",
"3",
"5",
"7",
"26",
"38",
"58",
"78",
"57",
"11",
"24",
"199",
"59",
"178",
"389",
"89",
"99",
"499",
"789",
"1697",
"795",
"989",
"4",
"13",
"18",
"... | Takahashi has two positive integers A and B.
It is known that A plus B equals N. Find the minimum possible value of "the sum of the digits of A" plus "the sum of the digits of B" (in base 10).
Constraints
* 2 ≤ N ≤ 10^5
* N is an integer.
Input
Input is given from Standard Input in the following format:
N
Outp... |
{
"inputs": [
"//usr///local//nginx/sbin\n",
"/a//aa/a//\n",
"/root/pokerband/trunk/server/game/code/src/main/java/com/uosipa/pokerband/gameserver/game/\n",
"////////////////////////////////////////////////////////////////////////////////////////////////////\n",
"/aa//b/aa\n",
"/zzzzzzzzzzzzzz... | The new operating system BerOS has a nice feature. It is possible to use any number of characters '/' as a delimiter in path instead of one traditional '/'. For example, strings //usr///local//nginx/sbin// and /usr/local/nginx///sbin are equivalent. The character '/' (or some sequence of such characters) at the end of ... |
{
"inputs": [
"3\n1 4 1\n",
"2\n2 1\n",
"6\n-1 1 0 0 -1 -1\n",
"4\n2 0 -2 -1\n",
"4\n2 -7 -2 -6\n",
"100\n968 793 -628 -416 942 -308 977 168 728 -879 952 781 -425 -475 -480 738 -740 142 -319 -116 -701 -183 41 324 -918 -391 -176 781 763 888 475 -617 134 -802 -133 -211 855 -869 -236 503 550 387 ... | Polycarpus has an array, consisting of n integers a1, a2, ..., an. Polycarpus likes it when numbers in an array match. That's why he wants the array to have as many equal numbers as possible. For that Polycarpus performs the following operation multiple times:
* he chooses two elements of the array ai, aj (i ≠ j);
... |
{
"inputs": [
"4 160\n88 69 62 29 58 52 44\n",
"2 200\n100 250 100\n",
"10 50\n10 1 9 2 8 3 7 4 6 5 5 6 4 7 3 8 2 9 1\n",
"2 9\n10 4 4\n",
"16 61\n7 6 7 13 13 5 8 9 6 11 6 1 0 10 2 2 0 2 7 7 10 5 11 8 11 2 5 0 2 9 12\n",
"5 99\n87 0 65 0 72 0 188 0 91\n",
"1 1000\n1000000\n",
"10 15\n0... | It's another Start[c]up, and that means there are T-shirts to order. In order to make sure T-shirts are shipped as soon as possible, we've decided that this year we're going to order all of the necessary T-shirts before the actual competition. The top C contestants are going to be awarded T-shirts, but we obviously don... |
{
"inputs": [
"3 3\n1 2 3\n2 1 3\n3 3 3\n8 5\n3 3 4 3 4\n2 1 2 3 2\n7 9 7 8 7\n3 4 3 3 4\n1 2 2 3 2\n4 5 6 5 6\n7 9 7 7 8\n4 5 5 6 6\n5 5\n1 2 3 4 5\n2 3 4 5 1\n3 4 5 1 2\n4 5 1 2 3\n5 1 2 3 4\n5 9\n1 1 1 1 1 1 1 1 1\n2 2 2 2 2 2 2 2 2\n3 3 3 3 3 3 3 3 3\n4 4 4 4 4 4 4 4 4\n5 5 5 5 5 5 5 5 5\n0 0",
"3 3\n1 2 ... | Great performance strategy
Taro, an examinee, participated in an N-day study camp. In this training camp, M subjects are tested every day, and after the training camp, a report card with all the test scores is distributed. The report card consists of N sheets of paper, and on the i-th sheet, only the subject names and... |
{
"inputs": [
"3 2\n1 2\n1 2",
"4 3\n1 2\n3 4\n2 3",
"10 10\n8 9\n2 8\n4 6\n4 9\n7 8\n2 8\n1 8\n3 4\n3 4\n2 7",
"3 1\n1 2",
"4 1\n1 2\n3 4\n2 3",
"10 10\n8 9\n2 8\n4 6\n4 9\n7 8\n2 9\n1 8\n3 4\n3 4\n2 7",
"3 2\n1 2\n2 2",
"4 3\n1 2\n3 4\n2 2",
"6 1\n1 2",
"1 1\n1 2\n3 4\n2 3",
... | There are N turkeys. We number them from 1 through N.
M men will visit here one by one. The i-th man to visit will take the following action:
* If both turkeys x_i and y_i are alive: selects one of them with equal probability, then eats it.
* If either turkey x_i or y_i is alive (but not both): eats the alive one.
* ... |
{
"inputs": [
"3\nabc\nabc\na\nb\nabba\nbaab",
"3\nabc\nabc\nb\nb\nabba\nbaab",
"3\nbaa\n`cc\nb\nb\n`bab\nbaac",
"3\naab\n_dc\na\nb\nba`b\ncbaa",
"3\nabc\nacc\na\nb\nabba\nbaab",
"3\nbaa\ndc^\n`\nb\n`b`b\naaac",
"3\n_ba\ndb`\nb\na\ndb`b\nc_ac",
"3\ncbb\n`ab\nb\nb\n`bc`\na_aa",
"3\n... | Chef likes strings a lot but he likes palindromic strings more. Today, Chef has two strings A and B, each consisting of lower case alphabets.
Chef is eager to know whether it is possible to choose some non empty strings s1 and s2 where s1 is a substring of A, s2 is a substring of B such that s1 + s2 is a palindromic ... |
{
"inputs": [
"acbacbacaa\n00000000000000000000000000\n2\n",
"ababab\n01000000000000000000000000\n1\n",
"aaaabaababbbbbbbbbaaabaaabbbababbbbbbabbaaabaabaabaaabaaaabbababbaaaaaaababbaababbabbaabbbabaabbbbababaaabbabbbabaaabbbabbbbbbbbabababaaaaaabaababbbbbaaaaaaaaaaaaaaababbbbabbbbbbababaabbabbbaababaabaaa... | You've got string s, consisting of small English letters. Some of the English letters are good, the rest are bad.
A substring s[l...r] (1 ≤ l ≤ r ≤ |s|) of string s = s1s2...s|s| (where |s| is the length of string s) is string slsl + 1...sr.
The substring s[l...r] is good, if among the letters sl, sl + 1, ..., sr t... |
{
"inputs": [
"3 12\n1 4 5\n",
"3 7\n1 4 9\n",
"2 10\n8 5\n",
"3 100\n10 11 12\n",
"9 98\n4961671 4961689 4961707 4961725 4961743 4961761 4961779 4961797 4961815\n",
"2 5\n3 0\n",
"100 13\n0 13 26 39 52 65 78 91 104 117 130 143 156 169 182 195 208 221 234 247 260 273 286 299 312 325 338 35... | To become the king of Codeforces, Kuroni has to solve the following problem.
He is given n numbers a_1, a_2, ..., a_n. Help Kuroni to calculate ∏_{1≤ i<j≤ n} |a_i - a_j|. As result can be very big, output it modulo m.
If you are not familiar with short notation, ∏_{1≤ i<j≤ n} |a_i - a_j| is equal to |a_1 - a_2|⋅|a_1 ... |
{
"inputs": [
"4\n8\n2 1 3 5 1 2 4 5\n15\n16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1\n2\n3 3\n14\n1 2 3 4 5 6 7 8 9 10 11 12 13 14\n",
"4\n8\n2 1 3 5 1 2 4 5\n15\n16384 8192 4096 2048 1024 504 256 128 64 32 16 8 4 2 1\n2\n3 3\n14\n1 2 3 4 5 6 7 8 9 10 11 12 13 14\n",
"4\n8\n2 1 3 5 1 2 4 5\n15... | You are given an array a consisting of n elements. You may apply several operations (possibly zero) to it.
During each operation, you choose two indices i and j (1 ≤ i, j ≤ n; i ≠ j), increase a_j by a_i, and remove the i-th element from the array (so the indices of all elements to the right to it decrease by 1, and n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.