vgel/INTELLECT-2-RL-Dataset-Code-Only huggingface dataset:
A basketball competition is held where the number of players in a team does not have a maximum or minimum limit (not necessarily $5$ players in one team for each match). There are $N$ candidate players in the competition that will be trained by Pak Chanek, the best basketball coach on earth. The $i$-th candidate player has a power of $P_i$.

Pak Chanek will form zero or more teams from the $N$ candidate players on the condition that each candidate player may only join in at most one team. Each of Pak Chanek's teams will be sent to compete once with an enemy team that has a power of $D$. In each match, the team sent is said to defeat the enemy team if the sum of powers from the formed players is strictly greater than $D$.

One of Pak Chanek's skills is that when a team that has been formed plays in a match, he can change the power of each player in the team to be equal to the biggest player power from the team.

Determine the maximum number of wins that can be achieved by Pak Chanek.


-----Input-----

The first line contains two integers $N$ and $D$ ($1 \le N \le 10^5$, $1 \le D \le 10^9$) — the number of candidate players and the power of the enemy team.

The second line contains $N$ integers $P_1, P_2, \ldots, P_N$ ($1 \le P_i \le 10^9$) — the powers of all candidate players.


-----Output-----

A line containing an integer representing the maximum number of wins that can be achieved by Pak Chanek.


-----Examples-----

Input
6 180
90 80 70 60 50 100
Output
2


-----Note-----

The $1$-st team formed is a team containing players $4$ and $6$. The power of each player in the team becomes $100$. So the total power of the team is $100 + 100 = 200 > 180$.

The $2$-nd team formed is a team containing players $1$, $2$, and $5$. The power of each player in the team becomes $90$. So the total power of the team is $90 + 90 + 90 = 270 > 180$.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
You are playing following game: given an array A of N natural numbers. All numbers in the array A are at most M. On every turn you may pick any two different elements Ai and Aj (i≠j), such that Ai, Aj ≤ M, and add K to both. The game ends when you are not able to continue. That is, when there is no pair (i,j) left such that both of them are less than equal to M.

Let's call two arrays different if the sum of all their elements is different. When the game ends, you note down the final array A. How many different final arrays can you have.

-----Input-----

The first line contains three integers N, M and K. N elements of the array follow in the next line.

-----Output-----

Output single integer - answer for the given problem modulo 109+7.


-----Constraints-----
-  1 ≤ N ≤ 105
-  1 ≤ M,K ≤ 1012
-  1 ≤ Ai ≤ M

-----Example-----
Input:
3 3 2
1 2 3
Output:
2

-----Explanation-----

All possible sums are 14 and 10. You can get them by, for example, these arrays:
A=(5, 4, 5),
A=(1, 4, 5)

The above arrays are different because their sums are different.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Louise joined a social networking site to stay in touch with her friends. The signup page required her to input a name and a password. However, the password must be strong. The website considers a password to be strong if it satisfies the following criteria:

Its length is at least $\boldsymbol{6}$.  
It contains at least one digit.  
It contains at least one lowercase English character. 
It contains at least one uppercase English character. 
It contains at least one special character. The special characters are: !@#$%^&*()-+  

She typed a random string of length $n$ in the password field but wasn't sure if it was strong. Given the string she typed, can you find the minimum number of characters she must add to make her password strong?

Note: Here's the set of types of characters in a form you can paste in your solution:

numbers = "0123456789"
lower_case = "abcdefghijklmnopqrstuvwxyz"
upper_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
special_characters = "!@#$%^&*()-+"

Example  

$\textbf{password}=\textbf{'2bbbb'}$  

This password is 5 characters long and is missing an uppercase and a special character.  The minimum number of characters to add is $2$.  

$\textbf{password}=\textbf{'2bb#A'}$  

This password is 5 characters long and has at least one of each character type.  The minimum number of characters to add is $\mbox{1}$.    

Function Description  

Complete the minimumNumber function in the editor below.  

minimumNumber has the following parameters:  

int n:  the length of the password  
string password: the password to test  

Returns  

int:  the minimum number of characters to add  

Input Format

The first line contains an integer $n$, the length of the password.

