In Berland each high school student is characterized by academic performance — integer value between 1 and 5.In high school 0xFF there are two groups of pupils: the group A and the group B. Each group consists of exactly n students. An academic performance of each student is known — integer value between 1 and 5.The school director wants to redistribute students between groups so that each of the two groups has the same number of students whose academic performance is equal to 1, the same number of students whose academic performance is 2 and so on. In other words, the purpose of the school director is to change the composition of groups, so that for each value of academic performance the numbers of students in both groups are equal.To achieve this, there is a plan to produce a series of exchanges of students between groups. During the single exchange the director selects one student from the class A and one student of class B. After that, they both change their groups.Print the least number of exchanges, in order to achieve the desired equal numbers of students for each academic performance.

The first line of the input contains integer number n (1 ≤ n ≤ 100) — number of students in both groups. The second line contains sequence of integer numbers a1, a2, ..., an (1 ≤ ai ≤ 5), where ai is academic performance of the i-th student of the group A. The third line contains sequence of integer numbers b1, b2, ..., bn (1 ≤ bi ≤ 5), where bi is academic performance of the i-th student of the group B.

Print the required minimum number of exchanges or -1, if the desired distribution of students can not be obtained.

var n = readline();
var group_a = readline().split(' ');
var group_b = readline().split(' ');

function solve(a, b) {
    var rlt = {};

    a.forEach(str => {rlt[str] = (rlt[str] || 0) +1;})
    b.forEach(str => {rlt[str] = (rlt[str] || 0) -1;})
    // print(JSON.stringify(rlt))
    var r = 0;
    for (var key in rlt) {
        if (rlt[key]%2)
            return -1
        r += Math.abs(rlt[key])/2
    }
    return r/2
}

print(solve(group_a, group_b))

function ansa(s,a,b){

    var cnt = [0,0,0,0,0,0]
    var all = 0;
    for(var i = 0 ; i < s ; i++){
      cnt[a[i]] += 1;
    //  console.log(a[i],cnt[a[i]])
    }
    for(var i = 0 ; i < s ; i++){
      cnt[b[i]] -= 1;
  //    console.log(b[i],cnt[a[i]])
    }
    for(var i = 1 ; i <= 5 ; i++){
      if(Math.abs(cnt[i]) % 2 !== 0){
        print("-1");
        return;
      }
    }
    for(var i = 1 ; i <= 5 ; i++){
//console.log(cnt[i])
      all += Math.abs(cnt[i]);
    }
    print(all/4);
}

//ansa(6,[1,1,1,1,1,1],[5,5,5,5,5,5])

var line = readline();

var a = readline().split(" ");
for(var i = 0 ; i < a.length ; i++) a[i] = parseInt(a[i]);
var b = readline().split(' ');
for(var i = 0 ; i < b.length ; i++) b[i] = parseInt(b[i]);

ansa(parseInt(line),a,b);

tmp1 = Array(0,0,0,0,0,0);
tmp2 = Array(0,0,0,0,0,0);
n = Number(readline());
ar1 = readline().split(' ').map(Number);
ar2 = readline().split(' ').map(Number);
ans = 0;
for(var i = 0;i<n;i++) {
	tmp1[ar1[i]]++;
	tmp2[ar2[i]]++;
}
for(var i = 1;i<=5;i++) {
	if((tmp1[i]-tmp2[i])%2 != 0) {
		ans=-1;
		break;
	}
	ans+=((x)=>{if(x < 0) {
		return -x;
	}
	else {
		return x;
	}})(tmp1[i]-tmp2[i])/4;
}
print(ans);

var сount = readline();

var class1 = readline().split(' ').sort().reverse();
var class2 = readline().split(' ').sort().reverse();

var deIntersection = deIntersect(class1, class2);
class1 = deIntersection.a;
class2 = deIntersection.b;

var fail = false;
var replaceCount = 0;

var index = 0;

while (index < class1.length) {
    if (class1[index] !== class2[index]) {
        if (class2[index] > class1[index]) {
            if (class2.lastIndexOf(class2[index]) !== index
            	&& class1.lastIndexOf(class1[index]) !== index) {
				var class2Index = class2.lastIndexOf(class2[index]);
				class2.splice(class2Index,1);
				class1.splice(0,1);
				replaceCount++;
	        } else {
	        	fail = true;
	        }
        }
        if (class2[index] < class1[index]) {
            if (class1.lastIndexOf(class1[index]) !== index
            	&& class2.lastIndexOf(class2[index]) !== index) {
				var class1Index = class1.lastIndexOf(class1[index])
				class1.splice(class1Index,1);
				class2.splice(index, 1);
				replaceCount++;
	        } else {
	        	fail = true;
	        }
        }
    }
    index++;
}

if (!fail) {
	print(replaceCount);
} else {
	print(-1);
}

function deIntersect (a,b) {
	a.forEach ((item, index) => {
		var indexInB = b.indexOf(item);
		if (indexInB !== -1) {
			b[indexInB] = 'empty';
			a[index] = 'empty';
		}
	});

	var newA = a.filter((item) => {
		return item !== 'empty';
	});

	var newB = b.filter((item) => {
		return item !== 'empty';
	});

	return {'a': newA, 'b': newB}
}

var n = parseInt(readline());
var ga = readline().split(' ').map(function(x) {
  return parseInt(x);
});
var gb = readline().split(' ').map(function(x) {
  return parseInt(x);
});
tot = [];
tota = [];
totb = [];
for(var i = 1; i <= 5; i += 1) {
  tot[i] = 0;
  tota[i] = 0;
  totb[i] = 0;
}
ga.forEach(function(x) {
  tot[x] += 1;
  tota[x] += 1;
});
gb.forEach(function(x) {
  tot[x] += 1;
  totb[x] += 1;
});
var s = true;
var r = 0;
for(var i = 1; i <= 5; i += 1) {
  if(tot[i] % 2 !== 0) {
    s = false;
  }
  r += Math.abs(tot[i] / 2 - tota[i]);
}
if(s) {
  print(r / 2);
} else {
  print(-1);
}

