vgel/INTELLECT-2-RL-Dataset-Code-Only huggingface dataset:
Title: Snow Footprints

Time Limit: None seconds

Memory Limit: None megabytes

Problem Description:
There is a straight snowy road, divided into *n* blocks. The blocks are numbered from 1 to *n* from left to right. If one moves from the *i*-th block to the (*i*<=+<=1)-th block, he will leave a right footprint on the *i*-th block. Similarly, if one moves from the *i*-th block to the (*i*<=-<=1)-th block, he will leave a left footprint on the *i*-th block. If there already is a footprint on the *i*-th block, the new footprint will cover the old one.

At the beginning, there were no footprints. Then polar bear Alice starts from the *s*-th block, makes a sequence of moves and ends in the *t*-th block. It is known that Alice never moves outside of the road. 

You are given the description of Alice's footprints. Your task is to find a pair of possible values of *s*,<=*t* by looking at the footprints.

Input Specification:
The first line of the input contains integer *n* (3<=≤<=*n*<=≤<=1000).

The second line contains the description of the road — the string that consists of *n* characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint).

It's guaranteed that the given string contains at least one character not equal to ".". Also, the first and the last character will always be ".". It's guaranteed that a solution exists.

Output Specification:
Print two space-separated integers — the values of *s* and *t*. If there are several possible solutions you can print any of them.

Demo Input:
['9\n..RRLL...\n', '11\n.RRRLLLLL..\n']

Demo Output:
['3 4\n', '7 5\n']

Note:
The first test sample is the one in the picture.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
NVWLS, or “No Vowels” puzzles are popular among puzzle enthusiasts. For example, consider the following no-vowels message:

BTWNSBTLSHDNGNDTHBSNCFLGHTLSTHNNCFQLSN

which is inscribed on the famous “Kryptos” statue located at the CIA’s headquarters in Virginia. This message is derived from the following sentence by removing all vowels and spaces:

BETWEEN SUBTLE SHADING AND THE ABSENCE OF LIGHT
LIES THE NUANCE OF IQLUSION

Given a dictionary (a set of words that can be used to construct a sentence) and a message (which comes from a sentence which uses only those words, but with all vowels and spaces removed), reconstruct the original sentence using the dictionary words!

-----Input-----
The first line contains an integer $n$ denoting the number of words in the dictionary. The next $n$ lines each contain a dictionary word using one or more uppercase English letters. Each word contains at least one consonant.

For the purposes of this problem, the letters A, E, I, O, and U are vowels and all other letters are consonants.

The dictionary is followed by a single non-empty line of uppercase consonants representing the no-vowels message. It is guaranteed that the no-vowels message can be constructed in at least one way using only the dictionary words.

The total number of letters in all dictionary words is no greater than $100000$. The total number of letters in the no-vowels message does not exceed $300000$.

-----Output-----
Output a whitespace-separated sequence of dictionary words that yields the original no-vowels message when all spaces and vowels are removed. If there are multiple reconstructions, choose the one with the largest overall number of vowels. If there are still multiple reconstructions, you may output any one of them. No judge input will require your program to output more than $15000000$ characters.

-----Examples-----
Sample Input:
11
BETWEEN
SUBTLE
SHADING
AND
THE
ABSENCE
OF
LIGHT
LIES
NUANCE
IQLUSION
BTWNSBTLSHDNGNDTHBSNCFLGHTLSTHNNCFQLSN
Sample Output:
BETWEEN SUBTLE SHADING AND THE ABSENCE OF LIGHT LIES THE NUANCE OF IQLUSION

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Title: bHTML Tables Analisys

Time Limit: 2 seconds

Memory Limit: 256 megabytes

Problem Description:
In this problem is used an extremely simplified version of HTML table markup. Please use the statement as a formal document and read it carefully.

A string is a bHTML table, if it satisfies the grammar: 

Blanks in the grammar are only for purposes of illustration, in the given data there will be no spaces. The bHTML table is very similar to a simple regular HTML table in which meet only the following tags : "table", "tr", "td", all the tags are paired and the table contains at least one row and at least one cell in each row. Have a look at the sample tests as examples of tables.

As can be seen, the tables may be nested. You are given a table (which may contain other(s)). You need to write a program that analyzes all the tables and finds the number of cells in each of them. The tables are not required to be rectangular.

