function main(input) {
  const args = input;
  var rplc1 = /eraser/g;
  var rplc2 = /dreamer/g;
  var rplc3 = /erase/g;
  var rplc4 = /dream/g;
  var i = args.replace(rplc1,'');
  var j = i.replace(rplc2,'');
  var k = j.replace(rplc3,'');
  var l = k.replace(rplc4,'');
  if(l){
    console.log('NO');
  }else{
    console.log('YES');
  }

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function main( input ) {
    const reverse = (s) => {
        return s.split('').reverse().join('');
    }

    const WORDS = ['dream', 'dreamer', 'erase', 'eraser'].map(reverse);
    const S = reverse(input.split('\n')[0]);

    let index = 0;
    while(true) {
        let w = WORDS.find( (w) => S.startsWith(w, index) );
        if(!w) break;
        index += w.length;
    }

    if( S.length === index ) {
        console.log('YES');
    } else {
        console.log('NO');
    }
}

main( require('fs').readFileSync('/dev/stdin', 'utf8') )

Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.

Score : 300 points

Problem Statement

You are given a string S consisting of lowercase English letters.
Another string T is initially empty.
Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times:

Append one of the following at the end of T: dream, dreamer, erase and eraser.

Constraints

1≦|S|≦10^5

S consists of lowercase English letters.

Input

The input is given from Standard Input in the following format:

S

Output

If it is possible to obtain S = T, print YES. Otherwise, print NO.

Sample Input 1

erasedream

Sample Output 1

YES

Append erase and dream at the end of T in this order, to obtain S = T.

Sample Input 2

dreameraser

Sample Output 2

YES

Append dream and eraser at the end of T in this order, to obtain S = T.

Sample Input 3

dreamerer

Sample Output 3

NO

Submitted source-code file size, in bytes.

Execution CPU time reported by official Project CodeNet metadata, in milliseconds.

Peak memory usage reported by official Project CodeNet metadata, in kilobytes.


'use strict'

function main(input) {
  let s = input
  s = s.split('').reverse().join('')
  let dividers = ['dream', 'erase', 'eraser', 'dreamer']
  dividers = dividers.map(divider => divider.split('').reverse().join(''))

  let result = false
  const length = s.length
  for (let i=0; i<length;) {
    let tmpResult = false
    for (let j=0; j<dividers.length; j++) {
      if (s.startsWith(dividers[j])) {
        s = s.slice(dividers[j].length)
        i += dividers[j].length
        tmpResult = true
        break
      }
    }

    if (tmpResult === false) {
      break
    }
    if (s.length === 0) {
      result = true
      break
    }

  }

  if (result) {
    console.log('YES')
  } else {
    console.log('NO')
  }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


'use strict'

function main(input) {
  let s = input

  while(true) {
    if (s.endsWith('dream') || s.endsWith('erase')) {
      s = s.slice(0, -5)
    } else if (s.endsWith('eraser')) {
      s = s.slice(0, -6)
    } else if (s.endsWith('dreamer'))  {
      s = s.slice(0, -7)
    } else {
      break
    }
  }

  if (s.length === 0) {
    console.log('YES')
  } else {
    console.log('NO')
  }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


'use strict';
function main(input) {
    var reverse = input.trim().split('').reverse().join('')
    var words = ['dream', 'dreamer', 'erase' ,'eraser']
    var rws = words.map(a=>a.split('').reverse().join(''))
    let index = 0
	while (true) {
      const f = rws.find(a=>rws.startsWith(a,index))
      if(!f) break
      index = index + f.length
      if(index === rws.length) {
        console.log('YES')
      }else{
        console.log('NO')
      }
    }
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


// ABC049

// inputに入力データ全体が入る
function Main(input) {
  var S = reverse(input.split("\n")[0].toString());
  const a = reverse("dream");
  const b = reverse("dreamer");
  const c = reverse("erase");
  const d = reverse("eraser");
  var flag = 0;
  var result = "YES";

  while(S.length > 0 && flag != 1) {
    if(!S.indexOf(a)){
      S = S.slice( a.length ) ;
    } else if(!S.indexOf(b)){
      S = S.slice( b.length ) ;
    } else if(!S.indexOf(c)){
      S = S.slice( c.length ) ;
    } else if(!S.indexOf(d)){
      S = S.slice( d.length ) ;
    } else {
      flag = 1;
      result = "NO";
    }
  }
  console.log(result);
}

// 文字逆さ
function reverse(s) {
  var tmp = s.split("");
  var str = "";
  for(var i=tmp.length-1;i>=0;i--) {
    str += tmp[i].toString();
  }
  return str;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


// ABC 049

// inputに入力データ全体が入る
function Main(input) {
  var str = input;
  // 正規表現による指定
  str = str.replace(/erase/g, '');
  str = str.replace(/eraser/g, '');
  str = str.replace(/dreamer/g, '');
  str = str.replace(/dream/g, '');

  if(str == "") {
    console.log("YES");
  } else {
    console.log("NO");
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


// ABC 049

// inputに入力データ全体が入る
function Main(input) {
  var str = input;
  // 正規表現による指定
  str = str.replace(/erase/g, '');
  str = str.replace(/eraser/g, '');
  str = str.replace(/dreamer/g, '');
  str = str.replace(/dream/g, '');

  if(str == "") {
    console.log("YES");
  } else {
    str = input;
    str = str.replace(/eraser/g, '');
    str = str.replace(/erase/g, '');
    str = str.replace(/dreamer/g, '');
    str = str.replace(/dream/g, '');
    if(str == "") {
      console.log("YES");
    } else {
      console.log("NO");
    }
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


'use strict'
const main = arg => {
	const input = arg.trim().split("\n");
	let s = input[0]
	const parts = ['dream', 'dreamer', 'erase', 'eraser']
	const replaced = []
	let failure = 0
	let sameCount = 0
	//replaceを続け、replaceできなくなったら一つ戻る
	while(1) {
		for(let i = 0 ; i < parts.length ; i++) {

			let before = s
			s = s.replace(new RegExp('^' + parts[i]), '')
			if(s === '') {
				console.log('YES')
				return
			}
			if(s === before) {
				sameCount++
			} else {
				sameCount = 0
				failure = 0
				replaced.push({moji: parts[i], idx: i})
			}
			if(sameCount >= parts.length - 1) {
				failure++
				// １つ前の選択肢を戻す
				s = replaced[replaced.length - 1].moji + s
				i = replaced[replaced.length - 1].idx
			}
			if(failure >= parts.length) {
				console.log('NO')
				return
			}
		}
	}
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


"use strict"

function Main(input) {
  const reverse = (s) => {
    return s.split('').reverse().join('');
  };

  const WORDS = ['dream', 'dreamer', 'erase', 'eraser'].map(reverse);
  const S = reverse(input.split('\n')[0]);

  let index = 0;

  while (true) {
    let w = WORDS.find((w) => S.startsWith(w, index));
    if (!w) break;
    index += w.length;
  }

  if (S.length === index) {
    console.log('YES');
  } else {
    console.log('NO');
  }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


"use strict";
const main = arg => {
  let word = arg.trim();
  let judge　= "NO";
  let isRoop = true;
  roop:
  while(isRoop){
    switch (word.substr(-3, 3)){
      case 'eam':
        // 5文字分削る
        word = word.slice(0,-5);
        break;
      case 'mer':
        word = word.slice(0,-7);
        break;
      case 'ase':
        word = word.slice(0,-5);
        break;
      case 'ser':
        word = word.slice(0,-6);
        break;
      default:
        isRoop = false;
        break roop;
    }
  }
  if(word.length == 0){
  judge = "YES"
  }
  console.log(judge);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function Main(input){
  var S = input[0].toString();

  var revS = S.split('').reverse().join('');
  var divide = ['dream', 'dreamer', 'erase', 'eraser'].map(s => {
    return s.split('').reverse().join('');
  });

  var stringN = 0;

  while(stringN < revS.length){
    var word = divide.find(w => {
      return revS.startsWith(w, stringN);
    });

    if(word　!== false){
      console.log('NO');
    } else {
      stringN += word.length;
    }
  }

  console.log('YES');
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function Main(input){
  var S = input[0].toString();

  var revS = S.split('').reverse().join('');
  var divide = ['dream', 'dreamer', 'erase', 'eraser'].map(s => {
    return s.split('').reverse().join('');
  });

  var stringN = 0;

  while(stringN < revS.length){
    var word = divide.find(w => {
      return revS.startsWith(w, stringN);
    });

    if(!word){
      console.log('NO');
    } else {
      stringN += word.length;
    }
  }

  console.log('YES');
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function Main(input){
  var S = input.split('');
  var T = '';
  var length = S.length;

  if(length < 5){
    console.log('NO');
  } else {
    for(var i = 5; i <= length; i += 5){
      var str = S[i-5] + S[i-4] + S[i-3] + S[i-2] + S[i-1];
      if(str == 'dream'){
        if(i+2 < length){
          var a = S[i] + S[i+1] + S[i+2];
          if(a == 'era'){
            T = T + 'dream';
          } else {
            T = T + 'dreamer';
            i += 2;
          }
        } else if(i+1 < length){
          var a = S[i] + S[i+1];
          if(a == 'er'){
            T = T + 'dreamer';
            i += 2;
          } else {
            T = T + 'dream';
          }
        } else {
          T = T + 'dream';
        }
      } else if(str == 'erase'){
        if(i < length){
          if(S[i]== 'r'){
            T = T + 'eraser';
            i += 1;
          } else {
            T = T + 'erase';
          }
        } else {
          T = T + 'erase';
        }
      } else {
        break;
      }
    }

    if(T == S){
      console.log('YES');
    } else {
      console.log('NO');
    }
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function Main(input) {
    var erased = input.replace(/eraser/g, '').replace(/erase/g, '').
    replace(/dreamer/g, '').replace(/dream/g, '');
    if (erased === '') {
        console.log("YES");
    } else {
        console.log("NO");
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function Main(input){
  var word = input.split('').reverse();
  word.shift();
  var words = ["dream","dreamer","erase","eraser"];
  var rwords = [];
  for(var i of words){
    rwords.push(i.split('').reverse());
  }
  while((word!='')&&(NG!=4)){
    var NG = 0;
    r: for(var i of rwords){
      for(var j=0;j<i.length;j++){
        if(word[j]!=i[j]){
          NG++;
          break;
        }
        if(j==i.length-1){
          word.splice(0,i.length);
          break r;
        }
      }
    }

  }
  if(word==''){
    console.log('YES');
  }else{
    console.log('NO');
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


"use strict";

const main = arg => {
    arg = arg.trim().split("\n");
    const S = arg[0].split("");
    const reversed = [...S].reverse();

    let temp = [];

    for(let i in S) {
        if(S.slice(-5).join("") === "erase" || S.slice(-5).join("") === "dream") {
            S.splice(S.length - 5, 5);
        } else if(S.slice(-6).join("") === "eraser" || S.slice(-6).join("") === "dreamer") {
            S.splice(S.length - 6, 6);
        } else {
            console.log("NO");
            return;
        }
    }

    console.log("YES");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function reverse(s) {
  return s.split('').reverse().join('');
}

function r_search(input){
  const words = ['dreamer', 'dream', 'eraser', 'erase'];
  const reversed_words = words.map(x => reverse(x));
  var current_input = reverse(input);

  length_check_loop: while(current_input!=""){
    for(word of reversed_words){

      if(current_input.startsWith(word)){
        current_input = current_input.substring(word.length)
        continue length_check_loop;
      }
    }
    return false;
  }
  return true;
}

function main(input) {
  if(r_search(input)){
    console.log('YES');
  }else{
    console.log('NO');
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function reverse(s) {
  return s.split('').reverse().join('');
}

function r_search(input){
  const words = ['dreamer', 'dream', 'eraser', 'erase'];
  const reversed_words = words.map(x => reverse(x));
  var current_input = reverse(input);

  length_check_loop: while(current_input.length > 0){
    for(word of reversed_words){
      if(current_input.startsWith(word)){
        current_input = current_input.substring(word.length)
        continue length_check_loop;
      }
    }
    return false;
  }
  return true;
}

function main(input) {
  if(r_search(input)){
    console.log('YES');
  }else{
    console.log('NO');
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


"use strict";

var main = function main(input) {
  var revInput = input.trim().split('').reverse().join('');
  var flag = true;

  for (var i = 0; i < revInput.length; i++) {
    if (revInput.charAt(i) == 'm') {
      if (revInput.slice(i, i + 5) === 'maerd') {
        i += 4;
      } else {
        flag = false;
        break;
      }
    } else if (revInput.charAt(i) == 'e') {
      if (revInput.slice(i, i + 5) === 'esare') {
        i += 4;
      } else {
        flag = false;
        break;
      }
    } else if (revInput.charAt(i) == 'r') {
      if (revInput.slice(i, i + 6) === 'resare') {
        i += 5;
      } else if (revInput.slice(i, i + 7) === 'remaerd') {
        i += 6;
      } else {
        flag = false;
        break;
      }
    }
  }

  console.log(flag == true ? 'Yes' : 'No');
};

main(require('fs').readFileSync('/dev/stdin', 'utf-8'));


var S = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')[0]
var ans = 0
var status =0
while(status == 0){
  	//console.log(S,status)
  	if(S != ""){
		var seven = S.slice(-7);
      	var six = S.slice(-6)
		var five = S.slice(-5);
      	//console.log(six)
		if(seven =="dreamer"){
	      S = S.slice(0,-7)
    	}
      	else if(six =="eraser"){
	      S = S.slice(0,-6)
    	}
		else if(five == "dream" || five == "erase"){
          //console.log(five)
	      S = S.slice(0,-5)
	    }
  		else{
      		status = 1
      		console.log("NO")
    	}
    }else{
      status =1;
      console.log("YES")
    }
}


function main(input) {
    const reverseString = (s) => {
        // var ret='';
	    // for (var i = cad.length-1; i>=0; i--)
		//     ret+=cad[i];
	    // return ret;
        return s.split('').reverse().join('');
    };

    // 文字列を反転
    const WORDS = ['dream', 'dreamer', 'erase', 'eraser'].map(reverseString);
    var S = reverseString(input);

    var index = 0;

    while(S.length > 0) {
        // var w = WORDS.find((w) => S.startsWith(w, index));
        // if (!w) break;
        // index += w.length;
        var w = WORDS.find((w) => S.startsWith(w));
        if (!w) break;
        S = S.substr(w.length);
    }

    if (S.length === index) {
        console.log('YES');
    } else {
        console.log('NO');
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function main(input) {
    const reverseString = (s) => {
        return s.split('').reverse().join('');
    };

    // 文字列を反転
    const WORDS = ['dream', 'dreamer', 'erase', 'eraser'].map(reverseString);
    var S = reverseString(input);

    var index = 0;

    while(true) {
        // var w = WORDS.find((w) => S.startsWith(w, index));
        // if (!w) break;
        // index += w.length;
        var w = WORDS.find((w) => S.startsWith(w));
        if (!w) break;
        S = S.substr(w.length);
    }

    if (S.length === index) {
        console.log('YES');
    } else {
        console.log('NO');
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function Main(input) {
	var lastChar = "";
  var output = 0;
  for(var i = 0; i < input.length; i++){
    var tmp = input.slice(i,i + 1);
    if(lastChar == ""){
       lastChar = tmp;
      continue;
    }else{
       if(lastChar != tmp){
          lastChar = tmp;
         output++;
          }
    }
  }
  console.log(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Score : 300 points

Problem Statement

Two foxes Jiro and Saburo are playing a game called 1D Reversi. This game is played on a board, using black and white stones. On the board, stones are placed in a row, and each player places a new stone to either end of the row. Similarly to the original game of Reversi, when a white stone is placed, all black stones between the new white stone and another white stone, turn into white stones, and vice versa.

In the middle of a game, something came up and Saburo has to leave the game. The state of the board at this point is described by a string S. There are |S| (the length of S) stones on the board, and each character in S represents the color of the i-th (1 ≦ i ≦ |S|) stone from the left. If the i-th character in S is B, it means that the color of the corresponding stone on the board is black. Similarly, if the i-th character in S is W, it means that the color of the corresponding stone is white.

Jiro wants all stones on the board to be of the same color. For this purpose, he will place new stones on the board according to the rules. Find the minimum number of new stones that he needs to place.

Constraints

1 ≦ |S| ≦ 10^5

Each character in S is B or W.

Input

The input is given from Standard Input in the following format:

S

Output

Print the minimum number of new stones that Jiro needs to place for his purpose.

Sample Input 1

BBBWW

Sample Output 1

1

By placing a new black stone to the right end of the row of stones, all white stones will become black. Also, by placing a new white stone to the left end of the row of stones, all black stones will become white.

In either way, Jiro's purpose can be achieved by placing one stone.

Sample Input 2

WWWWWW

Sample Output 2

0

If all stones are already of the same color, no new stone is necessary.

Sample Input 3

WBWBWBWBWB

Sample Output 3

9


"use strict";

const main = arg => {
    arg = arg.trim().split("\n");
    const S = arg[0].split("");
    const list = [];

    let last;

    for(let i in S) {
        if(S[i] !== last) {
            list.push(S[i]);
        }

        last = S[i];
    }

    console.log(list.join("").length - 1);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function Main(input) {
  input = input.split("\n");
  var s = input[0];
  if(s.match(/BW/g)){
  var l1 = s.match(/BW/g).length;
  }else{
    l1=0;
  }
  if(s.match(/WB/g)){
  var l2 = s.match(/WB/g).length;
  }else{
    l2=0;
  }
  console.log('%s', l1+l2);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


let _inputLines;
let _lineNumber = 0;
let inputReader = _inputReader ();

function _main() {

	_inputLines = _inputData.trim().split('\n').map((string) => {
		return string.trim();
	});;

	let [a, b] = inputReader.readArray();
	//console.log(typeof c);
	a = parseInt(a);
	b = parseInt(b);
	//c = parseInt(c);
	let arr = [];
	for(let i=0;i<a;i++){
		let str = inputReader.readLine().split('').sort().join('');
		arr.push(str);
	}
	arr.sort();
	let res='';
	for (let array of arr){
		res+=array;
	}
	console.log(res);

	// let input = inputReader.readLine().split(' ');
	// let a = input[0];
	// let b = input[1];
	// //let b = inputReader.readLine().split('');
	// //console.log(a,b);

	// let res = '';
	// for(let i=0;i<size;i++){
	//     res +=a[i];
	//     res+=b[i];
	// }
	// console.log(res);

	//console.log(noOfTestCases,typeof noOfTestCases);
	// while(noOfTestCases--){
	//     let [a,b] = inputReader.readNumberArray();
	//     let count = 1;
	//     if(a<=2){
	//         console.log(1);
	//         continue;
	//     }
	//     let floor;
	//     if((a-2)%b===0)
	//         floor = (a-2)/b +1;
	//     else
	//          floor = Math.ceil((a-2)/b)+1;
	//     console.log(floor);

	// }

}

var _inputData = '';
function cacheInput(data) {
	_inputData += data;
}

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', cacheInput).on('end', _main);

function _inputReader () {
	function readArray() {
		return _inputLines[_lineNumber++].split(' ');
	}

	function readLine(){
		return _inputLines[_lineNumber++];
	}

	function readNumberArray(){
		return _inputLines[_lineNumber++].split(' ').map(val => Number(val));
	}

	return {
		readArray,
		readLine,
		readNumberArray,
	}
}

Score : 200 points

Problem Statement

Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L.

She will concatenate all of the strings in some order, to produce a long string.

Among all strings that she can produce in this way, find the lexicographically smallest one.

Here, a string s=s_1s_2s_3...s_n is lexicographically smaller than another string t=t_1t_2t_3...t_m if and only if one of the following holds:

There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i.

s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.

Constraints

1 ≦ N, L ≦ 100

For each i, the length of S_i equals L.

For each i, S_i consists of lowercase letters.

Input

The input is given from Standard Input in the following format:

N L
S_1
S_2
:
S_N

Output

Print the lexicographically smallest string that Iroha can produce.

Sample Input 1

3 3
dxx
axx
cxx

Sample Output 1

axxcxxdxx

The following order should be used: axx, cxx, dxx.


function main(input) {
  const args = input.split('\n');
  const ary1 = args[0].split(' ').map(n => parseInt(n, 10));
  const N = ary1[0];
  const L = ary1[1];
  let ary2 = [];

  for (let i = 1; i <= N; i++) {
  	ary2.push(args[i]);
  }

  ary2 = ary2.sort((a, b) => {
  	a = a.toString().toLowerCase();
    b = b.toString().toLowerCase();
    if (a < b) {
      return -1;
    } else if (a > b) {
      return 1;
    }
    return 0;
  });

  console.log(ary2.join(''));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


"use strict"
const assert = require('assert');

function main(input) {
    let ret = check(input);
    console.log(ret);
}

function check(input) {
    let [n, array] = input.split(" ");
    let ls = array.split("\n");
    let l = ls[0];
    l = parseInt(l);
    let s = ls.slice(1, n + 1);
    s.sort(function (a, b) {
        return (a < b ? -1 : 1);
    });
    let ans = (s.join(""));
    return ans;
}

var input;
input = require('fs').readFileSync('/dev/stdin', 'utf8');
main(input);

// check
// var answer;

// input = `3 3
// dxx
// axx
// cxx`;
// answer = "axxcxxdxx";
// assert.equal(check(input), answer);


"use strict"
const assert = require('assert');

function main(input) {
    let ret = check(input);
    console.log(ret);
}

function check(input) {
    let [n, array] = input.split(" ");
    let ls = array.split("\n");
    let l = ls[0];
    l = parseInt(l);
    let s = ls.slice(1, n + 1);
    s.sort(function (a, b) {
        return (a < b ? -1 : 1);
    }
    );
    let ans = (s.join(""))
    return ans;
}

var input;
input = require('fs').readFileSync('/dev/stdin', 'utf8');
main(input);

// check
// var answer;

// input = `3 3
// dxx
// axx
// cxx`;
// answer = "axxcxxdxx";
// assert.equal(check(input), answer);


'use strict'

const Main = (input) => {
  const tmp = input.trim().split('\n')
  const N = parseInt(tmp[0].split(' ')[0])
  const L = parseInt(tmp[0].split(' ')[1])

  const Sarr = []
  for (let i = 1; i < tmp.length; i++) {
    Sarr.push(tmp[i])
  }

  let result = Sarr.sort().join('')

  console.log(result)
  return result
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))


function Main(input) {

  const inputs = input.split("\n");

  inputs = inputs.shift().join('');

  console.log(inputs);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


"use strict"
function main(arg) {
  const data = arg.trim().split("\n")
  console.log(solve(data.slice(1)))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function solve(arr) {
  arr.sort((s1, s2) => s1.localeCompare(s2))
  return arr.join('')
}


"use strict"
function main(arg) {
  const data = arg.trim().split("\n")
  console.log(solve(data.slice(1)))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function solve(arr) {
  return arr.sort((s1, s2) => s1 > s2).join('')
}


function Main(input) {
  var s = input.split("\n").slice(1).map(e => e).sort().join("");
  console.log(s);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


(function (n) {
  console.log(n.split('\n').slice(1).sort().join(''));
}(require("fs").readFileSync("/dev/stdin", "utf8")));