vgel/INTELLECT-2-RL-Dataset-Code-Only huggingface dataset:
The problem is to check whether the decimal representation of a given binary number is divisible by 5 or not.
Example 1:
Input: bin = "1010"
Output: "Yes"
Explanation: Decimal equivalent is
10 which is divisible by 5.
Ã¢â¬â¹Example 2:
Input: bin = "1110"
Output: "No"
Explanation: Decimal equivalent is
14 which is not divisible by 5.
Your Task:  
You don't need to read input or print anything. Your task is to complete the function isDivisibleBy5() which takes the string bin as inputs and returns the "Yes" if binary number is divisible by 5, else returns "No".
Expected Time Complexity: O(|S|)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ |S| ≤ 10^{5}

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Your task is to return the number of visible dots on a die after it has been rolled(that means the total count of dots that would not be touching the table when rolled)

6, 8, 10, 12, 20 sided dice are the possible inputs for "numOfSides" 

topNum is equal to the number that is on top, or the number that was rolled.

for this exercise, all opposite faces add up to be 1 more than the total amount of sides
  Example: 6 sided die would have 6 opposite 1, 4 opposite 3, and so on.
for this exercise, the 10 sided die starts at 1 and ends on 10.

Note: topNum will never be greater than numOfSides

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Given a sentence text (A sentence is a string of space-separated words) in the following format:

First letter is in upper case.
Each word in text are separated by a single space.

Your task is to rearrange the words in text such that all words are rearranged in an increasing order of their lengths. If two words have the same length, arrange them in their original order.
Return the new text following the format shown above.
 
Example 1:
Input: text = "Leetcode is cool"
Output: "Is cool leetcode"
Explanation: There are 3 words, "Leetcode" of length 8, "is" of length 2 and "cool" of length 4.
Output is ordered by length and the new first word starts with capital letter.

Example 2:
Input: text = "Keep calm and code on"
Output: "On and keep calm code"
Explanation: Output is ordered as follows:
"On" 2 letters.
"and" 3 letters.
"keep" 4 letters in case of tie order by position in original text.
"calm" 4 letters.
"code" 4 letters.

Example 3:
Input: text = "To be or not to be"
Output: "To be or to be not"

 
Constraints:

text begins with a capital letter and then contains lowercase letters and single space between words.
1 <= text.length <= 10^5

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Comrade Dujikov is busy choosing artists for Timofey's birthday and is recieving calls from Taymyr from Ilia-alpinist.

Ilia-alpinist calls every n minutes, i.e. in minutes n, 2n, 3n and so on. Artists come to the comrade every m minutes, i.e. in minutes m, 2m, 3m and so on. The day is z minutes long, i.e. the day consists of minutes 1, 2, ..., z. How many artists should be killed so that there are no artists in the room when Ilia calls? Consider that a call and a talk with an artist take exactly one minute.


-----Input-----

The only string contains three integers — n, m and z (1 ≤ n, m, z ≤ 10^4).


-----Output-----

Print single integer — the minimum number of artists that should be killed so that there are no artists in the room when Ilia calls.


-----Examples-----
Input
1 1 10

Output
10

Input
1 2 5

Output
2

Input
2 3 9

Output
1



-----Note-----

Taymyr is a place in the north of Russia.

In the first test the artists come each minute, as well as the calls, so we need to kill all of them.

In the second test we need to kill artists which come on the second and the fourth minutes.

In the third test — only the artist which comes on the sixth minute.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
To store DNA sequences your company has developed a LongLongString class that can store strings with up to ten billion characters. The class supports two basic operations: 
 - Ins($p$, $c$): Insert the character $c$ at position $p$.
 - Del($p$): Delete the character at position $p$.

A DNA editing program is written as a series of Ins and Del operations. Your job is to write a program that compare two DNA editing programs and determine if they are identical, i.e., when applied to any sufficiently long string, whether the end result is the same.

For example:
 - Del(1) Del(2) and Del(3) Del(1) are identical.
 - Del(2) Del(1) and Del(1) Del(2) are different.
 - An empty sequence and Ins(1, $X$) Del(1) are identical.
 - Ins(14, $B$) Ins(14, $A$) and Ins(14, $A$) Ins(15, $B$) are identical.
 - Ins(14, $A$) Ins(15, $B$) and Ins(14, $B$) Ins(15, $A$) are different.