Input Specification:
For convenience, input data can be separated into non-empty lines in an arbitrary manner. The input data consist of no more than 10 lines. Combine (concatenate) all the input lines into one, to get a text representation *s* of the specified table. String *s* corresponds to the given grammar (the root element of grammar is TABLE), its length does not exceed 5000. Only lower case letters are used to write tags. There are no spaces in the given string *s*.

Output Specification:
Print the sizes of all the tables in the non-decreasing order.

Demo Input:
['&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;\n', '&lt;table&gt;\n&lt;tr&gt;\n&lt;td&gt;\n&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;/\ntd\n&gt;&lt;/tr&gt;&lt;tr\n&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;\n&lt;/td&gt;\n&lt;/tr&gt;\n&lt;/table&gt;\n', '&lt;table&gt;&lt;tr&gt;&lt;td&gt;\n&lt;table&gt;&lt;tr&gt;&lt;td&gt;\n&lt;table&gt;&lt;tr&gt;&lt;td&gt;\n&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;\n&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;\n&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;\n&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;\n&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;\n']

Demo Output:
['1 ', '1 4 ', '1 1 1 3 ']

Note:
none

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

Time Limit: None seconds

Memory Limit: None megabytes

Problem Description:
To make a paper airplane, one has to use a rectangular piece of paper. From a sheet of standard size you can make $s$ airplanes.

A group of $k$ people decided to make $n$ airplanes each. They are going to buy several packs of paper, each of them containing $p$ sheets, and then distribute the sheets between the people. Each person should have enough sheets to make $n$ airplanes. How many packs should they buy?

Input Specification:
The only line contains four integers $k$, $n$, $s$, $p$ ($1 \le k, n, s, p \le 10^4$) — the number of people, the number of airplanes each should make, the number of airplanes that can be made using one sheet and the number of sheets in one pack, respectively.

Output Specification:
Print a single integer — the minimum number of packs they should buy.

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

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

Note:
In the first sample they have to buy $4$ packs of paper: there will be $12$ sheets in total, and giving $2$ sheets to each person is enough to suit everyone's needs.

In the second sample they have to buy a pack for each person as they can't share sheets.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Given an array of N integers arr[ ], the task is to count the minimum number of operations to equalize the array i.e. to make all array elements equal.
In one operation, you can choose two elements arr[i] and arr[j] such that arr[i] > arr[j] and change them to arr[i] = arr[i] - 1 and arr[j] = arr[j] + 1.
If it is impossible to equalize the array print "-1".
Example 1:
Input:
N = 5
arr[] = {1, 3, 2, 0, 4}
Output:  3
Explanation: We can equalize the array by 
making value of all elements equal to 2. 
To achieve this we need to do minimum 3 
operations:
1. arr[0]++ and arr[1]--
2. arr[3]++ and arr[4]--
3. arr[3]++ and arr[4]--
Example 2:
Input:
N = 3
arr[] = {1, 7, 1}
Output:  4
Your Task:
This is a function problem. You don't need to take any input, as it is already accomplished by the driver code. You just need to complete the function minOperations() that takes array arr[ ] and integer N as input parameters and returns the required answer.
Note - return -1, if it is not possible to equalize the array.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1).
Constraints:
1 ≤ N ≤ 10^{5}

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
You are on the island which can be represented as a $n \times m$ table. The rows are numbered from $1$ to $n$ and the columns are numbered from $1$ to $m$. There are $k$ treasures on the island, the $i$-th of them is located at the position $(r_i, c_i)$.

Initially you stand at the lower left corner of the island, at the position $(1, 1)$. If at any moment you are at the cell with a treasure, you can pick it up without any extra time. In one move you can move up (from $(r, c)$ to $(r+1, c)$), left (from $(r, c)$ to $(r, c-1)$), or right (from position $(r, c)$ to $(r, c+1)$). Because of the traps, you can't move down.

However, moving up is also risky. You can move up only if you are in a safe column. There are $q$ safe columns: $b_1, b_2, \ldots, b_q$. You want to collect all the treasures as fast as possible. Count the minimum number of moves required to collect all the treasures.


-----Input-----

