Alexey, a merry Berland entrant, got sick of the gray reality and he zealously wants to go to university. There are a lot of universities nowadays, so Alexey is getting lost in the diversity — he has not yet decided what profession he wants to get. At school, he had bad grades in all subjects, and it's only thanks to wealthy parents that he was able to obtain the graduation certificate.The situation is complicated by the fact that each high education institution has the determined amount of voluntary donations, paid by the new students for admission — ni berubleys. He cannot pay more than ni, because then the difference between the paid amount and ni can be regarded as a bribe!Each rector is wearing the distinctive uniform of his university. Therefore, the uniform's pockets cannot contain coins of denomination more than ri. The rector also does not carry coins of denomination less than li in his pocket — because if everyone pays him with so small coins, they gather a lot of weight and the pocket tears. Therefore, a donation can be paid only by coins of denomination x berubleys, where li ≤ x ≤ ri (Berland uses coins of any positive integer denomination). Alexey can use the coins of different denominations and he can use the coins of the same denomination any number of times. When Alexey was first confronted with such orders, he was puzzled because it turned out that not all universities can accept him! Alexey is very afraid of going into the army (even though he had long wanted to get the green uniform, but his dad says that the army bullies will beat his son and he cannot pay to ensure the boy's safety). So, Alexey wants to know for sure which universities he can enter so that he could quickly choose his alma mater.Thanks to the parents, Alexey is not limited in money and we can assume that he has an unlimited number of coins of each type.In other words, you are given t requests, each of them contains numbers ni, li, ri. For each query you need to answer, whether it is possible to gather the sum of exactly ni berubleys using only coins with an integer denomination from li to ri berubleys. You can use coins of different denominations. Coins of each denomination can be used any number of times.

The first line contains the number of universities t, (1 ≤ t ≤ 1000) Each of the next t lines contain three space-separated integers: ni, li, ri (1 ≤ ni, li, ri ≤ 109; li ≤ ri).

For each query print on a single line: either "Yes", if Alexey can enter the university, or "No" otherwise.

NoteYou can pay the donation to the first university with two coins: one of denomination 2 and one of denomination 3 berubleys. The donation to the second university cannot be paid.

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var caseNum = parseInt(readline());
	for (var caseIndex = 0; caseIndex < caseNum; ++caseIndex) {
		var integers = tokenizeIntegers(readline());
		var target = integers[0], min = integers[1], max = integers[2];

		var coinNum = Math.floor(target/min);
		print(coinNum*max >= target ? "Yes" : "No");
	}
}

main();


You are given three integers $$$a$$$, $$$b$$$ and $$$c$$$.Find two positive integers $$$x$$$ and $$$y$$$ ($$$x > 0$$$, $$$y > 0$$$) such that:   the decimal representation of $$$x$$$ without leading zeroes consists of $$$a$$$ digits;  the decimal representation of $$$y$$$ without leading zeroes consists of $$$b$$$ digits;  the decimal representation of $$$gcd(x, y)$$$ without leading zeroes consists of $$$c$$$ digits. $$$gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$.Output $$$x$$$ and $$$y$$$. If there are multiple answers, output any of them.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 285$$$) — the number of testcases. Each of the next $$$t$$$ lines contains three integers $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b \le 9$$$, $$$1 \le c \le min(a, b)$$$) — the required lengths of the numbers. It can be shown that the answer exists for all testcases under the given constraints. Additional constraint on the input: all testcases are different.

For each testcase print two positive integers — $$$x$$$ and $$$y$$$ ($$$x > 0$$$, $$$y > 0$$$) such that    the decimal representation of $$$x$$$ without leading zeroes consists of $$$a$$$ digits;  the decimal representation of $$$y$$$ without leading zeroes consists of $$$b$$$ digits;  the decimal representation of $$$gcd(x, y)$$$ without leading zeroes consists of $$$c$$$ digits.

/*
| In English По-русски
lukas_rimkus | Logout

HOME
TOP
CONTESTS
GYM
PROBLEMSET
GROUPS
RATING
EDU
API
CALENDAR
HELP

PROBLEMSSUBMIT CODEMY SUBMISSIONSSTATUSHACKSSTANDINGSCUSTOM INVOCATION

My contest submissions

#	When	Who	Problem	Lang	Verdict	Time	Memory
112854886	Apr/12/2021 18:31UTC+2	lukas_rimkus	B - GCD Length	Node.js	Time limit exceeded on test 2	2000 ms	12000 KB
112853780	Apr/12/2021 18:29UTC+2	lukas_rimkus	B - GCD Length	Node.js	Wrong answer on test 1	31 ms	0 KB
112852890	Apr/12/2021 18:27UTC+2	lukas_rimkus	B - GCD Length	Node.js	Wrong answer on test 1	31 ms	0 KB
112851646	Apr/12/2021 18:24UTC+2	lukas_rimkus	B - GCD Length	Node.js	Time limit exceeded on test 1	2000 ms	11800 KB
112851156	Apr/12/2021 18:23UTC+2	lukas_rimkus	B - GCD Length	Node.js	Wrong answer on test 1	46 ms	0 KB
112849514	Apr/12/2021 18:19UTC+2	lukas_rimkus	B - GCD Length	Node.js	Time limit exceeded on test 2	2000 ms	11800 KB
112845911	Apr/12/2021 18:11UTC+2	lukas_rimkus	B - GCD Length	Node.js	Wrong answer on test 1	373 ms	11300 KB
112834898	Apr/12/2021 17:47UTC+2	lukas_rimkus	A - Review Site	Node.js	Accepted	218 ms	6100 KB

Educational Codeforces Round 107 (Rated for Div. 2)
Finished
Practice
Add to favourites

→ Virtual participation
Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - solve these problems in the archive. If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive. Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

→ Practice
You are registered for practice. You can solve problems unofficially. Results can be found in the contest status and in the bottom of standings.

→ Clone Contest to Mashup
You can clone this contest to a mashup.

→ Contest materials
Announcement

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov
The only programming contests Web 2.0 platform
Server time: Apr/12/2021 23:55:11UTC+2 (h2).
Mobile version, switch to desktop version.
Privacy Policy
Supported by
Telegram ИТМО
By lukas_rimkus, contest: Educational Codeforces Round 107 (Rated for Div. 2), problem: (B) GCD Length, Time limit exceeded on test 2, #, Copy
*/
'use-strict'

process.stdin.resume();
process.stdin.setEncoding('utf8');

let data = '';
let currentLine = 0;

process.stdin.on('data', chunk => {
data += chunk;
});

process.stdin.on('end', () =>{
    data = data.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));

    let testCases = parseInt(readLine());

    while(testCases--) {
        const [a,b,c] = readLine().split(' ').map(Number );
        const x = Math.pow(10,a-1) + Math.pow(10,c-1);
        const y = Math.pow(10,b-1);
        console.log(x,y)

    }
})

function readLine(){
    return data[currentLine++]
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------

function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var a = nextInt();
		var b = nextInt();
		var c = nextInt();
		var g = Math.pow(10, c - 1);
		var x = g;
		var y = g;
		while(x < Math.pow(10, a - 1)){
			x *= 3;
		}
		while(y < Math.pow(10, b - 1)){
			y *= 7;
		}
		myout(x + " " + y);
	}
}

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
  let t = parseInt(readline());
  const gcd = (a, b) => (a % b === 0 ? b : gcd(b, a % b));
  while (t--) {
    let [a, b, c] = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    let g = 1,
      f = 1,
      s = 1;
    for (let i = 2; i <= c; i++) g *= 10;
    for (let i = 2; i <= a; i++) f *= 10;
    for (let i = 2; i <= b; i++) s *= 10;
    if (f >= s) s += g;
    else f += g;
    console.log(f + " " + s);
  }
};
solve();

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

function solve(a, b, c) {
  function getPrime(n) {
    next: while (n++) {
      for (let i = 2; i <= n / i; i++) {
        if (n % i === 0) continue next;
      }
      return n;
    }
    return 1;
  }
  let z = getPrime(10 ** (c - 1));
  let x = 1;
  let y = 1;
  if (a === b) {
    x = getPrime(Math.floor(10 ** (a - 1) / z) + 1);
    y = getPrime(x);
  } else {
    x = getPrime(Math.floor(10 ** (a - 1) / z) + 1);
    y = getPrime(Math.floor(10 ** (b - 1) / z) + 1);
  }
  x = BigInt(x) * BigInt(z);
  y = BigInt(y) * BigInt(z);
  return `${x.toString()} ${y.toString()}`;
}

async function main(read) {
  let res = [];
  let t = Number(await read());
  while (t--) {
    const [a, b, c] = (await read()).split(' ').map(Number);
    res.push(solve(a, b, c));
  }
  console.log(res.join('\n'));
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
void async function () {
  const inputs = [];
  let i = 0;
  for await (const line of rl) {
    inputs.push(line.trim());
  }
  function read() {
    return inputs[i++];
  }
  await main(read);
}();

const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
let input = [];
rl.on('line', line => {
    input.push(line);
})
rl.on('close', line => {
    var t = Number(input[0]);
    for (var i = 1; i < input.length; i++) {
        var [a, b, c] = input[i].split(" ").map((i) => {
            return Number(i);
        });
        var num1 = 10 ** (a - 1);
        var num2 = 10 ** (b - 1) + 10 ** (c - 1);
        console.log(num1 + " " + num2);
    }
})

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

function readline() {
  return inputString[currentLine++];
}

var maxN = 2 * 1e5 + 10
var mod = BigInt(1e9 + 7)

// Make a Snippet for the code above this and then write your logic in main();

function main() {
  var j = 0
  var array2 = [
    3, 5, 11,
    13, 101, 103,
    1009, 1013, 10007,
    10009, 100003, 100019,
    1000003, 1000033, 10000019,
    10000079,
    179424673, 179424691
  ]

  const xx = readline();
  Array(Number(xx)).fill(1).map((t, i) => {
    // var n = parseInt(readline());
    // var [n, m] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // })
    var [a, b, c] = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });
    a--
    b--
    var cc = c - 1
    if (cc === 0) {
      console.log(array2[Math.floor(a * 2)], array2[b * 2 + 1])
      return
    }
    a = a - cc
    b = b - cc
    console.log(array2[a * 2] * Math.pow(10, cc), array2[b * 2 + 1] * Math.pow(10, cc))
  })
}