var n = readline();
var group_a = readline().split(' ');
var group_b = readline().split(' ');

function solve(a, b) {
    var rlt = {};

    a.forEach(str => {rlt[str] ++;})
    b.forEach(str => {rlt[str] --;})

    var r = 0;
    for (var key in rlt) {
        if (rlt[key]%2)
            return -1
        r += Math.abs(rlt[key])/2
    }
    return r
}

print(solve(group_a, group_b))

var n = readline();
var group_a = readline().split(' ');
var group_b = readline().split(' ');

function solve(a, b) {
    var rlt = {};

    a.forEach(str => {rlt[str] = (rlt[str] || 0) +1;})
    b.forEach(str => {rlt[str] = (rlt[str] || 0) -1;})
    print(JSON.stringify(rlt))
    var r = 0;
    for (var key in rlt) {
        if (rlt[key]%2)
            return -1
        r += Math.abs(rlt[key])/2
    }
    return r/2
}

print(solve(group_a, group_b))

function ansa(s,a,b){

    var cnt = []
    var all = 0;
    for(var i = 0 ; i < s ; i++)cnt[i] = 0;
    for(var i = 0 ; i < s ; i++)cnt[a[i] - 1] += 1;
    for(var i = 0 ; i < s ; i++)cnt[b[i] - 1] -= 1;
    for(var i = 0 ; i < s ; i++){
      if(Math.abs(cnt[i]) % 2 !== 0){
        print("-1");
        return;
      }
    }
    for(var i = 0 ; i < s ; i++){
      all += Math.abs(cnt[i]);
    }
    print(all/4);
}

var line = readline();

var a = readline().split(" ");
for(var i = 0 ; i < a.length ; i++) a[i] = parseInt(a[i]);
var b = readline().split(' ');
for(var i = 0 ; i < b.length ; i++) b[i] = parseInt(b[i]);

ansa(parseInt(line),a,b);

function ansa(s,a,b){

    var cnt = []
    var all = 0;
    for(var i = 0 ; i < s ; i++)cnt[i] = 0;
    for(var i = 0 ; i < s ; i++)cnt[a[i] - 1] += 1;
    for(var i = 0 ; i < s ; i++)cnt[b[i] - 1] -= 1;
    for(var i = 0 ; i < s ; i++){
      if(Math.abs(cnt[i]) % 2 !== 0){
        print("-1");
        return;
      }
    }
    for(var i = 0 ; i < s ; i++){
      all += Math.abs(cnt[i]);
    }
    print(all/2);
}

var line = readline();

var a = readline().split(" ");
for(var i = 0 ; i < a.length ; i++) a[i] = parseInt(a[i]);
var b = readline().split(' ');
for(var i = 0 ; i < b.length ; i++) b[i] = parseInt(b[i]);

ansa(parseInt(line),a,b);

function ansa(s,a,b){

    var cnt = [0,0,0,0,0,0]
    var all = 0;
    for(var i = 0 ; i < s ; i++){
      cnt[a[i]] += 1;
    //  console.log(a[i],cnt[a[i]])
    }
    for(var i = 0 ; i < s ; i++){
      cnt[b[i]] -= 1;
  //    console.log(b[i],cnt[a[i]])
    }
    for(var i = 0 ; i < s ; i++){
      if(Math.abs(cnt[i]) % 2 !== 0){
        print("-1");
        return;
      }
    }
    for(var i = 1 ; i <= 5 ; i++){
//console.log(cnt[i])
      all += Math.abs(cnt[i]);
    }
    print(all/4);
}

//ansa(6,[1,1,1,1,1,1],[5,5,5,5,5,5])

var line = readline();

var a = readline().split(" ");
for(var i = 0 ; i < a.length ; i++) a[i] = parseInt(a[i]);
var b = readline().split(' ');
for(var i = 0 ; i < b.length ; i++) b[i] = parseInt(b[i]);

ansa(parseInt(line),a,b);

var сount = readline();

var class1 = readline().split(' ').sort().reverse();
var class2 = readline().split(' ').sort().reverse();

var deIntersection = deIntersect(class1, class2);
class1 = deIntersection.a;
class2 = deIntersection.b;

var fail = false;
var replaceCount = 0;

class1.forEach((item, index) => {
    if (class1[index] !== class2[index]) {
        if (class2[index] > class1[index]) {
            if (class2.lastIndexOf(class2[index]) !== index) {
				var class2Index = class2.lastIndexOf(class2[index])
				var temp = class2[class2Index];
				class2[class2Index] = class1[index];
				class1[index] = temp;
				replaceCount++;
	        } else {
	        	fail = true;
	        }
        }
        if (class2[index] < class1[index]) {
            if (class1.lastIndexOf(class1[index]) !== index) {
				var class1Index = class1.lastIndexOf(class1[index])
				var temp = class1[class1Index];
				class1[class1Index] = class2[index];
				class2[index] = temp;
				replaceCount++;
	        } else {
	        	fail = true;
	        }
        }
    }
});

if (!fail) {
	print(replaceCount);
} else {
	print(-1);
}

function deIntersect (a,b) {
	a.forEach ((item, index) => {
		var indexInB = b.indexOf(item);
		if (indexInB !== -1) {
			b[indexInB] = 'empty';
			a[index] = 'empty';
		}
	});

	var newA = a.filter((item) => {
		return item !== 'empty';
	});

	var newB = b.filter((item) => {
		return item !== 'empty';
	});

	return {'a': newA, 'b': newB}
}

var сount = readline();

var class1 = readline().split(' ').sort().reverse();
var class2 = readline().split(' ').sort().reverse();

