vgel/INTELLECT-2-RL-Dataset-Code-Only huggingface dataset:
# Definition

**_Jumping number_** is the number that *All adjacent digits in it differ by 1*.

____

# Task

**_Given_** a number, **_Find if it is Jumping or not_** . 
____

# Warm-up (Highly recommended)

# [Playing With Numbers Series](https://www.codewars.com/collections/playing-with-numbers)
___

# Notes 

* **_Number_** *passed is always*  **_Positive_** .

* **_Return_** *the result as* **_String_** . 

* **_The difference between_** *‘9’ and ‘0’* is **_not considered as 1_** . 

* **_All single digit numbers_** are considered as **_Jumping numbers_**. 
___

# Input >> Output Examples

```
jumpingNumber(9) ==> return "Jumping!!"
```
## **_Explanation_**:

* It's  **_single-digit number_** 
___

```
jumpingNumber(79) ==> return "Not!!"
```

## **_Explanation_**:

* *Adjacent digits* **_don't differ by 1_**
___

```
jumpingNumber(23) ==> return "Jumping!!"
```

## **_Explanation_**:

* *Adjacent digits* **_differ by 1_**
___

```
jumpingNumber(556847) ==> return "Not!!"
```

## **_Explanation_**:

* *Adjacent digits* **_don't differ by 1_**
___

```
jumpingNumber(4343456) ==> return "Jumping!!"
```

## **_Explanation_**:

* *Adjacent digits* **_differ by 1_**
___

```
jumpingNumber(89098) ==> return "Not!!"
```

## **_Explanation_**:

* *Adjacent digits* **_don't differ by 1_**
___

```
jumpingNumber(32) ==> return "Jumping!!"
```

## **_Explanation_**:

* *Adjacent digits* **_differ by 1_**
___
___
___

# [Playing with Numbers Series](https://www.codewars.com/collections/playing-with-numbers)

# [Playing With Lists/Arrays Series](https://www.codewars.com/collections/playing-with-lists-slash-arrays)

# [For More Enjoyable Katas](http://www.codewars.com/users/MrZizoScream/authored)
___

## ALL translations are welcomed

## Enjoy Learning !!
# Zizou

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Title: Tavas and Malekas

Time Limit: None seconds

Memory Limit: None megabytes

Problem Description:
Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string *s* of length *n* comes out from Tavas' mouth instead.

Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on *s*. Malekas has a favorite string *p*. He determined all positions *x*1<=&lt;<=*x*2<=&lt;<=...<=&lt;<=*x**k* where *p* matches *s*. More formally, for each *x**i* (1<=≤<=*i*<=≤<=*k*) he condition *s**x**i**s**x**i*<=+<=1... *s**x**i*<=+<=|*p*|<=-<=1<==<=*p* is fullfilled.