The first line contains integers $n$, $m$, $k$ and $q$ ($2 \le n, \, m, \, k, \, q \le 2 \cdot 10^5$, $q \le m$) — the number of rows, the number of columns, the number of treasures in the island and the number of safe columns.

Each of the next $k$ lines contains two integers $r_i, c_i$, ($1 \le r_i \le n$, $1 \le c_i \le m$) — the coordinates of the cell with a treasure. All treasures are located in distinct cells.

The last line contains $q$ distinct integers $b_1, b_2, \ldots, b_q$ ($1 \le b_i \le m$) — the indices of safe columns.


-----Output-----

Print the minimum number of moves required to collect all the treasures.


-----Examples-----
Input
3 3 3 2
1 1
2 1
3 1
2 3

Output
6
Input
3 5 3 2
1 2
2 3
3 1
1 5

Output
8
Input
3 6 3 2
1 6
2 2
3 4
1 6

Output
15


-----Note-----

In the first example you should use the second column to go up, collecting in each row treasures from the first column. [Image] 

In the second example, it is optimal to use the first column to go up. [Image] 

In the third example, it is optimal to collect the treasure at cell $(1;6)$, go up to row $2$ at column $6$, then collect the treasure at cell $(2;2)$, go up to the top row at column $1$ and collect the last treasure at cell $(3;4)$. That's a total of $15$ moves. [Image]

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
You are given two positive integers A and B. Compare the magnitudes of these numbers.

Constraints

* 1 ≤ A, B ≤ 10^{100}
* Neither A nor B begins with a `0`.

Input

Input is given from Standard Input in the following format:


A
B


Output

Print `GREATER` if A>B, `LESS` if A<B and `EQUAL` if A=B.

Examples

Input

36
24


Output

GREATER


Input

850
3777


Output

LESS


Input

9720246
22516266


Output

LESS


Input

123456789012345678901234567890
234567890123456789012345678901


Output

LESS

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Mirko and Slavko are playing a chess like game. The game is played on a non-standard chess board sized $R$ rows by $C$ columns. Each player starts with some number of chess kings. In chess kings can move from their current field to any of the $8$ neighbouring fields. Player spread is defined as the complete sum of distances between all pairs of pieces of the given player. The distance between two pieces is the smallest number of moves required for both pieces to reach the same field. No actual moves are performed when calculating the distance and as such enemy pieces do not influence the result. Mirko knows that the spread is a vital piece of strategic information and would like you to make him a program that will calculate both his and Slavko’s spread.

-----Input-----
The first line of input contains two integers $R$ and $C$ ($1 \le R , C \le 1000$), number of rows and columns. Next $R$ lines contain $C$ characters each. Character ‘M’ denotes Mirko’s piece, ‘S’ Slavko’s piece and ‘.’ denotes an empty field. There is at least one piece per player on the board. Otherwise the game would be over.

-----Output-----
In the first and only line of output you need to print exactly two integers. The first integers is the spread of Mirko’s and the second Slavko’s pieces.

-----Examples-----
Sample Input 1:
2 3
SMS
MMS
Sample Output 1:
3 5

Sample Input 2:
2 3
S.M
M..
Sample Output 2:
2 0

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Topologically sorting the nodes of a directed graph (digraph) $G$ means putting the nodes in linear order\[ v_0, v_1, v_2, v_3, \ldots \]

such that whenever there is an edge from node $x$ to node $y$ in $G$, $x$ always precedes $y$ in the linear ordering. It is not hard to show that the nodes of a digraph can be topologically sorted if and only if the graph is acyclic (does not contain any directed cycles).

Kahn’s Algorithm is a well-known topological sorting algorithm. Beginning with a digraph $G$ and an empty list $L$, it repeatedly executes the following three steps:
 - Let $S$ be the set of source nodes, i.e., the nodes with no incoming edges. If $S$ is empty, terminate the algorithm.
 - Let $\alpha $ be any node in $S$. Remove $\alpha $ and all its outgoing edges from $G$. If this removal of edges creates new source nodes, add these to $S$.
 - Insert $\alpha $ at the end of $L$.

Once Kahn’s Algorithm terminates, if $G$ is now empty, then $L$ contains the nodes of the initial graph in topologically sorted order (such an ordering may not be unique). Otherwise, $G$ has one or more cycles, and therefore topological sorting is impossible.