var deIntersection = deIntersect(class1, class2);
class1 = deIntersection.a;
class2 = deIntersection.b;

print (class1);
print (class2);

var fail = false;
var replaceCount = 0;

var index = 0;

while (index < class1.length) {
    if (class1[index] !== class2[index]) {
        if (class2[index] > class1[index]) {
            if (class2.lastIndexOf(class2[index]) !== index) {
				var class2Index = class2.lastIndexOf(class2[index])
				class2.splice(class2Index,1);
				class1.splice(0,1);
				replaceCount++;
	        } else {
	        	fail = true;
	        }
        }
        if (class2[index] < class1[index]) {
            if (class1.lastIndexOf(class1[index]) !== index) {
				var class1Index = class1.lastIndexOf(class1[index])
				class1.splice(class1Index,1);
				class2.splice(index, 1);
				replaceCount++;
	        } else {
	        	fail = true;
	        }
        }
    }
    index++;
}

if (!fail) {
	print(replaceCount);
} else {
	print(-1);
}

function deIntersect (a,b) {
	a.forEach ((item, index) => {
		var indexInB = b.indexOf(item);
		if (indexInB !== -1) {
			b[indexInB] = 'empty';
			a[index] = 'empty';
		}
	});

	var newA = a.filter((item) => {
		return item !== 'empty';
	});

	var newB = b.filter((item) => {
		return item !== 'empty';
	});

	return {'a': newA, 'b': newB}
}

var сount = readline();

var class1 = readline().split(' ').sort().reverse();
var class2 = readline().split(' ').sort().reverse();

var deIntersection = deIntersect(class1, class2);
class1 = deIntersection.a;
class2 = deIntersection.b;

print(class1);
print(class2);

var fail = false;
var replaceCount = 0;

class1.forEach((item, index) => {
    if (class1[index] !== class2[index]) {
        if (class2[index] > class1[index]) {
            if (class2.lastIndexOf(class2[index]) !== index) {
				var class2Index = class2.lastIndexOf(class2[index])
				var temp = class2[class2Index];
				class2[class2Index] = class1[index];
				class1[index] = temp;
				replaceCount++;
	        } else {
	        	fail = true;
	        }
        }
        if (class2[index] < class1[index]) {
            if (class1.lastIndexOf(class1[index]) !== index) {
				var class1Index = class1.lastIndexOf(class1[index])
				var temp = class1[class1Index];
				class1[class1Index] = class2[index];
				class2[index] = temp;
				replaceCount++;
	        } else {
	        	fail = true;
	        }
        }
    }
});

if (!fail) {
	print(replaceCount);
} else {
	print(-1);
}

function deIntersect (a,b) {
	a.forEach ((item, index) => {
		var indexInB = b.indexOf(item);
		if (indexInB !== -1) {
			b[indexInB] = 'empty';
			a[index] = 'empty';
		}
	});

	var newA = a.filter((item) => {
		return item !== 'empty';
	});

	var newB = b.filter((item) => {
		return item !== 'empty';
	});

	return {'a': newA, 'b': newB}
}

var сount = readline();

var class1 = readline().split(' ').sort().reverse();
var class2 = readline().split(' ').sort().reverse();

var deIntersection = deIntersect(class1, class2);
class1 = deIntersection.a;
class2 = deIntersection.b;

var fail = false;
var replaceCount = 0;

var index = 0;

while (index < class1.length) {
    if (class1[index] !== class2[index]) {
        if (class2[index] > class1[index]) {
            if (class2.lastIndexOf(class2[index]) !== index) {
				var class2Index = class2.lastIndexOf(class2[index])
				class2.splice(class2Index,1);
				class1.splice(0,1);
				replaceCount++;
	        } else {
	        	fail = true;
	        }
        }
        if (class2[index] < class1[index]) {
            if (class1.lastIndexOf(class1[index]) !== index) {
				var class1Index = class1.lastIndexOf(class1[index])
				class1.splice(class1Index,1);
				class2.splice(index, 1);
				replaceCount++;
	        } else {
	        	fail = true;
	        }
        }
    }
    index++;
}

if (!fail) {
	print(replaceCount);
} else {
	print(-1);
}

function deIntersect (a,b) {
	a.forEach ((item, index) => {
		var indexInB = b.indexOf(item);
		if (indexInB !== -1) {
			b[indexInB] = 'empty';
			a[index] = 'empty';
		}
	});

	var newA = a.filter((item) => {
		return item !== 'empty';
	});

	var newB = b.filter((item) => {
		return item !== 'empty';
	});

	return {'a': newA, 'b': newB}
}