-----Input-----
Input will consist of the descriptions of two DNA editing programs.

Each program will consist of some number of operations (between $0$ and $2000$). Each operation will be given on its own line. The first character of the line will be D for a Del operation, I for an Ins operation, or E marking the end of the program.

A Del operation will have the D character, followed by a space, and then a single integer between $1$ and $10^{10}$, indicating the character position to delete. All characters after this deleted character will be shifted one position lower.

An Ins operation will have the I character, followed by a space, and then a single integer between $1$ and $10^{10}$, indicating the location to insert the new character; all pre-existing characters with this index and higher will be shifted one position higher. Following this integer will be another space and then an uppercase alphabetic character that is the character to insert.

-----Output-----
If the two programs are identical, print “0” on a single line (without quotation marks). Otherwise, print “1” on a single line (without quotation marks).

-----Examples-----
Sample Input 1:
D 1
D 2
E
D 3
D 1
E
Sample Output 1:
0

Sample Input 2:
D 2
D 1
E
D 1
D 2
E
Sample Output 2:
1

Sample Input 3:
I 1 X
D 1
E
E
Sample Output 3:
0

Sample Input 4:
I 14 B
I 14 A
E
I 14 A
I 15 B
E
Sample Output 4:
0

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Title: White, Black and White Again

Time Limit: None seconds

Memory Limit: None megabytes

Problem Description:
Polycarpus is sure that his life fits the description: "first there is a white stripe, then a black one, then a white one again". So, Polycarpus is sure that this rule is going to fulfill during the next *n* days. Polycarpus knows that he is in for *w* good events and *b* not-so-good events. At least one event is going to take place during each day. As each day is unequivocally characterizes as a part of a white or a black stripe, then each day is going to have events of the same type only (ether good or not-so-good).