The second line contains the password string. Each character is either a lowercase/uppercase English alphabet, a digit, or a special character.

Constraints

$1\leq n\leq100$  
All characters in $password$ are in [a-z], [A-Z], [0-9], or [!@#\$%^&*()-+ ].

Sample Input 0
3
Ab1

Sample Output 0
3

Explanation 0

She can make the password strong by adding $3$ characters, for example,  \$ hk, turning the password into Ab1\$hk which is strong. 

$2$ characters aren't enough since the length must be at least $\boldsymbol{6}$.  

Sample Input 1
11
#HackerRank

Sample Output 1
1

Explanation 1

The password isn't strong, but she can make it strong by adding a single digit.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Santa has $n$ candies and he wants to gift them to $k$ kids. He wants to divide as many candies as possible between all $k$ kids. Santa can't divide one candy into parts but he is allowed to not use some candies at all.

Suppose the kid who recieves the minimum number of candies has $a$ candies and the kid who recieves the maximum number of candies has $b$ candies. Then Santa will be satisfied, if the both conditions are met at the same time:

  $b - a \le 1$ (it means $b = a$ or $b = a + 1$);  the number of kids who has $a+1$ candies (note that $a+1$ not necessarily equals $b$) does not exceed $\lfloor\frac{k}{2}\rfloor$ (less than or equal to $\lfloor\frac{k}{2}\rfloor$). 

$\lfloor\frac{k}{2}\rfloor$ is $k$ divided by $2$ and rounded down to the nearest integer. For example, if $k=5$ then $\lfloor\frac{k}{2}\rfloor=\lfloor\frac{5}{2}\rfloor=2$.

Your task is to find the maximum number of candies Santa can give to kids so that he will be satisfied.

You have to answer $t$ independent test cases.


-----Input-----

The first line of the input contains one integer $t$ ($1 \le t \le 5 \cdot 10^4$) — the number of test cases.

The next $t$ lines describe test cases. The $i$-th test case contains two integers $n$ and $k$ ($1 \le n, k \le 10^9$) — the number of candies and the number of kids.


-----Output-----

For each test case print the answer on it — the maximum number of candies Santa can give to kids so that he will be satisfied.


-----Example-----
Input
5
5 2
19 4
12 7
6 2
100000 50010

Output
5
18
10
6
75015



-----Note-----

In the first test case, Santa can give $3$ and $2$ candies to kids. There $a=2, b=3,a+1=3$.

In the second test case, Santa can give $5, 5, 4$ and $4$ candies. There $a=4,b=5,a+1=5$. The answer cannot be greater because then the number of kids with $5$ candies will be $3$.

In the third test case, Santa can distribute candies in the following way: $[1, 2, 2, 1, 1, 2, 1]$. There $a=1,b=2,a+1=2$. He cannot distribute two remaining candies in a way to be satisfied.

In the fourth test case, Santa can distribute candies in the following way: $[3, 3]$. There $a=3, b=3, a+1=4$. Santa distributed all $6$ candies.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Given a square grid of integers arr, a falling path with non-zero shifts is a choice of exactly one element from each row of arr, such that no two elements chosen in adjacent rows are in the same column.
Return the minimum sum of a falling path with non-zero shifts.
 
Example 1:
Input: arr = [[1,2,3],[4,5,6],[7,8,9]]
Output: 13
Explanation: 
The possible falling paths are:
[1,5,9], [1,5,7], [1,6,7], [1,6,8],
[2,4,8], [2,4,9], [2,6,7], [2,6,8],
[3,4,8], [3,4,9], [3,5,7], [3,5,9]
The falling path with the smallest sum is [1,5,7], so the answer is 13.

 
Constraints:

1 <= arr.length == arr[i].length <= 200
-99 <= arr[i][j] <= 99

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Emma and Marcos are two friends who love horror films. This year, and possibly the years hereafter, they want to watch as many films together as possible. Unfortunately, they do not exactly have the same taste in films. So, inevitably, every now and then either Emma or Marcos has to watch a film she or he dislikes. When neither of them likes a film, they will not watch it. To make things fair they thought of the following rule: They can not watch two films in a row which are disliked by the same person. In other words, if one of them does not like the current film, then they are reassured they will like the next one. They open the TV guide and mark their preferred films. They only receive one channel which shows one film per day. Luckily, the TV guide has already been determined for the next $1$ million days.

Can you determine the maximal number of films they can watch in a fair way?

-----Input-----
The input consists of two lines, one for each person. Each of these lines is of the following form:
 - One integer $0 \leq k \leq 1000000$ for the number of films this person likes;
 - followed by $k$ integers indicating all days (numbered by $0, \dots , 999999$) with a film this person likes.

-----Output-----
Output a single line containing a single integer, the maximal number of films they can watch together in a fair way.

-----Examples-----
Sample Input 1:
1 40
2 37 42
Sample Output 1:
3

Sample Input 2:
1 1
3 1 3 2
Sample Output 2:
2

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Photography is a deceptively simple subject to the naïve outsider.

In truth, viewing angles, saturation levels, contrast, proper lighting and focusing all play a part. Today, we are most concerned with the problem of focus.

The proudest space telescope of all, Inquisition IV, launched into space over a decade ago and is starting to show its age in the pictures sent back. Not only is the resolution low by modern standards, all images are painfully blurry! Each pixel in the camera viewport is reported as the average of all those around it in an $N \times N$ box, rounded downwards into an integer.

To secure more funding for future research (and, if budget allows it, some lens wipes for the next telescope) you need to prove you know what’s out there, specifically the number of stellar bodies visible to the telescope. As is well-known by now, stellar bodies are very bright: in fact it is guaranteed that each registers as a region of horizontally and vertically connected pixels of total brightness to the sensor, while everything else registers as fully black.

Handily the telescope has framed the entire “scene”, including capturing all of the surrounding blurriness on camera. This means that any pixels outside the capture region can also be considered as totally black.

-----Input-----
 - One line containing three integers $N$, $R$ and $C$ ($1\le N \le 99 \le R, C \le 1000$; $N\equiv 1\mod 2$) indicating the blur box width and rows and columns registered by the camera respectively.
 - Another $R$ lines, each containing $C$ space-separated hexadecimal integers $L_{r,c}$ ($\mathtt{0x0000} \le L_{r,c} \le \mathtt{0xFFFF}$) where a value of $\mathtt{0x0000}$ is total blackness and a value of $\mathtt{0xFFFF}$ is total whiteness.

-----Output-----
A single integer: the number of stellar bodies visible in the snapshot.

-----Examples-----
Sample Input:
1 5 6
0000 FFFF 0000 0000 0000 0000
FFFF FFFF 0000 FFFF FFFF 0000
0000 0000 0000 FFFF 0000 0000
0000 FFFF FFFF FFFF FFFF 0000
0000 0000 0000 0000 0000 0000
Sample Output:
2

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Title: Checkout Assistant

Time Limit: 1 seconds

Memory Limit: 256 megabytes

Problem Description:
Bob came to a cash &amp; carry store, put *n* items into his trolley, and went to the checkout counter to pay. Each item is described by its price *c**i* and time *t**i* in seconds that a checkout assistant spends on this item. While the checkout assistant is occupied with some item, Bob can steal some other items from his trolley. To steal one item Bob needs exactly 1 second. What is the minimum amount of money that Bob will have to pay to the checkout assistant? Remember, please, that it is Bob, who determines the order of items for the checkout assistant.

Input Specification:
The first input line contains number *n* (1<=≤<=*n*<=≤<=2000). In each of the following *n* lines each item is described by a pair of numbers *t**i*, *c**i* (0<=≤<=*t**i*<=≤<=2000,<=1<=≤<=*c**i*<=≤<=109). If *t**i* is 0, Bob won't be able to steal anything, while the checkout assistant is occupied with item *i*.

Output Specification:
Output one number — answer to the problem: what is the minimum amount of money that Bob will have to pay.

Demo Input:
['4\n2 10\n0 20\n1 5\n1 3\n', '3\n0 1\n0 10\n0 100\n']

Demo Output:
['8\n', '111\n']

Note:
none

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Programmers' kids solve this riddle in 5-10 minutes. How fast can you do it?


-----Input-----

The input contains a single integer n (0 ≤ n ≤ 2000000000).


-----Output-----

Output a single integer.


-----Examples-----
Input
11

Output
2

Input
14

Output
0

Input
61441

Output
2

Input
571576

Output
10

Input
2128506

Output
3

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Title: Maximum Control (easy)

Time Limit: None seconds

Memory Limit: None megabytes

Problem Description:
The Resistance is trying to take control over all planets in a particular solar system. This solar system is shaped like a tree. More precisely, some planets are connected by bidirectional hyperspace tunnels in such a way that there is a path between every pair of the planets, but removing any tunnel would disconnect some of them.

The Resistance already has measures in place that will, when the time is right, enable them to control every planet that is not remote. A planet is considered to be remote if it is connected to the rest of the planets only via a single hyperspace tunnel.

How much work is there left to be done: that is, how many remote planets are there?

Input Specification:
The first line of the input contains an integer *N* (2<=≤<=*N*<=≤<=1000) – the number of planets in the galaxy.

The next *N*<=-<=1 lines describe the hyperspace tunnels between the planets. Each of the *N*<=-<=1 lines contains two space-separated integers *u* and *v* (1<=≤<=*u*,<=*v*<=≤<=*N*) indicating that there is a bidirectional hyperspace tunnel between the planets *u* and *v*. It is guaranteed that every two planets are connected by a path of tunnels, and that each tunnel connects a different pair of planets.

Output Specification:
A single integer denoting the number of remote planets.

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

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

Note:
In the first example, only planets 2, 3 and 5 are connected by a single tunnel.

In the second example, the remote planets are 2 and 3.

Note that this problem has only two versions – easy and medium.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Title: Bracket Sequence

Time Limit: None seconds

Memory Limit: None megabytes

Problem Description:
A bracket sequence is a string, containing only characters "(", ")", "[" and "]".

A correct bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters "1" and "+" between the original characters of the sequence. For example, bracket sequences "()[]", "([])" are correct (the resulting expressions are: "(1)+[1]", "([1+1]+1)"), and "](" and "[" are not. The empty string is a correct bracket sequence by definition.

A substring *s*[*l*... *r*] (1<=≤<=*l*<=≤<=*r*<=≤<=|*s*|) of string *s*<==<=*s*1*s*2... *s*|*s*| (where |*s*| is the length of string *s*) is the string *s**l**s**l*<=+<=1... *s**r*. The empty string is a substring of any string by definition.

You are given a bracket sequence, not necessarily correct. Find its substring which is a correct bracket sequence and contains as many opening square brackets «[» as possible.

Input Specification:
The first and the only line contains the bracket sequence as a string, consisting only of characters "(", ")", "[" and "]". It is guaranteed that the string is non-empty and its length doesn't exceed 105 characters.

Output Specification:
In the first line print a single integer — the number of brackets «[» in the required bracket sequence. In the second line print the optimal sequence. If there are more than one optimal solutions print any of them.

Demo Input:
['([])\n', '(((\n']

Demo Output:
['1\n([])\n', '0\n\n']

Note:
none

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Chef likes to travel a lot. Every day Chef tries to visit as much cities as possible. Recently he had a quite a few trips of great Chefland for learning various recipes. Chefland had N cities numbered from 1 to N. People in Chefland are very friendly, friendliness of i-th city is given by Fi.

Before starting of each trip, Chef's initial enjoyment is 1 unit. Whenever he visits a city with friendliness Fi, his enjoyment gets multiplied by Fi units.


City 1 is the home city of Chef. He starts each trip from his home city. Before starting a trip, he chooses a parameter R which denotes that he will start from city 1, and go to city 1 + R, then to 1 + 2 * R, then to 1 + 3 * R, till 1 + i * R such that i is largest integer satisfying 1 + i * R ≤ N.


Now, Chef wants you to help him recreate his visit of the cities. Specifically, he will ask you Q queries, each of which can be of following two types.

1 p f : friendliness of p-th city changes to f, i.e. Fp = f 
2 R   : Find out the total enjoyment Chef will have during this trip. As Chef does not like big numbers, he just asks you to output two things, first digit of the enjoyment and value of enjoyment modulo 10^9 + 7.


Input
There is a single test case.
First line of input contains a single integer N, denoting number of cities in Chefland.
Second line of the input contains N space separated integer - F1, F2, ..., FN, denoting the friendliness of the cities in order from 1 to N.
Next line contains an integer Q, denoting number of queries.
For each of the next Q queries, each line corresponds to one of the two types of the query. First there will be an integer denoting the type of the query, followed by the actual query. For query of type 1, there will be three space separated integers "1 p f" as defined above. For query of type 2, there will be two space separated integers "2 R ", as defined above.

Output
For each query of type 2, output two space separated integers, first digit of Chef's enjoyment in this trip followed by the value of enjoyment modulo 10^9 + 7.

Constraints

 1 ≤ N, Q ≤ 10^5 
 1 ≤ Fi ≤ 10^9 
 1 ≤ f ≤ 10^9 
 1 ≤ p ≤ N 
 1 ≤ R ≤ N 


Example
Input:
5
1 2 3 4 5
3
2 1
1 3 10
2 2

Output:
1 120
5 50

Explanation
In the first query, Chef is going to visit cities 1, 2, 3, 4, 5 in order. At the end of the trip, his total enjoyment will be 1 * 2 * 3 * 4 * 5 = 120. First digit of enjoyment is 1 and 120 modulo 10^9 + 7 is 120.
In the third query, Chef is going to visit cities 1, 3, 5 in order. At the end of the trip, his total enjoyment will be 1 * 10 * 5 = 50.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Define a "prime prime" number to be a rational number written as one prime number over another prime number: `primeA / primeB` (e.g. `7/31`)

Given a whole number `N`, generate the number of "prime prime" rational numbers less than 1, using only prime numbers between `0` and `N` (non inclusive).

Return the count of these "prime primes", and the integer part  of their sum.

## Example

```python
N = 6

# The "prime primes" less than 1 are:
2/3, 2/5, 3/5               # count: 3

2/3 + 2/5 + 3/5 = 1.6667    # integer part: 1

Thus, the function should return 3 and 1.
```

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.

However, all is not lost. Kevin is a big proponent of alternative thinking and believes that his score, instead of being the sum of his points, should be the length of the longest alternating subsequence of his string. Here, we define an alternating subsequence of a string as a not-necessarily contiguous subsequence where no two consecutive elements are equal. For example, {0, 1, 0, 1}, {1, 0, 1}, and {1, 0, 1, 0} are alternating sequences, while {1, 0, 0} and {0, 1, 0, 1, 1} are not.

Kevin, being the sneaky little puffball that he is, is willing to hack into the USAICO databases to improve his score. In order to be subtle, he decides that he will flip exactly one substring—that is, take a contiguous non-empty substring of his score and change all '0's in that substring to '1's and vice versa. After such an operation, Kevin wants to know the length of the longest possible alternating subsequence that his string could have.


-----Input-----

The first line contains the number of questions on the olympiad n (1 ≤ n ≤ 100 000).

The following line contains a binary string of length n representing Kevin's results on the USAICO. 


-----Output-----

Output a single integer, the length of the longest possible alternating subsequence that Kevin can create in his string after flipping a single substring.


-----Examples-----
Input
8
10000011

Output
5

Input
2
01

Output
2



-----Note-----

In the first sample, Kevin can flip the bolded substring '10000011' and turn his string into '10011011', which has an alternating subsequence of length 5: '10011011'.

In the second sample, Kevin can flip the entire string and still have the same score.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Complete the function, which calculates how much you need to tip based on the total amount of the bill and the service. 

You need to consider the following ratings:

- Terrible: tip 0%
- Poor: tip 5%
- Good: tip 10%
- Great: tip 15%
- Excellent: tip 20%

The rating is **case insensitive** (so "great" = "GREAT"). If an unrecognised rating is received, then you need to return:

* `"Rating not recognised"` in Javascript, Python and Ruby...
* ...or `null` in Java
* ...or `-1` in C#

Because you're a nice person, you **always round up** the tip, regardless of the service.

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