Recently Adaltik discovered japanese crosswords. Japanese crossword is a picture, represented as a table sized a × b squares, and each square is colored white or black. There are integers to the left of the rows and to the top of the columns, encrypting the corresponding row or column. The number of integers represents how many groups of black squares there are in corresponding row or column, and the integers themselves represents the number of consecutive black squares in corresponding group (you can find more detailed explanation in Wikipedia https://en.wikipedia.org/wiki/Japanese_crossword).Adaltik decided that the general case of japanese crossword is too complicated and drew a row consisting of n squares (e.g. japanese crossword sized 1 × n), which he wants to encrypt in the same way as in japanese crossword.    The example of encrypting of a single row of japanese crossword. Help Adaltik find the numbers encrypting the row he drew.

The first line of the input contains a single integer n (1 ≤ n ≤ 100) — the length of the row. The second line of the input contains a single string consisting of n characters 'B' or 'W', ('B' corresponds to black square, 'W' — to white square in the row that Adaltik drew).

The first line should contain a single integer k — the number of integers encrypting the row, e.g. the number of groups of black squares in the row. The second line should contain k integers, encrypting the row, e.g. corresponding to sizes of groups of consecutive black squares in the order from left to right.

NoteThe last sample case correspond to the picture in the statement.

var a = parseInt(readline()),
	b = readline(),
    array = [],
    count = 0

	for (var i = 0; i < b.length; i++) {
		if (b[i] == 'B') {
			count++
		}
		if (b[i] == 'W') {
			if (count != 0)
				array.push(count)
			count = 0
		}
	}
	if (count != 0) {
		array.push(count)
	}
	print(array.length)
	if (array.length != 0) {
		print(array.join(' '))
	}

var a = readline().split(' ').map(Number);
var b = readline().toString() + "W";
var c = 0, d = 0,res = "";

for(var i = 0;i <= a;++i)
    if(b[i] === 'B')
        ++c;
    else if (c !== 0)
        res = res + c.toString() + " ",c = 0,++d;

print(d)
print(res);

var len = parseInt(readline());
	var str = readline();
	var ans = 0, sum = 0;
	var s='', s1=[];
	var a=[];
	if(str.indexOf('B') < 0){
		print(0);
	}
	else if(str.indexOf('W') < 0){
		ans = len;
		print(1);
		print(ans);
	}
	else{
		var r = "W";
		s = str.replace(new RegExp(r, 'gm'),' ');
		var r1 = /\s+/g;
		s = s.replace(r1,' ');
		s1 = s.split(" ");
		var k = 0;
		for(var i = 0; i < s1.length; i++){
			if(s1[i] !== ""){
				a[k++] = s1[i].length;
			}
		}
		print(k);
		for(var j = 0; j < k; j++){
			print(a[j]+' ');
		}
	}

var n = parseInt(readline()),
    tab = readline(),
	state = 'W',
	curlen = 0,
	res = []

for (var i = 0 ; i < tab.length ; i++) {
  if (tab[i] == 'B') curlen++
  else if (state == 'B') {
	res.push(curlen)
	curlen = 0
  }
  state = tab[i]
}
if (state == 'B') res.push(curlen)

print(res.length)
print(res.join(' '))

var n = parseInt(readline());
var row = readline();

var counters = [];
counters[0] = 0;

var current_counter = 0;
var k = 0;

for(var i = 0; i < n; i++) {

    if(i > 0 && row[i - 1] === 'W' && row[i] === 'B' && counters[current_counter] > 0) {
        current_counter++;
        counters[current_counter] = 0;
    }

    if(row[i] === 'B')
        counters[current_counter]++;
}

if(!(counters.length === 1 && counters[0] === 0))
    k = counters.length;

// print result
print(k);
if(k > 0)
    print(counters.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↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : 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 N = nextInt();
  var s = next().split("W");
  var output = [];
  for(var i = 0; i < s.length; i++){
    if(s[i] != ""){
      output.push(s[i].length);
    }
  }
  myout(output.length);
  myout(myconv(output, 8));
}

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

rl.on('line', (str) => {
  if (c === 0) {
    c++;
    return;
  }

  const ans = str.match(/[B]+/g) || [];
  console.log(ans.length);
  console.log(ans.map(x => x.length).join(' '));

  // let ans = 0;
  // const arr = [];
  // let inc = 0;

  // for (let i = 0; i < str.length - 1; i++) {
  //   if (str[i] === 'B') {
  //     inc++;

  //     if (str[i + 1] === 'W') {
  //       ans++;
  //       arr.push(inc);
  //     }
  //   }
  //   else {
  //     inc = 0;
  //   }
  // }

  // if (str[str.length - 1] === 'B') {
  //   ans++;
  //   inc++;
  //   arr.push(inc);
  // }

  // console.log(ans);
  // console.log(arr.join(' '));

  c++;
});

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

rl.on('line', (str) => {
  if (c === 0) {
    c++;
    return;
  }

  let ans = 0;
  const arr = [];
  let inc = 0;

  for (let i = 0; i < str.length - 1; i++) {
    if (str[i] === 'B') {
      inc++;

      if (str[i + 1] === 'W') {
        ans++;
        arr.push(inc);
      }
    }
    else {
      inc = 0;
    }
  }

  if (str[str.length - 1] === 'B') {
    ans++;
    inc++;
    arr.push(inc);
  }

  console.log(ans);
  console.log(arr.join(' '));

  c++;
});

var a = readline().split(' ').map(Number);
var b = readline().toString() + "W";
var c = 0, d = 0,res = "";

for(var i = 0;i <= a;++i)
    if(b[i] === 'B')
        ++c;
    else if (c !== 0)
        res = res + c.toString() + " ",c = 0;

print(res);

var len = parseInt(readline());
	var str = readline();
	var ans = 0, sum = 0;
	var s='', s1=[];
	var a=[];
	if(str.indexOf('B') === -1){
		sum = 0;
		//return sum;
		print(sum);
	}
	else if(str.indexOf('W') === -1){
		sum = 1;
		ans = len;
		print(ans);
	}
	else{
		/*for(var i = 0; i < len; i++){
			if(str[i] === 'W'){
				s = str.replace('W',' ');
			}
		}
		}*/
		var r = "W";
		s = str.replace(new RegExp(r, 'gm'),' ');
		var r1 = /\s+/g;
		s = s.replace(r1,' ');
		s1 = s.split(" ");
		var k = 0;
		for(var i = 0; i < s1.length; i++){
			if(s1[i] !== ""){
				a[k++] = s1[i].length;
			}
		}
	}
	//return k +' ' +a;
	print(k);
	for(var j = 0; j < k; j++){
		print(a[j]+' ');
	}

var len = parseInt(readline());
	var str = readline();
	var ans = 0, sum = 0;
	var s='', s1=[];
	var a=[];
	if(str.indexOf('B') === -1){
		print(0);
	}
	else if(str.indexOf('W') === -1){
		ans = len;
		print(ans);
	}
	else{
		/*for(var i = 0; i < len; i++){
			if(str[i] === 'W'){
				s = str.replace('W',' ');
			}
		}
		}*/
		var r = "W";
		s = str.replace(new RegExp(r, 'gm'),' ');
		var r1 = /\s+/g;
		s = s.replace(r1,' ');
		s1 = s.split(" ");
		var k = 0;
		for(var i = 0; i < s1.length; i++){
			if(s1[i] !== ""){
				a[k++] = s1[i].length;
			}
		}
	}
	//return k +' ' +a;

	print(k);
	for(var j = 0; j < k; j++){
		print(a[j]+' ');
	}

var len = parseInt(readline());
	var str = readline();
	var ans = 0, sum = 0;
	var s='', s1=[];
	var a=[];
	if(str.indexOf('B') < 0){
		print(0);
	}
	else if(str.indexOf('W') < 0){
		ans = len;
		print(ans);
	}
	else{
		var r = "W";
		s = str.replace(new RegExp(r, 'gm'),' ');
		var r1 = /\s+/g;
		s = s.replace(r1,' ');
		s1 = s.split(" ");
		var k = 0;
		for(var i = 0; i < s1.length; i++){
			if(s1[i] !== ""){
				a[k++] = s1[i].length;
			}
		}
			print(k);
    	for(var j = 0; j < k; j++){
    		print(a[j]+' ');
    	}
	}


You are developing a new feature for the website which sells airline tickets: being able to sort tickets by price! You have already extracted the tickets' prices, so there's just the last step to be done...You are given an array of integers. Sort it in non-descending order.

The input consists of a single line of space-separated integers. The first number is n (1 ≤ n ≤ 10) — the size of the array. The following n numbers are the elements of the array (1 ≤ ai ≤ 100).

Output space-separated elements of the sorted array.

NoteRemember, this is a very important feature, and you have to make sure the customers appreciate it!

const input = readline().split(" ").map(x => Number(x));
const n = input[0];
const numbers = input.slice(1, 1 + n);
print(numbers.sort((a, b) => a > b ? 1 : a < b ? -1 : 0).join(" "));
while (performance.now() < 1500) { }

var x = 12345;
for(var i = 0; i < 10000000; i += 1) {
  x %= i;
}
print(readline().split(' ').slice(1).map(function(x) { return parseInt(x); }).sort(function(a, b) { return a - b; }).concat(x).slice(0, -1).join(' '));


Yet another Armageddon is coming! This time the culprit is the Julya tribe calendar. The beavers in this tribe knew math very well. Smart Beaver, an archaeologist, got a sacred plate with a magic integer on it. The translation from Old Beaverish is as follows: "May the Great Beaver bless you! May your chacres open and may your third eye never turn blind from beholding the Truth! Take the magic number, subtract a digit from it (the digit must occur in the number) and get a new magic number. Repeat this operation until a magic number equals zero. The Earth will stand on Three Beavers for the time, equal to the number of subtractions you perform!"Distinct subtraction sequences can obviously get you different number of operations. But the Smart Beaver is ready to face the worst and is asking you to count the minimum number of operations he needs to reduce the magic number to zero.

The single line contains the magic integer n, 0 ≤ n.   to get 20 points, you need to solve the problem with constraints: n ≤ 106 (subproblem C1);  to get 40 points, you need to solve the problem with constraints: n ≤ 1012 (subproblems C1+C2);  to get 100 points, you need to solve the problem with constraints: n ≤ 1018 (subproblems C1+C2+C3).

Print a single integer — the minimum number of subtractions that turns the magic number to a zero.

NoteIn the first test sample the minimum number of operations can be reached by the following sequence of subtractions:  24 → 20 → 18 → 10 → 9 → 0

let store = [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}];