Then Malekas wrote down one of subsequences of *x*1,<=*x*2,<=... *x**k* (possibly, he didn't write anything) on a piece of paper. Here a sequence *b* is a subsequence of sequence *a* if and only if we can turn *a* into *b* by removing some of its elements (maybe no one of them or all).

After Tavas woke up, Malekas told him everything. He couldn't remember string *s*, but he knew that both *p* and *s* only contains lowercase English letters and also he had the subsequence he had written on that piece of paper.

Tavas wonders, what is the number of possible values of *s*? He asked SaDDas, but he wasn't smart enough to solve this. So, Tavas asked you to calculate this number for him.

Answer can be very large, so Tavas wants you to print the answer modulo 109<=+<=7.

Input Specification:
The first line contains two integers *n* and *m*, the length of *s* and the length of the subsequence Malekas wrote down (1<=≤<=*n*<=≤<=106 and 0<=≤<=*m*<=≤<=*n*<=-<=|*p*|<=+<=1).

The second line contains string *p* (1<=≤<=|*p*|<=≤<=*n*).

The next line contains *m* space separated integers *y*1,<=*y*2,<=...,<=*y**m*, Malekas' subsequence (1<=≤<=*y*1<=&lt;<=*y*2<=&lt;<=...<=&lt;<=*y**m*<=≤<=*n*<=-<=|*p*|<=+<=1).

Output Specification:
In a single line print the answer modulo 1000<=000<=007.

Demo Input:
['6 2\nioi\n1 3\n', '5 2\nioi\n1 2\n']

Demo Output:
['26\n', '0\n']

Note:
In the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.

Here |*x*| denotes the length of string x.

Please note that it's possible that there is no such string (answer is 0).

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
As a big fan of Formula One, Charlie is really happy with the fact that he has to organize ticket sells for the next Grand Prix race in his own city. Unfortunately, the finacial crisis is striking everywhere and all the banknotes left in his country are valued either 10 euros or 20 euros. The price of all tickets for the race is 10 euros, so whenever someone comes to the ticket store only with 20 euro banknote Charlie must have a 10 euro banknote to give them change. Charlie realize that with the huge deficit of banknotes this could be a problem. Charlie has some priceless information but couldn't make use of it, so he needs your help. Exactly n + m people will come to buy a ticket. n of them will have only a single 10 euro banknote, and m of them will have only a single 20 euro banknote. Currently Charlie has k 10 euro banknotes, which he can use for change if needed. All n + m people will come to the ticket store in random order, all orders are equiprobable. Return the probability that the ticket selling process will run smoothly, i.e. Charlie will have change for every person with 20 euro banknote.

Input

The input consist of a single line with three space separated integers, n, m and k (0 ≤ n, m ≤ 105, 0 ≤ k ≤ 10).

Output

Output on a single line the desired probability with at least 4 digits after the decimal point.

Examples

Input

5 3 1


Output

0.857143


Input

0 5 5


Output

1


Input

0 1 0


Output

0

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Title: Kay and Snowflake

Time Limit: None seconds

Memory Limit: None megabytes

Problem Description:
After the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes.

Once upon a time, he found a huge snowflake that has a form of the tree (connected acyclic graph) consisting of *n* nodes. The root of tree has index 1. Kay is very interested in the structure of this tree.

After doing some research he formed *q* queries he is interested in. The *i*-th query asks to find a centroid of the subtree of the node *v**i*. Your goal is to answer all queries.

Subtree of a node is a part of tree consisting of this node and all it's descendants (direct or not). In other words, subtree of node *v* is formed by nodes *u*, such that node *v* is present on the path from *u* to root.

Centroid of a tree (or a subtree) is a node, such that if we erase it from the tree, the maximum size of the connected component will be at least two times smaller than the size of the initial tree (or a subtree).

Input Specification:
The first line of the input contains two integers *n* and *q* (2<=≤<=*n*<=≤<=300<=000, 1<=≤<=*q*<=≤<=300<=000) — the size of the initial tree and the number of queries respectively.

The second line contains *n*<=-<=1 integer *p*2,<=*p*3,<=...,<=*p**n* (1<=≤<=*p**i*<=≤<=*n*) — the indices of the parents of the nodes from 2 to *n*. Node 1 is a root of the tree. It's guaranteed that *p**i* define a correct tree.

Each of the following *q* lines contain a single integer *v**i* (1<=≤<=*v**i*<=≤<=*n*) — the index of the node, that define the subtree, for which we want to find a centroid.

Output Specification:
For each query print the index of a centroid of the corresponding subtree. If there are many suitable nodes, print any of them. It's guaranteed, that each subtree has at least one centroid.

Demo Input:
['7 4\n1 1 3 3 5 3\n1\n2\n3\n5\n']

Demo Output:
['3\n2\n3\n6\n']

Note:
The first query asks for a centroid of the whole tree — this is node 3. If we delete node 3 the tree will split in four components, two of size 1 and two of size 2.

The subtree of the second node consists of this node only, so the answer is 2.

Node 3 is centroid of its own subtree.

The centroids of the subtree of the node 5 are nodes 5 and 6 — both answers are considered correct.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.

Pikachu is a cute and friendly pokémon living in the wild pikachu herd.

But it has become known recently that infamous team R wanted to steal all these pokémon! Pokémon trainer Andrew decided to help Pikachu to build a pokémon army to resist.

First, Andrew counted all the pokémon — there were exactly $n$ pikachu. The strength of the $i$-th pokémon is equal to $a_i$, and all these numbers are distinct.

As an army, Andrew can choose any non-empty subsequence of pokemons. In other words, Andrew chooses some array $b$ from $k$ indices such that $1 \le b_1 < b_2 < \dots < b_k \le n$, and his army will consist of pokémons with forces $a_{b_1}, a_{b_2}, \dots, a_{b_k}$.

The strength of the army is equal to the alternating sum of elements of the subsequence; that is, $a_{b_1} - a_{b_2} + a_{b_3} - a_{b_4} + \dots$.

Andrew is experimenting with pokémon order. He performs $q$ operations. In $i$-th operation Andrew swaps $l_i$-th and $r_i$-th pokémon.

Note: $q=0$ in this version of the task.

Andrew wants to know the maximal stregth of the army he can achieve with the initial pokémon placement. He also needs to know the maximal strength after each operation.

Help Andrew and the pokémon, or team R will realize their tricky plan!


-----Input-----

Each test contains multiple test cases.

The first line contains one positive integer $t$ ($1 \le t \le 10^3$) denoting the number of test cases. Description of the test cases follows.

The first line of each test case contains two integers $n$ and $q$ ($1 \le n \le 3 \cdot 10^5, q = 0$) denoting the number of pokémon and number of operations respectively.

The second line contains $n$ distinct positive integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le n$) denoting the strengths of the pokémon.