var eratosthenes = function (n) {
  // Eratosthenes algorithm to find all primes under n
  var array = [], upperLimit = Math.sqrt(n), output = [];

  // Make an array from 2 to (n - 1)
  for (var i = 0; i < n; i++) {
    array.push(true);
  }

  // Remove multiples of primes starting from 2, 3, 5,...
  for (var i = 2; i <= upperLimit; i++) {
    if (array[i]) {
      for (var j = i * i; j < n; j += i) {
        array[j] = false;
      }
    }
  }

  // All array[i] set to true are primes
  for (var i = 2; i < n; i++) {
    if (array[i]) {
      output.push(i);
    }
  }

  return output;
};

'use-strict'

process.stdin.resume();
process.stdin.setEncoding('utf8');

let data = '';
let currentLine = 0;

process.stdin.on('data', chunk => {
data += chunk;
});

process.stdin.on('end', () =>{
    data = data.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));

    let testCases = parseInt(readLine());

    while(testCases--) {

        const [a,b,c] = readLine().split(' ').map(Number);

        let xstart = '1';

        for(let i = 1 ; i < a; i++){
            xstart+= '0';
        }
        xstart = parseInt(xstart);
        let xend = '';
        for(let i = 0; i < a; i++){
            xend+= '9';
        }
        xend = parseInt(xend);

        let ystart = '1';
        for(let i = 1; i < b; i++){
            ystart += '0';
        }
        ystart = parseInt(ystart);

        let yend = '';
        for(let i = 0; i < b; i++){
            yend += '9';
        }
        yend = parseInt(yend);

        let cstart = '1';
        for(let i = 1; i < c; i++){
            cstart += '0';
        }
        cstart = parseInt(cstart);

        let cend = '';
        for(let i = 0; i < c; i++){
            cend += '9';
        }
        cend = parseInt(cend);

        let stop = false;
        for(let i = xstart; i <= xend; i++){
            if(Number(i.toString().split('').pop()) === 0) continue;
            for(let j = ystart; j <= yend; j++){
                if(Number(j.toString().split('').pop()) === 0) continue;
                    var ans = gcd(i,j);
                    if(ans.toString().length === c.toString().length && Number(ans.toString().split('').pop() !== 0)){
                        console.log(i,j);
                        stop = true;
                        break;
                    }
            }
            if(stop) break;
        }
    }
});

function get_ints() {
    return data.shift().split(' ').map(Number);
}

function readLine() {
        return data[currentLine++];
}

function gcd(x, y) {
    if ((typeof x !== 'number') || (typeof y !== 'number'))
      return false;
    x = Math.abs(x);
    y = Math.abs(y);
    while(y) {
      var t = y;
      y = x % y;
      x = t;
    }
    return x;
  }

'use-strict'

process.stdin.resume();
process.stdin.setEncoding('utf8');

let data = '';
let currentLine = 0;

process.stdin.on('data', chunk => {
data += chunk;
});

process.stdin.on('end', () =>{
    data = data.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));

    let testCases = parseInt(readLine());

    while(testCases--) {

        const [a,b,c] = readLine().split(' ').map(Number);

        let xstart = '1';

        for(let i = 1 ; i < a; i++){
            xstart+= '0';
        }
        xstart = parseInt(xstart);
        let xend = '';
        for(let i = 0; i < a; i++){
            xend+= '9';
        }
        xend = parseInt(xend);

        let ystart = '1';
        for(let i = 1; i < b; i++){
            ystart += '0';
        }
        ystart = parseInt(ystart);

        let yend = '';
        for(let i = 0; i < b; i++){
            yend += '9';
        }
        yend = parseInt(yend);

        let cstart = '1';
        for(let i = 1; i < c; i++){
            cstart += '0';
        }
        cstart = parseInt(cstart);

        let cend = '';
        for(let i = 0; i < c; i++){
            cend += '9';
        }
        cend = parseInt(cend);

        let stop = false;
        for(let i = xstart; i <= xend; i++){
            if(Number(i.toString().split('').pop()) === 0) continue;
            for(let j = ystart; j <= yend; j++){
                if(Number(j.toString().split('').pop()) === 0) continue;
                    if(gcd(i,j).toString().length === c.toString().length){
                        console.log(i,j);
                        stop = true;
                        break;
                    }
            }
            if(stop) break;
        }
    }
});

function get_ints() {
    return data.shift().split(' ').map(Number);
}

function readLine() {
        return data[currentLine++];
}

function gcd(x, y) {
    if ((typeof x !== 'number') || (typeof y !== 'number'))
      return false;
    x = Math.abs(x);
    y = Math.abs(y);
    while(y) {
      var t = y;
      y = x % y;
      x = t;
    }
    return x;
  }

'use-strict'

process.stdin.resume();
process.stdin.setEncoding('utf8');

let data = '';
let currentLine = 0;

process.stdin.on('data', chunk => {
data += chunk;
});

process.stdin.on('end', () =>{
    data = data.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));

    let testCases = parseInt(readLine());

    while(testCases--) {

        const [a,b,c] = readLine().split(' ').map(Number);

        let xstart = '1';

        for(let i = 1 ; i < a; i++){
            xstart+= '0';
        }
        xstart = parseInt(xstart);
        let xend = '';
        for(let i = 0; i < a; i++){
            xend+= '9';
        }
        xend = parseInt(xend);

        let ystart = '1';
        for(let i = 1; i < b; i++){
            ystart += '0';
        }
        ystart = parseInt(ystart);

        let yend = '';
        for(let i = 0; i < b; i++){
            yend += '9';
        }
        yend = parseInt(yend);

        let cstart = '1';
        for(let i = 1; i < c; i++){
            cstart += '0';
        }
        cstart = parseInt(cstart);

        let cend = '';
        for(let i = 0; i < c; i++){
            cend += '9';
        }
        cend = parseInt(cend);

        let stop = false;
        for(let i = xstart; i <= xend; i++){
            if(Number(i.toString().split('').pop()) === 0) continue;
            for(let j = ystart; j <= yend; j++){
                if(Number(j.toString().split('').pop()) === 0) continue;
                    if(gcd(i,j) === c.toString().length){
                        console.log(i,j);
                        stop = true;
                        break;
                    }

            }
            if(stop) break;
        }
    }
});

function get_ints() {
    return data.shift().split(' ').map(Number);
}

function readLine() {
        return data[currentLine++];
}

function gcd(x, y) {
    if ((typeof x !== 'number') || (typeof y !== 'number'))
      return false;
    x = Math.abs(x);
    y = Math.abs(y);
    while(y) {
      var t = y;
      y = x % y;
      x = t;
    }
    return x;
  }

'use-strict'

process.stdin.resume();
process.stdin.setEncoding('utf8');

let data = '';
let currentLine = 0;

process.stdin.on('data', chunk => {
data += chunk;
});

process.stdin.on('end', () =>{
    data = data.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));

    let testCases = parseInt(readLine());

    while(testCases--) {

        const [a,b,c] = readLine().split(' ').map(Number);

        let xstart = '1';

        for(let i = 1 ; i < a; i++){
            xstart+= '0';
        }
        xstart = parseInt(xstart);
        let xend = '';
        for(let i = 0; i < a; i++){
            xend+= '9';
        }
        xend = parseInt(xend);

        let ystart = '1';
        for(let i = 1; i < b; i++){
            ystart += '0';
        }
        ystart = parseInt(ystart);

        let yend = '';
        for(let i = 0; i < b; i++){
            yend += '9';
        }
        yend = parseInt(yend);
        let stop = false;
        for(let i = xstart; i <= xend; i++){
            if(Number(i.toString().split('').pop()) === 0) continue;
            for(let j = ystart; j <= yend; j++){
                if(Number(j.toString().split('').pop()) === 0) continue;
                if(gcd(i,j) === c){
                    console.log(i,j);
                    stop = true;
                    break;
                }
            }
            if(stop) break;
        }
    }
});

function get_ints() {
    return data.shift().split(' ').map(Number);
}

function readLine() {
        return data[currentLine++];
}

function gcd(x, y) {
    if ((typeof x !== 'number') || (typeof y !== 'number'))
      return false;
    x = Math.abs(x);
    y = Math.abs(y);
    while(y) {
      var t = y;
      y = x % y;
      x = t;
    }
    return x;
  }

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------

function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var a = nextInt();
		var b = nextInt();
		var c = nextInt();
		var g = Math.pow(10, c - 1);
		var x = g;
		var y = g;
		while(x < Math.pow(10, a - 1)){
			x *= 2;
		}
		while(y < Math.pow(10, b - 1)){
			y *= 2;
		}
		myout(x + " " + y);
	}
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------

function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var a = nextInt();
		var b = nextInt();
		var c = nextInt();
		var g = Math.pow(10, c - 1);
		var x = 1;
		var y = 1;
		while(x < Math.pow(10, a - 1)){
			x *= 2;
		}
		while(y < Math.pow(10, b - 1)){
			y *= 2;
		}
		myout(x + " " + y);
	}
}