function checkDigit(n, dig) {
  if (dig === 0 && n === 0) {
    return { count: 0, decrement: 0 };
  }
  return {
    count: 1,
    decrement: Math.max(n, dig) - n
  };
}

function splitNumber(n) {
  const digitsPow = 10 ** Math.floor(Math.log10(n));
  let first = Math.floor(n / digitsPow);
  let tail = n % digitsPow;
  return [first, tail];
}

function solveCore(n, dig = 0) {
  if (store[dig][n]) {
    return store[dig][n];
  }
  if (n < 10) {
    return (store[dig][n] = checkDigit(n, dig));
  }

  let rest = n;
  let [first, tail] = splitNumber(rest);
  let count = 0;

  while (rest > 0) {
    const r = solveCore(tail, Math.max(first, dig));
    count += r.count;
    rest -= tail + r.decrement;
    [first, tail] = splitNumber(rest);
  }

  return (store[dig][n] = { count, decrement: -rest });
}
function solve(n) {
  store = [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}];
  const r = solveCore(n, 0);
  return r.count;
}

function* main() {
  const n = parseInt(yield);
  const r = solve(n);
  console.log(r);
  process.exit(0);
}

if (!module.parent) {
  (() => {
    const q = main();
    q.next();
    require("readline")
      .createInterface({
        input: process.stdin,
        output: null
      })
      .on("line", line => q.next(line));
  })();
}

exports.solve = solve;

let store = [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}];

function checkDigit(n, dig) {
  if (dig == 0) {
    return { count: int(n == 0 ? 0 : 1), decrement: 0 };
  }
  if (dig > n) {
    return {
      count: int(1),
      decrement: dig - n
    };
  }
  return {
    count: int(2),
    decrement: dig
  };
}

function getNumString(arr) {
  const joined = arr.join("");
  const trimmed = joined.replace(/0/g, " ").trimLeft();
  return trimmed.replace(/\s/g, "0") || "0";
}

