vgel/INTELLECT-2-RL-Dataset-Code-Only huggingface dataset:
You are given non-negative integers A, B and C.

Does there exist a non-negative integer X such that A \oplus X+ B \oplus X = C \oplus X?

As a reminder, \oplus denotes the [bitwise XOR operation].

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

- The first line of input will contain a single integer T, denoting the number of test cases.
- The only line of each test case contains three space-separated non-negative integers A, B and C.

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

For each test case, print on a new line the answer: YES if valid X exists, and NO otherwise.

Each character of the output may be printed in either uppercase or lowercase, i.e, the strings Yes, YES, yes, yEs will all be treated as identical.

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

$1 ≤ T ≤ 10^{5}$
$0 ≤ A, B, C < 2^{27}$

----- Sample Input 1 ------ 
5
2 5 7
2 3 13
7 0 7
2 7 6
1 6 6

----- Sample Output 1 ------ 
YES
NO
YES
YES
YES

----- explanation 1 ------ 
Test case $1$: $X=0$ satisfies the equation.

Test case $2$: It can be proved that there does not exist a non-negative integer $X$ which satisfies the equation.

Test case $3$: $X=0$ satisfies the equation.

Test case $4$: $X=3$ satisfies the equation.

Test case $5$: $X=1$ satisfies the equation.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
In a tournament with $m$ teams, each team consisting of $n$ players, construct a playing schedule so that each player is paired up against all players in all teams except their own. That is, each player should play $(m-1) \cdot n$ games. 

The playing schedule should be divided into rounds. A player can play at most one game per round. If a player does not play a game in a round, that player is said to have a bye in that round.

Your task is to write a program that constructs a playing schedule so that no player has a bye in more than $1$ round. In other words, the total number of rounds in the playing schedule should be no more than $(m-1) \cdot n + 1$.

The order of the rounds and games, and who is home and away in a game, does not matter.

-----Input-----
The input consists of a single line with two integers $n$ and $m$ ($1 \le n \le 25$, $2 \le m \le 25$, $n \cdot m \le 100$), the number of players in a team and the total number of teams, respectively.

-----Output-----
Output one line per round in the playing schedule. Each line should contain a space separated list of games. A game is in the format “<player>-<player>”. The players in the first team are denoted as $\texttt{A}1, \texttt{A}2, ..., \texttt{A}n$; the second team $\texttt{B}1, \texttt{B}2, \ldots \texttt{B}n$ and so on.

-----Examples-----
Sample Input 1:
3 2
Sample Output 1:
A1-B2 B1-A2 A3-B3
A2-B3 B2-A3 A1-B1
A3-B1 B3-A1 A2-B2

Sample Input 2:
2 3
Sample Output 2:
A1-B1 A2-C2 B2-C1
A1-C1 A2-B1 B2-C2
A1-B2 A2-C1 B1-C2
A1-C2 A2-B2 B1-C1

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

Time Limit: None seconds

Memory Limit: None megabytes

Problem Description:
Little girl Susie went shopping with her mom and she wondered how to improve service quality. 

There are *n* people in the queue. For each person we know time *t**i* needed to serve him. A person will be disappointed if the time he waits is more than the time needed to serve him. The time a person waits is the total time when all the people who stand in the queue in front of him are served. Susie thought that if we swap some people in the queue, then we can decrease the number of people who are disappointed. 

Help Susie find out what is the maximum number of not disappointed people can be achieved by swapping people in the queue.

Input Specification:
The first line contains integer *n* (1<=≤<=*n*<=≤<=105).

The next line contains *n* integers *t**i* (1<=≤<=*t**i*<=≤<=109), separated by spaces.

Output Specification:
Print a single number — the maximum number of not disappointed people in the queue.

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

Demo Output:
['4\n']

Note:
Value 4 is achieved at such an arrangement, for example: 1, 2, 3, 5, 15. Thus, you can make everything feel not disappointed except for the person with time 5.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Little kids, Jack and Evan like playing their favorite game Glass-and-Stone. Today they want to play something new and came across Twitter on their father's laptop.