Regardless of the outcome of Kahn’s Algorithm, consider any iteration of Step $1$ above. If $S$ contains more than one node, then $\alpha $ can be any one of them, and the choice of $\alpha $ affects the composition of $S$ in later iterations, when further choices may be made that affect the composition of $S$ in yet later iterations, and so on. Taking into account all possible sequences of choices of $\alpha $ during the execution of Kahn’s Algorithm, what is the largest $S$ can ever be at the beginning of Step $1$?

-----Input-----
The input specifies a single directed graph. The first line of input contains two space-separated integers, $n$ and $m$ ($1 \leq n \leq 500$,  $0 \leq m \leq n(n-1)$), where $n$ is the number of nodes and $m$ is the number of edges. This is followed by $m$ lines, each containing two space-separated integers, $x$ and $y$ ($0 \leq x,y \leq (n-1)$, $x \neq y$), indicating that there is a directed edge from node $x$ to node $y$, where nodes are indexed $0, 1, 2, \ldots , (n-1)$. No edge will be listed more than once.

-----Output-----
Output a line containing a single integer: the largest possible size of $S$ at the beginning of any iteration of Step $1$ in the execution of Kahn’s Algorithm.

-----Examples-----
Sample Input:
4 3
0 1
1 2
2 3
Sample Output:
1

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
A number M is said to be a *Mystical Number* with respect to a number X if (M \oplus X) > (M \& X).

You are given an array A of size N. You are also given Q queries. Each query consists of three integers L, R, and X.

For each query, find the count of *Mystical Numbers* in the subarray A[L:R] with respect to the number X. 

Notes:
\oplus represents the [Bitwise XOR] operation and \& represents the [Bitwise AND] operation.
A[L:R] denotes the subarray A[L], A[L+1], \ldots, A[R].

------ Input Format ------ 

- The first line contains a single integer T - the number of test cases. Then the test cases follow.
- The first line of each test case contains an integer N - the size of the array A.
- The second line of each test case contains N space-separated integers A_{1}, A_{2}, \dots, A_{N} denoting the array A.
- The third line of each test case contains an integer Q - denoting the number of queries.
- The i^{th} of the next Q lines contains three space-separated integers L , R and X.

------ Output Format ------ 

For each testcase, 
- For each query, print in a new line, the count of *Mystical Numbers* among A[L], A[L+1], \ldots, A[R] with respect to the number X. 

------ Constraints ------ 

$1 ≤ T ≤ 100$
$1 ≤ N ≤ 2 \cdot 10^{5}$
$0 ≤ A_{i} < 2^{31}$
$1 ≤ Q ≤ 2 \cdot 10^{5}$
$1 ≤ L ≤ R ≤ N$
$0 ≤ X < 2^{31}$
- Sum of $N$ over all test cases does not exceed $2 \cdot 10^{5}$.
- Sum of $Q$ over all test cases does not exceed $2 \cdot 10^{5}$.

----- Sample Input 1 ------ 
1
5
1 2 3 4 5
2
1 5 4
2 5 2
----- Sample Output 1 ------ 
3
2
----- explanation 1 ------ 
Test case $1$:  
- Query $1$: $L = 1 , R = 5 , X = 4$. 
- $A_{1} \oplus X = 5, A_{1} \& X = 0$.
- $A_{2} \oplus X = 6, A_{2} \& X = 0$.
- $A_{3} \oplus X = 7, A_{3} \& X = 0$.
- $A_{4} \oplus X = 0, A_{4} \& X = 4$.
- $A_{5} \oplus X = 1, A_{5} \& X = 4$.

Mystical numbers are $A_{1} , A_{2},$ and $A_{3}$ with respect to $4$. Therefore, the answer to this query is $3$.
- Query $2$: $L = 2 , R = 5 , X = 2$.
- $A_{2} \oplus X = 0, A_{2} \& X = 2$.
- $A_{3} \oplus X = 1, A_{3} \& X = 2$.
- $A_{4} \oplus X = 6, A_{4} \& X = 0$.
- $A_{5} \oplus X = 7, A_{5} \& X = 0$.

Mystical numbers are $A_{4}$ and $A_{5}$ with respect to $2$. Therefore , the answer to this query is $2$.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
This task will exclusively concentrate only on the arrays where all elements equal 1 and/or 2.