function solveCore(n, dig = 0) {
  if (store[dig][n]) {
    return store[dig][n];
  }
  if (n.length === 1) {
    return (store[dig][n] = checkDigit(n, dig));
  }

  let first = n[0];
  let tailArr = n.substring(1).split("");
  let total = int();

  while (first >= 0) {
    const r = solveCore(getNumString(tailArr), Math.max(first, dig));
    total = plus(total, r.count);
    first -= 1;
    tailArr = tailArr.map(() => "9");
    tailArr.pop();
    tailArr.push(`${(10 - r.decrement) % 10}`);
  }

  return (store[dig][n] = { count: total, decrement: 10 - tailArr.pop() });
}

function solve(n) {
  store = [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}];
  const r = solveCore(n, 0);
  return bintToString(r.count);
}

function* main() {
  const n = yield;
  const r = solve(n);
  console.log(r);
  process.exit(0);
}

if (!module.parent) {
  (() => {
    const q = main();
    q.next();
    require("readline")
      .createInterface({
        input: process.stdin,
        output: null
      })
      .on("line", line => q.next(line));
  })();
}

function int(n = 0) {
  return [
    n,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0
  ];
}
function plus(int1, int2) {
  let z = 0;
  return int1.map((_, i) => {
    z = z + int1[i] + int2[i];
    const r = z % 10;
    z = Math.floor(z / 10);
    return r;
  });
}

function bintToString(i) {
  return getNumString(Array.from(i).reverse());
}

exports.solve = solve;

function solve(n) {
  let rest = n;
  let count = 0;
  while (rest > 0) {
    rest -= Math.max(...rest.toString().split(""));
    count += 1;
  }
  return count;
}

function* main() {
  const n = parseInt(yield);
  const r = solve(n);
  console.log(r);
  process.exit(0);
}

if (!module.parent) {
  (() => {
    const q = main();
    q.next();
    require("readline")
      .createInterface({
        input: process.stdin,
        output: null
      })
      .on("line", line => q.next(line));
  })();
}

exports.solve = solve;

'use strict';

function createReadLine() {
  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++];
  }

  return readline;
}

const readline = createReadLine();

function readInts(){
  return readline().split(' ').map((value => Number.parseInt(value)));
}

function readFloats(){
  return readline().split(' ').map((value => Number.parseFloat(value)));
}

function readStr() {
  return readline();
}

function readInt(){
  return Number.parseInt(readline());
}

function readFloat(){
  return Number.parseFloat(readline());
}

function main() {
  const str = readStr();
  const result = solve(str);
  console.log(result);
}

function solve(str){
  const strArr = str.toString().split('')
  let number = Number.parseInt(str);
  let counter = 0;
  while (number > 0){
    number = number - Math.max(...number.toString().split(''))
    counter ++;
  }
  return counter;
}

module.exports.solve = solve;

function check9(n) {
  const ns = n.toString();
  const indexOf9 = ns.indexOf("9");
  if (indexOf9 < 0) {
    return 0;
  }
  const rest = n % 10 ** (ns.length - indexOf9 - 1);
  const count = Math.floor(rest / 9);
  return count + 1;
}

function solve(n) {
  let rest = n;
  let count = 0;
  while (rest > 9) {
    const count9 = check9(rest);
    if (count9 > 0) {
      rest -= count9 * 9;
      count += count9;
    } else {
      rest -= Math.max(...rest.toString().split(""));
      count += 1;
    }

    // console.log(rest, count, count9)
  }
  return count + 1;
}

function* main() {
  const n = parseInt(yield);
  const r = solve(n);
  console.log(r);
  process.exit(0);
}

if (!module.parent) {
  (() => {
    const q = main();
    q.next();
    require("readline")
      .createInterface({
        input: process.stdin,
        output: null
      })
      .on("line", line => q.next(line));
  })();
}

exports.solve = solve;

let store = [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}];

function checkDigit(n, dig) {
  if (dig == 0) {
    return { count: n == 0 ? 0 : 1, decrement: 0 };
  }
  if (dig > n) {
    return {
      count: 1,
      decrement: dig - n
    };
  }
  return {
    count: 2,
    decrement: dig
  };
}

function getNumString(arr) {
  const joined = arr.join("");
  const trimmed = joined.replace(/0/g, " ").trimLeft();
  return trimmed.replace(/\s/g, "0") || "0";
}

function solveCore(n, dig = 0) {
  if (store[dig][n]) {
    return store[dig][n];
  }
  if (n.length === 1) {
    return (store[dig][n] = checkDigit(n, dig));
  }

  let first = n[0];
  let tailArr = n.substring(1).split("");
  let total = 0;

  while (first >= 0) {
    const r = solveCore(getNumString(tailArr), Math.max(first, dig));
    total += r.count;
    first -= 1;
    tailArr = tailArr.map(() => "9");
    tailArr.pop();
    tailArr.push(`${(10 - r.decrement) % 10}`);
  }

  return (store[dig][n] = { count: total, decrement: 10 - tailArr.pop() });
}

function solve(n) {
  store = [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}];
  const r = solveCore(n, 0);
  return r.count;
}

function* main() {
  const n = yield;
  const r = solve(n);
  console.log(r);
  process.exit(0);
}

if (!module.parent) {
  (() => {
    const q = main();
    q.next();
    require("readline")
      .createInterface({
        input: process.stdin,
        output: null
      })
      .on("line", line => q.next(line));
  })();
}

exports.solve = solve;

let store = [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}];

function checkDigit(n, dig) {
  if (dig == 0) {
    return { count: int(n == 0 ? 0 : 1), decrement: 0 };
  }
  if (dig > n) {
    return {
      count: int(1),
      decrement: dig - n
    };
  }
  return {
    count: int(2),
    decrement: dig
  };
}

function getNumString(arr) {
  const joined = arr.join("");
  const trimmed = joined.replace(/0/g, " ").trimLeft();
  return trimmed.replace(/\s/g, "0") || "0";
}