They saw it for the first time but were already getting bored to see a bunch of sentences having at most 140 characters each. The only thing they liked to play with it is, closing and opening tweets.

There are N tweets on the page and each tweet can be opened by clicking on it, to see some statistics related to that tweet. Initially all the tweets are closed. Clicking on an open tweet closes it and clicking on a closed tweet opens it. There is also a button to close all the open tweets. Given a sequence of K clicks by Jack, Evan has to guess the total number of open tweets just after each click. Please help Evan in this game.

-----Input-----
First line contains two integers N K, the number of tweets (numbered 1 to N) and the number of clicks respectively (1 ≤ N, K ≤ 1000). Each of the following K lines has one of the following.

- CLICK X , where X is the tweet number (1 ≤ X ≤ N)
- CLOSEALL

-----Output-----
Output K lines, where the ith line should contain the number of open tweets just after the ith click.

-----Example-----
Input:
3 6
CLICK 1
CLICK 2
CLICK 3
CLICK 2
CLOSEALL
CLICK 1

Output:
1
2
3
2
0
1

Explanation:

Let open[x] = 1 if the xth tweet is open and 0 if its closed.

Initially open[1..3] = { 0 , 0 , 0 }. Here is the state of open[1..3] after each click and corresponding count of open tweets.

CLICK 1 : { 1, 0, 0 }, open count = 1

CLICK 2 : { 1, 1, 0 }, open count = 2

CLICK 3 : { 1, 1, 1 }, open count = 3

CLICK 2 : { 1, 0, 1 }, open count = 2

CLOSEALL : { 0, 0, 0 }, open count = 0

CLICK 1 : { 1, 0, 0 }, open count = 1

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Congratulations! You are now the judge of a programming contest! You’ve been put in charge of a problem, and since your problem may not have unique correct output, you’ve got to write an output checker for it.

Your problem is called “Good as Goldbach”, and it’s based on the Goldbach Conjecture (that any positive even integer greater than $3$ can be expressed as the sum of two primes). A solving program’s output should have three numbers separated by whitespace: First, a positive even integer greater than $3$ and less than or equal to $10^9$, and then two (positive) prime numbers which sum to the even number.

You must write a checker for this problem. Your checker should take the output of a contestant’s program, and determine whether or not it could possibly be correct. That is, determine if the contestant’s output consists only of three tokens separated by whitespace, the first of which is a positive even integer greater than $3$ and less than or equal to $10^9$, and the next two are positive prime integers which sum to the first. The integers should be in base ten, with no signs or leading zeros. Any amount of white space anywhere except within an integer, including blank lines, is OK. Any other output, extra characters, missing numbers, etc. should be considered incorrect.

-----Input-----
The input will consist of from $0$ to $1000$ lines. Each line consists of from $0$ to $100$ printable ASCII characters (with codes 32 through 126), or tabs.

-----Output-----
Output a single integer, which is $1$ if the input could possibly be a correct output for the “Good as Goldbach” problem, or $0$ if the input could not possibly be a correct output for the “Good as Goldbach” problem.

-----Examples-----
Sample Input 1:
10 3 7
Sample Output 1:
1

Sample Input 2:
10   3   7
Sample Output 2:
1

Sample Input 3:
314
159 265
358
Sample Output 3:
0

Sample Input 4:
22 19 3
Sample Output 4:
1

Sample Input 5:

   60
  
  29
  
      31
          
          
          
          
Sample Output 5:
1

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

Time Limit: None seconds

Memory Limit: None megabytes

Problem Description:
The construction of subway in Bertown is almost finished! The President of Berland will visit this city soon to look at the new subway himself.

There are *n* stations in the subway. It was built according to the Bertown Transport Law:
 1.  For each station *i* there exists exactly one train that goes from this station. Its destination station is *p**i*, possibly *p**i*<==<=*i*; 1.  For each station *i* there exists exactly one station *j* such that *p**j*<==<=*i*. 