Array a is k-period if its length is divisible by k and there is such array b of length k, that a is represented by array b written exactly $\frac{n}{k}$ times consecutively. In other words, array a is k-periodic, if it has period of length k.

For example, any array is n-periodic, where n is the array length. Array [2, 1, 2, 1, 2, 1] is at the same time 2-periodic and 6-periodic and array [1, 2, 1, 1, 2, 1, 1, 2, 1] is at the same time 3-periodic and 9-periodic.

For the given array a, consisting only of numbers one and two, find the minimum number of elements to change to make the array k-periodic. If the array already is k-periodic, then the required value equals 0.


-----Input-----

The first line of the input contains a pair of integers n, k (1 ≤ k ≤ n ≤ 100), where n is the length of the array and the value n is divisible by k. The second line contains the sequence of elements of the given array a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 2), a_{i} is the i-th element of the array.


-----Output-----

Print the minimum number of array elements we need to change to make the array k-periodic. If the array already is k-periodic, then print 0.


-----Examples-----
Input
6 2
2 1 2 2 2 1

Output
1

Input
8 4
1 1 2 1 1 1 2 1

Output
0

Input
9 3
2 1 1 1 2 1 1 1 2

Output
3



-----Note-----

In the first sample it is enough to change the fourth element from 2 to 1, then the array changes to [2, 1, 2, 1, 2, 1].

In the second sample, the given array already is 4-periodic.

In the third sample it is enough to replace each occurrence of number two by number one. In this case the array will look as [1, 1, 1, 1, 1, 1, 1, 1, 1] — this array is simultaneously 1-, 3- and 9-periodic.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Title: Squares and not squares

Time Limit: None seconds

Memory Limit: None megabytes

Problem Description:
Ann and Borya have *n* piles with candies and *n* is even number. There are *a**i* candies in pile with number *i*.

Ann likes numbers which are square of some integer and Borya doesn't like numbers which are square of any integer. During one move guys can select some pile with candies and add one candy to it (this candy is new and doesn't belong to any other pile) or remove one candy (if there is at least one candy in this pile). 

Find out minimal number of moves that is required to make exactly *n*<=/<=2 piles contain number of candies that is a square of some integer and exactly *n*<=/<=2 piles contain number of candies that is not a square of any integer.

Input Specification:
First line contains one even integer *n* (2<=≤<=*n*<=≤<=200<=000) — number of piles with candies.

Second line contains sequence of integers *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=109) — amounts of candies in each pile.

Output Specification:
Output minimal number of steps required to make exactly *n*<=/<=2 piles contain number of candies that is a square of some integer and exactly *n*<=/<=2 piles contain number of candies that is not a square of any integer. If condition is already satisfied output 0.

Demo Input:
['4\n12 14 30 4\n', '6\n0 0 0 0 0 0\n', '6\n120 110 23 34 25 45\n', '10\n121 56 78 81 45 100 1 0 54 78\n']

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

Note:
In first example you can satisfy condition in two moves. During each move you should add one candy to second pile. After it size of second pile becomes 16. After that Borya and Ann will have two piles with number of candies which is a square of integer (second and fourth pile) and two piles with number of candies which is not a square of any integer (first and third pile).

In second example you should add two candies to any three piles.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
This problem of Oz is very straight forward. You are given N distinct prime integers i.e p1, p2,..., pN and an interval [L,R]. Calculate number of integers in this interval that are divisible by at least one of the given primes.

Input : 
First line of input contain an integer T — the number of test cases. T tests follow. First line of each test case contain 3 integers — N, L, R. and the next line contains N distinct prime integers - p1, p2,..., pN.

Output :
For each test case output a single number — number of integers in [L,R], that are divisible by at least one of the given primes.

Constraints :
1 ≤ T ≤ 10
1 ≤ N ≤ 10
1 < pi < 1000 where i=1,2..N 
1 ≤ L ≤ R ≤ 10^18

SAMPLE INPUT
2
1 1 10
3
2 1 10
2 3

SAMPLE OUTPUT
3
7

Explanation

For second sample : 
Numbers in the interval [1,10] which are divisible by at least one prime from (2,3) are as follow :
2, 3, 4, 6, 8, 9, 10

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