function solveCore(n, dig = 0) {
  if (store[dig][n]) {
    return store[dig][n];
  }
  if (n.length === 1) {
    return (store[dig][n] = checkDigit(n, dig));
  }

  let first = n[0];
  let tailArr = n.substring(1).split("");
  let total = int();

  while (first >= 0) {
    const r = solveCore(getNumString(tailArr), Math.max(first, dig));
    total = plus(total, r.count);
    first -= 1;
    tailArr = tailArr.map(() => "9");
    tailArr.pop();
    tailArr.push(`${(10 - r.decrement) % 10}`);
  }

  return (store[dig][n] = { count: total, decrement: 10 - tailArr.pop() });
}

function solve(n) {
  store = [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}];
  const r = solveCore(n, 0);
  console.log(
    n,
    store.map(o => Object.keys(o).length).reduce((acc, c) => acc + c)
  );
  return bintToString(r.count);
}

function* main() {
  const n = yield;
  const r = solve(n);
  console.log(r);
  process.exit(0);
}

if (!module.parent) {
  (() => {
    const q = main();
    q.next();
    require("readline")
      .createInterface({
        input: process.stdin,
        output: null
      })
      .on("line", line => q.next(line));
  })();
}

function int(n = 0) {
  return [
    n,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0
  ];
}
function plus(int1, int2) {
  let z = 0;
  return int1.map((_, i) => {
    z = z + int1[i] + int2[i];
    const r = z % 10;
    z = Math.floor(z / 10);
    return r;
  });
}

function bintToString(i) {
  return getNumString(Array.from(i).reverse());
}

exports.solve = solve;


Array of integers is unimodal, if:  it is strictly increasing in the beginning;  after that it is constant;  after that it is strictly decreasing. The first block (increasing) and the last block (decreasing) may be absent. It is allowed that both of this blocks are absent.For example, the following three arrays are unimodal: [5, 7, 11, 11, 2, 1], [4, 4, 2], [7], but the following three are not unimodal: [5, 5, 6, 6, 1], [1, 2, 1, 2], [4, 5, 5, 6].Write a program that checks if an array is unimodal.

The first line contains integer n (1 ≤ n ≤ 100) — the number of elements in the array. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 1 000) — the elements of the array.

Print "YES" if the given array is unimodal. Otherwise, print "NO". You can output each letter in any case (upper or lower).

NoteIn the first example the array is unimodal, because it is strictly increasing in the beginning (from position 1 to position 2, inclusively), that it is constant (from position 2 to position 4, inclusively) and then it is strictly decreasing (from position 4 to position 6, inclusively).

var n = readline()
var arr = readline().split(' ').map(x => parseInt(x))
var unimodal = 'YES'
var lastmov = null;

for(var i = 1; i < arr.length; i++){
	var curmov = arr[i] == arr[i - 1] ? 1 : arr[i] < arr[i - 1] ? 2 : 0;
	if(lastmov == null) { lastmov = curmov; continue; }
	if(curmov < lastmov) { unimodal = 'NO'; break; }
	lastmov = curmov;
}

print(unimodal)

main();
function main() {
    var size = parseInt(readline());
    var array = readline().split(' ');
    if ((size==1) || (size==2)) {
        return print("YES");
    } else {
        for (var i=0; i<size; i++) {array[i] = parseInt(array[i]);}
        var state = (array[0]<array[1]) ? "up" : (array[0]==array[1] ? "const" : "down");
        if (state!="WRONG") {
            for (var i=2; i<size; i++) {
                if (state=="up") {
                    if (array[i-1]==array[i]) state="const"
                    else if (array[i-1]>array[i]) state="down";
                } else if (state=="const") {
                    if (array[i-1]<array[i]) return print("NO")
                    else if (array[i-1]>array[i]) state="down";
                } else {
                    if (array[i-1]<=array[i]) return print("NO");
                }
            }
        } else {
            return print("NO");
        }
        return print("YES");
    }
}

var n = Number(readline());
var arr = readline().split(' ').map(Number);
var i = 1, prev = arr[0], cur = arr[1];

while (prev < cur) {
    i++;
    prev = cur;
    cur = arr[i];
}

while (prev == cur) {
    i++;
    prev = cur;
    cur = arr[i];
}

while (prev > cur) {
    i++;
    prev = cur;
    cur = arr[i];
}

if (i == arr.length) {
    print('YES');
}
else {print('NO');}

var aLength = parseInt(readline()),
    arr = readline().split(' '),
    lastElem = null,
    action = -1,
    output = 'YES';

if (aLength !== 1) {
    for (var i = 0; i < aLength; i++) {
        if (lastElem !== null) {
            if (lastElem > parseInt(arr[i])) {
                action = 2;

            } else if (lastElem === parseInt(arr[i])) {
                if(action === 2) {
                    output = 'NO';
                    break;
                }
                action = 1;

            } else {
                if(action === 1 || action === 2) {
                    output = 'NO';
                    break;
                }
                action = 0;
            }
        }

        lastElem = parseInt(arr[i]);
    }
}

print(output);

var n = readline();
var arr = readline().split(' ').map(x => parseInt(x));
var unimodal = 'YES';
var getconst = false;

for(var i = 1; i < arr.length; i++){

	if(!getconst) getconst = arr[i] <= arr[i- 1] ;

	if(arr[i] == arr[i- 1]) continue;

	if(!getconst && arr[i] < arr[i - 1]){
		unimodal = 'NO';
		break;
	}

	if(getconst && arr[i] > arr[i - 1]){
		unimodal = 'NO';
		break;
	}
}

print(unimodal);

var n = readline()
var arr = readline().split(' ').map(x => parseInt(x))
var unimodal = 'YES'
var getconst = false;

for(var i = 1; i < arr.length; i++){

	if(!getconst) getconst = arr[i] == arr[i- 1]

	if(arr[i] == arr[i- 1]) continue;

	if(!getconst && arr[i] < arr[i - 1]){
		unimodal = 'NO'
		break;
	}

	if(getconst && arr[i] > arr[i - 1]){
		unimodal = 'NO'
		break;
	}
}