Slava plays his favorite game "Peace Lightning". Now he is flying a bomber on a very specific map.Formally, map is a checkered field of size 1 × n, the cells of which are numbered from 1 to n, in each cell there can be one or several tanks. Slava doesn't know the number of tanks and their positions, because he flies very high, but he can drop a bomb in any cell. All tanks in this cell will be damaged.If a tank takes damage for the first time, it instantly moves to one of the neighboring cells (a tank in the cell n can only move to the cell n - 1, a tank in the cell 1 can only move to the cell 2). If a tank takes damage for the second time, it's counted as destroyed and never moves again. The tanks move only when they are damaged for the first time, they do not move by themselves.Help Slava to destroy all tanks using as few bombs as possible.

The first line contains a single integer n (2 ≤ n ≤ 100 000) — the size of the map.

In the first line print m — the minimum number of bombs Slava needs to destroy all tanks. In the second line print m integers k1, k2, ..., km. The number ki means that the i-th bomb should be dropped at the cell ki. If there are multiple answers, you can print any of them.

n=+readline()
if (2==9)
{
    print(3)
    print("1 2 1")
}
else
{
    x=[]
    for (i=2;i<=n;i+=2)
    {
        x.push(i)
    }
    for (i=1;i<=n;i+=2)
    {
        x.push(i)
    }
    for (i=2;i<=n;i+=2)
    {
        x.push(i)
    }
    print(x.length)
    print(x.join(' '))
}

n=+readline()
if (2==n)
{
    print(3)
    print("1 2 1")
}
else
{
    x=[]
    for (i=2;i<=n;i++)
    {
        x.push(i)
        x.push(i-1)
    }
    print(x*2-2)
    print(x.join(' '))
}

n=+readline()
if (2==n)
{
    print(3)
    print("1 2 1")
}
else
{
    x=[]
    for (i=2;i<=n;i++)
    {
        x.push(i)
        x.push(i-1)
    }
    print(n*2-2)
    print(x.join(' '))
}


You are given an integer $$$n$$$ ($$$n \ge 0$$$) represented with $$$k$$$ digits in base (radix) $$$b$$$. So,$$$$$$n = a_1 \cdot b^{k-1} + a_2 \cdot b^{k-2} + \ldots a_{k-1} \cdot b + a_k.$$$$$$For example, if $$$b=17, k=3$$$ and $$$a=[11, 15, 7]$$$ then $$$n=11\cdot17^2+15\cdot17+7=3179+255+7=3441$$$.Determine whether $$$n$$$ is even or odd.

The first line contains two integers $$$b$$$ and $$$k$$$ ($$$2\le b\le 100$$$, $$$1\le k\le 10^5$$$) — the base of the number and the number of digits. The second line contains $$$k$$$ integers $$$a_1, a_2, \ldots, a_k$$$ ($$$0\le a_i < b$$$) — the digits of $$$n$$$. The representation of $$$n$$$ contains no unnecessary leading zero. That is, $$$a_1$$$ can be equal to $$$0$$$ only if $$$k = 1$$$.

Print "even" if $$$n$$$ is even, otherwise print "odd". You can print each letter in any case (upper or lower).

NoteIn the first example, $$$n = 3 \cdot 13^2 + 2 \cdot 13 + 7 = 540$$$, which is even.In the second example, $$$n = 123456789$$$ is odd.In the third example, $$$n = 32 \cdot 99^4 + 92 \cdot 99^3 + 85 \cdot 99^2 + 74 \cdot 99 + 4 = 3164015155$$$ is odd.In the fourth example $$$n = 2$$$.

(function() {
    var read = {
        number: function() {
            return +readline();
        },
        arr: function(divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function(divider) {
            return readline()
                .split(divider ? divider : '')
                .map(item => +item);
        }
    }

    var n = read.arrNumber(' ');
    var b = n[0];
    var k = n[1];

    var a = read.arrNumber(' ');

    var res = a[k - 1];
    var last = b;

    for(var i = k - 2; i >= 0; i--) {
        var number = a[i] * last;
        var str = number.toString();
        var y = +(str[str.length - 1]);
        var lastString = (last * b).toString();
        last = +lastString[lastString.length - 1];
        res += number;
    }
    print(res % 2 ? 'odd' : 'even');
}());

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;
let b, k;

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    [b, k] = d.split(' ').map(Number);
    return;
  }

  const arr = d.split(' ').map(Number);
  let odd = arr[arr.length - 1] % 2;

  for (let i = 0; i < arr.length - 1; i++) {
    if ((arr[i] * b) % 2) {
      odd++;
    }
  }

  if (odd % 2) {
    console.log('odd');
  }
  else {
    console.log('even');
  }

  c++;
});

(function() {
    var read = {
        number: function() {
            return +readline();
        },
        arr: function(divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function(divider) {
            return readline()
                .split(divider ? divider : '')
                .map(item => +item);
        }
    }

    var n = read.arrNumber(' ');
    var b = n[0];
    var k = n[1];

    var a = read.arrNumber(' ');

    var res = 0;

    var hh = 0;
    var last = b;
    a.forEach(function(i){
        var str = (i * b).toString();
        var y  = +(str[str.length - 1])
        res += y;
        last = y;
        hh++;
    });

    print(res % 2 ? 'odd' : 'even');
}());


There is an array $$$a$$$ of length $$$n$$$. You may perform the following operation any number of times:  Choose two indices $$$l$$$ and $$$r$$$ where $$$1 \le l < r \le n$$$ and $$$a_l = a_r$$$. Then, set $$$a[l \ldots r] = [a_{l+1}, a_{l+2}, \ldots, a_r, a_l]$$$. You are also given another array $$$b$$$ of length $$$n$$$ which is a permutation of $$$a$$$. Determine whether it is possible to transform array $$$a$$$ into an array $$$b$$$ using the above operation some number of times.

Each test contains multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10 ^ 5$$$)  — the length of array $$$a$$$ and $$$b$$$. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le n$$$)  — elements of the array $$$a$$$. The third line of each test case contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$1 \le b_i \le n$$$)  — elements of the array $$$b$$$. It is guaranteed that $$$b$$$ is a permutation of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10 ^ 5$$$

For each test case, print "YES" (without quotes) if it is possible to transform array $$$a$$$ to $$$b$$$, and "NO" (without quotes) otherwise. You can output "YES" and "NO" in any case (for example, strings "yEs", "yes" and "Yes" will be recognized as a positive response).

NoteIn the first test case, we can choose $$$l=2$$$ and $$$r=5$$$ to form $$$[1, 3, 3, 2, 2]$$$.In the second test case, we can choose $$$l=2$$$ and $$$r=4$$$ to form $$$[1, 4, 2, 2, 1]$$$. Then, we can choose $$$l=1$$$ and $$$r=5$$$ to form $$$[4, 2, 2, 1, 1]$$$.In the third test case, it can be proven that it is not possible to transform array $$$a$$$ to $$$b$$$ using the operation.

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

function solve(n, a, b) {
  const map = new Map();
  for (let i = 0; i < n; i++) {
    if (!map.has(a[i])) map.set(a[i], []);
    map.get(a[i]).push(i);
  }
  const flag = new Array(n).fill(0);
  new Array(n).fill(-1);
  const hasIndex = (i, j) => {
    let arr = map.get(i);
    while (arr.length && arr[arr.length - 1] > j) {
      arr.pop();
    }
    return !!arr.length;
  };
  for (let i = n - 1, j = n - 1; i >= 0; i--) {
    if (b[i] !== b[i + 1]) {
      if (!hasIndex(b[i], j)) {
        console.log('NO');
        return;
      }
      while (flag[j] && b[i] !== a[j]) {
        j--;
      }
      if (b[i] !== a[j]) {
        console.log('NO');
        return;
      }
      if (flag[j]) {
        const k = map.get(b[i]).pop();
        flag[k] = 1;
      }
      j--;
    } else {
      if (!hasIndex(b[i], j)) {
        console.log('NO');
        return;
      }
      const k = map.get(b[i]).pop();
      flag[k] = 1;
    }
  }
  console.log('YES');
}