$i$-th of the last $q$ lines contains two positive integers $l_i$ and $r_i$ ($1 \le l_i \le r_i \le n$) denoting the indices of pokémon that were swapped in the $i$-th operation.

It is guaranteed that the sum of $n$ over all test cases does not exceed $3 \cdot 10^5$, and the sum of $q$ over all test cases does not exceed $3 \cdot 10^5$. 


-----Output-----

For each test case, print $q+1$ integers: the maximal strength of army before the swaps and after each swap.


-----Example-----
Input
3
3 0
1 3 2
2 0
1 2
7 0
1 2 5 4 3 6 7

Output
3
2
9



-----Note-----

In third test case we can build an army in such way: [1 2 5 4 3 6 7], its strength will be $5−3+7=9$.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Title: Array and Operations

Time Limit: None seconds

Memory Limit: None megabytes

Problem Description:
You have written on a piece of paper an array of *n* positive integers *a*[1],<=*a*[2],<=...,<=*a*[*n*] and *m* good pairs of integers (*i*1,<=*j*1),<=(*i*2,<=*j*2),<=...,<=(*i**m*,<=*j**m*). Each good pair (*i**k*,<=*j**k*) meets the following conditions: *i**k*<=+<=*j**k* is an odd number and 1<=≤<=*i**k*<=&lt;<=*j**k*<=≤<=*n*.

In one operation you can perform a sequence of actions: 
 -  take one of the good pairs (*i**k*,<=*j**k*) and some integer *v* (*v*<=&gt;<=1), which divides both numbers *a*[*i**k*] and *a*[*j**k*]; -  divide both numbers by *v*, i. e. perform the assignments:  and . 
Determine the maximum number of operations you can sequentially perform on the given array. Note that one pair may be used several times in the described operations.

Input Specification:
The first line contains two space-separated integers *n*, *m* (2<=≤<=*n*<=≤<=100, 1<=≤<=*m*<=≤<=100).

The second line contains *n* space-separated integers *a*[1],<=*a*[2],<=...,<=*a*[*n*] (1<=≤<=*a*[*i*]<=≤<=109) — the description of the array.

The following *m* lines contain the description of good pairs. The *k*-th line contains two space-separated integers *i**k*, *j**k* (1<=≤<=*i**k*<=&lt;<=*j**k*<=≤<=*n*, *i**k*<=+<=*j**k* is an odd number).

It is guaranteed that all the good pairs are distinct.

Output Specification:
Output the answer for the problem.

Demo Input:
['3 2\n8 3 8\n1 2\n2 3\n', '3 2\n8 12 8\n1 2\n2 3\n']

Demo Output:
['0\n', '2\n']

Note:
none

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Alice is a beginner composer and now she is ready to create another masterpiece. And not even the single one but two at the same time! 

Alice has a sheet with n notes written on it. She wants to take two such non-empty non-intersecting subsequences that both of them form a melody and sum of their lengths is maximal.

Subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.

Subsequence forms a melody when each two adjacent notes either differs by 1 or are congruent modulo 7.

You should write a program which will calculate maximum sum of lengths of such two non-empty non-intersecting subsequences that both of them form a melody.


-----Input-----

