bartowski/agentica-org_DeepCoder-14B-Preview-GGUF
Text Generation • 15B • Updated
• 1.11k • 62
id int64 1 25.4k | question stringlengths 29 14k | solutions sequencelengths 1 6.38k | starter_code stringlengths 0 955 | input_output stringlengths 33 74M | difficulty stringclasses 6 values | raw_tags stringlengths 2 277 | name nulllengths 4 105 ⌀ | source stringclasses 9 values | tags stringlengths 2 183 | skill_types stringclasses 120 values | url stringlengths 36 108 ⌀ | Expected Auxiliary Space nullclasses 4 values | time_limit stringclasses 130 values | date timestamp[us] | picture_num stringclasses 8 values | memory_limit stringclasses 28 values | Expected Time Complexity nullclasses 9 values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | There are $n$ candy boxes in front of Tania. The boxes are arranged in a row from left to right, numbered from $1$ to $n$. The $i$-th box contains $r_i$ candies, candies have the color $c_i$ (the color can take one of three values — red, green, or blue). All candies inside a single box have the same color (and it is equal to $c_i$).
Initially, Tanya is next to the box number $s$. Tanya can move to the neighbor box (that is, with a number that differs by one) or eat candies in the current box. Tanya eats candies instantly, but the movement takes one second.
If Tanya eats candies from the box, then the box itself remains in place, but there is no more candies in it. In other words, Tanya always eats all the candies from the box and candies in the boxes are not refilled.
It is known that Tanya cannot eat candies of the same color one after another (that is, the colors of candies in two consecutive boxes from which she eats candies are always different). In addition, Tanya's appetite is constantly growing, so in each next box from which she eats candies, there should be strictly more candies than in the previous one.
Note that for the first box from which Tanya will eat candies, there are no restrictions on the color and number of candies.
Tanya wants to eat at least $k$ candies. What is the minimum number of seconds she will need? Remember that she eats candies instantly, and time is spent only on movements.
-----Input-----
The first line contains three integers $n$, $s$ and $k$ ($1 \le n \le 50$, $1 \le s \le n$, $1 \le k \le 2000$) — number of the boxes, initial position of Tanya and lower bound on number of candies to eat. The following line contains $n$ integers $r_i$ ($1 \le r_i \le 50$) — numbers of candies in the boxes. The third line contains sequence of $n$ letters 'R', 'G' and 'B', meaning the colors of candies in the correspondent boxes ('R' for red, 'G' for green, 'B' for blue). Recall that each box contains candies of only one color. The third line contains no spaces.
-----Output-----
Print minimal number of seconds to eat at least $k$ candies. If solution doesn't exist, print "-1".
-----Examples-----
Input
5 3 10
1 2 3 4 5
RGBRR
Output
4
Input
2 1 15
5 6
RG
Output
-1
-----Note-----
The sequence of actions of Tanya for the first example:
move from the box $3$ to the box $2$; eat candies from the box $2$; move from the box $2$ to the box $3$; eat candy from the box $3$; move from the box $3$ to the box $4$; move from the box $4$ to the box $5$; eat candies from the box $5$.
Since Tanya eats candy instantly, the required time is four seconds. | [
"INF = 10000000000.0\nmax_n = 50\nmax_k = 2000\n\ndef main():\n\t(n, s, k) = map(int, input().split())\n\ts -= 1\n\tbuf = [''] * (max_n + 1)\n\tdp = [[0 for i in range(max_n + 1)] for j in range(max_k + 1)]\n\tr = list(map(int, input().split()))\n\tc = input()\n\tanswer = INF\n\tfor i in range(len(c)):\n\t\tbuf[i] ... | {"inputs": ["5 3 10\n1 2 3 4 5\nRGBRR\n", "2 1 15\n5 6\nRG\n", "6 1 21\n4 2 3 5 1 6\nRGBGRB\n", "6 1 21\n6 5 4 3 2 1\nRGBRGB\n", "1 1 10\n10\nR\n", "2 1 10\n5 5\nRG\n", "2 1 10\n5 6\nRR\n", "5 3 10\n1 2 3 4 5\nRGBRG\n", "9 1 6\n1 1 1 3 3 3 2 2 2\nRGGBRRGBB\n", "50 39 2000\n48 43 26 24 46 37 15 30 39 34 4 14 29 34 8 18 40 8 17 37 15 29 2 23 41 7 12 13 36 11 24 22 26 46 11 31 10 46 11 35 6 41 16 50 11 1 46 20 46 28\nBGBBBBBBRGGBBBRRRRBBGRGGRBBRBBBRBBBBBRRGBGGRRRBBRB\n", "50 49 1000\n30 37 34 31 26 44 32 12 36 15 5 5 31 24 17 24 43 19 17 23 45 2 24 17 23 48 20 44 46 44 13 4 29 49 33 41 14 25 46 43 7 47 28 25 2 30 37 37 19 32\nGBBBRBGRBRBRGRGRBBGBGRRBGGRBGRBRRRRRRRBRGRGGGGBRGG\n", "50 32 600\n21 21 18 47 16 11 10 46 9 15 27 5 11 42 29 25 16 41 31 8 12 28 1 24 17 40 45 12 33 32 34 2 45 17 49 17 20 42 15 17 8 29 2 20 4 27 50 1 49 1\nBBRBBGBGBBRBGRRGRGGGBGBRRBBBGGBBBBGBGBRBBGRRGGBRGR\n", "50 37 500\n25 43 15 16 29 23 46 18 15 21 33 26 38 25 2 17 48 50 33 31 3 45 40 12 42 29 37 42 7 11 47 16 44 17 27 46 32 23 14 7 27 25 13 32 43 33 36 39 35 7\nGGBBRGBRRRRBBRGBRRRGGRGGRGGBRRRGBBRRGRGGRBGBGGRGBR\n", "50 4 200\n14 10 50 47 41 9 22 21 42 36 50 10 27 28 39 1 36 12 45 35 17 3 15 25 32 4 34 39 44 34 20 15 18 1 38 25 20 45 24 9 18 15 35 36 12 9 28 4 44 10\nBGBRRBGBRRRGRGRBRGGGRBRRGBBGGRBRRGGRGGGBRRBRGGBGBG\n", "50 50 1250\n1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 50 48 46 44 42 40 38 36 34 32 30 28 26 24 22 20 18 16 14 12 10 8 6 4 2\nRRRRRRRRRRRRRRRRRRRRRRRRRGGGGGGGGGGGGGGGGGGGGGGGGG\n", "30 28 208\n3 42 42 47 46 44 5 28 35 28 35 44 25 44 47 3 3 35 28 5 3 42 3 46 25 25 5 47 46 3\nBGBBGBBBBGRRGGGBRGRGRRGBBRRRRG\n", "39 21 282\n13 39 20 29 30 14 29 29 30 29 16 39 50 13 16 45 36 36 13 20 29 21 34 36 39 30 34 21 20 14 16 45 21 45 29 34 50 50 14\nGGGBRRGRBGBRRBRGRBRBBGBGBGRRRGGRBBRGBGB\n", "48 2 259\n25 31 22 30 30 17 31 50 28 30 46 43 4 6 10 22 50 14 5 46 12 6 46 3 17 12 4 28 25 14 5 5 6 14 22 12 17 43 43 10 4 3 31 3 25 28 50 10\nBBBBGGRRBRRBBRGGGBGGRGBRBGRGRGRBBRRBRRGBGBGGGRBR\n", "48 25 323\n39 37 32 4 4 32 18 44 49 4 12 12 12 22 22 37 38 32 24 45 44 37 18 39 45 22 24 22 45 39 4 22 24 22 12 49 4 29 18 38 29 29 38 44 12 12 49 4\nRRRRRBRRGBBRGRGGBGGBGBBBRBRGGGGBBRGRBGGGRBRBBRBG\n", "48 33 357\n18 37 22 21 4 17 39 32 40 43 29 29 50 21 39 43 11 11 4 50 36 40 32 50 18 32 11 36 29 36 22 21 29 43 49 18 17 29 37 40 17 37 49 4 39 49 22 29\nGRGGGGBRBRRGGRGBRGBBGRBRRGBBRRBBBGRBBBBGRGGRRBRG\n", "50 50 2000\n1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 50 48 46 44 42 40 38 36 34 32 30 28 26 24 22 20 18 16 14 12 10 8 6 4 2\nGRGRGBBGGRGGRRRGGBGGGRRRBGRRBGBRGBBGGGGRRGGBBRRRRG\n", "30 28 208\n3 42 42 47 46 44 5 28 35 28 35 44 25 44 47 3 3 35 28 5 3 42 3 46 25 25 5 47 46 3\nBGBBGBBBBGRRGGGBRGRGRRGBBRRRRG\n", "50 39 2000\n48 43 26 24 46 37 15 30 39 34 4 14 29 34 8 18 40 8 17 37 15 29 2 23 41 7 12 13 36 11 24 22 26 46 11 31 10 46 11 35 6 41 16 50 11 1 46 20 46 28\nBGBBBBBBRGGBBBRRRRBBGRGGRBBRBBBRBBBBBRRGBGGRRRBBRB\n", "50 32 600\n21 21 18 47 16 11 10 46 9 15 27 5 11 42 29 25 16 41 31 8 12 28 1 24 17 40 45 12 33 32 34 2 45 17 49 17 20 42 15 17 8 29 2 20 4 27 50 1 49 1\nBBRBBGBGBBRBGRRGRGGGBGBRRBBBGGBBBBGBGBRBBGRRGGBRGR\n", "48 2 259\n25 31 22 30 30 17 31 50 28 30 46 43 4 6 10 22 50 14 5 46 12 6 46 3 17 12 4 28 25 14 5 5 6 14 22 12 17 43 43 10 4 3 31 3 25 28 50 10\nBBBBGGRRBRRBBRGGGBGGRGBRBGRGRGRBBRRBRRGBGBGGGRBR\n", "1 1 10\n10\nR\n", "9 1 6\n1 1 1 3 3 3 2 2 2\nRGGBRRGBB\n", "5 3 10\n1 2 3 4 5\nRGBRG\n", "6 1 21\n6 5 4 3 2 1\nRGBRGB\n", "2 1 10\n5 5\nRG\n", "2 1 10\n5 6\nRR\n", "50 50 2000\n1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 50 48 46 44 42 40 38 36 34 32 30 28 26 24 22 20 18 16 14 12 10 8 6 4 2\nGRGRGBBGGRGGRRRGGBGGGRRRBGRRBGBRGBBGGGGRRGGBBRRRRG\n", "48 33 357\n18 37 22 21 4 17 39 32 40 43 29 29 50 21 39 43 11 11 4 50 36 40 32 50 18 32 11 36 29 36 22 21 29 43 49 18 17 29 37 40 17 37 49 4 39 49 22 29\nGRGGGGBRBRRGGRGBRGBBGRBRRGBBRRBBBGRBBBBGRGGRRBRG\n", "48 25 323\n39 37 32 4 4 32 18 44 49 4 12 12 12 22 22 37 38 32 24 45 44 37 18 39 45 22 24 22 45 39 4 22 24 22 12 49 4 29 18 38 29 29 38 44 12 12 49 4\nRRRRRBRRGBBRGRGGBGGBGBBBRBRGGGGBBRGRBGGGRBRBBRBG\n", "39 21 282\n13 39 20 29 30 14 29 29 30 29 16 39 50 13 16 45 36 36 13 20 29 21 34 36 39 30 34 21 20 14 16 45 21 45 29 34 50 50 14\nGGGBRRGRBGBRRBRGRBRBBGBGBGRRRGGRBBRGBGB\n", "50 49 1000\n30 37 34 31 26 44 32 12 36 15 5 5 31 24 17 24 43 19 17 23 45 2 24 17 23 48 20 44 46 44 13 4 29 49 33 41 14 25 46 43 7 47 28 25 2 30 37 37 19 32\nGBBBRBGRBRBRGRGRBBGBGRRBGGRBGRBRRRRRRRBRGRGGGGBRGG\n", "50 4 200\n14 10 50 47 41 9 22 21 42 36 50 10 27 28 39 1 36 12 45 35 17 3 15 25 32 4 34 39 44 34 20 15 18 1 38 25 20 45 24 9 18 15 35 36 12 9 28 4 44 10\nBGBRRBGBRRRGRGRBRGGGRBRRGBBGGRBRRGGRGGGBRRBRGGBGBG\n", "6 1 21\n4 2 3 5 1 6\nRGBGRB\n", "50 37 500\n25 43 15 16 29 23 46 18 15 21 33 26 38 25 2 17 48 50 33 31 3 45 40 12 42 29 37 42 7 11 47 16 44 17 27 46 32 23 14 7 27 25 13 32 43 33 36 39 35 7\nGGBBRGBRRRRBBRGBRRRGGRGGRGGBRRRGBBRRGRGGRBGBGGRGBR\n", "50 50 1250\n1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 50 48 46 44 42 40 38 36 34 32 30 28 26 24 22 20 18 16 14 12 10 8 6 4 2\nRRRRRRRRRRRRRRRRRRRRRRRRRGGGGGGGGGGGGGGGGGGGGGGGGG\n", "50 39 2000\n48 43 26 24 46 37 15 30 39 34 4 14 29 34 8 18 40 8 17 37 15 29 2 23 41 7 12 13 36 11 24 22 26 46 11 31 1 46 11 35 6 41 16 50 11 1 46 20 46 28\nBGBBBBBBRGGBBBRRRRBBGRGGRBBRBBBRBBBBBRRGBGGRRRBBRB\n", "48 2 259\n25 31 22 30 30 17 31 50 28 30 46 43 4 6 10 22 50 14 5 46 12 6 46 3 17 12 4 28 25 21 5 5 6 14 22 12 17 43 43 10 4 3 31 3 25 28 50 10\nBBBBGGRRBRRBBRGGGBGGRGBRBGRGRGRBBRRBRRGBGBGGGRBR\n", "9 1 6\n1 1 2 3 3 3 2 2 2\nRGGBRRGBB\n", "2 1 10\n9 5\nRG\n", "48 33 357\n18 37 22 21 4 17 39 32 40 43 29 29 50 21 39 43 11 11 4 50 36 40 32 50 18 32 11 36 29 36 22 21 29 43 49 18 17 29 37 40 17 37 2 4 39 49 22 29\nGRGGGGBRBRRGGRGBRGBBGRBRRGBBRRBBBGRBBBBGRGGRRBRG\n", "39 21 282\n13 39 20 29 30 14 29 29 30 29 16 39 50 13 16 45 36 36 13 10 29 21 34 36 39 30 34 21 20 14 16 45 21 45 29 34 50 50 14\nGGGBRRGRBGBRRBRGRBRBBGBGBGRRRGGRBBRGBGB\n", "50 37 500\n25 43 15 16 29 23 46 18 15 21 33 26 38 25 2 17 48 50 33 31 3 23 40 12 42 29 37 42 7 11 47 16 44 17 27 46 32 23 14 7 27 25 13 32 43 33 36 39 35 7\nGGBBRGBRRRRBBRGBRRRGGRGGRGGBRRRGBBRRGRGGRBGBGGRGBR\n", "39 36 282\n13 39 20 29 30 14 29 29 30 29 16 39 50 13 16 45 36 36 13 10 29 21 34 36 39 30 34 21 20 14 16 45 21 45 29 34 50 50 14\nGGGBRRGRBGBRRBRGRBRBBGBGBGRRRGGRBBRGBGB\n", "30 28 208\n3 42 42 47 46 12 5 28 35 28 35 44 25 44 47 3 3 35 28 5 3 42 3 46 25 25 5 47 46 3\nBGBBGBBBBGRRGGGBRGRGRRGBBRRRRG\n", "9 1 6\n1 1 1 3 3 6 2 2 2\nRGGBRRGBB\n", "5 3 10\n1 2 4 4 5\nRGBRG\n", "39 21 282\n13 39 20 29 30 14 29 29 30 29 16 39 50 13 16 45 36 36 13 20 44 21 34 36 39 30 34 21 20 14 16 45 21 45 29 34 50 50 14\nGGGBRRGRBGBRRBRGRBRBBGBGBGRRRGGRBBRGBGB\n", "50 4 200\n14 10 50 47 41 9 22 21 42 36 50 10 27 28 39 1 36 12 45 35 17 3 15 25 32 4 34 39 44 34 20 15 18 1 38 25 20 3 24 9 18 15 35 36 12 9 28 4 44 10\nBGBRRBGBRRRGRGRBRGGGRBRRGBBGGRBRRGGRGGGBRRBRGGBGBG\n", "6 1 21\n6 5 4 3 4 1\nRGBRGB\n", "50 50 2000\n1 3 5 7 9 11 13 15 32 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 50 48 46 44 42 40 38 36 34 32 30 28 26 24 22 20 18 16 14 12 10 8 6 4 2\nGRGRGBBGGRGGRRRGGBGGGRRRBGRRBGBRGBBGGGGRRGGBBRRRRG\n", "50 49 1000\n30 37 34 31 26 44 32 12 36 15 5 5 31 24 17 24 43 19 17 23 45 2 24 17 23 48 20 44 46 44 13 4 29 49 23 41 14 25 46 43 7 47 28 25 2 30 37 37 19 32\nGBBBRBGRBRBRGRGRBBGBGRRBGGRBGRBRRRRRRRBRGRGGGGBRGG\n", "6 1 21\n4 2 3 5 1 6\nRGBRGB\n", "50 50 1250\n1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 50 48 11 44 42 40 38 36 34 32 30 28 26 24 22 20 18 16 14 12 10 8 6 4 2\nRRRRRRRRRRRRRRRRRRRRRRRRRGGGGGGGGGGGGGGGGGGGGGGGGG\n", "2 1 24\n5 6\nRG\n", "48 2 259\n25 31 22 30 30 17 31 50 28 30 46 43 4 6 10 22 50 27 5 46 12 6 46 3 17 12 4 28 25 21 5 5 6 14 22 12 17 43 43 10 4 3 31 3 25 28 50 10\nBBBBGGRRBRRBBRGGGBGGRGBRBGRGRGRBBRRBRRGBGBGGGRBR\n", "9 1 6\n1 1 2 5 3 3 2 2 2\nRGGBRRGBB\n", "50 50 2000\n1 3 5 7 9 11 13 15 32 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 50 48 46 44 42 40 46 36 34 32 30 28 26 24 22 20 18 16 14 12 10 8 6 4 2\nGRGRGBBGGRGGRRRGGBGGGRRRBGRRBGBRGBBGGGGRRGGBBRRRRG\n", "50 49 1000\n30 37 34 31 26 44 32 12 36 15 5 5 31 24 17 24 43 19 17 23 45 2 24 17 23 48 20 44 46 44 13 4 29 49 23 15 14 25 46 43 7 47 28 25 2 30 37 37 19 32\nGBBBRBGRBRBRGRGRBBGBGRRBGGRBGRBRRRRRRRBRGRGGGGBRGG\n", "6 1 21\n4 2 3 5 1 6\nBGRBGR\n", "50 50 1250\n1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 50 48 11 44 42 40 38 36 34 32 44 28 26 24 22 20 18 16 14 12 10 8 6 4 2\nRRRRRRRRRRRRRRRRRRRRRRRRRGGGGGGGGGGGGGGGGGGGGGGGGG\n", "9 1 6\n1 1 1 5 3 3 2 2 2\nRGGBRRGBB\n", "50 50 2000\n1 3 5 7 9 11 13 15 32 19 21 32 25 27 29 31 33 35 37 39 41 43 45 47 49 50 48 46 44 42 40 46 36 34 32 30 28 26 24 22 20 18 16 14 12 10 8 6 4 2\nGRGRGBBGGRGGRRRGGBGGGRRRBGRRBGBRGBBGGGGRRGGBBRRRRG\n", "39 36 282\n13 39 20 29 30 14 29 29 30 29 16 39 50 13 16 45 36 36 13 10 29 21 34 36 39 30 34 21 21 14 16 45 21 45 29 34 50 50 14\nGGGBRRGRBGBRRBRGRBRBBGBGBGRRRGGRBBRGBGB\n", "50 49 1000\n30 37 34 31 26 44 32 12 36 15 5 5 31 24 17 24 43 19 17 23 45 2 24 17 23 48 20 44 46 44 13 4 29 49 23 15 14 25 46 43 7 47 28 50 2 30 37 37 19 32\nGBBBRBGRBRBRGRGRBBGBGRRBGGRBGRBRRRRRRRBRGRGGGGBRGG\n", "6 1 21\n5 2 3 5 1 6\nBGRBGR\n", "50 50 1250\n1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 50 48 11 44 42 40 38 36 34 32 44 28 26 24 22 20 18 16 14 12 10 8 6 4 2\nGGGGGGGGGGGGGGGGGGGGGGGGGRRRRRRRRRRRRRRRRRRRRRRRRR\n", "9 1 6\n1 1 1 5 3 1 2 2 2\nRGGBRRGBB\n", "50 50 2000\n1 3 5 7 9 11 13 15 32 19 21 32 25 27 29 31 33 35 37 39 41 43 45 47 49 50 48 46 44 42 40 46 36 34 32 30 28 26 24 22 20 18 16 14 12 10 1 6 4 2\nGRGRGBBGGRGGRRRGGBGGGRRRBGRRBGBRGBBGGGGRRGGBBRRRRG\n", "50 49 1000\n30 37 34 31 26 44 32 12 36 15 5 5 31 24 17 24 43 19 17 23 45 2 24 17 23 48 20 44 46 44 13 4 40 49 23 15 14 25 46 43 7 47 28 50 2 30 37 37 19 32\nGBBBRBGRBRBRGRGRBBGBGRRBGGRBGRBRRRRRRRBRGRGGGGBRGG\n", "50 50 1250\n1 3 5 7 9 11 13 15 17 17 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 50 48 11 44 42 40 38 36 34 32 44 28 26 24 22 20 18 16 14 12 10 8 6 4 2\nGGGGGGGGGGGGGGGGGGGGGGGGGRRRRRRRRRRRRRRRRRRRRRRRRR\n", "9 1 6\n1 1 1 5 3 1 4 2 2\nRGGBRRGBB\n", "50 50 2000\n1 3 7 7 9 11 13 15 32 19 21 32 25 27 29 31 33 35 37 39 41 43 45 47 49 50 48 46 44 42 40 46 36 34 32 30 28 26 24 22 20 18 16 14 12 10 1 6 4 2\nGRGRGBBGGRGGRRRGGBGGGRRRBGRRBGBRGBBGGGGRRGGBBRRRRG\n", "50 50 2000\n1 3 7 7 9 11 13 15 32 19 21 32 25 27 29 31 33 35 37 39 41 43 45 47 49 50 48 46 44 42 40 46 36 34 32 30 28 26 24 22 20 18 16 14 12 10 1 10 4 2\nGRGRGBBGGRGGRRRGGBGGGRRRBGRRBGBRGBBGGGGRRGGBBRRRRG\n", "50 50 2000\n1 3 7 7 9 11 13 15 32 19 21 32 25 10 29 31 33 35 37 39 41 43 45 47 49 50 48 46 44 42 40 46 36 34 32 30 28 26 24 22 20 18 16 14 12 10 1 10 4 2\nGRGRGBBGGRGGRRRGGBGGGRRRBGRRBGBRGBBGGGGRRGGBBRRRRG\n", "50 50 2000\n1 3 7 7 9 11 13 15 32 19 21 32 25 10 29 31 33 35 37 39 41 43 45 47 49 50 48 46 44 42 40 46 36 34 32 30 28 26 24 22 20 18 16 14 12 10 1 10 6 2\nGRGRGBBGGRGGRRRGGBGGGRRRBGRRBGBRGBBGGGGRRGGBBRRRRG\n", "50 39 2000\n48 43 26 24 46 37 15 30 39 34 4 14 29 34 8 18 40 8 17 40 15 29 2 23 41 7 12 13 36 11 24 22 26 46 11 31 10 46 11 35 6 41 16 50 11 1 46 20 46 28\nBGBBBBBBRGGBBBRRRRBBGRGGRBBRBBBRBBBBBRRGBGGRRRBBRB\n", "48 2 259\n25 31 22 30 30 17 31 50 28 30 46 43 4 6 10 22 50 14 5 46 12 6 46 4 17 12 4 28 25 14 5 5 6 14 22 12 17 43 43 10 4 3 31 3 25 28 50 10\nBBBBGGRRBRRBBRGGGBGGRGBRBGRGRGRBBRRBRRGBGBGGGRBR\n", "1 1 20\n10\nR\n", "2 1 16\n5 5\nRG\n", "2 1 10\n1 6\nRR\n", "50 50 2000\n1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 7 45 47 49 50 48 46 44 42 40 38 36 34 32 30 28 26 24 22 20 18 16 14 12 10 8 6 4 2\nGRGRGBBGGRGGRRRGGBGGGRRRBGRRBGBRGBBGGGGRRGGBBRRRRG\n", "48 33 357\n18 37 22 21 4 17 39 32 40 43 29 29 50 21 39 43 11 11 4 50 36 40 32 50 18 32 11 36 29 36 22 21 29 43 49 18 17 29 37 40 17 43 49 4 39 49 22 29\nGRGGGGBRBRRGGRGBRGBBGRBRRGBBRRBBBGRBBBBGRGGRRBRG\n", "50 49 1000\n30 37 34 31 26 44 32 12 36 15 5 5 31 24 17 24 43 19 17 23 45 2 31 17 23 48 20 44 46 44 13 4 29 49 33 41 14 25 46 43 7 47 28 25 2 30 37 37 19 32\nGBBBRBGRBRBRGRGRBBGBGRRBGGRBGRBRRRRRRRBRGRGGGGBRGG\n", "6 1 21\n4 2 3 2 1 6\nRGBGRB\n", "50 50 1250\n1 3 5 7 9 11 13 15 17 19 21 1 25 27 29 31 33 35 37 39 41 43 45 47 49 50 48 46 44 42 40 38 36 34 32 30 28 26 24 22 20 18 16 14 12 10 8 6 4 2\nRRRRRRRRRRRRRRRRRRRRRRRRRGGGGGGGGGGGGGGGGGGGGGGGGG\n", "2 1 15\n5 1\nRG\n", "50 39 2000\n48 43 26 24 46 37 15 30 36 34 4 14 29 34 8 18 40 8 17 37 15 29 2 23 41 7 12 13 36 11 24 22 26 46 11 31 1 46 11 35 6 41 16 50 11 1 46 20 46 28\nBGBBBBBBRGGBBBRRRRBBGRGGRBBRBBBRBBBBBRRGBGGRRRBBRB\n", "2 1 15\n5 6\nRG\n", "5 3 10\n1 2 3 4 5\nRGBRR\n"], "outputs": ["4\n", "-1\n", "15\n", "10\n", "0\n", "-1\n", "-1\n", "2\n", "7\n", "-1\n", "-1\n", "185\n", "86\n", "23\n", "992\n", "20\n", "24\n", "39\n", "64\n", "63\n", "-1\n", "20\n", "-1\n", "185\n", "39\n", "0\n", "7\n", "2\n", "10\n", "-1\n", "-1\n", "-1\n", "63\n", "64\n", "24\n", "-1\n", "23\n", "15\n", "86\n", "992", "-1\n", "39\n", "3\n", "2\n", "63\n", "24\n", "86\n", "31\n", "20\n", "5\n", "4\n", "28\n", "23\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "39\n", "3\n", "-1\n", "-1\n", "-1\n", "-1\n", "3\n", "-1\n", "31\n", "-1\n", "-1\n", "-1\n", "3\n", "-1\n", "-1\n", "-1\n", "3\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "39\n", "-1\n", "-1\n", "-1\n", "-1\n", "63\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "4\n"]} | HARD | ['dp'] | null | codeforces | ['Dynamic programming'] | ['Dynamic programming'] | https://codeforces.com/problemset/problem/1057/C | null | null | 2019-12-31T00:00:00 | null | null | null | |
3 | If you visit Aizu Akabeko shrine, you will find a unique paper fortune on which a number with more than one digit is written.
Each digit ranges from 1 to 9 (zero is avoided because it is considered a bad omen in this shrine). Using this string of numeric values, you can predict how many years it will take before your dream comes true. Cut up the string into more than one segment and compare their values. The difference between the largest and smallest value will give you the number of years before your wish will be fulfilled. Therefore, the result varies depending on the way you cut up the string. For example, if you are given a string 11121314 and divide it into segments, say, as 1,11,21,3,14, then the difference between the largest and smallest is 21 - 1 = 20. Another division 11,12,13,14 produces 3 (i.e. 14 - 11) years. Any random division produces a game of luck. However, you can search the minimum number of years using a program.
Given a string of numerical characters, write a program to search the minimum years before your wish will be fulfilled.
Input
The input is given in the following format.
n
An integer n is given. Its number of digits is from 2 to 100,000, and each digit ranges from 1 to 9.
Output
Output the minimum number of years before your wish will be fulfilled.
Examples
Input
11121314
Output
3
Input
123125129
Output
6
Input
119138
Output
5 | [
"def sub(maxs, mins):\n\tfor i in range(len(maxs)):\n\t\tif maxs[i] != mins[i]:\n\t\t\tif i == len(maxs) - 1:\n\t\t\t\treturn int(maxs[i]) - int(mins[i])\n\t\t\tif i == len(maxs) - 2:\n\t\t\t\treturn int(maxs[i:i + 2]) - int(mins[i:i + 2])\n\t\t\treturn 10\n\treturn 0\n\ndef checkEqual(S):\n\tans = 8\n\tfor k in ra... | {"inputs": ["9714431", "16612328", "23422731", "754526", "955577", "75547", "2112", "799", "88", "32523857", "4787", "1859551", "135661", "3675", "156692", "167918384", "83994", "4837847", "14513597", "15282598", "12659326", "1468417", "6280", "115464", "52376853", "2315", "3641224", "97187", "836", "195884", "36250", "2427817", "17598762", "5744554", "9295", "129848", "3863342", "3743", "133862", "1237", "1625", "1179729", "12651", "3776912", "4829", "73", "2228", "2546", "3136", "138", "3380", "4828", "3652", "5667", "7275", "774", "9329", "279", "15119", "200", "2461", "19", "2258", "31", "1250", "1216", "1595", "271", "236", "187", "166", "123", "231272", "12342923", "16587352", "32887158", "42478456", "353843", "1884868", "148239", "54241537", "213811", "3614", "1003", "177127860", "54250", "1720310", "6415742", "12117", "1293", "5541389", "44936", "550", "43448", "664", "39426", "5003285", "73925", "4379155", "2270", "123125129", "119138", "11121314"], "outputs": ["8\n", "7\n", "6\n", "5\n", "4\n", "3\n", "1\n", "2\n", "0\n", "6\n", "4\n", "8\n", "5\n", "4\n", "8\n", "8\n", "6\n", "5\n", "8\n", "8\n", "8\n", "7\n", "8\n", "5\n", "6\n", "4\n", "5\n", "8\n", "5\n", "8\n", "6\n", "7\n", "8\n", "3\n", "3\n", "8\n", "6\n", "4\n", "7\n", "6\n", "5\n", "8\n", "5\n", "8\n", "7\n", "4\n", "6\n", "4\n", "5\n", "5\n", "8\n", "6\n", "4\n", "2\n", "3\n", "3\n", "7\n", "7\n", "6\n", "2\n", "5\n", "8\n", "6\n", "2\n", "5\n", "4\n", "8\n", "6\n", "4\n", "7\n", "5\n", "2\n", "6\n", "8\n", "7\n", "7\n", "6\n", "5\n", "7\n", "8\n", "6\n", "7\n", "5\n", "3\n", "8\n", "5\n", "7\n", "6\n", "5\n", "8\n", "8\n", "6\n", "5\n", "5\n", "2\n", "7\n", "8\n", "7\n", "8\n", "7\n", "6", "5", "3"]} | UNKNOWN_DIFFICULTY | [] | null | aizu | [] | [] | null | null | 1.0 seconds | null | null | 268.435456 megabytes | null | |
4 | You have a deck of $n$ cards, and you'd like to reorder it to a new one.
Each card has a value between $1$ and $n$ equal to $p_i$. All $p_i$ are pairwise distinct. Cards in a deck are numbered from bottom to top, i. e. $p_1$ stands for the bottom card, $p_n$ is the top card.
In each step you pick some integer $k > 0$, take the top $k$ cards from the original deck and place them, in the order they are now, on top of the new deck. You perform this operation until the original deck is empty. (Refer to the notes section for the better understanding.)
Let's define an order of a deck as $\sum\limits_{i = 1}^{n}{n^{n - i} \cdot p_i}$.
Given the original deck, output the deck with maximum possible order you can make using the operation above.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
The first line of each test case contains the single integer $n$ ($1 \le n \le 10^5$) — the size of deck you have.
The second line contains $n$ integers $p_1, p_2,\dots, p_n$ ($1 \le p_i \le n$; $p_i \neq p_j$ if $i \neq j$) — values of card in the deck from bottom to top.
It's guaranteed that the sum of $n$ over all test cases doesn't exceed $10^5$.
-----Output-----
For each test case print the deck with maximum possible order. Print values of cards in the deck from bottom to top.
If there are multiple answers, print any of them.
-----Examples-----
Input
4
4
1 2 3 4
5
1 5 2 4 3
6
4 2 5 3 6 1
1
1
Output
4 3 2 1
5 2 4 3 1
6 1 5 3 4 2
1
-----Note-----
In the first test case, one of the optimal strategies is the next one:
take $1$ card from the top of $p$ and move it to $p'$: $p$ becomes $[1, 2, 3]$, $p'$ becomes $[4]$;
take $1$ card from the top of $p$: $p$ becomes $[1, 2]$, $p'$ becomes $[4, 3]$;
take $1$ card from the top of $p$: $p$ becomes $[1]$, $p'$ becomes $[4, 3, 2]$;
take $1$ card from the top of $p$: $p$ becomes empty, $p'$ becomes $[4, 3, 2, 1]$.
In result, $p'$ has order equal to $4^3 \cdot 4 + 4^2 \cdot 3 + 4^1 \cdot 2 + 4^0 \cdot 1$ $=$ $256 + 48 + 8 + 1 = 313$.
In the second test case, one of the optimal strategies is:
take $4$ cards from the top of $p$ and move it to $p'$: $p$ becomes $[1]$, $p'$ becomes $[5, 2, 4, 3]$;
take $1$ card from the top of $p$ and move it to $p'$: $p$ becomes empty, $p'$ becomes $[5, 2, 4, 3, 1]$;
In result, $p'$ has order equal to $5^4 \cdot 5 + 5^3 \cdot 2 + 5^2 \cdot 4 + 5^1 \cdot 3 + 5^0 \cdot 1$ $=$ $3125 + 250 + 100 + 15 + 1 = 3491$.
In the third test case, one of the optimal strategies is:
take $2$ cards from the top of $p$ and move it to $p'$: $p$ becomes $[4, 2, 5, 3]$, $p'$ becomes $[6, 1]$;
take $2$ cards from the top of $p$ and move it to $p'$: $p$ becomes $[4, 2]$, $p'$ becomes $[6, 1, 5, 3]$;
take $2$ cards from the top of $p$ and move it to $p'$: $p$ becomes empty, $p'$ becomes $[6, 1, 5, 3, 4, 2]$.
In result, $p'$ has order equal to $6^5 \cdot 6 + 6^4 \cdot 1 + 6^3 \cdot 5 + 6^2 \cdot 3 + 6^1 \cdot 4 + 6^0 \cdot 2$ $=$ $46656 + 1296 + 1080 + 108 + 24 + 2 = 49166$. | [
"import heapq\nfrom math import sqrt\nimport operator\nimport sys\ninf_var = 0\nif inf_var == 1:\n\tinf = open('input.txt', 'r')\nelse:\n\tinf = sys.stdin\ninput = inf.readline\n\ndef read_one_int():\n\treturn int(input().rstrip('\\n'))\n\ndef read_list_of_ints():\n\tres = [int(val) for val in input().rstrip('\\n')... | {"inputs": ["4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1\n", "4\n4\n2 1 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1\n", "4\n4\n2 1 3 4\n5\n1 5 2 4 3\n6\n2 4 5 3 6 1\n1\n1\n", "4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1\n"], "outputs": ["4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1\n", "4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1\n", "4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1\n", "\n4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1\n"]} | EASY | ['data structures', 'greedy', 'math'] | null | codeforces | ['Data structures', 'Mathematics', 'Greedy algorithms'] | ['Data structures', 'Greedy algorithms'] | https://codeforces.com/problemset/problem/1492/B | null | 1 second | 2021-02-23T00:00:00 | 0 | 512 megabytes | null | |
8 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | [
"def is_anagram(test, original):\n\treturn sorted(original.lower()) == sorted(test.lower())\n",
"from collections import Counter\n\ndef is_anagram(test, original):\n\treturn Counter(test.lower()) == Counter(original.lower())\n",
"def is_anagram(test, original):\n\treturn sorted(test.upper()) == sorted(original.... | def is_anagram(test, original):
| {"fn_name": "is_anagram", "inputs": [["foefet", "toffee"], ["Buckethead", "DeathCubeK"], ["Twoo", "WooT"], ["dumble", "bumble"], ["ound", "round"], ["apple", "pale"]], "outputs": [[true], [true], [true], [false], [false], [false]]} | EASY | ['Strings', 'Fundamentals'] | null | codewars | ['String algorithms', 'Fundamentals'] | [] | https://www.codewars.com/kata/529eef7a9194e0cbc1000255 | null | null | null | null | null | null |
10 | Arkady decides to observe a river for n consecutive days. The river's water level on each day is equal to some real value.
Arkady goes to the riverside each day and makes a mark on the side of the channel at the height of the water level, but if it coincides with a mark made before, no new mark is created. The water does not wash the marks away. Arkady writes down the number of marks strictly above the water level each day, on the i-th day this value is equal to mi.
Define di as the number of marks strictly under the water level on the i-th day. You are to find out the minimum possible sum of di over all days. There are no marks on the channel before the first day.
Input
The first line contains a single positive integer n (1 ≤ n ≤ 105) — the number of days.
The second line contains n space-separated integers m1, m2, ..., mn (0 ≤ mi < i) — the number of marks strictly above the water on each day.
Output
Output one single integer — the minimum possible sum of the number of marks strictly below the water level among all days.
Examples
Input
6
0 1 0 3 0 2
Output
6
Input
5
0 1 2 1 2
Output
1
Input
5
0 1 1 2 2
Output
0
Note
In the first example, the following figure shows an optimal case.
<image>
Note that on day 3, a new mark should be created because if not, there cannot be 3 marks above water on day 4. The total number of marks underwater is 0 + 0 + 2 + 0 + 3 + 1 = 6.
In the second example, the following figure shows an optimal case.
<image> | [
"n = int(input())\nabove = list(map(int, input().split()))\ntotal = [x + 1 for x in above]\nfor i in range(0, n - 1)[::-1]:\n\ttotal[i] = max(total[i], total[i + 1] - 1)\nfor i in range(1, n):\n\ttotal[i] = max(total[i], total[i - 1])\nbelow = [t - a - 1 for (t, a) in zip(total, above)]\nprint(sum(below))\n",
"fr... | {"inputs": ["3\n0 1 1\n", "4\n0 0 1 2\n", "2\n0 0\n", "4\n0 1 1 0\n", "3\n0 1 0\n", "2\n0 1\n", "8\n0 0 2 0 3 0 3 2\n", "3\n0 1 2\n", "10\n0 0 2 2 3 2 3 3 1 3\n", "6\n0 0 0 2 0 1\n", "10\n0 1 2 0 4 5 3 6 0 5\n", "4\n0 0 1 1\n", "3\n0 0 0\n", "9\n0 1 0 1 1 4 0 4 8\n", "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 12 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 25 14 5 8 28 29 30 31 31 31 0 3 15 31 8 33 6 35 35 35 36 36 37 37 38 39 28 0 2 23 41 9 9 0 6 25 41 41 12 42 43 43 36 44 51 45 43 4\n", "3\n0 0 1\n", "5\n0 1 0 3 1\n", "4\n0 1 0 3\n", "7\n0 1 1 3 0 0 6\n", "1\n0\n", "3\n0 0 2\n", "4\n0 1 1 1\n", "10\n0 0 1 2 3 2 3 3 1 3\n", "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 12 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 25 14 5 8 28 29 30 31 31 31 0 3 15 31 8 33 6 35 35 35 36 36 37 37 38 39 28 0 2 26 41 9 9 0 6 25 41 41 12 42 43 43 36 44 51 45 43 4\n", "5\n0 1 0 3 0\n", "7\n0 1 2 3 0 0 6\n", "5\n0 1 2 0 2\n", "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 12 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 25 0 5 8 28 29 30 31 31 31 0 3 15 31 8 33 6 35 35 35 36 36 37 37 38 39 28 0 2 26 41 9 9 0 6 25 41 41 12 42 43 43 36 44 51 45 43 4\n", "7\n0 0 1 3 0 0 6\n", "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 12 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 25 0 5 8 28 29 48 31 31 31 0 3 15 31 8 33 6 35 35 35 36 36 37 37 38 39 28 0 2 26 41 9 9 0 6 25 41 41 12 42 43 43 36 44 51 45 43 4\n", "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 12 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 25 0 5 8 28 29 48 31 31 31 0 3 15 31 8 33 6 35 35 35 36 0 37 37 38 39 28 0 2 26 41 9 9 0 6 25 41 41 12 42 43 43 36 44 51 45 43 4\n", "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 12 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 30 0 5 8 28 29 48 31 31 31 0 3 15 31 8 33 6 35 35 35 36 0 37 37 38 39 28 0 2 26 41 9 9 0 6 25 41 41 12 42 43 43 36 44 51 45 43 4\n", "10\n0 0 2 2 1 2 3 3 1 3\n", "10\n0 1 2 0 4 0 3 6 0 5\n", "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 12 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 25 14 5 8 28 29 30 31 31 31 0 3 15 31 8 33 6 35 35 35 36 36 37 37 38 39 28 0 2 23 41 9 9 0 6 25 41 41 12 42 43 43 36 44 51 11 43 4\n", "10\n0 0 1 2 3 2 3 0 1 3\n", "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 16 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 25 14 5 8 28 29 30 31 31 31 0 3 15 31 8 33 6 35 35 35 36 36 37 37 38 39 28 0 2 26 41 9 9 0 6 25 41 41 12 42 43 43 36 44 51 45 43 4\n", "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 0 9 9 4 10 11 12 2 12 12 12 12 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 25 0 5 8 28 29 30 31 31 31 0 3 15 31 8 33 6 35 35 35 36 36 37 37 38 39 28 0 2 26 41 9 9 0 6 25 41 41 12 42 43 43 36 44 51 45 43 4\n", "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 12 9 21 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 25 0 5 8 28 29 48 31 31 31 0 3 15 31 8 33 6 35 35 35 36 0 37 37 38 39 28 0 2 26 41 9 9 0 6 25 41 41 12 42 43 43 36 44 51 45 43 4\n", "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 12 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 30 0 5 8 28 29 48 31 31 31 0 3 15 31 8 33 6 35 35 35 36 0 37 37 38 39 28 0 2 26 41 9 9 0 6 25 41 41 12 42 43 43 36 44 69 45 43 4\n", "10\n0 1 2 0 4 0 3 6 1 5\n", "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 12 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 25 14 5 8 28 29 30 31 31 31 0 3 15 31 8 33 6 35 35 35 36 71 37 37 38 39 28 0 2 23 41 9 9 0 6 25 41 41 12 42 43 43 36 44 51 11 43 4\n", "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 16 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 25 14 5 8 28 29 30 31 31 31 0 3 15 31 8 33 6 35 35 35 36 36 37 37 38 39 28 0 0 26 41 9 9 0 6 25 41 41 12 42 43 43 36 44 51 45 43 4\n", "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 0 9 9 4 10 11 12 2 12 12 12 12 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 25 0 5 8 28 29 30 31 31 31 0 3 15 31 13 33 6 35 35 35 36 36 37 37 38 39 28 0 2 26 41 9 9 0 6 25 41 41 12 42 43 43 36 44 51 45 43 4\n", "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 12 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 25 0 5 8 28 29 48 31 31 31 0 3 15 31 8 33 6 35 35 35 36 36 37 37 38 8 28 0 2 26 41 9 9 0 6 25 41 41 12 42 20 43 36 44 51 45 43 4\n", "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 12 9 21 14 8 15 15 15 19 25 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 25 0 5 8 28 29 48 31 31 31 0 3 15 31 8 33 6 35 35 35 36 0 37 37 38 39 28 0 2 26 41 9 9 0 6 25 41 41 12 42 43 43 36 44 51 45 43 4\n", "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 12 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 30 0 5 8 28 29 48 31 31 31 0 3 3 31 8 33 6 35 35 35 36 0 37 37 38 39 28 0 2 26 41 9 9 0 6 25 41 41 12 42 43 43 36 44 69 45 43 4\n", "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 12 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 25 14 5 8 28 29 30 31 31 31 0 3 15 31 8 33 6 35 35 35 36 71 37 37 38 39 28 0 2 23 41 9 5 0 6 25 41 41 12 42 43 43 36 44 51 11 43 4\n", "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 9 12 16 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 25 14 5 8 28 29 30 31 31 31 0 3 15 31 8 33 6 35 35 35 36 36 37 37 38 39 28 0 0 26 41 9 9 0 6 25 41 41 12 42 43 43 36 44 51 45 43 4\n", "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 12 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 25 0 10 8 28 29 48 31 31 31 0 3 15 31 8 33 6 35 35 35 36 36 37 37 38 8 28 0 2 26 41 9 9 0 6 25 41 41 12 42 20 43 36 44 51 45 43 4\n", "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 12 9 21 14 8 15 15 15 19 25 7 17 17 18 19 9 10 5 0 22 9 2 24 24 4 24 7 25 0 5 8 28 29 48 31 31 31 0 3 15 31 8 33 6 35 35 35 36 0 37 37 38 39 28 0 2 26 41 9 9 0 6 25 41 41 12 42 43 43 36 44 51 45 43 4\n", "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 12 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 30 0 5 8 28 29 48 31 31 31 0 3 3 31 8 33 6 35 35 35 36 0 37 37 38 39 28 0 2 26 41 9 9 0 0 25 41 41 12 42 43 43 36 44 69 45 43 4\n", "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 12 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 25 14 5 3 28 29 30 31 31 31 0 3 15 31 8 33 6 35 35 35 36 71 37 37 38 39 28 0 2 23 41 9 5 0 6 25 41 41 12 42 43 43 36 44 51 11 43 4\n", "4\n0 1 0 2\n", "4\n0 1 0 0\n", "6\n0 0 0 1 0 1\n", "4\n0 0 1 0\n", "4\n0 1 1 3\n", "5\n0 1 1 1 2\n", "5\n0 1 2 1 4\n", "6\n0 1 1 3 0 2\n", "4\n0 1 2 1\n", "5\n0 1 0 1 0\n", "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 12 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 25 0 5 8 28 29 48 31 31 31 0 3 15 31 8 33 6 35 35 35 36 36 37 37 38 8 28 0 2 26 41 9 9 0 6 25 41 41 12 42 43 43 36 44 51 45 43 4\n", "6\n0 0 0 1 1 1\n", "5\n0 1 2 0 4\n", "6\n0 0 1 3 0 2\n", "4\n0 0 2 1\n", "5\n0 1 1 1 0\n", "10\n0 1 1 0 4 0 3 6 1 5\n", "6\n0 0 1 3 0 3\n", "4\n0 0 2 0\n", "5\n0 1 1 2 0\n", "10\n0 1 1 1 4 0 3 6 1 5\n", "6\n0 0 0 3 0 3\n", "5\n0 1 1 2 2\n", "5\n0 1 2 1 2\n", "6\n0 1 0 3 0 2\n"], "outputs": ["0\n", "0\n", "0\n", "1\n", "1\n", "0\n", "7\n", "0\n", "4\n", "4\n", "12\n", "0\n", "0\n", "17\n", "761\n", "0\n", "4\n", "2\n", "10\n", "0\n", "1\n", "0\n", "3\n", "758\n", "5\n", "9\n", "2\n", "772\n", "11\n", "1479\n", "1515\n", "1510\n", "4\n", "16\n", "795\n", "6\n", "774\n", "773\n", "1549\n", "1771\n", "15\n", "2658\n", "776\n", "768\n", "1533\n", "1543\n", "1783\n", "2662\n", "779\n", "1528\n", "1559\n", "1789\n", "2667\n", "1\n", "2\n", "1\n", "1\n", "1\n", "0\n", "2\n", "5\n", "1\n", "2\n", "1510\n", "0\n", "3\n", "6\n", "2\n", "1\n", "16\n", "5\n", "3\n", "2\n", "15\n", "6\n", "0\n", "1\n", "6\n"]} | MEDIUM_HARD | ['data structures', 'greedy', 'dp'] | null | codeforces | ['Dynamic programming', 'Data structures', 'Greedy algorithms'] | ['Dynamic programming', 'Data structures', 'Greedy algorithms'] | https://codeforces.com/problemset/problem/957/D | null | 1.0 seconds | null | null | 256.0 megabytes | null | |
12 | Tom has finally taken over the business empire and now looking for
a new Name of the business to make a new start.
Joe (Tom's dear friend) suggested a string $S$ consisting of
Uppercase and lowercase letters
Tom wants to make some changes as per the following criteria:
1) String should $not$ have any vowels .
2) Every other uppercase consonant(other characters except vowels) should
be in lowercase
For ex:
If the consonant character is Z then it should be z
3) There should be a character "." before each consonant.
Help Tom to make the required Changes.
-----Input:-----
- First line will contain string $S$,This string only consists of uppercase and lowercase letters.
-----Output:-----
Print the resulting string. It is guaranteed that this string is not empty.
-----Constraints-----
- Length of string is in [1 .. 100]
-----Sample Input:-----
$CodeSprInT$
-----Sample Output:-----
.c.d.s.p.r.n.t
-----EXPLANATION:-----
C is a consonant and it is in uppercase so turn it in lower case and add a “.” before it
o is a vowel so it is deleted
d is a consonant and in lowercase so just add a “.” before it
e is a vowel so it is deleted
S is a consonant and it is in uppercase so turn it in lower case and add a “.” before it
p is a consonant and in lowercase so just add a “.” before it
r is a consonant and in lowercase so just add a “.” before it
I is a vowel so it is deleted
n is a consonant and in lowercase so just add a “.” before it
T is a consonant and it is in uppercase so turn it in lower case and add a “.” before it | [
"s = input().lower()\nvow = ['a', 'e', 'i', 'o', 'u', 'y']\nans = ''\nfor ch in s:\n\tif ch in vow:\n\t\tcontinue\n\tif ch.isalpha():\n\t\tans += '.' + ch\nprint(ans)\n"
] | {"inputs": [["CodeSprInT"]], "outputs": [[".c.d.s.p.r.n.t"]]} | UNKNOWN_DIFFICULTY | [] | null | codechef | [] | [] | https://www.codechef.com/SPRT2020/problems/EMPRNM | null | null | null | null | null | null | |
13 | When Chef was born, his parents took him to the famous monk Doctor Strange to know whether he will land himself in heaven after his life or not. According to Strange, Chef will live for $L$ years in total. If he wants to go to heaven, he must spend at least $50\%$ of his life years doing good deeds. He also shows them his future using a string $S$ of length $L$ where $S_{i} = 0$ means the $i$-th year will be counted as bad as per the rule books of heaven and $S_{i} = 1$ means the $i$-th year will be counted as good.
Also, Strange can use his special powers to make Chef end his life earlier than that planned by god, i.e, he can choose some $L'$ ($1≤ L'≤ L$) and make him live for only $L' $ years. Strange wants Chef to succeed, so if there is any choice of $L'$ that allows Chef to go to heaven, he will do so.
Tell whether Chef can go to heaven.
------ Input ------
The first line contains an integer $T$, the number of test cases. Then the test cases follow.
Each test case contains two lines of input.
The first line contains a single integer $L$.
The second line contains a string $S$ of length $L$, consisting of symbols 0 and 1.
------ Output ------
For each test case, output the answer in a single line: "YES" if Chef can go to heaven and "NO" if not (without quotes).
You may print each character of each string in uppercase or lowercase (for example, the strings "yEs", "yes", "Yes" and "YES" will all be treated as identical).
------ Constraints ------
$1 ≤ L ≤ 10^{5}$
The sum of $L$ over all tests does not exceed $10^{6}$
------ Subtasks ------
Subtask #1 (100 points): original constraints
----- Sample Input 1 ------
3
2
10
3
001
4
0100
----- Sample Output 1 ------
YES
NO
YES
----- explanation 1 ------
Test case 1: If Chef lives for the complete $2$ years, he will have a total of $1$ good year which is $\frac{1 * 100}{2} = 50\%$ of his life, and hence he will go to heaven.
Test case 2: There's no way Chef can go to heaven.
Test case 3: If Chef lives for $2$ years, he will have a total of $1$ good year which is $\frac{1 * 100}{2} = 50\%$ of his life, and hence he will go to heaven. | [
"for i in range(0, int(input())):\n\tn = int(input())\n\tl = list(input())\n\tt = 0\n\ta = 0\n\tb = 0\n\tfor j in range(0, n):\n\t\tt = t + 1\n\t\tif l[j] == '0':\n\t\t\ta = a + 1\n\t\telse:\n\t\t\tb = b + 1\n\t\tif b >= t / 2:\n\t\t\tprint('YES')\n\t\t\tbreak\n\t\telif j == n - 1 and b < t / 2:\n\t\t\tprint('NO')\... | {"inputs": ["3\n2\n10\n3\n001\n4\n0100"], "outputs": ["YES\nNO\nYES"]} | EASY | ['Algorithms', 'Greedy'] | null | codechef | ['Greedy algorithms'] | ['Greedy algorithms'] | https://www.codechef.com/problems/CCHEAVEN | null | 0.5 seconds | 2021-04-02T00:00:00 | 0 | 50000 bytes | null | |
15 | You are given an array A of N integers A_{1}, A_{2}, \ldots, A_{N}. Determine if there are two [permutations] B and C of this array, for which the following condition is satisfied:
* There doesn't exist a pair of integers (i, j) such that 1 ≤ i ≤ j ≤ N and (i, j) \neq (1, N), for which the subarray B[i:j] is a permutation of subarray C[i:j].
If there exist such permutations, find any of them.
As a reminder, B[i:j] refers to the subarray [B_{i}, B_{i+1}, \ldots, B_{j}]
------ Input Format ------
- The first line of the input contains a single integer T, the number of test cases. The description of the test cases follows.
- The first line of each test case contains a single integer N — the number of integers.
- The second line of each test case contains N space-separated integers A_{1}, A_{2}, \ldots, A_{N}.
------ Output Format ------
For each test case, if there are no such permutations B and C, output NO.
Otherwise, on the first line output YES. In the next line, output N integers B_{1}, B_{2}, \ldots, B_{N}. In the next line, output N integers C_{1}, C_{2}, \ldots, C_{N}.
You may print each character of YES/NO in either uppercase or lowercase (for example, the strings YES, yeS, YeS, and yEs will all be treated as identical).
------ Constraints ------
$1 ≤T ≤100$
$3 ≤N ≤1000$
$0 ≤A_{i} ≤10^{9}$
- The sum of $N$ over all test cases doesn't exceed $2000$.
----- Sample Input 1 ------
3
3
1 1 2
4
19 39 19 84
6
1 2 3 1 2 3
----- Sample Output 1 ------
NO
YES
19 19 39 84
39 84 19 19
YES
1 1 2 2 3 3
2 3 3 1 1 2
----- explanation 1 ------
Test case $1$: There are $3 \times 3 = 9$ pairs of permutations of the given array. Here's why they're all bad:
- If $B = [1, 1, 2]$ and $C = [1, 1, 2]$, $B[1:1] = C[1:1]$
- If $B = [1, 1, 2]$ and $C = [1, 2, 1]$, $B[1:1] = C[1:1]$
- If $B = [1, 1, 2]$ and $C = [2, 1, 1]$, $B[2:2] = C[2:2]$
- If $B = [1, 2, 1]$ and $C = [1, 1, 2]$, $B[1:1] = C[1:1]$
- If $B = [1, 2, 1]$ and $C = [1, 2, 1]$, $B[1:1] = C[1:1]$
- If $B = [1, 2, 1]$ and $C = [2, 1, 1]$, $B[3:3] = C[3:3]$
- If $B = [2, 1, 1]$ and $C = [1, 1, 2]$, $B[2:2] = C[2:2]$
- If $B = [2, 1, 1]$ and $C = [1, 2, 1]$, $B[3:3] = C[3:3]$
- If $B = [2, 1, 1]$ and $C = [2, 1, 1]$, $B[1:1] = C[1:1]$ | [
"t = int(input())\nfor _ in range(t):\n\tn = int(input())\n\tl = list(map(int, input().split()))\n\td = {}\n\tfor i in l:\n\t\td[i] = d.get(i, 0) + 1\n\tmx = 0\n\tfor i in d.values():\n\t\tif i >= mx:\n\t\t\tmx = i\n\tif len(d) == 2:\n\t\tprint('NO')\n\telif n % 2 == 0:\n\t\tif mx <= n // 2:\n\t\t\tprint('YES')\n\t... | {"inputs": ["3\n3\n1 1 2\n4\n19 39 19 84\n6\n1 2 3 1 2 3"], "outputs": ["NO\nYES\n19 19 39 84 \n39 84 19 19 \nYES\n1 1 2 2 3 3 \n2 3 3 1 1 2 "]} | HARD | ['shift', 'sorting', 'trygub_adm', 'cook141', 'constructive'] | null | codechef | ['Sorting', 'Constructive algorithms'] | ['Sorting'] | https://www.codechef.com/problems/DIFSUBARRAYS | null | 1 seconds | 2022-04-26T00:00:00 | 0 | 50000 bytes | null | |
18 | "You are given an array $a_1, a_2, \\dots, a_n$. You can perform the following operation any number (...TRUNCATED) | ["from collections import defaultdict, deque\nfrom heapq import heappush, heappop\nfrom bisect impor(...TRUNCATED) | "{\"inputs\": [\"5\\n4 3 2 2 3\\n\", \"7\\n3 3 4 4 4 3 3\\n\", \"3\\n1 3 5\\n\", \"1\\n1000\\n\", \"(...TRUNCATED) | HARD | ['greedy', 'dp'] | null | codeforces | ['Dynamic programming', 'Greedy algorithms'] | ['Dynamic programming', 'Greedy algorithms'] | https://codeforces.com/problemset/problem/1312/E | null | 2 seconds | 2020-03-09T00:00:00 | 0 | 256 megabytes | null | |
20 | "There are players standing in a row each player has a digit written on their T-Shirt (multiple play(...TRUNCATED) | ["import sys\n\ndef GRIG(L):\n\tLENT = len(L)\n\tMINT = 1\n\tGOT = 0\n\tDY = [[{x: 0 for x in range((...TRUNCATED) | {"inputs": [["1", "123343"]], "outputs": [["3"]]} | UNKNOWN_DIFFICULTY | [] | null | codechef | [] | [] | https://www.codechef.com/COVO2020/problems/GRIG | null | null | null | null | null | null |
This dataset contains verified solutions from the TACO dataset's training set. Solutions that fail to pass all the test cases are removed. Problems with no correct solution are also removed.
The solutions were executed on Intel E5-2620 v3 CPUs with the execution timeout set to 10 seconds.
| Dataset | # Problems | # Solutions |
|---|---|---|
| TACO | 25443 | 1468722 |
| TACO-verified | 12898 | 1043251 |
| Correct Ratio | 50.69 % | 71.03 % |
(Apr 11, 2025) Hello, friends from DeepCoder!
Please consider citing this repo if you find it useful.
@misc{likaixin2024taco-verified,
author = {Kaixin Li},
title = {Verified TACO Problems},
year = {2024},
url = {https://huggingface.co/datasets/likaixin/TACO-verified},
howpublished = {\url{https://huggingface.co/datasets/likaixin/TACO-verified}},
}