async function main(read) {
  let t = Number(await read());
  while (t--) {
    const n = Number(await read());
    const a = (await read()).split(' ').map(Number);
    const b = (await read()).split(' ').map(Number);
    solve(n, a, b);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
void async function () {
  const inputs = [];
  let i = 0;
  for await (const line of rl) {
    inputs.push(line.trim());
  }
  function read() {
    return inputs[i++];
  }
  await main(read);
}();

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

function solve(n, a, b) {
  const map = new Map();
  for (let i = 0; i < n; i++) {
    if (!map.has(a[i])) map.set(a[i], []);
    map.get(a[i]).push(i);
  }
  const flag = new Array(n).fill(0);
  new Array(n).fill(-1);
  const hasIndex = (i, j) => {
    let arr = map.get(i);
    while (arr.length && arr[arr.length - 1] > j) {
      arr.pop();
    }
    return !!arr.length;
  };
  for (let i = n - 1, j = n - 1; i >= 0; i--) {
    if (flag[j]) {
      if (!hasIndex(b[i], j - 1)) {
        console.log('NO');
        return;
      }
      while (flag[j] && b[i] !== a[j]) {
        j--;
      }
      if (a[j] !== b[i]) {
        console.log('NO');
        return;
      }
      if (flag[j]) {
        const k = map.get(b[i]).pop();
        flag[k] = 1;
      }
      j--;
    } else {
      if (a[j] !== b[i]) {
        if (!hasIndex(b[i], j - 1) || b[i] !== b[i + 1]) {
          console.log('NO');
          return;
        }
        const k = map.get(b[i]).pop();
        flag[k] = 1;
      } else {
        j--;
      }
    }
  }
  console.log('YES');
}

async function main(read) {
  let t = Number(await read());
  while (t--) {
    const n = Number(await read());
    const a = (await read()).split(' ').map(Number);
    const b = (await read()).split(' ').map(Number);
    solve(n, a, b);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
void async function () {
  const inputs = [];
  let i = 0;
  for await (const line of rl) {
    inputs.push(line.trim());
  }
  function read() {
    return inputs[i++];
  }
  await main(read);
}();

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

function solve(n, a, b) {
  const map = new Map();
  for (let i = 0; i < n; i++) {
    if (!map.has(a[i])) map.set(a[i], []);
    map.get(a[i]).push(i);
  }
  const flag = new Array(n).fill(0);
  new Array(n).fill(-1);
  const hasIndex = (i, j) => {
    let arr = map.get(i);
    while (arr.length && arr[arr.length - 1] > j) {
      arr.pop();
    }
    return !!arr.length;
  };
  for (let i = n - 1, j = n - 1; i >= 0; i--) {
    if (flag[j]) {
      if (!hasIndex(b[i], j - 1)) {
        console.log('NO');
        return;
      }
      while (flag[j] && b[i] !== a[j]) {
        j--;
      }
      if (a[j] !== b[i]) {
        console.log('NO');
        return;
      }
      if (flag[j]) {
        const k = map.get(b[i]).pop();
        flag[k] = 1;
      }
      j--;
    } else {
      if (a[j] !== b[i]) {
        if (!hasIndex(b[i], j - 1) || b[i] !== a[j + 1]) {
          console.log('NO');
          return;
        }
        const k = map.get(b[i]).pop();
        flag[k] = 1;
      } else {
        j--;
      }
    }
  }
  console.log('YES');
}

async function main(read) {
  let t = Number(await read());
  while (t--) {
    const n = Number(await read());
    const a = (await read()).split(' ').map(Number);
    const b = (await read()).split(' ').map(Number);
    solve(n, a, b);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
void async function () {
  const inputs = [];
  let i = 0;
  for await (const line of rl) {
    inputs.push(line.trim());
  }
  function read() {
    return inputs[i++];
  }
  await main(read);
}();


You are given an array $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ distinct integers. Count the number of pairs of indices $$$(i, j)$$$ such that $$$i < j$$$ and $$$a_i \cdot a_j = i + j$$$.

The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^5$$$) — the length of array $$$a$$$. The second line of each test case contains $$$n$$$ space separated integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq 2 \cdot n$$$) — the array $$$a$$$. It is guaranteed that all elements are distinct. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case, output the number of pairs of indices $$$(i, j)$$$ such that $$$i < j$$$ and $$$a_i \cdot a_j = i + j$$$.

NoteFor the first test case, the only pair that satisfies the constraints is $$$(1, 2)$$$, as $$$a_1 \cdot a_2 = 1 + 2 = 3$$$For the second test case, the only pair that satisfies the constraints is $$$(2, 3)$$$.For the third test case, the pairs that satisfy the constraints are $$$(1, 2)$$$, $$$(1, 5)$$$, and $$$(2, 3)$$$.

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let n = parseInt(readline());
    let arr = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    let bool = [];
    let k = Math.ceil(Math.sqrt(n + n - 1));
    for (let i = 0; i < n; i++) {
      if (arr[i] <= k) bool[i] = true;
      else bool[i] = false;
    }
    let cnt = 0,
      obj = {};
    for (let i = 0; i < n; i++) {
      if (bool[i]) {
        for (let j = 0; j < n; j++) {
          if (i === j) continue;
          let k = i + 1 + (j + 1);
          if (k === arr[i] * arr[j]) {
            let s1 = `${i + 1} ${j + 1}`;
            let s2 = `${j + 1} ${i + 1}`;
            if (!obj[s1] && !obj[s2]) cnt++;
            obj[s1] = 1;
            obj[s2] = 1;
          }
        }
      }
    }
    console.log(cnt);
  }
};
solve();

"use strict";

//                                  import for reading input                                  //
process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}
//                                                                                //
function main() {
  var t = +(readline());
  while (t--) {
    solution();
  }
}

function solution() {
  const n = +(readline());
  const arr = readline().split(' ').map((item) => +item);

  let counter = 0;
  for (let i = 0; i < n-1; i++) {
    let r = (i+1)%arr[i];
    let firstJ = (arr[i] - r > r) ? (i+1-2*r+arr[i]) : (i+1+2*(arr[i]-r));
    for (let j = firstJ-1; j < n; j += arr[i]) {
      if (arr[i]*arr[j] === i+j+2) counter++;
    }
  }
  console.log(counter);
}

const stdin = process.openStdin();
let content = '';

stdin.addListener('data', (data) => {
          content += data;
})

stdin.addListener('end', () => {
          content = content.split('\n');
          content.shift();
          content = content.map((string) => string.substring(0, string.length - 1));
          content.pop();
          content.forEach((str, i) => {
                    if (i % 2 === 1) {
                              str = str.split(' ').map(str => parseInt(str));
                              console.log(pleasantPairs(str));
                    }
          });
})

const pleasantPairs = (arr) => {
          let pairCount = 0;
          for (let i = 0; i < arr.length - 1; i++) {
                    let multiple = 1;
                    let j = (arr[i] * multiple) - (i + 1) - 1;
                    while (j < arr.length) {
                              if ((arr[j] * arr[i]) === (i + j + 2) && i < j) {
                                        pairCount++;
                              }
                              multiple++;
                              j = (arr[i] * multiple) - (i + 1) - 1;
                    }
          }
          return pairCount;
}

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var t = +lines[0]
    var l = 1;
    for (var i = 0; i < t; i++) {
        var n = +lines[l++]
        var arr = lines[l++].split(' ').map(Number)
        console.log(solve(n, arr));
    }
});

function solve(n, arr) {
    let count = 0
    arr.forEach((a, i) => {
        i++
        const limit = Math.floor(2 * n / a)
        for (let j = 1; j <= limit; j++) {
            const p = a * j - i - 1
            if (p > i - 1 && arr[p] === j) count++
        }
    })
    return count
}

var dataitr;
var stdin_input = "";
process.stdin.resume();
process.stdin.setEncoding("ascii");
process.stdin.on("data", function (input) { stdin_input += input; });
process.stdin.on("end", function () { dataitr = stdin_input.split('\n').values(); main(); });

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

function main () {
	let T = rn();
	while (T--) {
		const n = rn();
		const a = rna();
		a.unshift(0);

		let ans = 0;
		for (let i = 1; i <= n; i++) {
			const start = Math.ceil((2*i+1)/a[i])*a[i] - i;
			for(j = start; j <= n; j += a[i]) {
				ans += a[i] * a[j] == i + j;
			}
		}

		console.log(ans);
	}
}

const lib = require('readline');
const rl = lib.createInterface({
    input: process.stdin,
    output: process.stdout
});

const getLine = (function () {
    const getLineGen = (async function* () {
        for await (const line of rl) {
            yield line;
        }
    })();
    return async () => {
        let next;
        do {
            next = (await getLineGen.next());
        } while (!next.done && next.value === '');
        return next.value;
    };
})();

let solve = async () => {
    let nsc = parseInt(await getLine());
    for(let sc = 0; sc < nsc; sc++) {
        const n = parseInt(await getLine());
        const a = (await getLine()).split(' ').map(num => parseInt(num));
        let count = 0;
        for(let i = 0; i < n; i++) {
            let rem = (i + 1) % a[i];
            let need = (a[i] - rem) % a[i];
            let delta = (a[i] + need - rem) % a[i];
            for(let j = 0; i + 1 + delta + a[i] * j <= n; j++) {
                let ind2 = i + 1 + delta + a[i] * j;
                if (ind2 == i + 1)
                    continue;
                if (a[i] * a[ind2-1] === i + 1 + ind2)
                    count++;
            }
        }
        console.log(count);
    }
}

solve();