What is the number of distinct ways this scenario can develop over the next *n* days if Polycarpus is in for a white stripe (a stripe that has good events only, the stripe's length is at least 1 day), the a black stripe (a stripe that has not-so-good events only, the stripe's length is at least 1 day) and a white stripe again (a stripe that has good events only, the stripe's length is at least 1 day). Each of *n* days will belong to one of the three stripes only.

Note that even the events of the same type are distinct from each other. Even if some events occur on the same day, they go in some order (there are no simultaneous events).

Write a code that prints the number of possible configurations to sort the events into days. See the samples for clarifications on which scenarios should be considered distinct. Print the answer modulo 1000000009 (109<=+<=9).

Input Specification:
The single line of the input contains integers *n*, *w* and *b* (3<=≤<=*n*<=≤<=4000, 2<=≤<=*w*<=≤<=4000, 1<=≤<=*b*<=≤<=4000) — the number of days, the number of good events and the number of not-so-good events. It is guaranteed that *w*<=+<=*b*<=≥<=*n*.

Output Specification:
Print the required number of ways modulo 1000000009 (109<=+<=9).

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

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

Note:
We'll represent the good events by numbers starting from 1 and the not-so-good events — by letters starting from 'a'. Vertical lines separate days.

In the first sample the possible ways are: "1|a|2" and "2|a|1". In the second sample the possible ways are: "1|a|b|2", "2|a|b|1", "1|b|a|2" and "2|b|a|1". In the third sample the possible ways are: "1|ab|2", "2|ab|1", "1|ba|2" and "2|ba|1".

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
*This kata is based on [Project Euler Problem 539](https://projecteuler.net/problem=539)*

##Object

Find the last number between 1 and `n` (inclusive) that survives the elimination process

####How It Works

Start with the first number on the left then remove every other number moving right until you reach the the end, then from the numbers remaining start with the first number on the right and remove every other number moving left, repeat the process alternating between left and right until only one number remains which you return as the "last man standing"


##Example

    given an input of `9` our set of numbers is `1 2 3 4 5 6 7 8 9`

    start by removing from the left    2   4   6   8
                                     1   3   5   7   9
    

    then from the right                2       6
                                           4       8


    then the left again                        6
                                       2


    until we end with `6` as the last man standing


**Note:** due to the randomness of the tests it is possible that you will get unlucky and a few of the tests will be really large, so try submitting 2 or 3 times.

As allways any feedback would be much appreciated

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Everyone loves a freebie. Especially students.

It is well-known that if in the night before exam a student opens window, opens the student's record-book and shouts loudly three times "Fly, freebie, fly!" — then flown freebie helps him to pass the upcoming exam.

In the night before the exam on mathematical analysis n students living in dormitory shouted treasured words. The i-th student made a sacrament at the time t_{i}, where t_{i} is the number of seconds elapsed since the beginning of the night.

It is known that the freebie is a capricious and willful lady. That night the freebie was near dormitory only for T seconds. Therefore, if for two students their sacrament times differ for more than T, then the freebie didn't visit at least one of them.

Since all students are optimists, they really want to know what is the maximal number of students visited by the freebie can be.


-----Input-----

The first line of the input contains integer n (1 ≤ n ≤ 100), where n — the number of students shouted "Fly, freebie, fly!" The second line contains n positive integers t_{i} (1 ≤ t_{i} ≤ 1000).

The last line contains integer T (1 ≤ T ≤ 1000) — the time interval during which the freebie was near the dormitory.


-----Output-----

Print a single integer — the largest number of people who will pass exam tomorrow because of the freebie visit.


-----Examples-----
Input
6
4 1 7 8 3 8
1

Output
3

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Title: The Monster and the Squirrel

Time Limit: None seconds

Memory Limit: None megabytes

Problem Description:
Ari the monster always wakes up very early with the first ray of the sun and the first thing she does is feeding her squirrel.

Ari draws a regular convex polygon on the floor and numbers it's vertices 1,<=2,<=...,<=*n* in clockwise order. Then starting from the vertex 1 she draws a ray in the direction of each other vertex. The ray stops when it reaches a vertex or intersects with another ray drawn before. Ari repeats this process for vertex 2,<=3,<=...,<=*n* (in this particular order). And then she puts a walnut in each region inside the polygon.

Ada the squirrel wants to collect all the walnuts, but she is not allowed to step on the lines drawn by Ari. That means Ada have to perform a small jump if she wants to go from one region to another. Ada can jump from one region P to another region Q if and only if P and Q share a side or a corner.

Assuming that Ada starts from outside of the picture, what is the minimum number of jumps she has to perform in order to collect all the walnuts?

Input Specification:
The first and only line of the input contains a single integer *n* (3<=≤<=*n*<=≤<=54321) - the number of vertices of the regular polygon drawn by Ari.

Output Specification:
Print the minimum number of jumps Ada should make to collect all the walnuts. Note, that she doesn't need to leave the polygon after.

Demo Input:
['5\n', '3\n']

Demo Output:
['9\n', '1\n']

Note:
One of the possible solutions for the first sample is shown on the picture above.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
This is the simple version of Shortest Code series. If you need some challenges, please try the [challenge version](http://www.codewars.com/kata/56f928b19982cc7a14000c9d)

## Task: 

  Every uppercase letter is Father, The corresponding lowercase letters is the Son.
    
  Give you a string ```s```, If the father and son both exist, keep them. If it is a separate existence, delete them. Return the result.
    
  For example: 
    
   ```sc("Aab")``` should return ```"Aa"```
    
   ```sc("AabBc")``` should return ```"AabB"```
   
   ```sc("AaaaAaab")``` should return ```"AaaaAaa"```(father can have a lot of son)
    
   ```sc("aAAAaAAb")``` should return ```"aAAAaAA"```(son also can have a lot of father ;-)
    
    
### Series:
 - [Bug in Apple](http://www.codewars.com/kata/56fe97b3cc08ca00e4000dc9)
 - [Father and Son](http://www.codewars.com/kata/56fe9a0c11086cd842000008)
 - [Jumping Dutch act](http://www.codewars.com/kata/570bcd9715944a2c8e000009)
 - [Planting Trees](http://www.codewars.com/kata/5710443187a36a9cee0005a1)
 - [Give me the equation](http://www.codewars.com/kata/56fe9b65cc08cafbc5000de3)
 - [Find the murderer](http://www.codewars.com/kata/570f3fc5b29c702c5500043e)
 - [Reading a Book](http://www.codewars.com/kata/570ca6a520c69f39dd0016d4)
 - [Eat watermelon](http://www.codewars.com/kata/570df12ce6e9282a7d000947)
 - [Special factor](http://www.codewars.com/kata/570e5d0b93214b1a950015b1)
 - [Guess the Hat](http://www.codewars.com/kata/570ef7a834e61306da00035b)
 - [Symmetric Sort](http://www.codewars.com/kata/5705aeb041e5befba20010ba)
 - [Are they symmetrical?](http://www.codewars.com/kata/5705cc3161944b10fd0004ba)
 - [Max Value](http://www.codewars.com/kata/570771871df89cf59b000742)
 - [Trypophobia](http://www.codewars.com/kata/56fe9ffbc25bf33fff000f7c)
 - [Virus in Apple](http://www.codewars.com/kata/5700af83d1acef83fd000048)
 - [Balance Attraction](http://www.codewars.com/kata/57033601e55d30d3e0000633)
 - [Remove screws I](http://www.codewars.com/kata/5710a50d336aed828100055a)
 - [Remove screws II](http://www.codewars.com/kata/5710a8fd336aed00d9000594)
 - [Regular expression compression](http://www.codewars.com/kata/570bae4b0237999e940016e9)
 - [Collatz Array(Split or merge)](http://www.codewars.com/kata/56fe9d579b7bb6b027000001)
 - [Tidy up the room](http://www.codewars.com/kata/5703ace6e55d30d3e0001029)
 - [Waiting for a Bus](http://www.codewars.com/kata/57070eff924f343280000015)

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Boris really likes numbers and even owns a small shop selling interesting numbers. He has n decimal numbers Bi. Cost of the number in his shop is equal to the sum of costs of its digits. You are given the values cd, where cd is the cost of the digit d. Of course, Boris is interested in that numbers he owns have the maximum cost possible.

Recently Boris got hold of the magical artifact A, which can allow him to increase the cost of his collection. Artifact is a string, consisting of digits and '?' symbols. To use the artifact, Boris must replace all '?' with digits to get a decimal number without leading zeros (it is also not allowed to get number 0). After that, the resulting number is added to all numbers Bi in Boris' collection. He uses the artifact exactly once.

What is the maximum cost of the collection Boris can achieve after using the artifact?

Input

First line contains artifact A, consisting of digits '0'–'9' and '?' symbols (1 ≤ |A| ≤ 1000). Next line contains n — the amount of numbers in Boris' collection (1 ≤ n ≤ 1000). Next n lines contain integers Bi (1 ≤ Bi < 101000). A doesn't start with '0'.

Last line contains ten integers — costs of digits c0, c1, ..., c9 (0 ≤ ci ≤ 1000).

Output

Output one integer — the maximum possible cost of the collection after using the artifact.

Examples

Input

42
3
89
1
958
0 0 1 1 2 2 3 3 4 4


Output

4


Input

?5?
4
2203
5229
276
6243
2 1 6 1 1 2 5 2 2 3


Output

62

Note

In the second sample input, the optimal way is to compose the number 453. After adding this number, Boris will have numbers 2656, 5682, 729 and 6696. The total cost of all digits in them is equal to 18 + 15 + 11 + 18 = 62.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
"The zombies are lurking outside. Waiting. Moaning. And when they come..."

"When they come?"

"I hope the Wall is high enough."

Zombie attacks have hit the Wall, our line of defense in the North. Its protection is failing, and cracks are showing. In places, gaps have appeared, splitting the wall into multiple segments. We call on you for help. Go forth and explore the wall! Report how many disconnected segments there are.

The wall is a two-dimensional structure made of bricks. Each brick is one unit wide and one unit high. Bricks are stacked on top of each other to form columns that are up to R bricks high. Each brick is placed either on the ground or directly on top of another brick. Consecutive non-empty columns form a wall segment. The entire wall, all the segments and empty columns in-between, is C columns wide.


-----Input-----

The first line of the input consists of two space-separated integers R and C, 1 ≤ R, C ≤ 100. The next R lines provide a description of the columns as follows:   each of the R lines contains a string of length C,  the c-th character of line r is B if there is a brick in column c and row R - r + 1, and . otherwise.  The input will contain at least one character B and it will be valid.


-----Output-----

The number of wall segments in the input configuration.


-----Examples-----
Input
3 7
.......
.......
.BB.B..

Output
2

Input
4 5
..B..
..B..
B.B.B
BBB.B

Output
2

Input
4 6
..B...
B.B.BB
BBB.BB
BBBBBB

Output
1

Input
1 1
B

Output
1

Input
10 7
.......
.......
.......
.......
.......
.......
.......
.......
...B...
B.BB.B.

Output
3

Input
8 8
........
........
........
........
.B......
.B.....B
.B.....B
.BB...BB

Output
2



-----Note-----

In the first sample case, the 2nd and 3rd columns define the first wall segment, and the 5th column defines the second.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
You are given a grid with dimension $n$ x $m$ and two points with coordinates $X(x1,y1)$ and $Y(x2,y2)$ . Your task is to find the number of ways in which one can go from point $A(0, 0)$ to point $B (n, m)$ using the $shortest$ possible path such that the shortest path neither passes through $X$ nor through $Y$. 

Consider the above 4 x 4 grid . Our shortest path can't pass through points (1,3) and (3,3) (marked by yellow dots). One of the possible shortest path is from $A$ to $C$ and then from $C$ to $B$.

-----Input:-----
- First line contains $T$, number of testcases. Then the testcases follow. 
- Each testcase contains of a single line of input, six space separated integers $n, m, x1, y1, x2, y2$. 

-----Output:-----
- For each testcase, output in a single line number of ways modulo $998244353$.

-----Constraints-----
- $1 \leq T \leq 10^5$
- $3 \leq n,m \leq 10^5$
- $1 \leq x1, x2 \leq n - 1$
- $1 \leq y1, y2 \leq m - 1$
- $x1 \leq x2$
- $y1 \leq y2$
- $X$ and $Y$ never coincide.

-----Sample Input:-----
1
3 3 1 1 1 2

-----Sample Output:-----
5

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Welcome young Jedi! In this Kata you must create a function that takes an amount of US currency in `cents`, and returns a dictionary/hash which shows the least amount of coins used to make up that amount. The only coin denominations considered in this exercise are: `Pennies (1¢), Nickels (5¢), Dimes (10¢) and Quarters (25¢)`.
Therefor the dictionary returned should contain exactly 4 key/value pairs.

Notes:

* If the function is passed either 0 or a negative number, the function should return the dictionary with all values equal to 0.
* If a float is passed into the function, its value should be be rounded down, and the resulting dictionary should never contain fractions of a coin.


## Examples
```
loose_change(56)    ==>  {'Nickels': 1, 'Pennies': 1, 'Dimes': 0, 'Quarters': 2}
loose_change(-435)  ==>  {'Nickels': 0, 'Pennies': 0, 'Dimes': 0, 'Quarters': 0}
loose_change(4.935) ==>  {'Nickels': 0, 'Pennies': 4, 'Dimes': 0, 'Quarters': 0}
```

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Title: The Last Fight Between Human and AI

Time Limit: None seconds

Memory Limit: None megabytes

Problem Description:
100 years have passed since the last victory of the man versus computer in Go. Technologies made a huge step forward and robots conquered the Earth! It's time for the final fight between human and robot that will decide the faith of the planet.

The following game was chosen for the fights: initially there is a polynomial 

Polynomial *P*(*x*) is said to be divisible by polynomial *Q*(*x*) if there exists a representation *P*(*x*)<==<=*B*(*x*)*Q*(*x*), where *B*(*x*) is also some polynomial.

Some moves have been made already and now you wonder, is it true that human can guarantee the victory if he plays optimally?

Input Specification:
The first line of the input contains two integers *n* and *k* (1<=≤<=*n*<=≤<=100<=000,<=|*k*|<=≤<=10<=000) — the size of the polynomial and the integer *k*.

The *i*-th of the following *n*<=+<=1 lines contain character '?' if the coefficient near *x**i*<=-<=1 is yet undefined or the integer value *a**i*, if the coefficient is already known (<=-<=10<=000<=≤<=*a**i*<=≤<=10<=000). Each of integers *a**i* (and even *a**n*) may be equal to 0.

Please note, that it's not guaranteed that you are given the position of the game where it's computer's turn to move.

Output Specification:
Print "Yes" (without quotes) if the human has winning strategy, or "No" (without quotes) otherwise.

Demo Input:
['1 2\n-1\n?\n', '2 100\n-10000\n0\n1\n', '4 5\n?\n1\n?\n1\n?\n']

Demo Output:
['Yes\n', 'Yes', 'No']

Note:
In the first sample, computer set *a*<sub class="lower-index">0</sub> to  - 1 on the first move, so if human can set coefficient *a*<sub class="lower-index">1</sub> to 0.5 and win.

In the second sample, all coefficients are already set and the resulting polynomial is divisible by *x* - 100, so the human has won.

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