print(unimodal)

var arr = readline().split(' ').map(x => parseInt(x))
var unimodal = 'YES'
var getconst = false;

for(var i = 1; i < arr.length; i++){

	if(!getconst) getconst = arr[i] <= arr[i- 1]

	if(arr[i] == arr[i- 1]) continue;

	if(!getconst && arr[i] < arr[i - 1]){
		unimodal = 'NO'
		break;
	}

	if(getconst && arr[i] > arr[i - 1]){
		unimodal = 'NO'
		break;
	}
}

print(unimodal)

main();
function main() {
    var size = parseInt(readline());
    var array = readline().split(' ');
    if ((size==1) || (size==2)) {
        return print("YES");
    } else {
        for (var i=0; i<size; i++) {array[i] = parseInt(array[i]);}
        var state = (array[0]<array[1]) ? "up" : (array[0]==array[1] ? "const" : "WRONG");
        if (state!="WRONG") {
            for (var i=2; i<size; i++) {
                if (state=="up") {
                    if (array[i-1]==array[i]) state="const"
                    else if (array[i-1]>array[i]) state="down";
                } else if (state=="const") {
                    if (array[i-1]<array[i]) return print("NO")
                    else if (array[i-1]>array[i]) state="down";
                } else {
                    if (array[i-1]<=array[i]) return print("NO");
                }
            }
        } else {
            return print("NO");
        }
        return print("YES");
    }
}

main();
function main() {
    var size = parseInt(readline());
    var array = readline().split(' ');
    if ((size==1) || (size==2)) {
        return print("YES");
    } else {
        var state = (array[0]<array[1]) ? "up" : (array[0]==array[1] ? "const" : "WRONG");
        if (state!="WRONG") {
            for (var i=2; i<size; i++) {
                if (state=="up") {
                    if (array[i-1]==array[i]) state="const"
                    else if (array[i-1]>array[i]) state="down";
                } else if (state=="const") {
                    if (array[i-1]<array[i]) return print("NO")
                    else if (array[i-1]>array[i]) state="down";
                } else {
                    if (array[i-1]<=array[i]) return print("NO");
                }
            }
        } else {
            return print("NO");
        }
        return print("YES");
    }
}

var aLength = parseInt(readline()),
    arr = readline().split(' '),
    lastElem = null,
    action = -1,
    output = 'YES';

if (aLength !== 1) {
    for (var i = 0; i < aLength; i++) {
        if (lastElem !== null) {
            if (lastElem > arr[i]) {
                if(action === -1) {
                    output = 'NO';
                    break;
                }
                action = 2;

            } else if (lastElem === arr[i]) {
                if(action === 2) {
                    output = 'NO';
                    break;
                }
                action = 1;

            } else {
                if(action === 1 || action === 2) {
                    output = 'NO';
                    break;
                }
                action = 0;
            }
        }

        lastElem = arr[i];
    }
}

print(output);

var aLength = parseInt(readline()),
    arr = readline().split(' '),
    lastElem = null,
    action = -1,
    output = 'YES';

if (aLength !== 1) {
    for (var i = 0; i < aLength; i++) {
        if (lastElem !== null) {
            if (lastElem > parseInt(arr[i])) {
                if(action === -1) {
                    output = 'NO';
                    break;
                }
                action = 2;

            } else if (lastElem === parseInt(arr[i])) {
                if(action === 2) {
                    output = 'NO';
                    break;
                }
                action = 1;

            } else {
                if(action === 1 || action === 2) {
                    output = 'NO';
                    break;
                }
                action = 0;
            }
        }

        lastElem = parseInt(arr[i]);
    }
}

print(output);


Vasily the bear has a favorite rectangle, it has one vertex at point (0, 0), and the opposite vertex at point (x, y). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes. Vasya also loves triangles, if the triangles have one vertex at point B = (0, 0). That's why today he asks you to find two points A = (x1, y1) and C = (x2, y2), such that the following conditions hold:  the coordinates of points: x1, x2, y1, y2 are integers. Besides, the following inequation holds: x1 < x2;  the triangle formed by point A, B and C is rectangular and isosceles ( is right);  all points of the favorite rectangle are located inside or on the border of triangle ABC;  the area of triangle ABC is as small as possible. Help the bear, find the required points. It is not so hard to proof that these points are unique.

The first line contains two integers x, y ( - 109 ≤ x, y ≤ 109, x ≠ 0, y ≠ 0).

Print in the single line four integers x1, y1, x2, y2 — the coordinates of the required points.

print(function(x, y){
	var dx = Math.abs(x);
	var dy = Math.abs(y);
	var d = dx+dy;
	var a = [ d*x/dx, 0 ];
	var b = [ 0, d*y/dy ];
	return ( x<0 ? a.concat(b) : b.concat(a) ).join(' ');
}.apply(0, readline().split(' ').map(Number)));

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], 10);
	};
	return tokens;
}

function main() {
	var data = tokenizeIntegers(readline()),
		a = data[0], b = data[1],
		x = Math.abs(a) + Math.abs(b),
		y = x;
	x *= a/Math.abs(a);
	y *= b/Math.abs(b);
	if (x < 0) {
		print(x, 0, 0, y);
	} else {
		print(0, y, x, 0);
	}
}

main();

var xy = readline().split(' ').map(Number);
var x = xy[0], y = xy[1];
var x1 = 0, y1 = 0, x2 = 0, y2 = 0;
if (x > 0) {
    x2 = x + Math.abs(y);
    if (y > 0) y1 = x2;
    else y1 = -x2;
} else {
    x1 = x - Math.abs(y);
    if (y > 0) y2 = -x1;
    else y2 = x1;
}
print(x1, y1, x2, y2);