var t = +readline();
for (var tt = 0; tt < t; tt += 1) {
  var n = +readline();
  var arr = readline()
    .split(" ")
    .map((num) => {
      return +num;
    });
  arr.unshift(0);
  var find = [];
  for (var k = 1; k <= n; k += 1) {
    var numToFind = 1;
    while (true) {
      var indexToFind = Math.abs(arr[k] * numToFind - k);
      if (indexToFind <= n) {
        if (indexToFind > k) find.push([numToFind, indexToFind]);
      } else {
        break;
      }
      numToFind += 1;
    }
  }
  var ans = 0;
  find.forEach((value) => {
    if (arr[value[1]] === value[0]) ans += 1;
  });
  print(ans);
}

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let n = parseInt(readline());
    let arr = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    let bool = [];
    let k = Math.ceil(Math.sqrt(n + n - 1));
    for (let i = 0; i < n; i++) {
      if (arr[i] <= k) bool[i] = true;
      else bool[i] = false;
    }
    let cnt = 0,
      obj = {};
    for (let i = 0; i < n; i++) {
      if (bool[i]) {
        for (let j = 0; j < n; j++) {
          let k = i + 1 + (j + 1);
          if (k === arr[i] * arr[j]) {
            let s1 = `${i + 1} ${j + 1}`;
            let s2 = `${j + 1} ${i + 1}`;
            if (!obj[s1] && !obj[s2]) cnt++;
            obj[s1] = 1;
            obj[s2] = 1;
          }
        }
      }
    }
    console.log(cnt);
  }
};
solve();

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let n = parseInt(readline());
    let arr = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    let bool = [];
    let k = Math.ceil(Math.sqrt(n));
    for (let i = 0; i < n; i++) {
      if (arr[i] <= k) bool[i] = true;
      else bool[i] = false;
    }
    let cnt = 0,
      obj = {};
    for (let i = 0; i < n; i++) {
      if (bool[i]) {
        for (let j = 0; j < n; j++) {
          let k = i + 1 + (j + 1);
          if (k === arr[i] * arr[j]) {
            let s1 = `${i + 1} ${j + 1}`;
            let s2 = `${j + 1} ${i + 1}`;
            if (!obj[s1] && !obj[s2]) cnt++;
            obj[s1] = 1;
            obj[s2] = 1;
          }
        }
      }
    }
    console.log(cnt);
  }
};
solve();

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let n = parseInt(readline());
    let arr = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    let bool = [];
    let k = Math.ceil(Math.sqrt(n));
    for (let i = 0; i < n; i++) {
      if (arr[i] <= k) bool[i] = true;
      else bool[i] = false;
    }
    let cnt = 0,
      obj = {};
    for (let i = 0; i < n; i++) {
      if (bool[i]) {
        for (let j = 0; j < n; j++) {
          let k = i + 1 + (j + 1);
          if (k === arr[i] * arr[j]) {
            if (!obj[i + j + 2]) cnt++;
            obj[i + j + 2] = 1;
          }
        }
      }
    }
    console.log(cnt);
  }
};
solve();

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let n = parseInt(readline());
    let arr = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    let bool = [];
    let k = Math.floor(Math.sqrt(n));
    for (let i = 0; i < n; i++) {
      if (arr[i] <= k) bool[i] = true;
      else bool[i] = false;
    }
    let cnt = 0;
    for (let i = 0; i < n; i++) {
      if (bool[i]) {
        for (let j = 0; j < n; j++) {
          let k = i + 1 + (j + 1);
          if (k === arr[i] * arr[j]) cnt++;
        }
      }
    }
    console.log(cnt);
  }
};
solve();

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var t = +lines[0]
    var l = 1;
    for (var i = 0; i < t; i++) {
        var n = +lines[l++]
        var arr = lines[l++].split(' ').map(Number)
        console.log(solve(n, arr));
    }
});

function solve(n, arr) {
    let count = 0
    arr.forEach((a, i) => {
        i++
        const limit = Math.floor(2 * n / a)
        for (let j = 1; j <= limit; j++) {
            if (arr[a * j - i - 1] === j) count++
        }
    })
    return count / 2
}


You have been blessed as a child of Omkar. To express your gratitude, please solve this problem for Omkar!An array $$$a$$$ of length $$$n$$$ is called complete if all elements are positive and don't exceed $$$1000$$$, and for all indices $$$x$$$,$$$y$$$,$$$z$$$ ($$$1 \leq x,y,z \leq n$$$), $$$a_{x}+a_{y} \neq a_{z}$$$ (not necessarily distinct).You are given one integer $$$n$$$. Please find any complete array of length $$$n$$$. It is guaranteed that under given constraints such array exists.

Each test contains multiple test cases. The first line contains $$$t$$$ ($$$1 \le t \le 1000$$$)  — the number of test cases. Description of the test cases follows. The only line of each test case contains one integer $$$n$$$ ($$$1 \leq n \leq 1000$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$1000$$$.

For each test case, print a complete array on a single line. All elements have to be integers between $$$1$$$ and $$$1000$$$ and for all indices $$$x$$$,$$$y$$$,$$$z$$$ ($$$1 \leq x,y,z \leq n$$$) (not necessarily distinct), $$$a_{x}+a_{y} \neq a_{z}$$$ must hold. If multiple solutions exist, you may print any.

NoteIt can be shown that the outputs above are valid for each test case. For example, $$$44+44 \neq 384$$$.Below are some examples of arrays that are NOT complete for the 1st test case:$$$[1,2,3,4,5]$$$ Notice that $$$a_{1}+a_{2} = a_{3}$$$.$$$[1,3000,1,300,1]$$$ Notice that $$$a_{2} = 3000 > 1000$$$.

var n = readline();
var b=n;
var res = [];
while (n--){
    res.push(Array(parseInt(readline())).fill(1))
}
for(var i =0;i<b;i++){
    write(res[i].join(" ") + "\n")
}

function solve() {
   var n = Number(read());
   var ans = '';
   for (var  i = 0; i < n; i++) {
      ans += '1 ';
   }
   write(ans);
}

function init() {
   var T;
   T = 1;
   T = Number(read());
   for (var t = 0; t < T; t++) {
      solve();
   }
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
      });
   } else {
      var RL = require('readline').createInterface({
         input : process.stdin,
         output : process.stdout
      });

      RL.on('line', (line) => {
         MEMORY.push(line);
      });

      RL.on('close', init);
   }
} else {
   init();
}

function write(value) {
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  let t = +readLine();
  while (t--) {
    const len = +readLine();
    const result = Array(len).fill(1).join(" ");
    console.log(result);
  }
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw "ArrayIndexOutOfBoundsException ‚There is no more input";}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var t = nextInt();
  var output = new Array(t);
  for(var i = 0; i < t; i++){
    var N = nextInt();
    var list = new Array(N).fill(1);
    output[i] = myconv(list, 8);
  }
  myout(myconv(output, 9));
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let stdinInput = '';

process.stdin.on('data', input => {
  stdinInput += input;
});

process.stdin.on('end', () => {
  main(stdinInput);
});

function main(data) {
	data = data.split('\n');
	const testCases = data[0] * 1;
	let i = 1;
	while (i <= testCases) {
	  let n = data[i] * 1;
	  let arr = Array(n).fill(1);
	  arr = arr.join(' ');
	  console.log(arr);
	  i += 1;
	}
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function readint() {
    let line = readline().split(' ').map(function(num) {
        return parseInt(num);
    });
    return line;
}

function readfloat() {
    let line = readline().split(' ').map(function(num) {
        return parseFloat(num);
    });
    return line;
}

function print(x) {
    console.log(x);
}

function write(x) {
    process.stdout.write(x);
}
function main() {
    let t = parseInt(readline());
    //go go bro!!!
    while(t--) {
        let n = readint();
        while(n--) {
            write(1 + " ");
        }
        write("\n");
    }

}

// node template.js < A-small.in > A-small.out

function main() {
    var tests = 1;
    tests = nextInt();

    for (let t = 1; t <= tests; t++) {
        let N = nextInt();

        for(let i = 0; i < N; i++) {
            process.stdout.write(N + " ");
        }
        print("");
    }
}

// ------- Template ------------------
function newTensor(dimensions, value) {
    let res = [];
    let dim = dimensions[0], subdim = dimensions.slice(1);
    if (subdim.length == 0) {
        for(let i = 0; i < dim; i++) {
            res.push(value);
        }
    } else {
        for(let i = 0; i < dim; i++) {
            res.push(newTensor(subdim, value));
        }
    }
    return res;
}

if (!String.prototype.startsWith) {
    Object.defineProperty(String.prototype, 'startsWith', {
        value: function(search, rawPos) {
            var pos = rawPos > 0 ? rawPos|0 : 0;
            return this.substring(pos, pos + search.length) === search;
        }
    });
}
if (!String.prototype.endsWith) {
    String.prototype.endsWith = function(search, this_len) {
        if (this_len === undefined || this_len > this.length) {
            this_len = this.length;
        }
        return this.substring(this_len - search.length, this_len) === search;
    };
}

var curTokens = [], curToken = 0;

function next() {
    while (curToken >= curTokens.length) {
        curTokens = readline().split(/[\s]+/);
        curToken = 0;
    }
    return curTokens[curToken++];
}

function nextInt() {
    return parseInt(next());
}

// code for nodejs
var inputBuffer = '', curLine = 0;

function readline() {
    return inputBuffer[curLine++];
}

function print(data) {
    process.stdout.write(data + '\n');
}

process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', function (chunk) {
    inputBuffer += chunk;
});

process.stdin.on('end', function () {
    inputBuffer = inputBuffer.split(/[\s]+/);
    main();
});

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    A();
});

function readline() {
    return inputString[currentLine++];
}

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function A(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let n = pi(readline());
        let ans = '';
        for(let i = 0; i < n; i++){
            ans += '1 ';
        }
        console.log(ans);
    }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
/**
4
3
1 2 3
4
3 1 2 4
3
2 3 1
6
2 4 6 1 3 5

**/

function gcd(a, b) {
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
};

function main() {
    let n = Number(readline());

    for(let r=0;r<n;r++) {
        solve();
    }

}

function solve() {
    let n = Number(readline())

    let min = 1;
    let max = 1000;

    let a = [];

        while(a.length < n / 2) {
            a.push(384);
        }

        while(a.length >= n / 2 && a.length < n) {
            a.push(44);
        }

    console.log(a.join(" "));
}

var n = readline();
var b=n;
var res = [];
while (n--){
    res.push(Array(parseInt(readline())).fill(1))
}
for(var i =0;i<b;i++){
    write(res[i].join(" "))
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw "ArrayIndexOutOfBoundsException ‚There is no more input";}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var t = nextInt();
  var output = new Array(t);
  for(var i = 0; i < t; i++){
    var N = nextInt();
    var list = [];
    for(var j = 0; j < N; j++){
      list.push(j * 2 + 1);
    }
    output[i] = myconv(list, 8);
  }
  myout(myconv(output, 9));
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function readint() {
    let line = readline().split(' ').map(function(num) {
        return parseInt(num);
    });
    return line;
}

function readfloat() {
    let line = readline().split(' ').map(function(num) {
        return parseFloat(num);
    });
    return line;
}

function print(x) {
    console.log(x);
}

function write(x) {
    process.stdout.write(x);
}
function main() {
    let t = parseInt(readline());
    //go go bro!!!
    while(t--) {
        let n = readint();
        while(n--) {
            write(1 + " ");
        }
        print('\n');
    }

}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    A();
});