The first line contains one integer number n (2 ≤ n ≤ 5000).

The second line contains n integer numbers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^5) — notes written on a sheet.


-----Output-----

Print maximum sum of lengths of such two non-empty non-intersecting subsequences that both of them form a melody.


-----Examples-----
Input
4
1 2 4 5

Output
4

Input
6
62 22 60 61 48 49

Output
5



-----Note-----

In the first example subsequences [1, 2] and [4, 5] give length 4 in total.

In the second example subsequences [62, 48, 49] and [60, 61] give length 5 in total. If you choose subsequence [62, 61] in the first place then the second melody will have maximum length 2, that gives the result of 4, which is not maximal.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Yaroslav thinks that two strings s and w, consisting of digits and having length n are non-comparable if there are two numbers, i and j (1 ≤ i, j ≤ n), such that s_{i} > w_{i} and s_{j} < w_{j}. Here sign s_{i} represents the i-th digit of string s, similarly, w_{j} represents the j-th digit of string w.

A string's template is a string that consists of digits and question marks ("?").

Yaroslav has two string templates, each of them has length n. Yaroslav wants to count the number of ways to replace all question marks by some integers in both templates, so as to make the resulting strings incomparable. Note that the obtained strings can contain leading zeroes and that distinct question marks can be replaced by distinct or the same integers.

Help Yaroslav, calculate the remainder after dividing the described number of ways by 1000000007 (10^9 + 7).


-----Input-----

The first line contains integer n (1 ≤ n ≤ 10^5) — the length of both templates. The second line contains the first template — a string that consists of digits and characters "?". The string's length equals n. The third line contains the second template in the same format.


-----Output-----

In a single line print the remainder after dividing the answer to the problem by number 1000000007 (10^9 + 7).


-----Examples-----
Input
2
90
09

Output
1

Input
2
11
55

Output
0

Input
5
?????
?????

Output
993531194



-----Note-----

The first test contains no question marks and both strings are incomparable, so the answer is 1.

The second test has no question marks, but the given strings are comparable, so the answer is 0.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Great scientific discoveries are often named by the last names of scientists that made them. For example, the most popular asymmetric cryptography system, RSA was discovered by Rivest, Shamir and Adleman. Another notable example is the Knuth-Morris-Pratt algorithm, named by Knuth, Morris and Pratt.

Scientific papers reference earlier works a lot and it’s not uncommon for one document to use two different naming conventions: the short variation (e.g. KMP) using only the first letters of authors last names and the long variation (e.g. Knuth-Morris-Pratt) using complete last names separated by hyphens.

We find mixing two conventions in one paper to be aesthetically unpleasing and would like you to write a program that will transform long variations into short.

-----Input-----
The first and only line of input will contain at most $100$ characters, uppercase and lowercase letters of the English alphabet and hyphen (‘-’ ASCII $45$). The first character will always be an uppercase letter. Hyphens will always be followed by an uppercase letter. All other characters will be lowercase letters.

-----Output-----
The first and only line of output should contain the appropriate short variation.

-----Examples-----
Sample Input 1:
Knuth-Morris-Pratt
Sample Output 1:
KMP

Sample Input 2:
Mirko-Slavko
Sample Output 2:
MS

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
This task is very simple.You are given two string A and B and you have to find how many times you can form string B from string A. You are only allow to delete some character from string A and Change postion of characters .You are not allow to use same index character of A two times in the same string to form string B.

For example :- string A = aba  and string B=ab, 
             so we can form 2 string from A same as B
 two string are different if atleast one place you use differently indexed character from A.

 InputFirst line  of input will have no. test cases (T) and  each test case contain two strings A and B .
 Output  Number of time string B can form from A. Output become large so take module with 10^9+7.

Constraints
1 ≤ T ≤ 100 

1 ≤ |A| , |B| ≤10^6

String consist only lowercase letters 'a' to 'z'

SAMPLE INPUT
1
aba 
ab

SAMPLE OUTPUT
2

Explanation

for A= aba two string can be form first by delete 'a' at index 2 and second  by deleting 'a' at index 0 and then  replacing  position of a and b

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Title: Invariance of Tree

Time Limit: None seconds

Memory Limit: None megabytes

Problem Description:
A tree of size *n* is an undirected connected graph consisting of *n* vertices without cycles.