The President will consider the convenience of subway after visiting it. The convenience is the number of ordered pairs (*x*,<=*y*) such that person can start at station *x* and, after taking some subway trains (possibly zero), arrive at station *y* (1<=≤<=*x*,<=*y*<=≤<=*n*).

The mayor of Bertown thinks that if the subway is not convenient enough, then the President might consider installing a new mayor (and, of course, the current mayor doesn't want it to happen). Before President visits the city mayor has enough time to rebuild some paths of subway, thus changing the values of *p**i* for not more than two subway stations. Of course, breaking the Bertown Transport Law is really bad, so the subway must be built according to the Law even after changes.

The mayor wants to do these changes in such a way that the convenience of the subway is maximized. Help him to calculate the maximum possible convenience he can get!

Input Specification:
The first line contains one integer number *n* (1<=≤<=*n*<=≤<=100000) — the number of stations.

The second line contains *n* integer numbers *p*1, *p*2, ..., *p**n* (1<=≤<=*p**i*<=≤<=*n*) — the current structure of the subway. All these numbers are distinct.

Output Specification:
Print one number — the maximum possible value of convenience.

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

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

Note:
In the first example the mayor can change *p*<sub class="lower-index">2</sub> to 3 and *p*<sub class="lower-index">3</sub> to 1, so there will be 9 pairs: (1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3), (3, 1), (3, 2), (3, 3).

In the second example the mayor can change *p*<sub class="lower-index">2</sub> to 4 and *p*<sub class="lower-index">3</sub> to 5.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Joe has been hurt on the Internet. Now he is storming around the house, destroying everything in his path.

Joe's house has n floors, each floor is a segment of m cells. Each cell either contains nothing (it is an empty cell), or has a brick or a concrete wall (always something one of three). It is believed that each floor is surrounded by a concrete wall on the left and on the right.

Now Joe is on the n-th floor and in the first cell, counting from left to right. At each moment of time, Joe has the direction of his gaze, to the right or to the left (always one direction of the two). Initially, Joe looks to the right.

Joe moves by a particular algorithm. Every second he makes one of the following actions:   If the cell directly under Joe is empty, then Joe falls down. That is, he moves to this cell, the gaze direction is preserved.  Otherwise consider the next cell in the current direction of the gaze.   If the cell is empty, then Joe moves into it, the gaze direction is preserved.  If this cell has bricks, then Joe breaks them with his forehead (the cell becomes empty), and changes the direction of his gaze to the opposite.  If this cell has a concrete wall, then Joe just changes the direction of his gaze to the opposite (concrete can withstand any number of forehead hits).  

Joe calms down as soon as he reaches any cell of the first floor.

The figure below shows an example Joe's movements around the house.

 [Image] 

Determine how many seconds Joe will need to calm down.


-----Input-----

The first line contains two integers n and m (2 ≤ n ≤ 100, 1 ≤ m ≤ 10^4).

Next n lines contain the description of Joe's house. The i-th of these lines contains the description of the (n - i + 1)-th floor of the house — a line that consists of m characters: "." means an empty cell, "+" means bricks and "#" means a concrete wall.

It is guaranteed that the first cell of the n-th floor is empty.


-----Output-----

Print a single number — the number of seconds Joe needs to reach the first floor; or else, print word "Never" (without the quotes), if it can never happen.

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.


-----Examples-----
Input
3 5
..+.#
#+..+
+.#+.

Output
14
Input
4 10
...+.##+.+
+#++..+++#
++.#++++..
.+##.++#.+

Output
42

Input
2 2
..
++

Output
Never

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Given are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists.
 - Let s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\ldots{s'}_i (the first i characters in s').

-----Notes-----
 - A subsequence of a string a is a string obtained by deleting zero or more characters from a and concatenating the remaining characters without changing the relative order. For example, the subsequences of contest include net, c, and contest.

-----Constraints-----
 - 1 \leq |s| \leq 10^5
 - 1 \leq |t| \leq 10^5
 - s and t consists of lowercase English letters.

-----Input-----
Input is given from Standard Input in the following format:
s
t

-----Output-----
If there exists an integer i satisfying the following condition, print the minimum such i; otherwise, print -1.

-----Sample Input-----
contest
son

-----Sample Output-----
10

t = son is a subsequence of the string contestcon (the first 10 characters in s' = contestcontestcontest...), so i = 10 satisfies the condition.
On the other hand, t is not a subsequence of the string contestco (the first 9 characters in s'), so i = 9 does not satisfy the condition.
Similarly, any integer less than 9 does not satisfy the condition, either. Thus, the minimum integer i satisfying the condition is 10.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
We all know that Gayle likes dealing only in fours and sixes.Therefore the balls he faced can be represented as a sequence of fours and sixes.

But Gayle likes to hit sixes only in groups of size S (i.e. Once he starts hitting a six, he doesn't stop until he hits exactly S sixes). He may start hitting sixes immediately after ending a group of S sixes. This new group is considered different from previous one.

Abishek was told that Gayle played some number in range [a,b] (a & b included) number of balls. Being a fan of Gayle, Abishek know value of S. He now tries to determine how many ways Gayle would have scored through out his innings. 

Help Abishek in finding out what he requires. As the result can be very large print it modulo 1000000007.
INPUT :
First line contains number of test cases T.
Second line contains the size S.
The next T lines contains pairs of integers a and b.

OUTPUT :
Print T lines, answer for each test case in a new line.

CONSTRAINTS :
1 ≤ T ≤ 1000000
1 ≤ s ≤ 100000
1 ≤ a ≤ b ≤ 100000

Problem Setter : Abishek

SAMPLE INPUT
3
2
1 3
2 3
4 4

SAMPLE OUTPUT
6
5
5

Explanation

S = 2
Case #1 : a = 1, b = 3
Gayle would have played in any of these 6 ways, {4} {4,4} {6,6} {4,4,4} {4,6,6} {6,6,4}
Case #3 : a = 4, b = 4
Gayle faces exactly 4 balls. All possible cases would be {4,4,4,4} {4,4,6,6} {4,6,6,4} {6,6,4,4} {6,6,6,6}

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new control element was delivered to the store recently and Artem immediately bought it.

That element can store information about the matrix of integers size n × m. There are n + m inputs in that element, i.e. each row and each column can get the signal. When signal comes to the input corresponding to some row, this row cyclically shifts to the left, that is the first element of the row becomes last element, second element becomes first and so on. When signal comes to the input corresponding to some column, that column shifts cyclically to the top, that is first element of the column becomes last element, second element becomes first and so on. Rows are numbered with integers from 1 to n from top to bottom, while columns are numbered with integers from 1 to m from left to right.

Artem wants to carefully study this element before using it. For that purpose he is going to set up an experiment consisting of q turns. On each turn he either sends the signal to some input or checks what number is stored at some position of the matrix.

Artem has completed his experiment and has written down the results, but he has lost the chip! Help Artem find any initial matrix that will match the experiment results. It is guaranteed that experiment data is consistent, which means at least one valid matrix exists.


-----Input-----

The first line of the input contains three integers n, m and q (1 ≤ n, m ≤ 100, 1 ≤ q ≤ 10 000) — dimensions of the matrix and the number of turns in the experiment, respectively.

Next q lines contain turns descriptions, one per line. Each description starts with an integer t_{i} (1 ≤ t_{i} ≤ 3) that defines the type of the operation. For the operation of first and second type integer r_{i} (1 ≤ r_{i} ≤ n) or c_{i} (1 ≤ c_{i} ≤ m) follows, while for the operations of the third type three integers r_{i}, c_{i} and x_{i} (1 ≤ r_{i} ≤ n, 1 ≤ c_{i} ≤ m,  - 10^9 ≤ x_{i} ≤ 10^9) are given.

Operation of the first type (t_{i} = 1) means that signal comes to the input corresponding to row r_{i}, that is it will shift cyclically. Operation of the second type (t_{i} = 2) means that column c_{i} will shift cyclically. Finally, operation of the third type means that at this moment of time cell located in the row r_{i} and column c_{i} stores value x_{i}.


-----Output-----

Print the description of any valid initial matrix as n lines containing m integers each. All output integers should not exceed 10^9 by their absolute value.

If there are multiple valid solutions, output any of them.


-----Examples-----
Input
2 2 6
2 1
2 2
3 1 1 1
3 2 2 2
3 1 2 8
3 2 1 8

Output
8 2 
1 8 

Input
3 3 2
1 2
3 2 2 5

Output
0 0 0 
0 0 5 
0 0 0

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.

Kolya remembers that at the beginning of the game his game-coin score was equal to n and that he have bought only some houses (for 1 234 567 game-coins each), cars (for 123 456 game-coins each) and computers (for 1 234 game-coins each).

Kolya is now interested, whether he could have spent all of his initial n game-coins buying only houses, cars and computers or there is a bug in the game. Formally, is there a triple of non-negative integers a, b and c such that a × 1 234 567 + b × 123 456 + c × 1 234 = n?

Please help Kolya answer this question.


-----Input-----

The first line of the input contains a single integer n (1 ≤ n ≤ 10^9) — Kolya's initial game-coin score.


-----Output-----

Print "YES" (without quotes) if it's possible that Kolya spent all of his initial n coins buying only houses, cars and computers. Otherwise print "NO" (without quotes).


-----Examples-----
Input
1359257

Output
YES
Input
17851817

Output
NO


-----Note-----

In the first sample, one of the possible solutions is to buy one house, one car and one computer, spending 1 234 567 + 123 456 + 1234 = 1 359 257 game-coins in total.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
We define an infinite two dimensional array $F$ using the following formula:
 - $F_{0, 0} = 0$,
 - $F_{0, 1} = F_{1, 0} = 1$,
 - For $i \ge 2$, $F_{i, 0} = F_{i-1, 0} + F_{i-2, 0}$,
 - For $i \ge 2$, $F_{0, i} = F_{0, i-1} + F_{0, i-2}$,
 - For $i, j \ge 1$, $F_{i, j} = F_{i-1, j} + F_{i, j-1}$.

Here are the first few values of $F$:

Given $x$ and $y$, your task is to calculate $F_{x, y}$.

-----Input-----
The input consists of only a single line, containing $2$ integers $x$ and $y$ $(0 < x, y < 10^6)$.

-----Output-----
Print a single integer — the value of $F_{x, y}$, modulo $10^9 + 7$.

-----Examples-----
Sample Input:
2 2
Sample Output:
6

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
You will be given two ASCII strings, `a` and `b`. Your task is write a function to determine which one of these strings is "worth" more, and return it.

A string's worth is determined by the sum of its ASCII codepoint indexes. So, for example, the string `HELLO` has a value of 372: H is codepoint 72, E 69, L 76, and O is 79. The sum of these values is 372.

In the event of a tie, you should return the first string, i.e. `a`.

Write Python code to solve the problem. Present the code in 
```python
Your code
```
at the end.
Xenia the mathematician has a sequence consisting of n (n is divisible by 3) positive integers, each of them is at most 7. She wants to split the sequence into groups of three so that for each group of three a, b, c the following conditions held:  a < b < c;  a divides b, b divides c. 

Naturally, Xenia wants each element of the sequence to belong to exactly one group of three. Thus, if the required partition exists, then it has $\frac{n}{3}$ groups of three.

Help Xenia, find the required partition or else say that it doesn't exist.


-----Input-----

The first line contains integer n (3 ≤ n ≤ 99999) — the number of elements in the sequence. The next line contains n positive integers, each of them is at most 7.

It is guaranteed that n is divisible by 3.


-----Output-----

If the required partition exists, print $\frac{n}{3}$ groups of three. Print each group as values of the elements it contains. You should print values in increasing order. Separate the groups and integers in groups by whitespaces. If there are multiple solutions, you can print any of them.

If there is no solution, print -1.


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

Output
-1

Input
6
2 2 1 1 4 6

Output
1 2 4
1 2 6

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