function readline() {
    return inputString[currentLine++];
}

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function A(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let n = pi(readline());
        let res = [];
        res.push(1);
        res.push(3);
        let last = 1+2;
        for(let i = 2; i < n; i++){
            res.push(res[res.length-1]+res[res.length-2]+1);
        }

        let ans = '';
        for(let i of res)
            ans += `${i} `;
        console.log(ans);
    }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    A();
});

function readline() {
    return inputString[currentLine++];
}

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function A(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let n = pi(readline());
        let res = [];
        res.push(1);
        res.push(2);
        let last = 1+2;
        for(let i = 2; i < n; i++){
            res.push(res[res.length-1]+res[res.length-2]+1);
        }

        for(let i of res)
            console.log(i);
    }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    A();
});

function readline() {
    return inputString[currentLine++];
}

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function A(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let n = pi(readline());
        let res = [];
        res.push(1);
        res.push(2);
        let last = 1+2;
        for(let i = 2; i < n; i++){
            res.push(res[res.length-1]+res[res.length-2]+1);
        }

        let ans = '';
        for(let i of res)
            ans += `${i} `;
        console.log(ans);
    }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
/**
4
3
1 2 3
4
3 1 2 4
3
2 3 1
6
2 4 6 1 3 5

**/

function gcd(a, b) {
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
};

function main() {
    let n = Number(readline());

    for(let r=0;r<n;r++) {
        solve();
    }

}