Consider some tree with *n* vertices. We call a tree invariant relative to permutation *p*<==<=*p*1*p*2... *p**n*, if for any two vertices of the tree *u* and *v* the condition holds: "vertices *u* and *v* are connected by an edge if and only if vertices *p**u* and *p**v* are connected by an edge".

You are given permutation *p* of size *n*. Find some tree size *n*, invariant relative to the given permutation.

Input Specification:
The first line contains number *n* (1<=≤<=*n*<=≤<=105) — the size of the permutation (also equal to the size of the sought tree).

The second line contains permutation *p**i* (1<=≤<=*p**i*<=≤<=*n*).

Output Specification:
If the sought tree does not exist, print "NO" (without the quotes).

Otherwise, print "YES", and then print *n*<=-<=1 lines, each of which contains two integers — the numbers of vertices connected by an edge of the tree you found. The vertices are numbered from 1, the order of the edges and the order of the vertices within the edges does not matter.

If there are multiple solutions, output any of them.

Demo Input:
['4\n4 3 2 1\n', '3\n3 1 2\n']

Demo Output:
['YES\n4 1\n4 2\n1 3\n', 'NO\n']

Note:
In the first sample test a permutation transforms edge (4, 1) into edge (1, 4), edge (4, 2) into edge (1, 3) and edge (1, 3) into edge (4, 2). These edges all appear in the resulting tree.

It can be shown that in the second sample test no tree satisfies the given condition.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Tanish is the president of the chemistry club at his school. He considers everyone who doesn't like chemistry as his enemy. After years of research, he has invented a lethal poison, which he named success. Now Tanish plans to kill all his enemies with his success. Success is extremely deadly and is untraceable in small concentrations.
Tanish has $\text{N}$ flasks lying on the shelf of his lab. All of these flasks contain the same volume of poison solution. The concentration of poison in the $\text{ith}$ flask is $\mathbf{a_i}$. In one move - Tanish picks up any two flasks, pours half of the contents of each of these flasks into a third initially empty flask, discards the two flasks and places the third flask (which now has the same volume of solution as all other flasks) on the shelf. He performs N-1 such moves to end up with only one flask of poison on the shelf. He wishes to perform these moves such that the concentration of poison in this flask is the minimum possible. What is the minimum concentration of poison that he can achieve?

-----Input-----
First line of the input contains a single integer $\text{T}$ - the number of test cases. 
For each test case,
The first line contains a single integer $\text{N}$, the number of bottles. 
The second line contains N space-separated integers, the concentrations. 

-----Output-----
For each test case, print one line containing the lowest final concentration. The output will be accepted if the absolute error is $\leq 10^{-6}$.

-----Constraints-----
$1 \leq \text{T} \leq 10$
$2 \leq \text{N} \leq 10^4$
$0 \leq \mathbf{a_i} \leq 10^9$

-----Sample Input-----
2
2
9 3
3
3 2 9

-----Sample Output-----
6.00000000
4.00000000

-----Explanation-----
In test 1, Tanish mixes flasks 1 and 2. In test 2, he first mixes flasks 1 and 3 to get a flask of concentration 6 and then mixes this flask with flask 2 to get a flask of poison concentration 4.    

-----Note-----
The concentration is given in the unit ppb i.e. parts per billion.
1 gram poison in $10^9$ ml solution is 1 ppb.
Concentration in ppb = (Number of grams of poison / Volume of solution in ml) x $10^9$

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Simon is a contestant on the new exciting game show, Add ’Em Up! In this show, contestants are given a set of cards with multi-digit numbers on them, and need to select two cards that add up to a given sum. However, to make things more interesting, the font that the cards are printed in (see below) means that certain cards will display different numbers if turned upside-down, and it is legal to turn either or both of the cards if necessary to generate the sum. Please help Simon win the game!

-----Input-----
The first line contains two integers, $n$, the number of cards, and $s$, the desired sum. The second line will contain $n$ integers between $1$ and $100000000$ inclusive. You may assume that $1\leq n\leq 100000$ and $2\leq s\leq 200000000$.

-----Output-----
The output should be a single line consisting of the string YES if two cards can be chosen such that (in some orientation) they add up to $s$, and the string NO otherwise.

-----Examples-----
Sample Input:
3 66
15 21 22
Sample Output:
NO

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.