function solve() {
    let n = Number(readline())

    let min = 1;
    let max = 1000;

    let a = [];
    while(a.length < n) {
        if(min !== max) {
            a.push(min);
            if(a.length !== n) {
                a.push(max);
            }

            min++;
            max--;
        }

    }

    console.log(a.join(" "));
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
/**
4
3
1 2 3
4
3 1 2 4
3
2 3 1
6
2 4 6 1 3 5

**/

function gcd(a, b) {
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
};

function main() {
    let n = Number(readline());

    for(let r=0;r<n;r++) {
        solve();
    }

}

function solve() {
    let n = Number(readline())

    let min = 1;
    let max = 1000;

    let a = [];
    while(a.length < n) {
        if(min !== max) {
            a.push(min);
            a.push(max);

            min++;
            max--;
        }

    }

    console.log(a.join(" "));
}


The Little Elephant has got a problem — somebody has been touching his sorted by non-decreasing array a of length n and possibly swapped some elements of the array.The Little Elephant doesn't want to call the police until he understands if he could have accidentally changed the array himself. He thinks that he could have accidentally changed array a, only if array a can be sorted in no more than one operation of swapping elements (not necessarily adjacent). That is, the Little Elephant could have accidentally swapped some two elements.Help the Little Elephant, determine if he could have accidentally changed the array a, sorted by non-decreasing, himself.

The first line contains a single integer n (2 ≤ n ≤ 105) — the size of array a. The next line contains n positive integers, separated by single spaces and not exceeding 109, — array a. Note that the elements of the array are not necessarily distinct numbers.

In a single line print "YES" (without the quotes) if the Little Elephant could have accidentally changed the array himself, and "NO" (without the quotes) otherwise.

NoteIn the first sample the array has already been sorted, so to sort it, we need 0 swap operations, that is not more than 1. Thus, the answer is "YES".In the second sample we can sort the array if we swap elements 1 and 3, so we need 1 swap operation to sort the array. Thus, the answer is "YES".In the third sample we can't sort the array in more than one swap operation, so the answer is "NO".

;(function () {
	print(function (n) {
		var a = readline().split(' ').map(Number),
			b = a.map(function (e) { return e; }).sort(function (a, b) { return a - b; }),
			t = 0;

		a.forEach(function (e, i) {
			t += Number(e !== b[i]);
		});

		switch (t) {
			case 0:
			case 2:
				return 'YES';
			default:
				return 'NO';
		}
	}(+readline()));
}).call(this);

;(function () {
	print(function (n) {
		var a = readline().split(' ').map(Number),
			b = a.sort(function (a, b) { return a - b; }),
			t = 0;

		a.forEach(function (e, i) {
			t += Number(e !== b[i]);
		});

		switch (t) {
			case 0:
			case 2:
				return 'YES';
			default:
				return 'NO';
		}
	}(+readline()));
}).call(this);


Pig is visiting a friend.Pig's house is located at point 0, and his friend's house is located at point m on an axis.Pig can use teleports to move along the axis.To use a teleport, Pig should come to a certain point (where the teleport is located) and choose where to move: for each teleport there is the rightmost point it can move Pig to, this point is known as the limit of the teleport.Formally, a teleport located at point x with limit y can move Pig from point x to any point within the segment [x; y], including the bounds.  Determine if Pig can visit the friend using teleports only, or he should use his car.

The first line contains two integers n and m (1 ≤ n ≤ 100, 1 ≤ m ≤ 100) — the number of teleports and the location of the friend's house. The next n lines contain information about teleports. The i-th of these lines contains two integers ai and bi (0 ≤ ai ≤ bi ≤ m), where ai is the location of the i-th teleport, and bi is its limit. It is guaranteed that ai ≥ ai - 1 for every i (2 ≤ i ≤ n).

Print "YES" if there is a path from Pig's house to his friend's house that uses only teleports, and "NO" otherwise. You can print each letter in arbitrary case (upper or lower).

NoteThe first example is shown on the picture below:  Pig can use the first teleport from his house (point 0) to reach point 2, then using the second teleport go from point 2 to point 3, then using the third teleport go from point 3 to point 5, where his friend lives.The second example is shown on the picture below:  You can see that there is no path from Pig's house to his friend's house that uses only teleports.

// write by lpy in 2017/12/21
//title is Visting a Friend
/*
	the input of this argument
*/
var arr = readline().split(" ");
var n = Number(arr[0]);
var m = Number(arr[1]);

function input_str(n){
	// var array = [[0,2],[2,4],[3,5]];
	var array = new Array();
	for(var i = 0; i < n;i++){
		array[i] = new Array();
		var str = readline().split(" ");
		array[i][0] = Number(str[0]);
		array[i][1] = Number(str[1]);
	}
	return array;
}

function f(n,m){// n is the number of input, m is the friend's house
	var array = input_str(n);
	var left = array[0][0],right = array[0][1];
	// console.log(left, right);
	var result = true;
	for(var i = 1; i < n; i++){
		var a1 = left, b1 = right;
		// console.log(a1, b1);
		var a2 = array[i][0], b2 = array[i][1];
		if(a1 <= a2){
			left = a1;
			if(a2 <= b1){
				if(b1 <= b2){
					right = b2;
				}
				else right = b1;
			}
			else{
				result = false;
			}
		}
		else {
			left = a2;
			if(a1 <= b2){
				if(b1 <= b2){
					right = b2;
				}
				else right = b1;
			}
			else result = false;
		}
	}
	var ans;
	if(result===true){
		if(left === 0 && right === m)
			ans = 'YES';
		else ans = 'NO';
	}
	else ans = 'NO';
	return ans;
}
print(f(n, m));
// console.log(f(2,1));

var arr = readline().split(' ').map(Number);
var n = arr[0];
var m = arr[1];
arr = [];
var cursor = 0;
for (var i = 0; i < n; i++) {
	var temp = readline().split(' ').map(Number);
	var left = temp[0];
	var right = temp[1];

	if (left > cursor) {
		break;
	}
	if (right > cursor) {
		cursor = right;
	}
}

if (cursor >= m) {
	print('YES');
} else {
	print('NO');
}

var read = readline().split(" ").map(Number);
var loop = read[0];
var limit = read[1];
var reject = false;
var found = false;
var lst = 0;
function getPt( loop, limit ){
		 while( loop ){
			    loop--;
				var arr = readline().split(" ").map(Number);
				var x = arr[0];var y = arr[1];
				if ( x > lst ){
					   reject = true;
					   break;
				}
				if ( y > lst ){
					   lst = y;
					   if( lst == limit ){
							   found = true;
							   break;
						}
			    }

		 }

		 if(reject)
				write("NO\n");
		 if(found)
				write("YES\n");
		 if(!reject && !found)
				write( lst == limit ? "YES" : "NO");
}

getPt( loop, limit);

// FUCK IT I FORGOT, VALUES IN ARRAY SHOULD
// BE PARSEINT SO THAT I USED .map(Number);
var read = readline().split(" ").map(Number);
var loop = read[0];
var limit = read[1];
var reject = false;
var found = false;
var lst = 0;
getPt( loop, limit);
function getPt( loop, limit ){
				 while( loop ){
					 			loop--;
								var arr = readline().split(" ").map(Number);
								var x = arr[0];var y = arr[1];
								if ( x > lst ){
											 reject = true;
											 break;
								}
								if ( y > lst ){
											 lst = y;
											 if( lst == limit ){
												 			 found = true;
															 break;
											 }
								}

				 }
				 if(reject)
				 			 write("NO\n");
				 if(found)
				 			 write("YES\n");
				 if(!reject && !found){
					 		 write( lst == limit ? "YES" : "NO");
				 }
}

var x=readline().split(' ')
n=Number(x[0])
m=Number(x[1])
A=[]
B=[]
for (var i=0;i<n; ++i) {
	x=readline().split(' ')
	A.push(Number(x[0]))
	B.push(Number(x[1]))
}

T=[]
for (var i=0; i<n; ++i) {
	for (var j=A[i]; j<B[i]; ++j) {
		T[j] = true;
	}
}

R=true
for (var i=0;i<m;++i) R = R && T[i]
print(R?'YES':'NO')

var line = readline().split(' ');
var N = parseInt(line[0]);
var M = parseInt(line[1]);
var a = [], b=[];

for(var i = 0; i < N; i++) {
	var line = readline().split(' ');
	a[i] = parseInt(line[0]);
	b[i] = parseInt(line[1]);
}

var left = 0;

for(var i=0;i<N;i++){
	if(a[i]<=left && b[i] >left ){
		left = b[i];
	}
}

if(M <= left){
	print("YES");
}else{
	print("NO");
}

one=readline();
n=parseInt(one.split(' ')[0]);
m=parseInt(one.split(' ')[1]);
mas=[];
function compareNumeric(x, y) {
  if (x.a > y.a) return 1;
  if (x.a < y.a) return -1;
  if (x.a === y.a) {
    if (x.b > y.b) return 1;
    if (x.b < y.b) return -1;
  }
}
for(i=0;i<n;i++) {
    one=readline();
    mas[i]={};
    mas[i].a = parseInt(one.split(' ')[0]);
    mas[i].b = parseInt(one.split(' ')[1]);
}
mas.sort(compareNumeric);
max=0;
f=false;
for(i=0;i<n;i++) {
    if(mas[i].a <= max) {
       if(mas[i].b > max) {
           max = mas[i].b;
           if (max >= m) {
               f = true;
               break;
           }
       }
    } else {
       break;
    }
}
if (f) {print('YES');} else {print('NO');}

// write by lpy in 2017/12/21
//title is Visting a Friend
/*
	the input of this argument
*/
var arr = readline().split(" ");
var n = arr[0];
var m = arr[1];

//var array = [[0,4],[2,6],[6,7]];

function f(n,m){// n is the number of input, m is the friend's house

	//the [left,right]is existing range
	var str = readline().split(" ");
	var left = str[0], right = str[1];
	var result = 'YES';
	for(var i = 1; i < n; i++){
		var array = readline().split(" ");
		var a1 = left, b1 = right;
		// var a2 = array[i][0], b2 = array[i][1];
		var a2 = array[0],b2 = array[1];
		if(a1 <= a2){
			left = a1;
			if(a2 <= b1){
				if(b1 <= b2){
					right = b2;
				}
				else right = b1;
			}
			else{
				result = 'NO';
			}
		}
		else {
			left = a2;
			if(a1 <= b2){
				if(b1 <= b2){
					right = b2;
				}
				else right = b1;
			}
			else result = 'NO';
		}
	}
	return result;
}
print(f(n, m));
// console.log(f(3,5));

// write by lpy in 2017/12/21
//title is Visting a Friend
/*
	the input of this argument
*/
var arr = readline().split(" ");
var n = arr[0];
var m = arr[1];

// var array = [[1,1],[0,0]];

function f(n,m){// n is the number of input, m is the friend's house

	//the [left,right]is existing range
	var str = readline().split(" ");
	var left = str[0], right = str[1];
	// var left = array[0][0],right = array[0][1];
	// console.log(left, right);
	var result = true;
	for(var i = 1; i < n; i++){
		var array = readline().split(" ");
		var a1 = left, b1 = right;
		// console.log(a1, b1);
		// var a2 = array[i][0], b2 = array[i][1];
		// console.log(a2, b2);
		var a2 = array[0],b2 = array[1];
		if(a1 <= a2){
			left = a1;
			if(a2 <= b1){
				if(b1 <= b2){
					right = b2;
				}
				else right = b1;
			}
			else{
				result = false;
			}
		}
		else {
			left = a2;
			if(a1 <= b2){
				if(b1 <= b2){
					right = b2;
				}
				else right = b1;
			}
			else result = false;
		}
	}
	var ans;
	if(result){
		if(left === 0 && right === m)
			ans = 'YES';
		else ans = 'NO';
	}
	else ans = 'NO';
	return ans;
}
print(f(n, m));
// console.log(f(2,1));

// write by lpy in 2017/12/21
//title is Visting a Friend
/*
	the input of this argument
*/
var arr = readline().split(" ");
var n = arr[0];
var m = arr[1];

// var array = [[1,1],[0,0]];

function f(n,m){// n is the number of input, m is the friend's house

	//the [left,right]is existing range
	var str = readline().split(" ");
	var left = str[0], right = str[1];
	// var left = array[0][0],right = array[0][1];
	// console.log(left, right);
	var result = true;
	for(var i = 1; i < n; i++){
		var array = readline().split(" ");
		var a1 = left, b1 = right;
		// console.log(a1, b1);
		// var a2 = array[i][0], b2 = array[i][1];
		// console.log(a2, b2);
		var a2 = array[0],b2 = array[1];
		if(a1 <= a2){
			left = a1;
			if(a2 <= b1){
				if(b1 <= b2){
					right = b2;
				}
				else right = b1;
			}
			else{
				result = false;
			}
		}
		else {
			left = a2;
			if(a1 <= b2){
				if(b1 <= b2){
					right = b2;
				}
				else right = b1;
			}
			else result = false;
		}
	}
	var ans;
	if(result===true){
		if(left === 0 && right === m)
			ans = 'YES';
		else ans = 'NO';
	}
	else ans = 'NO';
	return ans;
}
print(f(n, m));
// console.log(f(2,1));

// write by lpy in 2017/12/21
//title is Visting a Friend
/*
	the input of this argument
*/
var arr = readline().split(" ");
var n = arr[0];
var m = arr[1];

//var array = [[0,4],[2,6],[6,7]];

function f(n,m){// n is the number of input, m is the friend's house
	var left = 0, right = 0;
	//the [left,right]is existing range
	var result = 'YES';
	for(var i = 0; i < n; i++){
		var array = readline().split(" ");
		var a1 = left, b1 = right;
		// var a2 = array[i][0], b2 = array[i][1];
		var a2 = array[0],b2 = array[1];
		if(a1 <= a2){
			left = a1;
			if(a2 <= b1){
				if(b1 <= b2){
					right = b2;
				}
				else right = b1;
			}
			else{
				result = 'NO';
			}
		}
		else {
			left = a2;
			if(a1 <= b2){
				if(b1 <= b2){
					right = b2;
				}
				else right = b1;
			}
			else result = 'NO';
		}
	}
	return result;
}
print(f(n, m));
// console.log(f(3,5));

var read = +readline().split(" ");
var loop = read[0];
var limit = read[1];
var reject = false;
var lst = 0;
function getPt( loop, limit ){
				 while( loop ){
					 	loop--;
						var arr = +readline().split(" ");
						x = arr[0],y = arr[1];
						if ( x > lst ){
	    					   reject = true;
						   	   break;
						}
						if ( y > lst )
							   lst = y;
				 }
				 if(reject)
				 	    write("NO\n");

				 return lst;
}

write(getPt(loop, limit));

var read = +readline().split(" ");
var loop = read[0];
var limit = read[1];
var lst = 0;
function getPt( loop, limit ){
				 while( loop ){
					 			loop--;
								var arr = +readline().split(" ");
								var x = arr[0];
								var y = arr[1];
								if ( x > lst )
											 break;
								if ( y > lst )
											 lst = y;

				 }

					 					if(lst == limit)
													 write("YES\n");
										else
													write("NO\n");
}
getPt( loop, limit);

var read = readline().split(" ").map(Number);
var loop = read[0];
var limit = read[1];
var lst = 0;
function getPt( loop, limit ){
				 while( loop ){
					 			loop--;
								var arr = readline().split(" ").map(Number);
								var x = arr[0];
								var y = arr[1];
								if ( x > lst )
											 break;
								if ( y > lst )
											 lst = y;

				 }

					 					if(lst == limit)
													 write(lst);
										else
													write(lst);
}
getPt( loop, limit);

var read = +readline().split(" ");
var loop = read[0];
var limit = read[1];
var reject = false;
var found = false;
var lst = 0;
var x;
var y;
getPt( loop, limit );
function getPt( loop, limit ){
				 while( loop ){
					 			loop--;
								var arr = +readline().split(" ");
								x = arr[0],y = arr[1];
								if ( x > lst ){
											 reject = true;
											 break;
								}
								if ( y > lst ){
											 lst = y;
											 if( lst == limit ){
												 			 found = true;
															 break;
											 }
								}

				 }
				 if(reject)
				 			 write("NO\n");
				 if(found)
				 			 write("YES\n");
				 if(!reject && !found)
							 write(lst = limit ? "YES" : "NO");
}

var read = +readline().split(" ");
var loop = read[0];
var limit = read[1];
var reject = false;
var found = false;
var lst = 0;
function getPt( loop, limit ){
				 while( loop ){
					 			loop--;
								var arr = +readline().split(" ");
								x = arr[0],y = arr[1];
								if ( x > lst ){
											 reject = true;
											 break;
								}
								if ( y > lst ){
											 lst = y;
											 if( lst == limit ){
												 			 found = true;
															 break;
											 }
								}

				 }
				 if(reject)
				 			 write("NO\n");
				 if(found)
				 			 write("YES\n");
				 if(!reject && !found)
				 return lst;
}
var result = getPt(loop, limit);
write(result == limit ? "YES" : "NO");

var read = +readline().split(" ");
var loop = read[0];
var limit = read[1];
var lst = 0;
function getPt( loop, limit ){
				 while( loop ){
					 			loop--;
								var arr = +readline().split(" ");
								var x = arr[0];
								var y = arr[1];
								if ( x > lst )
											 break;
								if ( y > lst )
											 lst = y;

				 }

					 					if(lst == limit)
													 write(lst);
										else
													write(lst);
}
getPt( loop, limit);

var read = +readline().split(" ");
var loop = read[0];
var limit = read[1];
var reject = false;
var found = false;
var lst = 0;
getPt( loop, limit );
function getPt( loop, limit ){
				 while( loop ){
					 			loop--;
								var arr = +readline().split(" ");
								x = arr[0],y = arr[1];
								if ( x > lst ){
											 reject = true;
											 break;
								}
								if ( y > lst ){
											 lst = y;
											 if( lst == limit ){
												 			 found = true;
															 break;
											 }
								}

				 }
				 if(reject)
				 			 write("NO\n");
				 if(found)
				 			 write("YES\n");
				 if(!reject && !found)
							 write(lst = limit ? "YES" : "NO");
}

var read = +readline().split(" ");
var loop = read[0];
var limit = read[1];
var reject = false;
var found = false;
var lst = 0;
while( loop ){
			 loop--;
		   var arr = +readline().split(" ");
			 x = arr[0],y = arr[1];
			 if ( x > lst ){
				   		reject = true;
							break;
				}
				if ( y > lst ){
							lst = y;
							if( lst == limit ){
									    found = true;
										  break;
											}
							}

				 }
if(reject)
			write("NO\n");
if(found)
			 write("YES\n");
if(!reject && !found)
					 write(lst = limit ? "YES" : "NO");

var read = +readline().split(" ");
var loop = read[0];
var limit = read[1];
var lst = 0;
getPt( loop, limit);
function getPt( loop, limit ){
				 while( loop ){
					 			loop--;
								var arr = +readline().split(" ");
								var x = arr[0];
								var y = arr[1];
								if ( x > lst ){
											 break;
								}
								if ( y > lst ){
											 lst = y;
								}

				 }

					 					if(lst == limit)
													 write("YES\n");
										else
													write("NO\n");
}

var read = +readline().split(" ");
var loop = read[0];
var limit = read[1];
var reject = false;
var found = false;
var lst = 0;
getPt( loop, limit);
function getPt( loop, limit ){
				 while( loop ){
					 			loop--;
								var arr = +readline().split(" ");
								var x = arr[0];var y = arr[1];
								if ( x > lst ){
											 reject = true;
											 break;
								}
								if ( y > lst ){
											 lst = y;
											 if( lst == limit ){
												 			 found = true;
															 break;
											 }
								}

				 }
				 if(reject)
				 			 write("NO\n");
				 if(found)
				 			 write("YES\n");
				 if(!reject && !found){
					 					if(lst == limit)
													 write("YES\n");
										else
													write("NO\n");
				 }
}

var line = readline().split(' ');
var N = parseInt(line[0]);
var M = parseInt(line[1]);
var a = [], b=[];

for(var i = 0; i < N; i++) {
	var line = readline().split(' ');
	a[i] = parseInt(line[0]);
	b[i] = parseInt(line[1]);
}

var left = 0;

for(var i=0;i<N;i++){
	if(a[i]<=left){
		left = b[i];
	}
}

if(M <= left){
	print("YES");
}else{
	print("NO");
}

one=readline();
n=parseInt(one.split(' ')[0]);
m=parseInt(one.split(' ')[1]);
mas=[];
function compareNumeric(x, y) {
  if (x.a > y.a) return 1;
  if (x.a < y.a) return -1;
}
for(i=0;i<n;i++) {
    one=readline();
    mas[i]={};
    mas[i].a = parseInt(one.split(' ')[0]);
    mas[i].b = parseInt(one.split(' ')[1]);
}
mas.sort(compareNumeric);
max=0;
for(i=0;i<n;i++) {
    if(mas[i].a <= max) {
       if(mas[i].b > max) {
           max = mas[i].b;
           if (max >= m) {
               print('YES');
           }
       }
    }
}
print('NO');

one=readline();
n=parseInt(one.split(' ')[0]);
m=parseInt(one.split(' ')[1]);
mas=[];
function compareNumeric(x, y) {
  if (x.a > y.a) return 1;
  if (x.a < y.a) return -1;
}
for(i=0;i<n;i++) {
    one=readline();
    mas[i]={};
    mas[i].a = parseInt(one.split(' ')[0]);
    mas[i].b = parseInt(one.split(' ')[1]);
}
mas.sort(compareNumeric);
max=0;
for(i=0;i<n;i++) {
    if(mas[i].a <= max) {
       if(mas[i].b > max) {
           max = mas[i].b;
           if (max >= m) {
               print('YES');
           }
       }
    } else {
       print('NO');
    }
}

one=readline();
n=parseInt(one.split(' ')[0]);
m=parseInt(one.split(' ')[1]);
mas=[];
function compareNumeric(x, y) {
  if (x.a > y.a) return 1;
  if (x.a < y.a) return -1;
  if (x.a === y.a) {
    if (x.b > y.b) return 1;
    if (x.b < y.b) return -1;
  }
}
for(i=0;i<n;i++) {
    one=readline();
    mas[i]={};
    mas[i].a = parseInt(one.split(' ')[0]);
    mas[i].b = parseInt(one.split(' ')[1]);
}
mas.sort(compareNumeric);
max=0;
for(i=0;i<n;i++) {
    if(mas[i].a <= max) {
       if(mas[i].b > max) {
           max = mas[i].b;
           if (max >= m) {
               print('YES');
               break;
           }
       }
    } else {
       print('NO');
       break;
    }
}
if (max < m) {print('NO');}

one=readline();
n=parseInt(one.split(' ')[0]);
m=parseInt(one.split(' ')[1]);
mas=[];
function compareNumeric(x, y) {
  if (x.a > y.a) return 1;
  if (x.a < y.a) return -1;
  if (x.a === y.a) {
    if (x.b > y.b) return 1;
    if (x.b < y.b) return -1;
  }
}
for(i=0;i<n;i++) {
    one=readline();
    mas[i]={};
    mas[i].a = parseInt(one.split(' ')[0]);
    mas[i].b = parseInt(one.split(' ')[1]);
}
mas.sort(compareNumeric);
max=0;
for(i=0;i<n;i++) {
    if(mas[i].a <= max) {
       if(mas[i].b > max) {
           max = mas[i].b;
           if (max >= m) {
               print('YES');
           }
       }
    } else {
       print('NO');
    }
}

// write by lpy in 2017/12/21
//title is Visting a Friend
/*
	the input of this argument
*/
var arr = readline().split(" ");
var n = arr[0];
var m = arr[1];

//var array = [[0,4],[2,6],[6,7]];

function f(n,m){// n is the number of input, m is the friend's house

	//the [left,right]is existing range
	var str = readline().split(" ");
	var left = str[0], right = str[1];
	var result = true;
	for(var i = 1; i < n; i++){
		var array = readline().split(" ");
		var a1 = left, b1 = right;
		// var a2 = array[i][0], b2 = array[i][1];
		var a2 = array[0],b2 = array[1];
		if(a1 <= a2){
			left = a1;
			if(a2 <= b1){
				if(b1 <= b2){
					right = b2;
				}
				else right = b1;
			}
			else{
				result = false;
			}
		}
		else {
			left = a2;
			if(a1 <= b2){
				if(b1 <= b2){
					right = b2;
				}
				else right = b1;
			}
			else result = false;
		}
	}
	var ans;
	if(left === 0 && right === m)
		ans = 'YES';
	else ans = 'NO';
	return ans;
}
print(f(n, m));
// console.log(f(3,5));


We're giving away nice huge bags containing number tiles! A bag we want to present to you contains $$$n$$$ tiles. Each of them has a single number written on it — either $$$1$$$ or $$$2$$$.However, there is one condition you must fulfill in order to receive the prize. You will need to put all the tiles from the bag in a sequence, in any order you wish. We will then compute the sums of all prefixes in the sequence, and then count how many of these sums are prime numbers. If you want to keep the prize, you will need to maximize the number of primes you get.Can you win the prize? Hurry up, the bags are waiting!

The first line of the input contains a single integer $$$n$$$ ($$$1 \leq n \leq 200\,000$$$) — the number of number tiles in the bag. The following line contains $$$n$$$ space-separated integers $$$a_1, a_2, \dots, a_n$$$ ($$$a_i \in \{1, 2\}$$$) — the values written on the tiles.

Output a permutation $$$b_1, b_2, \dots, b_n$$$ of the input sequence $$$(a_1, a_2, \dots, a_n)$$$ maximizing the number of the prefix sums being prime numbers. If there are multiple optimal permutations, output any.

NoteThe first solution produces the prefix sums $$$1, \mathbf{\color{blue}{2}}, \mathbf{\color{blue}{3}}, \mathbf{\color{blue}{5}}, \mathbf{\color{blue}{7}}$$$ (four primes constructed), while the prefix sums in the second solution are $$$1, \mathbf{\color{blue}{2}}, \mathbf{\color{blue}{3}}, \mathbf{\color{blue}{5}}, 6, \mathbf{\color{blue}{7}}, 8, 10, \mathbf{\color{blue}{11}}$$$ (five primes). Primes are marked bold and blue. In each of these cases, the number of produced primes is maximum possible.

(function () {
    var read = {
        number: function () {
            return +readline();
        },
        arr: function (divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function (divider) {
            return readline()
                .split(divider ? divider : '')
                .map(item => +item);
        }
    }

    var n = read.number();
    var a = read.arrNumber( ' ');

    var oneCount = 0;
    for(var i = 0; i < n; i++) {
        if(a[i] === 1) {
            oneCount ++;
        }
    }

    var twoCount = n - oneCount;

    var res = '';
    if(oneCount && twoCount ) {
        res += '2 1 ';
        for(var i = 0; i < twoCount - 1; i++) {
            res += (2 + ' ');
        }

        for(var i = 0; i < oneCount - 1; i++) {
            res += (1 + ' ');
        }
    }
    else {
        for(var i = 0; i < n; i++) {
            res += (a[i] + ' ')
        }
    }

    print(res);
}());