function main(input){
  var k = parseInt(input[0].split(' ')[1]);
  var line1 = input[1].split(' ');
  var arr = Array(line1.length);
  arr[0] = 0;
  for (var i=1; i<line1.length; i++){
    var min = null;
    for (var j=0; j<k; j++){
      if (i-j-1 >= 0) {
        var newMin = Math.abs(parseInt(line1[i-j-1]) - parseInt(line1[i])) + arr[i-j-1];
        if (min == null || newMin < min) min = newMin;
      }
    }
    arr[i] = min;
  }

  console.log(arr[line1.length-1]);
}

var input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main(input);
});


function main(input){
  var k = parseInt(input[0].split(' ')[1]);
  var line1 = input[1].split(' ');
  var arr = Array(line1.length);
  arr[0] = 0;
  for (var i=1; i<line1.length; i++){
    var arr2 = Array(k);
    for (var j=0; j<k; j++){
      if (i-j-1 < 0) arr2[j] = -1;
      else arr2[j] = Math.abs(parseInt(line1[i-j-1]) - parseInt(line1[i])) + arr[i-j-1];
    }
    var min = arr2.filter(n=>n>=0).reduce((n,min)=>n>=0&&min>n?n:min, arr2[0]);
    arr[i] = min;
  }

  console.log(arr[line1.length-1]);
}

var input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main(input);
});

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

Score : 100 points

Problem Statement

There are N stones, numbered 1, 2, \ldots, N.
For each i (1 \leq i \leq N), the height of Stone i is h_i.

There is a frog who is initially on Stone 1.
He will repeat the following action some number of times to reach Stone N:

If the frog is currently on Stone i, jump to one of the following: Stone i + 1, i + 2, \ldots, i + K. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on.

Find the minimum possible total cost incurred before the frog reaches Stone N.

Constraints

All values in input are integers.

2 \leq N \leq 10^5

1 \leq K \leq 100

1 \leq h_i \leq 10^4

Input

Input is given from Standard Input in the following format:

N K
h_1 h_2 \ldots h_N

Output

Print the minimum possible total cost incurred.

Sample Input 1

5 3
10 30 40 50 20

Sample Output 1

30

If we follow the path 1 → 2 → 5, the total cost incurred would be |10 - 30| + |30 - 20| = 30.

Sample Input 2

3 1
10 20 10

Sample Output 2

20

If we follow the path 1 → 2 → 3, the total cost incurred would be |10 - 20| + |20 - 10| = 20.

Sample Input 3

2 100
10 10

Sample Output 3

0

If we follow the path 1 → 2, the total cost incurred would be |10 - 10| = 0.

Sample Input 4

10 4
40 10 20 70 80 10 20 70 80 60

Sample Output 4

40

If we follow the path 1 → 4 → 8 → 10, the total cost incurred would be |40 - 70| + |70 - 70| + |70 - 60| = 40.

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.


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 ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = parseInt(a[i]);

    return a;
}

function main(){
    let [n,k] = ti(readline().split(' '));
    let w = new Array(n);
    let v = new Array(n);

    for(let i = 0; i < n; i++){
        let [x,y] = ti(readline().split(' '));
        w[i] = x;
        v[i] = y;
    }

    let dp = new Array(k+1);
    for(let i = 0; i < k+1; i++){
        dp[i] = new Array(n);
    }

    for(let i = 0; i < k+1; i++){
        for(let j = 0; j < n; j++){
            if(j === 0){
                dp[i][j] = w[j] <= i ? v[j] : 0;
            }else{
                if(i-w[j] >= 1)
                    dp[i][j] = Math.max(dp[i][j-1], v[j] + dp[i-w[j]][j-1]);
                else
                    dp[i][j] = dp[i][j-1];
            }
        }
    }

    console.log(dp[k][n-1]);
}

Score : 100 points

Problem Statement

There are N items, numbered 1, 2, \ldots, N.
For each i (1 \leq i \leq N), Item i has a weight of w_i and a value of v_i.

Taro has decided to choose some of the N items and carry them home in a knapsack.
The capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W.

Find the maximum possible sum of the values of items that Taro takes home.

Constraints

All values in input are integers.

1 \leq N \leq 100

1 \leq W \leq 10^5

1 \leq w_i \leq W

1 \leq v_i \leq 10^9

Input

Input is given from Standard Input in the following format:

N W
w_1 v_1
w_2 v_2
:
w_N v_N

Output

Print the maximum possible sum of the values of items that Taro takes home.

Sample Input 1

3 8
3 30
4 50
5 60

Sample Output 1

90

Items 1 and 3 should be taken.
Then, the sum of the weights is 3 + 5 = 8, and the sum of the values is 30 + 60 = 90.

Sample Input 2

5 5
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000

Sample Output 2

5000000000

The answer may not fit into a 32-bit integer type.

Sample Input 3

6 15
6 5
5 6
6 4
6 6
3 5
7 2

Sample Output 3

17

Items 2, 4 and 5 should be taken.
Then, the sum of the weights is 5 + 6 + 3 = 14, and the sum of the values is 6 + 6 + 5 = 17.


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

// Your code here!
const max = (a)=>{
    let i = a.length;
    let max=-Infinity;
    while (i--) {
        if (a[i] > max)max = a[i];
    }
    return max;
}
const min = (a)=>{
    let i = a.length;
    let max=Infinity;
    while (i--) {
        if (a[i] < max)max = a[i];
    }
    return max;
}
const Main = (p)=>{
	p = p.split("\n");//2 or more
	//let N = parseInt(p[0]);//N
	let N = parseInt(p[0].split(" ")[0]);//N M
	let W = parseInt(p[0].split(" ")[1]);//N M
	//let h = (p[1].split(" ").map(Number));//a1 a2 a3...

	let w = new Array(N);
	let v = new Array(N);
	//let c=new Array(N);
    //let z=new Array(N);
    for(let i=0;i<N;i++){
        let h = (p[i+1].split(" ").map(Number));
        w[i]=h[0];
        v[i]=h[1];
    }
	let m = new Array(N+1);
    //console.log(N,W,w,v);return;
    m[0]=new Array(W+1).fill(0);
    for(let i=0;i<N;i++){
        m[i+1]=m[i].concat();
        for(let j=0;j<=W;j++){
            if(j-w[i]>=0){
                //console.log(m[i][j-w[i]]+v[i],m[i][j])
                m[i+1][j]=Math.max(m[i][j-w[i]]+v[i],m[i][j]);
            }

        }
        //console.log(i,m[i])
    }
	//console.log(c);
	console.log(max(m[N]));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){return "";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var W = one[1];
  var dp = new Array(N + 1);
  for(var i = 0; i < N + 1; i++){
    dp[i] = new Array(W + 1).fill(0);
  }

  for(var i = 1; i <= N; i++){
    var tmp = nextIntArray();
    var value = tmp[1];
    var weight = tmp[0];
    for(var j = 0; j <= W; j++){
      dp[i][j] = dp[i - 1][j];
    }
    for(var j = weight; j <= W; j++){
      dp[i][j] = Math.max(dp[i - 1][j],dp[i - 1][j - weight] + value);
    }
  }
  //myerr(dp);
  myout(dp[N][W]);
}


//実験３：アドバイスに基づいて再帰で組む
//グローバル変数の定義
var N = 0;
var W = 0;
var obj = [];
var dp = [];
//再帰処理
function RecursiveDp(i,j){

  //メモによる再処理防止
  if (dp[i][j] != 0) {
    return dp[i][j];
  }

  var res = 0;
  if (i === N) {
    //商品がもうないので0を代入する
    res = 0;
  } else if (j < obj[i][0]) {
    //容量不足なので入れない処理だけをする
    res = RecursiveDp(i+1, j);
  } else {
    //入れると最大になるとは限らないので入れる時と入れない時の大きい方を取る
    res = Math.max(RecursiveDp(i+1, j), RecursiveDp(i+1,j-obj[i][0])+obj[i][1]);
  }
  dp[i][j] = res;
  return res;
}
function Main(input){
  //パラメータ受け取り
  input = input.split("\n");
  inputStr = input[0].split(" ");
  N = Number.parseInt(inputStr[0]);
  W = Number.parseInt(inputStr[1]);
  //要素の溜め込み
  for(var i=0 ; i<N ; i++){
    inputStr = input[i+1].split(" ");
    obj.push(inputStr.map( inputStr => parseInt(inputStr)))
  }
  //DP用メモの作成
  for(var i=0 ; i<=N ; i++){
    dp.push(Array(W+1).fill(0));
  }
  //再帰しつつ結果を出力
  console.log(RecursiveDp(0,W));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


//実験２：総和からの消し込み
//重くて価値が低い順にソート
//重さが基準以下となるまで、価値が低い順に引いていく
function Main(input){
  //パラメータ受け取り
  input = input.split("\n");
  inputStr = input[0].split(" ");
  var N = Number.parseInt(inputStr[0]);
  var W = Number.parseInt(inputStr[1]);
  var obj = [];
  var t_w = 0;
  var t_v = 0;
  for(var i=0 ; i<N ; i++){
    inputStr = input[i+1].split(" ");
    obj.push(inputStr.map( inputStr => parseInt(inputStr)))
    //総重量と総価値を記録
    t_w += obj[obj.length-1][0];
    t_v += obj[obj.length-1][1];
  }
  //console.log("総重量",t_w);
  //console.log("総価値",t_v);

  //ソート(価値を昇順[1]、重さを降順[0]でソート)
  obj.sort(function(a, b){
    	//重さを降順
		if (a[0] > b[0]) return -1;
		if (a[0] < b[0]) return 1;
		//価値は昇順
		if (a[1] > b[1]) return 1;
		if (a[1] < b[1]) return -1;
		return 0;
  });
  //重量(t_w)がW以下になるまで、価値(t_v)から消しこむ
  var i=0;
  while(t_w>W){
    t_w -= obj[i][0];
    t_v -= obj[i][1];
    i++;
  }
  //console.log("消し込み後重量",t_w);
  //console.log("その時の価値",t_v);
  console.log(t_v);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function main(input){
  const lines = input.split('\n');
  const NW = lines.shift().split(' ').map(x => parseInt(x));
  const N = NW[0]
  const W = NW[1]
  const items = lines.map(line => line.split(' ').map(x => parseInt(x)) );

//console.log(N);
//console.log(W);
//console.log(items);

  dp = Array(W+1)
  for(var i=0;i<W+1;i++){
    dp[i] = Array(N+1).fill(0);
  }

  for(var i=0;i<N;i++){
    for(var w=0;w<=W;w++){

      var weight = items[i][0]
      var value = items[i][1]
//console.log([weight, value, w,i]);
      if(weight <= w){
        dp[w][i+1] = Math.max(dp[w][i+1], dp[w-weight][i] + value);
      }else{
        dp[w][i+1] = dp[w][i];
      }

    }
  }

  const result = Math.max( ...dp.map(arr => Math.max(...arr)) )
  console.log(result);

}

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


'use strict';
console.log(function(args){
  const tmp = args.trim().split('\n');
  const s = tmp[0], t = tmp[1];
  const sl = s.length, tl = t.length;
  const dp = [Array(tl+1).fill('')];
  for ( let i = 0; i < sl; i++ ) {
    dp.push(['']);
    for ( let j = 0; j < tl; j++ ) {
      dp[i+1].push('');
      if ( t[j] === s[i] ) dp[i+1][j+1] = dp[i][j] + s[i];
      if ( dp[i+1][j+1].length < dp[i+1][j].length ) dp[i+1][j+1] = dp[i+1][j];
      if ( dp[i+1][j+1].length < dp[i][j+1].length ) dp[i+1][j+1] = dp[i][j+1];
    }
  }
  return dp[sl][tl];
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Score : 100 points

Problem Statement

You are given strings s and t.
Find one longest string that is a subsequence of both s and t.

Notes

A subsequence of a string x is the string obtained by removing zero or more characters from x and concatenating the remaining characters without changing the order.

Constraints

s and t are strings consisting of lowercase English letters.

1 \leq |s|, |t| \leq 3000

Input

Input is given from Standard Input in the following format:

s
t

Output

Print one longest string that is a subsequence of both s and t.
If there are multiple such strings, any of them will be accepted.

Sample Input 1

axyb
abyxb

Sample Output 1

axb

The answer is axb or ayb; either will be accepted.

Sample Input 2

aa
xayaz

Sample Output 2

aa

Sample Input 3

a
z

Sample Output 3

The answer is (an empty string).

Sample Input 4

abracadabra
avadakedavra

Sample Output 4

aaadara


'use strict'

function solve(S, T) {
  var dp = new Array(S.length + 1).fill(0).map(e => new Array(T.length + 1).fill([0, '']))
  for (var i = 1; i <= S.length; i++) {
    for (var j = 1; j <= T.length; j++) {
      if (S[i-1] === T[j-1]) {
        dp[i][j] = [1 + dp[i-1][j-1][0], dp[i-1][j-1][1] + S[i-1]]
      } else {
        var val = dp[i][j-1][0] > dp[i-1][j][0] ? dp[i][j-1][0] : dp[i-1][j][0]
        var s = dp[i][j-1][0] > dp[i-1][j][0] ? dp[i][j-1][1] : dp[i-1][j][1]
        dp[i][j] = [val, s]
      }
    }
  }
  return dp[S.length][T.length][1]
}

function main(input) {
  var lines = input.split("\n")
  var S = lines[0]
  var T = lines[1]
  var ans = solve(S,T)
  console.log(ans)
}

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


'use strict'
const lines = require('fs').readFileSync(0, 'utf8').split('\n')
const s = lines[0]
const t = lines[1]
var dp = new Array(s.length + 1).fill("");

for (let i=0;i < s.length;i++) {
  const temp = i
  const jtemp = 0
  for (let j=0;j < t.length;j++) {
    if (s.charAt(temp) == t.charAt(j)) {
      dp[i] = dp[i] + t.charAt(j)
      temp++
      jtemp = j
    }

    if (j == t.length - 1 && temp < s.length) {
      temp++
      j = jtemp
    }
  }
}
var max = ""
for (let i=0;i < dp.length;i++) {
  if (dp[i].length > max.length) max = dp[i]
}
console.log(max)


function main(input){
  const lines = input.split('\n');
  const S = lines.shift().split('');
  const T = lines.shift().split('');

  dp = []
  for(var i=0;i<=S.length;i++){
    dp.push( Array(T.length+1).fill(0) );
  }

  for(var i=1;i<=S.length;i++){
    for(var j=1;j<=T.length;j++){
      if(S[i-1]==T[j-1]){
        dp[i][j]=Math.max(dp[i][j], dp[i-1][j-1]+1);
      }else{
        dp[i][j]=Math.max(dp[i-1][j], dp[i][j-1]);
      }
    }
  }

  var i = S.length;
  var j = T.length;
  var result = [];
  while(i!=0 &&  j!=0){
    if(S[i-1]==T[j-1]){
      result.unshift(S[i-1]);
      i--;
      j--;
    }else{
      if(dp[i-1][j] < dp[i][j-1]){
        j--;
      }else{
        i--;
      }
    }
  }

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

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


'use strict';
(function(input){
  input=input.trim().split(/\n/);
  const s=input[0];
  const S=s.length;
  const t=input[1];
  const T=t.length;
  const dp=new Array(S+1).fill('場所取り').map(x=>new Array(T+1).fill(0));
  //console.log(dp);
  for(let i=0;i<S;i++){
    for(let j=0;j<T;j++){
      let cs=s[i];
      let ct=t[j];
      if(cs===ct){
        dp[i+1][j+1]=dp[i][j]+1;
      }else{
        dp[i+1][j+1]=Math.max(dp[i][j+1],dp[i+1][j]);
      }
    }
  }
  console.log(dp);
  var ans='';
  var I=S,J=T;
  while(I>0&&J>0){
    //console.log(I,J);
    if(dp[I][J]===dp[I][J-1])
      J--;
    else if(dp[I][J]===dp[I-1][J])
      I--;
    else{
      ans=s[I-1]+ans;
      I--;
      J--;
    }
  }
  console.log(ans);
})(require('fs').readFileSync('/dev/stdin','utf8'));


function Main(input) {
  input = input.split("\n");
  var s = input[0].split("");
  var t = input[1].split("");
  var dp =new Array(s.length+1);
  for(var i=0;i<s.length+1;i++){
    var tmp=new Array(t.length+1).fill(0);
    dp[i]=tmp;
  }
  for(var i=0;i<s.length;i++){
    for(var j=0;j<t.length;j++){
      if(s[i]==t[j]){
        dp[i+1][j+1]=Math.max(dp[i][j]+1,dp[i+1][j+1]);
      }
      dp[i+1][j+1]=Math.max(dp[i+1][j],dp[i+1][j+1]);
      dp[i+1][j+1]=Math.max(dp[i][j+1],dp[i+1][j+1]);
    }
  }
  var i=s.length;
  var j=t.length;
  var ans="";
  while(i>0&&j>0){
    if(dp[i][j]==dp[i-1][j]){
      i--;
    }else if(dp[i][j]==dp[i][j-1]){
      j--;
    }else{
      ans=s[i-1]+ans;
      i--;
    }
  }

  console.log('%s', ans);
  return ans;
}
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function Main(input) {
  input = input.split("\n");
  var s = input[0].split("");
  var t = input[1].split("");
  var M = [[-1]];
  var L = new Array();
  var maxj=0;
  var max=0;
  for(var i=0;i<t.length;i++){
    for(var j=0;j<M.length;j++){
      for(var k=M[j][M[j].length-1]+1;k<=s.length;k++){
        if(t[i]==s[k]){
          M.push([...M[j],k]);
          if(M[M.length-1].length>max){
            maxj=M.length-1;
            max=M[M.length-1].length;
          }
          break;
        }
      }
    }
  }
  var ans="";
  for(var i=1;i<max;i++){
    ans+=s[M[maxj][i]];
  }

  console.log('%s', ans);
  return ans;
}
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


'use strict';

function main(arg) {
  const input = arg.trim().split('\n');
  const d = Number(input[0]);
  const diff = 25 - d;
  let ans = 'Christmas';
  if (diff > 0) {
    ans = ans + ' Eve'.repeat(diff);
  }
  console.log(ans);
}

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

Score : 100 points

Problem Statement

In some other world, today is December D-th.

Write a program that prints Christmas if D = 25, Christmas Eve if D = 24, Christmas Eve Eve if D = 23 and Christmas Eve Eve Eve if D = 22.

Constraints

22 \leq D \leq 25

D is an integer.

Input

Input is given from Standard Input in the following format:

D

Output

Print the specified string (case-sensitive).

Sample Input 1

25

Sample Output 1

Christmas

Sample Input 2

22

Sample Output 2

Christmas Eve Eve Eve

Be sure to print spaces between the words.


function main(input){
    d=input;
    var a=["Christmas","Christmas Eve","Christmas Eve Eve","Christmas Eve Eve Eve"];
    var b=[25,24,23,22]
    for (var i = 0;i<4;i++){
        if (d==b[i]){
            console.log(a[i])
        }
    }
}

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


"use strict";
function Main(input) {
    let D = input.split("\n").map((v) => v - 0)[0];
    if (D == 25) console.log("Christmas");
    else if (D == 24) console.log("Christmas Eve");
    else if (D == 23) console.log("Christmas Eve Eve");
    else if (D == 22) console.log("Christmas Eve Eve Eve");
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function Main(input) {
	var day = parseInt(input, 10);
    if (day === 22) {
      console.log('Christmas Eve Eve Eve');
    } else if (day === 23) {
      console.log('Christmas Eve Eve');
    } else if (day === 24) {
      console.log('Christmas Eve');
    } else if (day === 25) {
      console.log('Christmas');
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

if (input === '25') {
  console.log('Christmas');
} else if (input === '24') {
  console.log('Christmas Eve');
} else if (input === '23') {
  console.log('Christmas Eve Eve');
} else {
  console.log('Christmas Eve Eve Eve');
}


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

const output;

if(output === '25') {
  output = 'Christmas';
} else if(output === '24') {
  output = 'Christmas Eve';
} else if(output === '23') {
  output = 'Christmas Eve Eve';
} else if(output === '22') {
  output = 'Christmas Eve Eve Eve';
} else {
  output = null;
}

console.log(output);


"use strict";
process.stdin.resume();
process.stdin.setEncoding('utf8');

var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
    let d = line;
    let diff = 25 - d;
    let ans = "Christmas";

    for (let i = 0; i < diff; i++) {
      ans += " Eve"
    }

    console.log(ans);
});


'use strict'
function Main(input) {
  const ar = input.split("\n").map(x => x.split(" "));
  const num = Number(ar[0]);

  const rep = 25 - num;
  console.log("Christmas" + " Eve".repeat(rep));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


  ans= Number.MAX_SAFE_INTEGER;
  l =require('fs').readFileSync('/dev/stdin','utf8').split("\n");
  k=Number(l[0].split(" ")[1])
  l.shift();
  l=l.map(n => Number(n)).sort((a,b)=> a-b);
  for(a=0;a<l.length-k+1;a++){
    dif=l[a+k-1]-l[a];
    if(dif < ans) ans = dif;
  }
  console.log(ans);


var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var d = o.a();
  var ans = "Christmas";
  for(; d< 25; d++)ans += " Eve";
  return ans;
}


function Main(input) {
  input = input.split("\n").map(x => parseInt(x, 10));

  const n = input[0];
  input.shift();

  const top = input.reduce((x, y) => math.Max(x, y));
  const sum = input.reduce((x, y) => x + y);

  console.log(sum - (top / 2))
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


'use strict'
const i = require("fs").readFileSync("/dev/stdin", "utf8");
let r;
switch (i) {
    case '22':
        r = 'Christmas Eve Eve Eve';
        break
    case '23':
        r = 'Christmas Eve Eve';
        break
    case '24':
        r = 'Christmas Eve'
        break
    case '25':
        r = 'Christmas';
        break
}
console.log(r);


'use strict'
const i = require("fs").readFileSync("/dev/stdin", "utf8");
let r = 'Christmas ';
switch (i) {
    case '22':
        r = r + 'Eve Eve Eve';
        break
    case '23':
        r = r + 'Eve Eve';
        break
    case '24':
        r = r + 'Eve'
        break
    case '25':
        r = r;
        break
}
console.log(r);


var Main = function(Input){
  var Result = '';
  if(Input == '25'){
    Result = 'Christmas';
  } else if(Input == '24'){
    Result = 'Christmas Eve';
  } else if(Input == '23'){
    Result = 'Christmas Eve Eve';
  } else if(Input == '22'){
    Result = 'Christmas Eve Eve Eve';
  }
  if(Result != ''){
    console.log(Result);
  }
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function main(input) {
    var args = input;

	switch (parseInt(args)) {
		case 25:
			console.log("Chritsmas");
			break;

		case 24:
			console.log("Christmas Eve");
			break;

		case 23:
			console.log("Chritsmas Eve Eve");
			break;

		case 22:
			console.log("Christmas Eve Eve Eve");
			break;

	}

}

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


s=require("fs").readFileSync("/dev/stdin","utf8");
if (s == "25") {
	console.log("Christmas");
} else if (s == "24") {
	console.log("Christmas Eve");
} else if (s == "23") {
	console.log("Christmas Eve Eve");
} else if (s == "22") {
	console.log("Christmas Eve Eve Eve");
}


"use strict";

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }

function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

function main(input) {
  var lines = input.split('\n');

  var _splitNum = splitNum(lines.shift()),
      _splitNum2 = _slicedToArray(_splitNum, 1),
      D = _splitNum2[0];

  switch (D) {
    case 25:
      console.log('Christmas');
      return;

    case 24:
      console.log('Christmas Eve');
      return;

    case 23:
      console.log('Christmas Eve Eve');
      return;

    case 22:
      console.log('Christmas Eve Eve Eve');
      return;
  }
}

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

function splitNum(line) {
  return line.split(/\s+/).map(function (n) {
    return parseInt(n);
  });
}


//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 N = nextInt();
  var max = 101;
  var dy = [-1,0,1,0];
  var dx = [0,-1,0,1];
  var list = new Array(max);
  var highList = new Array(max);
  var access = new Array(max);
  for(var i = 0; i < max; i++){
    list[i] = new Array(max).fill(0);
    highList[i] = new Array(max);
    access[i] = new Array(max).fill(false);
    for(var j = 0; j < max; j++){
      highList[i][j] = new Set();
    }
  }
  var check = new Array(N);
  for(var i = 0; i < N; i++){
    var tmp = nextIntArray();
    list[tmp[1]][tmp[0]] = tmp[2];
    //highList[tmp[1]][tmp[0]].add(tmp[2]);
    check[i] = [tmp[1], tmp[0]];
  }
  for(var i = 0; i < N; i++){
    if(list[check[i][0]][check[i][1]] != 0){
      bfs(check[i][0], check[i][1]);
    }
  }
  for(var i = 0; i < max; i++){
    for(var j = 0; j < max; j++){
      if(highList[i][j].size == 1){
        var output = Array.from(highList[i][j]);
        myout(j + " " + i + " " + output[0]);
        return;
      }
    }
  }
  var check2 = new Array(N);
  for(var i = 0; i < N; i++){
    check2[i] = check[i].join(":");
  }
  for(var i = 0; i < max; i++){
    for(var j = 0; j < max; j++){
      if(list[i][j] == 0 && check2.indexOf(i + ":" + j) == -1){
        myout(i + " " + j + " " + 1);
        return;
      }
    }
  }

  function bfs(y, x){
    for(var i = 0; i < max; i++){
      access[i] = new Array(max).fill(false);
    }
    access[y][x] = true;
    var queue = [[y, x, list[y][x]]];
    while(queue.length > 0){
      var now = queue.shift();
      var nowY = now[0];
      var nowX = now[1];
      var value = now[2];
      highList[nowY][nowX].add(value);
      for(var i = 0; i < dy.length; i++){
        var nextY = nowY + dy[i];
        var nextX = nowX + dx[i];
        if(nextY >= 0 && nextY < max && nextX >= 0 && nextX < max){
          if(!access[nextY][nextX]){
            access[nextY][nextX] = true;
            queue.push([nextY, nextX, value + 1]);
          }
        }
      }
    }
  }
}

Score: 300 points

Problem Statement

In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc.

The pyramid had center coordinates (C_X, C_Y) and height H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0).

Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information:

C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1.

Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i."

This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.

Constraints

N is an integer between 1 and 100 (inclusive).

x_i and y_i are integers between 0 and 100 (inclusive).

h_i is an integer between 0 and 10^9 (inclusive).

The N coordinates (x_1, y_1), (x_2, y_2), (x_3, y_3), ..., (x_N, y_N) are all different.

The center coordinates and the height of the pyramid can be uniquely identified.

Input

Input is given from Standard Input in the following format:

N
x_1 y_1 h_1
x_2 y_2 h_2
x_3 y_3 h_3
:
x_N y_N h_N

Output

Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between.

Sample Input 1

4
2 3 5
2 1 5
1 2 5
3 2 5

Sample Output 1

2 2 6

In this case, the center coordinates and the height can be identified as (2, 2) and 6.

Sample Input 2

2
0 0 100
1 1 98

Sample Output 2

0 0 100

In this case, the center coordinates and the height can be identified as (0, 0) and 100.

Note that C_X and C_Y are known to be integers between 0 and 100.

Sample Input 3

3
99 1 191
100 1 192
99 0 192

Sample Output 3

100 0 193

In this case, the center coordinates and the height can be identified as (100, 0) and 193.


//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 N = nextInt();
  var max = 101;
  var dy = [-1,0,1,0];
  var dx = [0,-1,0,1];
  var list = new Array(max);
  var highList = new Array(max);
  var access = new Array(max);
  for(var i = 0; i < max; i++){
    list[i] = new Array(max).fill(0);
    highList[i] = new Array(max);
    access[i] = new Array(max).fill(false);
    for(var j = 0; j < max; j++){
      highList[i][j] = new Set();
    }
  }
  var check = new Array(N);
  for(var i = 0; i < N; i++){
    var tmp = nextIntArray();
    list[tmp[1]][tmp[0]] = tmp[2];
    //highList[tmp[1]][tmp[0]].add(tmp[2]);
    check[i] = [tmp[1], tmp[0]];
  }
  for(var i = 0; i < N; i++){
    if(list[check[i][0]][check[i][1]] != 0){
      bfs(check[i][0], check[i][1]);
    }
  }
  for(var i = 0; i < max; i++){
    for(var j = 0; j < max; j++){
      if(highList[i][j].size == 1){
        var output = Array.from(highList[i][j]);
        myout(j + " " + i + " " + output[0]);
        return;
      }
    }
  }

  function bfs(y, x){
    for(var i = 0; i < max; i++){
      access[i] = new Array(max).fill(false);
    }
    access[y][x] = true;
    var queue = [[y, x, list[y][x]]];
    while(queue.length > 0){
      var now = queue.shift();
      var nowY = now[0];
      var nowX = now[1];
      var value = now[2];
      highList[nowY][nowX].add(value);
      for(var i = 0; i < dy.length; i++){
        var nextY = nowY + dy[i];
        var nextX = nowX + dx[i];
        if(nextY >= 0 && nextY < max && nextX >= 0 && nextX < max){
          if(!access[nextY][nextX]){
            access[nextY][nextX] = true;
            queue.push([nextY, nextX, value + 1]);
          }
        }
      }
    }
  }
}


'use strict';
const main = input => {
  const n = parseInt(input[0]);
  let x = new Array(n), y = new Array(n), h = new Array(n);
  for(let i=0; i<n; i++) {
    let s = input[i+1].split(' ');
    x[i] = parseInt(s[0]);
    y[i] = parseInt(s[1]);
    h[i] = parseInt(s[2]);
  }
  // console.log(n, x, y, h);
  for(let px=0; px<101; px++) {
    for(let py=0; py<101; py++) {
      let height = h[0]+Math.abs(px-x[0])+Math.abs(py-y[0]);
      let tf = 1;
      for(let k=1; k<n; k++) {
        if (height != h[k]+Math.abs(px-x[k])+Math.abs(py-y[k] || height < 1)) {
          tf = 0;
        }
      }
      if (tf==1) {
        console.log(px, py, height);
        return 0;

      }
    }
  }
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));


"use strict";

// read lines from stdin
const input = require("fs")
  .readFileSync("/dev/stdin", "utf8")
  .split("\n");

const N = parseInt(input[0], 10);
const points = [];
const outOfBounds = [];

for (let i = 1; i <= N; i++) {
  const line = input[i].split(" ").map((val) => parseInt(val, 10));
  if (line[2] > 0) {
    points.push({ x: line[0], y: line[1], h: line[2] });
  } else {
    outOfBounds.push({ x: line[0], y: line[1], h: line[2] });
  }
}

points.push(...outOfBounds);

for (let x = 0; x <= 100; x++) {
  for (let y = 0; y <= 100; y++) {
    let found = true;
    let estimate = {
      x,
      y,
      h: 0,
    }
    for (let i = 0; i < points.length; i++) {
      const point = points[i];

      if (estimate.h <= 0) {
        estimate.h = estimateTopHeight(point, estimate);
        continue;
      }

      if (!isValidHeight(point, estimate)) {
        found = false;
        break;
      }
    }

    if (found) {
      console.log(`${estimate.x} ${estimate.y} ${estimate.h}`);
      return;
    }
  }
}

function estimateTopHeight(current, top) {
  return current.h + Math.abs(top.x - current.x) + Math.abs(top.y - current.y);
}

function isValidHeight(current, top) {
  return Math.max(top.h - Math.abs(top.x - current.x) - Math.abs(top.y - current.y), 0) === current.h;
}


function main(input){
  const lines = input.split('\n');
  const N = parseInt(lines[0]);
  var vs = [];
  for(var i=0;i<N;i++){
    var line = lines[i+1].split(' ').map(x => parseInt(x));
    vs.push(line);
  }

  if(N==1){
    console.log(vs[0].join(' '));
    return;
  }

  const one_vs = vs.filter(v => v[2]>0);
  if(one_vs.length==1){
    console.log(one_vs[0].join(' '));
    return;
  }

  var candidates = [];
  for(var x=0;x<=100;x++){
    for(var y=0;y<=100;y++){
      var one_v = one_vs[0];
      var height = Math.abs(x - one_v[0]) + Math.abs(y - one_v[1]) + one_v[2]
      candidates.push([x,y,height]);
    }
  }

//console.log(candidates);

  var highest = [0,0,0];
  for(var j=0;j<candidates.length;j++){
    var candidate = candidates[j];
    var detected=true;
    for(var i=0;i<one_vs.length;i++){
      var one_v = one_vs[i];
      var tmp_height = Math.abs(candidate[0] - one_v[0]) + Math.abs(candidate[1] - one_v[1]) + one_v[2];
      if(candidate[2]!=tmp_height){detected=false;}
    }
    if(detected && candidate[2] > highest[2]){highest = candidate}
  }
  console.log(highest.join(' '));
}

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


parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"9xaU":[function(require,module,exports) {
var t=function(e){"use strict";var r=1e7,o=7,n=9007199254740992,i=h(n),u="0123456789abcdefghijklmnopqrstuvwxyz",p="function"==typeof BigInt;function a(t,e,r,o){return void 0===t?a[0]:void 0!==e&&(10!=+e||r)?$(t,e,r,o):Q(t)}function s(t,e){this.value=t,this.sign=e,this.isSmall=!1}function l(t){this.value=t,this.sign=t<0,this.isSmall=!0}function f(t){this.value=t}function v(t){return-n<t&&t<n}function h(t){return t<1e7?[t]:t<1e14?[t%1e7,Math.floor(t/1e7)]:[t%1e7,Math.floor(t/1e7)%1e7,Math.floor(t/1e14)]}function y(t){c(t);var e=t.length;if(e<4&&P(t,i)<0)switch(e){case 0:return 0;case 1:return t[0];case 2:return t[0]+t[1]*r;default:return t[0]+(t[1]+t[2]*r)*r}return t}function c(t){for(var e=t.length;0===t[--e];);t.length=e+1}function g(t){for(var e=new Array(t),r=-1;++r<t;)e[r]=0;return e}function m(t){return t>0?Math.floor(t):Math.ceil(t)}function d(t,e){var o,n,i=t.length,u=e.length,p=new Array(i),a=0,s=r;for(n=0;n<u;n++)a=(o=t[n]+e[n]+a)>=s?1:0,p[n]=o-a*s;for(;n<i;)a=(o=t[n]+a)===s?1:0,p[n++]=o-a*s;return a>0&&p.push(a),p}function w(t,e){return t.length>=e.length?d(t,e):d(e,t)}function b(t,e){var o,n,i=t.length,u=new Array(i),p=r;for(n=0;n<i;n++)o=t[n]-p+e,e=Math.floor(o/p),u[n]=o-e*p,e+=1;for(;e>0;)u[n++]=e%p,e=Math.floor(e/p);return u}function S(t,e){var o,n,i=t.length,u=e.length,p=new Array(i),a=0,s=r;for(o=0;o<u;o++)(n=t[o]-a-e[o])<0?(n+=s,a=1):a=0,p[o]=n;for(o=u;o<i;o++){if(!((n=t[o]-a)<0)){p[o++]=n;break}n+=s,p[o]=n}for(;o<i;o++)p[o]=t[o];return c(p),p}function q(t,e,o){var n,i,u=t.length,p=new Array(u),a=-e,f=r;for(n=0;n<u;n++)i=t[n]+a,a=Math.floor(i/f),i%=f,p[n]=i<0?i+f:i;return"number"==typeof(p=y(p))?(o&&(p=-p),new l(p)):new s(p,o)}function M(t,e){var o,n,i,u,p=t.length,a=e.length,s=g(p+a),l=r;for(i=0;i<p;++i){u=t[i];for(var f=0;f<a;++f)o=u*e[f]+s[i+f],n=Math.floor(o/l),s[i+f]=o-n*l,s[i+f+1]+=n}return c(s),s}function N(t,e){var o,n,i=t.length,u=new Array(i),p=r,a=0;for(n=0;n<i;n++)o=t[n]*e+a,a=Math.floor(o/p),u[n]=o-a*p;for(;a>0;)u[n++]=a%p,a=Math.floor(a/p);return u}function E(t,e){for(var r=[];e-- >0;)r.push(0);return r.concat(t)}function O(t,e,o){return new s(t<r?N(e,t):M(e,h(t)),o)}function B(t){var e,o,n,i,u=t.length,p=g(u+u),a=r;for(n=0;n<u;n++){o=0-(i=t[n])*i;for(var s=n;s<u;s++)e=i*t[s]*2+p[n+s]+o,o=Math.floor(e/a),p[n+s]=e-o*a;p[n+u]=o}return c(p),p}function I(t,e){var o,n,i,u,p=t.length,a=g(p),s=r;for(i=0,o=p-1;o>=0;--o)i=(u=i*s+t[o])-(n=m(u/e))*e,a[o]=0|n;return[a,0|i]}function A(t,e){var o,n=Q(e);if(p)return[new f(t.value/n.value),new f(t.value%n.value)];var i,u=t.value,v=n.value;if(0===v)throw new Error("Cannot divide by zero");if(t.isSmall)return n.isSmall?[new l(m(u/v)),new l(u%v)]:[a[0],t];if(n.isSmall){if(1===v)return[t,a[0]];if(-1==v)return[t.negate(),a[0]];var d=Math.abs(v);if(d<r){i=y((o=I(u,d))[0]);var w=o[1];return t.sign&&(w=-w),"number"==typeof i?(t.sign!==n.sign&&(i=-i),[new l(i),new l(w)]):[new s(i,t.sign!==n.sign),new l(w)]}v=h(d)}var b=P(u,v);if(-1===b)return[a[0],t];if(0===b)return[a[t.sign===n.sign?1:-1],a[0]];i=(o=u.length+v.length<=200?function(t,e){var o,n,i,u,p,a,s,l=t.length,f=e.length,v=r,h=g(e.length),c=e[f-1],m=Math.ceil(v/(2*c)),d=N(t,m),w=N(e,m);for(d.length<=l&&d.push(0),w.push(0),c=w[f-1],n=l-f;n>=0;n--){for(o=v-1,d[n+f]!==c&&(o=Math.floor((d[n+f]*v+d[n+f-1])/c)),i=0,u=0,a=w.length,p=0;p<a;p++)i+=o*w[p],s=Math.floor(i/v),u+=d[n+p]-(i-s*v),i=s,u<0?(d[n+p]=u+v,u=-1):(d[n+p]=u,u=0);for(;0!==u;){for(o-=1,i=0,p=0;p<a;p++)(i+=d[n+p]-v+w[p])<0?(d[n+p]=i+v,i=0):(d[n+p]=i,i=1);u+=i}h[n]=o}return d=I(d,m)[0],[y(h),y(d)]}(u,v):function(t,e){for(var o,n,i,u,p,a=t.length,s=e.length,l=[],f=[],v=r;a;)if(f.unshift(t[--a]),c(f),P(f,e)<0)l.push(0);else{i=f[(n=f.length)-1]*v+f[n-2],u=e[s-1]*v+e[s-2],n>s&&(i=(i+1)*v),o=Math.ceil(i/u);do{if(P(p=N(e,o),f)<=0)break;o--}while(o);l.push(o),f=S(f,p)}return l.reverse(),[y(l),y(f)]}(u,v))[0];var q=t.sign!==n.sign,M=o[1],E=t.sign;return"number"==typeof i?(q&&(i=-i),i=new l(i)):i=new s(i,q),"number"==typeof M?(E&&(M=-M),M=new l(M)):M=new s(M,E),[i,M]}function P(t,e){if(t.length!==e.length)return t.length>e.length?1:-1;for(var r=t.length-1;r>=0;r--)if(t[r]!==e[r])return t[r]>e[r]?1:-1;return 0}function Z(t){var e=t.abs();return!e.isUnit()&&(!!(e.equals(2)||e.equals(3)||e.equals(5))||!(e.isEven()||e.isDivisibleBy(3)||e.isDivisibleBy(5))&&(!!e.lesser(49)||void 0))}function x(e,r){for(var o,n,i,u=e.prev(),p=u,a=0;p.isEven();)p=p.divide(2),a++;t:for(n=0;n<r.length;n++)if(!e.lesser(r[n])&&!(i=t(r[n]).modPow(p,e)).isUnit()&&!i.equals(u)){for(o=a-1;0!=o;o--){if((i=i.square().mod(e)).isUnit())return!1;if(i.equals(u))continue t}return!1}return!0}s.prototype=Object.create(a.prototype),l.prototype=Object.create(a.prototype),f.prototype=Object.create(a.prototype),s.prototype.add=function(t){var e=Q(t);if(this.sign!==e.sign)return this.subtract(e.negate());var r=this.value,o=e.value;return e.isSmall?new s(b(r,Math.abs(o)),this.sign):new s(w(r,o),this.sign)},s.prototype.plus=s.prototype.add,l.prototype.add=function(t){var e=Q(t),r=this.value;if(r<0!==e.sign)return this.subtract(e.negate());var o=e.value;if(e.isSmall){if(v(r+o))return new l(r+o);o=h(Math.abs(o))}return new s(b(o,Math.abs(r)),r<0)},l.prototype.plus=l.prototype.add,f.prototype.add=function(t){return new f(this.value+Q(t).value)},f.prototype.plus=f.prototype.add,s.prototype.subtract=function(t){var e=Q(t);if(this.sign!==e.sign)return this.add(e.negate());var r=this.value,o=e.value;return e.isSmall?q(r,Math.abs(o),this.sign):function(t,e,r){var o;return P(t,e)>=0?o=S(t,e):(o=S(e,t),r=!r),"number"==typeof(o=y(o))?(r&&(o=-o),new l(o)):new s(o,r)}(r,o,this.sign)},s.prototype.minus=s.prototype.subtract,l.prototype.subtract=function(t){var e=Q(t),r=this.value;if(r<0!==e.sign)return this.add(e.negate());var o=e.value;return e.isSmall?new l(r-o):q(o,Math.abs(r),r>=0)},l.prototype.minus=l.prototype.subtract,f.prototype.subtract=function(t){return new f(this.value-Q(t).value)},f.prototype.minus=f.prototype.subtract,s.prototype.negate=function(){return new s(this.value,!this.sign)},l.prototype.negate=function(){var t=this.sign,e=new l(-this.value);return e.sign=!t,e},f.prototype.negate=function(){return new f(-this.value)},s.prototype.abs=function(){return new s(this.value,!1)},l.prototype.abs=function(){return new l(Math.abs(this.value))},f.prototype.abs=function(){return new f(this.value>=0?this.value:-this.value)},s.prototype.multiply=function(t){var e,o,n,i=Q(t),u=this.value,p=i.value,l=this.sign!==i.sign;if(i.isSmall){if(0===p)return a[0];if(1===p)return this;if(-1===p)return this.negate();if((e=Math.abs(p))<r)return new s(N(u,e),l);p=h(e)}return o=u.length,n=p.length,new s(-.012*o-.012*n+15e-6*o*n>0?function t(e,r){var o=Math.max(e.length,r.length);if(o<=30)return M(e,r);o=Math.ceil(o/2);var n=e.slice(o),i=e.slice(0,o),u=r.slice(o),p=r.slice(0,o),a=t(i,p),s=t(n,u),l=t(w(i,n),w(p,u)),f=w(w(a,E(S(S(l,a),s),o)),E(s,2*o));return c(f),f}(u,p):M(u,p),l)},s.prototype.times=s.prototype.multiply,l.prototype._multiplyBySmall=function(t){return v(t.value*this.value)?new l(t.value*this.value):O(Math.abs(t.value),h(Math.abs(this.value)),this.sign!==t.sign)},s.prototype._multiplyBySmall=function(t){return 0===t.value?a[0]:1===t.value?this:-1===t.value?this.negate():O(Math.abs(t.value),this.value,this.sign!==t.sign)},l.prototype.multiply=function(t){return Q(t)._multiplyBySmall(this)},l.prototype.times=l.prototype.multiply,f.prototype.multiply=function(t){return new f(this.value*Q(t).value)},f.prototype.times=f.prototype.multiply,s.prototype.square=function(){return new s(B(this.value),!1)},l.prototype.square=function(){var t=this.value*this.value;return v(t)?new l(t):new s(B(h(Math.abs(this.value))),!1)},f.prototype.square=function(t){return new f(this.value*this.value)},s.prototype.divmod=function(t){var e=A(this,t);return{quotient:e[0],remainder:e[1]}},f.prototype.divmod=l.prototype.divmod=s.prototype.divmod,s.prototype.divide=function(t){return A(this,t)[0]},f.prototype.over=f.prototype.divide=function(t){return new f(this.value/Q(t).value)},l.prototype.over=l.prototype.divide=s.prototype.over=s.prototype.divide,s.prototype.mod=function(t){return A(this,t)[1]},f.prototype.mod=f.prototype.remainder=function(t){return new f(this.value%Q(t).value)},l.prototype.remainder=l.prototype.mod=s.prototype.remainder=s.prototype.mod,s.prototype.pow=function(t){var e,r,o,n=Q(t),i=this.value,u=n.value;if(0===u)return a[1];if(0===i)return a[0];if(1===i)return a[1];if(-1===i)return n.isEven()?a[1]:a[-1];if(n.sign)return a[0];if(!n.isSmall)throw new Error("The exponent "+n.toString()+" is too large.");if(this.isSmall&&v(e=Math.pow(i,u)))return new l(m(e));for(r=this,o=a[1];!0&u&&(o=o.times(r),--u),0!==u;)u/=2,r=r.square();return o},l.prototype.pow=s.prototype.pow,f.prototype.pow=function(t){var e=Q(t),r=this.value,o=e.value,n=BigInt(0),i=BigInt(1),u=BigInt(2);if(o===n)return a[1];if(r===n)return a[0];if(r===i)return a[1];if(r===BigInt(-1))return e.isEven()?a[1]:a[-1];if(e.isNegative())return new f(n);for(var p=this,s=a[1];(o&i)===i&&(s=s.times(p),--o),o!==n;)o/=u,p=p.square();return s},s.prototype.modPow=function(t,e){if(t=Q(t),(e=Q(e)).isZero())throw new Error("Cannot take modPow with modulus 0");for(var r=a[1],o=this.mod(e);t.isPositive();){if(o.isZero())return a[0];t.isOdd()&&(r=r.multiply(o).mod(e)),t=t.divide(2),o=o.square().mod(e)}return r},f.prototype.modPow=l.prototype.modPow=s.prototype.modPow,s.prototype.compareAbs=function(t){var e=Q(t),r=this.value,o=e.value;return e.isSmall?1:P(r,o)},l.prototype.compareAbs=function(t){var e=Q(t),r=Math.abs(this.value),o=e.value;return e.isSmall?r===(o=Math.abs(o))?0:r>o?1:-1:-1},f.prototype.compareAbs=function(t){var e=this.value,r=Q(t).value;return(e=e>=0?e:-e)===(r=r>=0?r:-r)?0:e>r?1:-1},s.prototype.compare=function(t){if(t===1/0)return-1;if(t===-1/0)return 1;var e=Q(t),r=this.value,o=e.value;return this.sign!==e.sign?e.sign?1:-1:e.isSmall?this.sign?-1:1:P(r,o)*(this.sign?-1:1)},s.prototype.compareTo=s.prototype.compare,l.prototype.compare=function(t){if(t===1/0)return-1;if(t===-1/0)return 1;var e=Q(t),r=this.value,o=e.value;return e.isSmall?r==o?0:r>o?1:-1:r<0!==e.sign?r<0?-1:1:r<0?1:-1},l.prototype.compareTo=l.prototype.compare,f.prototype.compare=function(t){if(t===1/0)return-1;if(t===-1/0)return 1;var e=this.value,r=Q(t).value;return e===r?0:e>r?1:-1},f.prototype.compareTo=f.prototype.compare,s.prototype.equals=function(t){return 0===this.compare(t)},f.prototype.eq=f.prototype.equals=l.prototype.eq=l.prototype.equals=s.prototype.eq=s.prototype.equals,s.prototype.notEquals=function(t){return 0!==this.compare(t)},f.prototype.neq=f.prototype.notEquals=l.prototype.neq=l.prototype.notEquals=s.prototype.neq=s.prototype.notEquals,s.prototype.greater=function(t){return this.compare(t)>0},f.prototype.gt=f.prototype.greater=l.prototype.gt=l.prototype.greater=s.prototype.gt=s.prototype.greater,s.prototype.lesser=function(t){return this.compare(t)<0},f.prototype.lt=f.prototype.lesser=l.prototype.lt=l.prototype.lesser=s.prototype.lt=s.prototype.lesser,s.prototype.greaterOrEquals=function(t){return this.compare(t)>=0},f.prototype.geq=f.prototype.greaterOrEquals=l.prototype.geq=l.prototype.greaterOrEquals=s.prototype.geq=s.prototype.greaterOrEquals,s.prototype.lesserOrEquals=function(t){return this.compare(t)<=0},f.prototype.leq=f.prototype.lesserOrEquals=l.prototype.leq=l.prototype.lesserOrEquals=s.prototype.leq=s.prototype.lesserOrEquals,s.prototype.isEven=function(){return 0==(1&this.value[0])},l.prototype.isEven=function(){return 0==(1&this.value)},f.prototype.isEven=function(){return(this.value&BigInt(1))===BigInt(0)},s.prototype.isOdd=function(){return 1==(1&this.value[0])},l.prototype.isOdd=function(){return 1==(1&this.value)},f.prototype.isOdd=function(){return(this.value&BigInt(1))===BigInt(1)},s.prototype.isPositive=function(){return!this.sign},l.prototype.isPositive=function(){return this.value>0},f.prototype.isPositive=l.prototype.isPositive,s.prototype.isNegative=function(){return this.sign},l.prototype.isNegative=function(){return this.value<0},f.prototype.isNegative=l.prototype.isNegative,s.prototype.isUnit=function(){return!1},l.prototype.isUnit=function(){return 1===Math.abs(this.value)},f.prototype.isUnit=function(){return this.abs().value===BigInt(1)},s.prototype.isZero=function(){return!1},l.prototype.isZero=function(){return 0===this.value},f.prototype.isZero=function(){return this.value===BigInt(0)},s.prototype.isDivisibleBy=function(t){var e=Q(t);return!e.isZero()&&(!!e.isUnit()||(0===e.compareAbs(2)?this.isEven():this.mod(e).isZero()))},f.prototype.isDivisibleBy=l.prototype.isDivisibleBy=s.prototype.isDivisibleBy,s.prototype.isPrime=function(e){var r=Z(this);if(void 0!==r)return r;var o=this.abs(),n=o.bitLength();if(n<=64)return x(o,[2,3,5,7,11,13,17,19,23,29,31,37]);for(var i=Math.log(2)*n.toJSNumber(),u=Math.ceil(!0===e?2*Math.pow(i,2):i),p=[],a=0;a<u;a++)p.push(t(a+2));return x(o,p)},f.prototype.isPrime=l.prototype.isPrime=s.prototype.isPrime,s.prototype.isProbablePrime=function(e){var r=Z(this);if(void 0!==r)return r;for(var o=this.abs(),n=void 0===e?5:e,i=[],u=0;u<n;u++)i.push(t.randBetween(2,o.minus(2)));return x(o,i)},f.prototype.isProbablePrime=l.prototype.isProbablePrime=s.prototype.isProbablePrime,s.prototype.modInv=function(e){for(var r,o,n,i=t.zero,u=t.one,p=Q(e),a=this.abs();!a.isZero();)r=p.divide(a),o=i,n=p,i=u,p=a,u=o.subtract(r.multiply(u)),a=n.subtract(r.multiply(a));if(!p.isUnit())throw new Error(this.toString()+" and "+e.toString()+" are not co-prime");return-1===i.compare(0)&&(i=i.add(e)),this.isNegative()?i.negate():i},f.prototype.modInv=l.prototype.modInv=s.prototype.modInv,s.prototype.next=function(){var t=this.value;return this.sign?q(t,1,this.sign):new s(b(t,1),this.sign)},l.prototype.next=function(){var t=this.value;return t+1<n?new l(t+1):new s(i,!1)},f.prototype.next=function(){return new f(this.value+BigInt(1))},s.prototype.prev=function(){var t=this.value;return this.sign?new s(b(t,1),!0):q(t,1,this.sign)},l.prototype.prev=function(){var t=this.value;return t-1>-n?new l(t-1):new s(i,!0)},f.prototype.prev=function(){return new f(this.value-BigInt(1))};for(var J=[1];2*J[J.length-1]<=r;)J.push(2*J[J.length-1]);var L=J.length,U=J[L-1];function T(t){return Math.abs(t)<=r}function j(e,r,o){r=Q(r);for(var n=e.isNegative(),i=r.isNegative(),u=n?e.not():e,p=i?r.not():r,a=0,s=0,l=null,f=null,v=[];!u.isZero()||!p.isZero();)a=(l=A(u,U))[1].toJSNumber(),n&&(a=U-1-a),s=(f=A(p,U))[1].toJSNumber(),i&&(s=U-1-s),u=l[0],p=f[0],v.push(o(a,s));for(var h=0!==o(n?1:0,i?1:0)?t(-1):t(0),y=v.length-1;y>=0;y-=1)h=h.multiply(U).add(t(v[y]));return h}s.prototype.shiftLeft=function(t){var e=Q(t).toJSNumber();if(!T(e))throw new Error(String(e)+" is too large for shifting.");if(e<0)return this.shiftRight(-e);var r=this;if(r.isZero())return r;for(;e>=L;)r=r.multiply(U),e-=L-1;return r.multiply(J[e])},f.prototype.shiftLeft=l.prototype.shiftLeft=s.prototype.shiftLeft,s.prototype.shiftRight=function(t){var e,r=Q(t).toJSNumber();if(!T(r))throw new Error(String(r)+" is too large for shifting.");if(r<0)return this.shiftLeft(-r);for(var o=this;r>=L;){if(o.isZero()||o.isNegative()&&o.isUnit())return o;o=(e=A(o,U))[1].isNegative()?e[0].prev():e[0],r-=L-1}return(e=A(o,J[r]))[1].isNegative()?e[0].prev():e[0]},f.prototype.shiftRight=l.prototype.shiftRight=s.prototype.shiftRight,s.prototype.not=function(){return this.negate().prev()},f.prototype.not=l.prototype.not=s.prototype.not,s.prototype.and=function(t){return j(this,t,function(t,e){return t&e})},f.prototype.and=l.prototype.and=s.prototype.and,s.prototype.or=function(t){return j(this,t,function(t,e){return t|e})},f.prototype.or=l.prototype.or=s.prototype.or,s.prototype.xor=function(t){return j(this,t,function(t,e){return t^e})},f.prototype.xor=l.prototype.xor=s.prototype.xor;var C=1<<30,D=(r&-r)*(r&-r)|C;function z(t){var e=t.value,o="number"==typeof e?e|C:"bigint"==typeof e?e|BigInt(C):e[0]+e[1]*r|D;return o&-o}function R(t,e){return t=Q(t),e=Q(e),t.greater(e)?t:e}function k(t,e){return t=Q(t),e=Q(e),t.lesser(e)?t:e}function _(t,e){if(t=Q(t).abs(),e=Q(e).abs(),t.equals(e))return t;if(t.isZero())return e;if(e.isZero())return t;for(var r,o,n=a[1];t.isEven()&&e.isEven();)r=k(z(t),z(e)),t=t.divide(r),e=e.divide(r),n=n.multiply(r);for(;t.isEven();)t=t.divide(z(t));do{for(;e.isEven();)e=e.divide(z(e));t.greater(e)&&(o=e,e=t,t=o),e=e.subtract(t)}while(!e.isZero());return n.isUnit()?t:t.multiply(n)}s.prototype.bitLength=function(){var e=this;return e.compareTo(t(0))<0&&(e=e.negate().subtract(t(1))),0===e.compareTo(t(0))?t(0):t(function e(r,o){if(o.compareTo(r)<=0){var n=e(r,o.square(o)),i=n.p,u=n.e,p=i.multiply(o);return p.compareTo(r)<=0?{p:p,e:2*u+1}:{p:i,e:2*u}}return{p:t(1),e:0}}(e,t(2)).e).add(t(1))},f.prototype.bitLength=l.prototype.bitLength=s.prototype.bitLength;var $=function(t,e,r,o){r=r||u,t=String(t),o||(t=t.toLowerCase(),r=r.toLowerCase());var n,i=t.length,p=Math.abs(e),a={};for(n=0;n<r.length;n++)a[r[n]]=n;for(n=0;n<i;n++){if("-"!==(f=t[n])&&(f in a&&a[f]>=p)){if("1"===f&&1===p)continue;throw new Error(f+" is not a valid digit in base "+e+".")}}e=Q(e);var s=[],l="-"===t[0];for(n=l?1:0;n<t.length;n++){var f;if((f=t[n])in a)s.push(Q(a[f]));else{if("<"!==f)throw new Error(f+" is not a valid character");var v=n;do{n++}while(">"!==t[n]&&n<t.length);s.push(Q(t.slice(v+1,n)))}}return F(s,e,l)};function F(t,e,r){var o,n=a[0],i=a[1];for(o=t.length-1;o>=0;o--)n=n.add(t[o].times(i)),i=i.times(e);return r?n.negate():n}function G(e,r){if((r=t(r)).isZero()){if(e.isZero())return{value:[0],isNegative:!1};throw new Error("Cannot convert nonzero numbers to base 0.")}if(r.equals(-1)){if(e.isZero())return{value:[0],isNegative:!1};if(e.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-e.toJSNumber())).map(Array.prototype.valueOf,[1,0])),isNegative:!1};var o=Array.apply(null,Array(e.toJSNumber()-1)).map(Array.prototype.valueOf,[0,1]);return o.unshift([1]),{value:[].concat.apply([],o),isNegative:!1}}var n=!1;if(e.isNegative()&&r.isPositive()&&(n=!0,e=e.abs()),r.isUnit())return e.isZero()?{value:[0],isNegative:!1}:{value:Array.apply(null,Array(e.toJSNumber())).map(Number.prototype.valueOf,1),isNegative:n};for(var i,u=[],p=e;p.isNegative()||p.compareAbs(r)>=0;){i=p.divmod(r),p=i.quotient;var a=i.remainder;a.isNegative()&&(a=r.minus(a).abs(),p=p.next()),u.push(a.toJSNumber())}return u.push(p.toJSNumber()),{value:u.reverse(),isNegative:n}}function H(t,e,r){var o=G(t,e);return(o.isNegative?"-":"")+o.value.map(function(t){return function(t,e){return t<(e=e||u).length?e[t]:"<"+t+">"}(t,r)}).join("")}function K(t){if(v(+t)){var e=+t;if(e===m(e))return p?new f(BigInt(e)):new l(e);throw new Error("Invalid integer: "+t)}var r="-"===t[0];r&&(t=t.slice(1));var n=t.split(/e/i);if(n.length>2)throw new Error("Invalid integer: "+n.join("e"));if(2===n.length){var i=n[1];if("+"===i[0]&&(i=i.slice(1)),(i=+i)!==m(i)||!v(i))throw new Error("Invalid integer: "+i+" is not a valid exponent.");var u=n[0],a=u.indexOf(".");if(a>=0&&(i-=u.length-a-1,u=u.slice(0,a)+u.slice(a+1)),i<0)throw new Error("Cannot include negative exponent part for integers");t=u+=new Array(i+1).join("0")}if(!/^([0-9][0-9]*)$/.test(t))throw new Error("Invalid integer: "+t);if(p)return new f(BigInt(r?"-"+t:t));for(var h=[],y=t.length,g=o,d=y-g;y>0;)h.push(+t.slice(d,y)),(d-=g)<0&&(d=0),y-=g;return c(h),new s(h,r)}function Q(t){return"number"==typeof t?function(t){if(p)return new f(BigInt(t));if(v(t)){if(t!==m(t))throw new Error(t+" is not an integer.");return new l(t)}return K(t.toString())}(t):"string"==typeof t?K(t):"bigint"==typeof t?new f(t):t}s.prototype.toArray=function(t){return G(this,t)},l.prototype.toArray=function(t){return G(this,t)},f.prototype.toArray=function(t){return G(this,t)},s.prototype.toString=function(t,e){if(void 0===t&&(t=10),10!==t)return H(this,t,e);for(var r,o=this.value,n=o.length,i=String(o[--n]);--n>=0;)r=String(o[n]),i+="0000000".slice(r.length)+r;return(this.sign?"-":"")+i},l.prototype.toString=function(t,e){return void 0===t&&(t=10),10!=t?H(this,t,e):String(this.value)},f.prototype.toString=l.prototype.toString,f.prototype.toJSON=s.prototype.toJSON=l.prototype.toJSON=function(){return this.toString()},s.prototype.valueOf=function(){return parseInt(this.toString(),10)},s.prototype.toJSNumber=s.prototype.valueOf,l.prototype.valueOf=function(){return this.value},l.prototype.toJSNumber=l.prototype.valueOf,f.prototype.valueOf=f.prototype.toJSNumber=function(){return parseInt(this.toString(),10)};for(var V=0;V<1e3;V++)a[V]=Q(V),V>0&&(a[-V]=Q(-V));return a.one=a[1],a.zero=a[0],a.minusOne=a[-1],a.max=R,a.min=k,a.gcd=_,a.lcm=function(t,e){return t=Q(t).abs(),e=Q(e).abs(),t.divide(_(t,e)).multiply(e)},a.isInstance=function(t){return t instanceof s||t instanceof l||t instanceof f},a.randBetween=function(t,e){var o=k(t=Q(t),e=Q(e)),n=R(t,e).subtract(o).add(1);if(n.isSmall)return o.add(Math.floor(Math.random()*n));for(var i=G(n,r).value,u=[],p=!0,s=0;s<i.length;s++){var l=p?i[s]:r,f=m(Math.random()*l);u.push(f),f<l&&(p=!1)}return o.add(a.fromArray(u,r,!1))},a.fromArray=function(t,e,r){return F(t.map(Q),Q(e||10),r)},a}();"undefined"!=typeof module&&module.hasOwnProperty("exports")&&(module.exports=t),"function"==typeof define&&define.amd&&define("big-integer",[],function(){return t});
},{}],"Focm":[function(require,module,exports) {
var n={};!function(t){"use strict";(n["Control.Apply"]=n["Control.Apply"]||{}).arrayApply=function(n){return function(t){for(var r=n.length,a=t.length,o=new Array(r*a),e=0,i=0;i<r;i++)for(var u=n[i],c=0;c<a;c++)o[e++]=u(t[c]);return o}}}(),function(n){"use strict";n.boolConj=function(n){return function(t){return n&&t}},n.boolDisj=function(n){return function(t){return n||t}},n.boolNot=function(n){return!n}}(n["Data.HeytingAlgebra"]=n["Data.HeytingAlgebra"]||{}),function(t){"use strict";var r=n["Data.HeytingAlgebra"],a=(n["Data.Symbol"],n["Data.Unit"],n["Record.Unsafe"],n["Type.Data.Row"],n["Type.Data.RowList"],function(n,t,r,a,o,e){this.conj=n,this.disj=t,this.ff=r,this.implies=a,this.not=o,this.tt=e}),o=function(n){return n.not},e=function(n){return n.disj},i=new a(r.boolConj,r.boolDisj,!1,function(n){return function(t){return e(i)(o(i)(n))(t)}},r.boolNot,!0);t.HeytingAlgebra=a,t.tt=function(n){return n.tt},t.ff=function(n){return n.ff},t.implies=function(n){return n.implies},t.conj=function(n){return n.conj},t.disj=e,t.not=o,t.heytingAlgebraBoolean=i}(n["Data.HeytingAlgebra"]=n["Data.HeytingAlgebra"]||{}),function(t){"use strict";n["Data.Eq"],n["Data.HeytingAlgebra"],n["Data.Symbol"],n["Data.Unit"],n["Data.Void"],n["Record.Unsafe"],n["Type.Data.RowList"];t.Eq=function(n){this.eq=n},t.eq=function(n){return n.eq}}(n["Data.Eq"]=n["Data.Eq"]||{}),function(t){"use strict";n["Data.Semigroup"],n["Data.Symbol"],n["Data.Unit"],n["Data.Void"],n["Record.Unsafe"],n["Type.Data.RowList"];t.Semigroup=function(n){this.append=n},t.append=function(n){return n.append}}(n["Data.Semigroup"]=n["Data.Semigroup"]||{}),function(t){"use strict";n["Data.Show"],n["Data.Symbol"],n["Record.Unsafe"],n["Type.Data.RowList"];t.Show=function(n){this.show=n},t.show=function(n){return n.show}}(n["Data.Show"]=n["Data.Show"]||{}),function(t){"use strict";n["Data.Eq"],n["Data.Semigroup"],n["Data.Show"];var r=function(){function n(){}return n.value=new n,n}(),a=function(){function n(){}return n.value=new n,n}(),o=function(){function n(){}return n.value=new n,n}();t.LT=r,t.GT=a,t.EQ=o}(n["Data.Ordering"]=n["Data.Ordering"]||{}),function(t){"use strict";n["Data.Semiring"],n["Data.Symbol"],n["Data.Unit"],n["Record.Unsafe"],n["Type.Data.Row"],n["Type.Data.RowList"];t.Semiring=function(n,t,r,a){this.add=n,this.mul=t,this.one=r,this.zero=a},t.add=function(n){return n.add},t.zero=function(n){return n.zero},t.mul=function(n){return n.mul},t.one=function(n){return n.one}}(n["Data.Semiring"]=n["Data.Semiring"]||{}),function(t){"use strict";n["Data.Ring"];var r=n["Data.Semiring"],a=(n["Data.Symbol"],n["Data.Unit"],n["Record.Unsafe"],n["Type.Data.RowList"],function(n){return n.sub});t.Ring=function(n,t){this.Semiring0=n,this.sub=t},t.sub=a,t.negate=function(n){return function(t){return a(n)(r.zero(n.Semiring0()))(t)}}}(n["Data.Ring"]=n["Data.Ring"]||{}),function(t){"use strict";n["Data.Ord"],n["Data.Eq"],n["Data.Ord.Unsafe"];var r=n["Data.Ordering"],a=n["Data.Ring"],o=n["Data.Semiring"],e=(n["Data.Symbol"],n["Data.Unit"],n["Data.Void"],n["Record.Unsafe"],n["Type.Data.RowList"],function(n){return n.compare}),i=function(n){return function(t){return function(a){return!(e(n)(t)(a)instanceof r.LT)}}};t.Ord=function(n,t){this.Eq0=n,this.compare=t},t.compare=e,t.greaterThanOrEq=i,t.abs=function(n){return function(t){return function(r){return i(n)(r)(o.zero(t.Semiring0()))?r:a.negate(t)(r)}}}}(n["Data.Ord"]=n["Data.Ord"]||{}),function(t){"use strict";n["Control.Category"],n["Data.Boolean"],n["Data.Ord"],n["Data.Ring"];t.flip=function(n){return function(t){return function(r){return n(r)(t)}}}}(n["Data.Function"]=n["Data.Function"]||{}),function(t){"use strict";(n["Data.Functor"]=n["Data.Functor"]||{}).arrayMap=function(n){return function(t){for(var r=t.length,a=new Array(r),o=0;o<r;o++)a[o]=n(t[o]);return a}}}(),function(n){"use strict";var t=function(n){this.compose=n},r=new t(function(n){return function(t){return function(r){return n(t(r))}}});n.compose=function(n){return n.compose},n.Semigroupoid=t,n.semigroupoidFn=r}(n["Control.Semigroupoid"]=n["Control.Semigroupoid"]||{}),function(t){"use strict";var r=n["Data.Functor"],a=n["Control.Semigroupoid"],o=(n["Data.Function"],n["Data.Unit"],function(n){this.map=n}),e=new o(a.compose(a.semigroupoidFn)),i=new o(r.arrayMap);t.Functor=o,t.map=function(n){return n.map},t.functorFn=e,t.functorArray=i}(n["Data.Functor"]=n["Data.Functor"]||{}),function(t){"use strict";var r=n["Control.Apply"],a=(n["Control.Category"],n["Data.Function"],n["Data.Functor"]),o=function(n,t){this.Functor0=n,this.apply=t},e=new o(function(){return a.functorArray},r.arrayApply);t.Apply=o,t.apply=function(n){return n.apply},t.applyArray=e}(n["Control.Apply"]=n["Control.Apply"]||{}),function(t){"use strict";var r=n["Control.Apply"],a=(n["Data.Functor"],n["Data.Unit"],function(n,t){this.Apply0=n,this.pure=t}),o=new a(function(){return r.applyArray},function(n){return[n]});t.Applicative=a,t.pure=function(n){return n.pure},t.applicativeArray=o}(n["Control.Applicative"]=n["Control.Applicative"]||{}),function(t){"use strict";(n["Control.Bind"]=n["Control.Bind"]||{}).arrayBind=function(n){return function(t){for(var r=[],a=0,o=n.length;a<o;a++)Array.prototype.push.apply(r,t(n[a]));return r}}}(),function(t){"use strict";var r=n["Control.Bind"],a=(n["Control.Applicative"],n["Control.Apply"]),o=(n["Control.Category"],n["Data.Function"],n["Data.Functor"],n["Data.Unit"],function(n,t){this.Apply0=n,this.bind=t}),e=new o(function(){return a.applyArray},r.arrayBind);t.Bind=o,t.bind=function(n){return n.bind},t.bindArray=e}(n["Control.Bind"]=n["Control.Bind"]||{}),function(n){"use strict";n.range=function(n){return function(t){for(var r=n>t?-1:1,a=new Array(r*(t-n)+1),o=n,e=0;o!==t;)a[e++]=o,o+=r;return a[e]=o,a}},n.length=function(n){return n.length},n.indexImpl=function(n){return function(t){return function(r){return function(a){return a<0||a>=r.length?t:n(r[a])}}}},n.slice=function(n){return function(t){return function(r){return r.slice(n,t)}}},n.drop=function(n){return function(t){return n<1?t:t.slice(n)}}}(n["Data.Array"]=n["Data.Array"]||{}),function(n){"use strict";n.foldrArray=function(n){return function(t){return function(r){for(var a=t,o=r.length-1;o>=0;o--)a=n(r[o])(a);return a}}},n.foldlArray=function(n){return function(t){return function(r){for(var a=t,o=r.length,e=0;e<o;e++)a=n(a)(r[e]);return a}}}}(n["Data.Foldable"]=n["Data.Foldable"]||{}),function(t){"use strict";n["Data.Boolean"],n["Data.Eq"],n["Data.EuclideanRing"],n["Data.Ord"],n["Data.Ordering"],n["Data.Semigroup"],n["Data.Symbol"],n["Data.Unit"],n["Record.Unsafe"],n["Type.Data.RowList"];t.Monoid=function(n,t){this.Semigroup0=n,this.mempty=t},t.mempty=function(n){return n.mempty}}(n["Data.Monoid"]=n["Data.Monoid"]||{}),function(t){"use strict";n["Control.Alt"],n["Control.Alternative"],n["Control.Applicative"];var r=n["Control.Apply"],a=n["Control.Bind"],o=(n["Control.Category"],n["Control.Extend"],n["Control.Monad"],n["Control.MonadZero"],n["Control.Plus"],n["Data.Bounded"],n["Data.Eq"],n["Data.Function"],n["Data.Functor"]),e=(n["Data.Functor.Invariant"],n["Data.Monoid"],n["Data.Ord"],n["Data.Ordering"],n["Data.Semigroup"],n["Data.Show"],n["Data.Unit"],n.Prelude,function(){function n(){}return n.value=new n,n}()),i=function(){function n(n){this.value0=n}return n.create=function(t){return new n(t)},n}(),u=new o.Functor(function(n){return function(t){return t instanceof i?new i(n(t.value0)):e.value}}),c=new r.Apply(function(){return u},function(n){return function(t){if(n instanceof i)return o.map(u)(n.value0)(t);if(n instanceof e)return e.value;throw new Error("Failed pattern match at Data.Maybe (line 67, column 1 - line 67, column 35): "+[n.constructor.name,t.constructor.name])}}),f=new a.Bind(function(){return c},function(n){return function(t){if(n instanceof i)return t(n.value0);if(n instanceof e)return e.value;throw new Error("Failed pattern match at Data.Maybe (line 125, column 1 - line 125, column 33): "+[n.constructor.name,t.constructor.name])}});t.Nothing=e,t.Just=i,t.maybe=function(n){return function(t){return function(r){if(r instanceof e)return n;if(r instanceof i)return t(r.value0);throw new Error("Failed pattern match at Data.Maybe (line 217, column 1 - line 217, column 51): "+[n.constructor.name,t.constructor.name,r.constructor.name])}}},t.functorMaybe=u,t.applyMaybe=c,t.bindMaybe=f}(n["Data.Maybe"]=n["Data.Maybe"]||{}),function(t){"use strict";n["Control.Applicative"],n["Control.Apply"],n["Control.Bind"],n["Control.Monad"],n["Data.Bounded"],n["Data.Eq"],n["Data.Functor"];var r=n["Data.HeytingAlgebra"],a=n["Data.Monoid"],o=(n["Data.Ord"],n["Data.Semigroup"]),e=(n["Data.Semiring"],n["Data.Show"],n.Prelude,function(n){return new o.Semigroup(function(t){return function(a){return r.conj(n)(t)(a)}})});t.Conj=function(n){return n},t.semigroupConj=e,t.monoidConj=function(n){return new a.Monoid(function(){return e(n)},r.tt(n))}}(n["Data.Monoid.Conj"]=n["Data.Monoid.Conj"]||{}),function(t){"use strict";n["Control.Semigroupoid"],n["Data.Function"];var r=n["Data.Functor"],a=(n["Data.Monoid.Additive"],n["Data.Monoid.Conj"]),o=(n["Data.Monoid.Disj"],n["Data.Monoid.Dual"],n["Data.Monoid.Endo"],n["Data.Monoid.Multiplicative"],n["Data.Semigroup.First"],n["Data.Semigroup.Last"],n.Prelude,function(n,t){this.unwrap=n,this.wrap=t}),e=function(n){return n.wrap},i=function(n){return n.unwrap},u=new o(function(n){return n},a.Conj);t.unwrap=i,t.wrap=e,t.Newtype=o,t.alaF=function(n){return function(t){return function(a){return function(o){return function(u){return function(u){return function(c){return r.map(t)(i(o))(u(r.map(n)(e(a))(c)))}}}}}}},t.newtypeConj=u}(n["Data.Newtype"]=n["Data.Newtype"]||{}),function(t){"use strict";var r=n["Data.Foldable"],a=(n["Control.Alt"],n["Control.Applicative"],n["Control.Apply"],n["Control.Bind"],n["Control.Category"],n["Control.Plus"],n["Control.Semigroupoid"],n["Data.Eq"],n["Data.Function"],n["Data.Functor"]),o=(n["Data.HeytingAlgebra"],n["Data.Maybe"]),e=(n["Data.Maybe.First"],n["Data.Maybe.Last"],n["Data.Monoid"]),i=(n["Data.Monoid.Additive"],n["Data.Monoid.Conj"]),u=(n["Data.Monoid.Disj"],n["Data.Monoid.Dual"],n["Data.Monoid.Endo"],n["Data.Monoid.Multiplicative"],n["Data.Newtype"]),c=(n["Data.Ord"],n["Data.Ordering"],n["Data.Semigroup"]),f=(n["Data.Semiring"],n["Data.Unit"],n.Prelude,function(n,t,r){this.foldMap=n,this.foldl=t,this.foldr=r}),l=function(n){return n.foldr},s=function(n){return n.foldl},D=function(n){return function(t){return function(r){return l(n)(function(n){return function(a){return c.append(t.Semigroup0())(r(n))(a)}})(e.mempty(t))}}},d=new f(function(n){return D(d)(n)},r.foldlArray,r.foldrArray),p=function(n){return n.foldMap};t.Foldable=f,t.foldr=l,t.foldl=s,t.foldMap=p,t.foldMapDefaultR=D,t.all=function(n){return function(t){return u.alaF(a.functorFn)(a.functorFn)(u.newtypeConj)(u.newtypeConj)(i.Conj)(p(n)(i.monoidConj(t)))}},t.find=function(n){return function(t){return s(n)(function(n){return function(r){return n instanceof o.Nothing&&t(r)?new o.Just(r):n}})(o.Nothing.value)}},t.foldableArray=d}(n["Data.Foldable"]=n["Data.Foldable"]||{}),function(t){"use strict";(n["Partial.Unsafe"]=n["Partial.Unsafe"]||{}).unsafePartial=function(n){return n()}}(),function(t){"use strict";(n["Partial"]=n["Partial"]||{}).crashWith=function(){return function(n){throw new Error(n)}}}(),function(t){"use strict";var r=n.Partial;t.crashWith=r.crashWith}(n.Partial=n.Partial||{}),function(t){"use strict";var r=n["Partial.Unsafe"],a=n.Partial;t.unsafeCrashWith=function(n){return r.unsafePartial(function(t){return a.crashWith(t)(n)})}}(n["Partial.Unsafe"]=n["Partial.Unsafe"]||{}),function(t){"use strict";(n["Unsafe.Coerce"]=n["Unsafe.Coerce"]||{}).unsafeCoerce=function(n){return n}}(),function(t){"use strict";var r=n["Unsafe.Coerce"];t.unsafeCoerce=r.unsafeCoerce}(n["Unsafe.Coerce"]=n["Unsafe.Coerce"]||{}),function(t){"use strict";var r=n["Data.Array"],a=(n["Control.Alt"],n["Control.Alternative"],n["Control.Applicative"],n["Control.Apply"],n["Control.Bind"]),o=(n["Control.Category"],n["Control.Lazy"],n["Control.Monad.Rec.Class"],n["Control.Monad.ST"],n["Control.Monad.ST.Internal"],n["Control.Semigroupoid"],n["Data.Array.NonEmpty.Internal"],n["Data.Array.ST"],n["Data.Array.ST.Iterator"],n["Data.Boolean"],n["Data.Eq"],n["Data.Foldable"],n["Data.Function"]),e=(n["Data.Functor"],n["Data.HeytingAlgebra"],n["Data.Maybe"]),i=(n["Data.Ord"],n["Data.Ordering"],n["Data.Ring"],n["Data.Semigroup"],n["Data.Semiring"],n["Data.Traversable"],n["Data.Tuple"],n["Data.Unfoldable"],n["Partial.Unsafe"],n.Prelude,n["Unsafe.Coerce"],function(n){return[n]}),u=r.indexImpl(e.Just.create)(e.Nothing.value),c=o.flip(a.bind(a.bindArray));t.singleton=i,t.head=function(n){return u(n)(0)},t.index=u,t.concatMap=c,t.mapMaybe=function(n){return c(function(t){return e.maybe([])(i)(n(t))})},t.range=r.range,t.drop=r.drop}(n["Data.Array"]=n["Data.Array"]||{}),function(n){var t=require("big-integer");n["fromBase'"]=function(n){return function(r){return function(a){return function(o){try{var e=t(o,a);return n(e)}catch(i){return r}}}}},n.fromInt=function(n){return t(n)},n.toBase=function(n){return function(t){return t.toString(n)}},n.biAdd=function(n){return function(t){return n.add(t)}},n.biMul=function(n){return function(t){return n.multiply(t)}},n.biSub=function(n){return function(t){return n.minus(t)}},n.biEquals=function(n){return function(t){return n.equals(t)}},n.biCompare=function(n){return function(t){return n.compare(t)}}}(n["Data.BigInt"]=n["Data.BigInt"]||{}),function(t){"use strict";(n["Data.Int"]=n["Data.Int"]||{}).fromStringAsImpl=function(n){return function(t){return function(r){var a;a=r<11?"[0-"+(r-1).toString()+"]":11===r?"[0-9a]":"[0-9a-"+String.fromCharCode(86+r)+"]";var o=new RegExp("^[\\+\\-]?"+a+"+$","i");return function(a){if(o.test(a)){var e=parseInt(a,r);return(0|e)===e?n(e):t}return t}}}}}(),function(t){"use strict";var r=n["Data.Int"],a=(n["Control.Category"],n["Control.Semigroupoid"],n["Data.Boolean"],n["Data.Bounded"],n["Data.CommutativeRing"],n["Data.DivisionRing"],n["Data.Eq"],n["Data.EuclideanRing"],n["Data.HeytingAlgebra"],n["Data.Int.Bits"],n["Data.Maybe"]),o=(n["Data.Ord"],n["Data.Ordering"],n["Data.Ring"],n["Data.Semiring"],n["Data.Show"],n.Global,n.Math,n.Prelude,r.fromStringAsImpl(a.Just.create)(a.Nothing.value)),e=o(10);t.fromString=e,t.fromStringAs=o}(n["Data.Int"]=n["Data.Int"]||{}),function(t){"use strict";var r=n["Data.BigInt"],a=(n["Control.Semigroupoid"],n["Data.Array.NonEmpty"],n["Data.CommutativeRing"],n["Data.Eq"]),o=(n["Data.EuclideanRing"],n["Data.Function"],n["Data.Int"],n["Data.Maybe"]),e=n["Data.Ord"],i=n["Data.Ordering"],u=n["Data.Ring"],c=(n["Data.Semigroup"],n["Data.Semiring"]),f=(n["Data.Show"],n["Data.String.NonEmpty"],n["Data.String.NonEmpty.Internal"],n["Partial.Unsafe"],n.Prelude,r.toBase(10)),l=new c.Semiring(r.biAdd,r.biMul,r.fromInt(1),r.fromInt(0)),s=new u.Ring(function(){return l},r.biSub),D=r["fromBase'"](o.Just.create)(o.Nothing.value),d=D(10),p=new a.Eq(r.biEquals),g=new e.Ord(function(){return p},function(n){return function(t){var a=r.biCompare(n)(t);return 1===a?i.GT.value:0===a?i.EQ.value:i.LT.value}});t.fromString=d,t.fromBase=D,t.toString=f,t.eqBigInt=p,t.ordBigInt=g,t.semiringBigInt=l,t.ringBigInt=s,t.fromInt=r.fromInt}(n["Data.BigInt"]=n["Data.BigInt"]||{}),function(t){"use strict";n["Control.Alt"];var r=n["Control.Applicative"],a=n["Control.Apply"],o=n["Control.Bind"],e=(n["Control.Extend"],n["Control.Monad"],n["Control.Semigroupoid"],n["Data.Bifoldable"],n["Data.Bifunctor"],n["Data.Bitraversable"],n["Data.Bounded"],n["Data.Eq"],n["Data.Foldable"],n["Data.FoldableWithIndex"],n["Data.Function"],n["Data.Functor"]),i=(n["Data.Functor.Invariant"],n["Data.FunctorWithIndex"],n["Data.Maybe"]),u=(n["Data.Monoid"],n["Data.Ord"],n["Data.Ordering"],n["Data.Semigroup"],n["Data.Show"],n["Data.Traversable"],n["Data.TraversableWithIndex"],n["Data.Unit"],n.Prelude,function(){function n(n){this.value0=n}return n.create=function(t){return new n(t)},n}()),c=function(){function n(n){this.value0=n}return n.create=function(t){return new n(t)},n}(),f=new e.Functor(function(n){return function(t){if(t instanceof u)return new u(t.value0);if(t instanceof c)return new c(n(t.value0));throw new Error("Failed pattern match at Data.Either (line 38, column 8 - line 38, column 52): "+[t.constructor.name])}}),l=function(n){return function(t){return function(r){if(r instanceof u)return n(r.value0);if(r instanceof c)return t(r.value0);throw new Error("Failed pattern match at Data.Either (line 238, column 1 - line 238, column 64): "+[n.constructor.name,t.constructor.name,r.constructor.name])}}},s=new a.Apply(function(){return f},function(n){return function(t){if(n instanceof u)return new u(n.value0);if(n instanceof c)return e.map(f)(n.value0)(t);throw new Error("Failed pattern match at Data.Either (line 82, column 1 - line 82, column 41): "+[n.constructor.name,t.constructor.name])}}),D=new o.Bind(function(){return s},l(function(n){return function(t){return new u(n)}})(function(n){return function(t){return t(n)}})),d=new r.Applicative(function(){return s},c.create);t.Left=u,t.Right=c,t.either=l,t.note=function(n){return i.maybe(new u(n))(c.create)},t.functorEither=f,t.applyEither=s,t.applicativeEither=d,t.bindEither=D}(n["Data.Either"]=n["Data.Either"]||{}),function(n){"use strict";n.split=function(n){return function(t){return t.split(n)}},n.trim=function(n){return n.trim()},n.joinWith=function(n){return function(t){return t.join(n)}}}(n["Data.String.Common"]=n["Data.String.Common"]||{}),function(t){"use strict";var r=n["Data.String.Common"];n["Data.Eq"],n["Data.Ordering"],n["Data.String.Pattern"],n.Prelude;t.split=r.split,t.trim=r.trim,t.joinWith=r.joinWith}(n["Data.String.Common"]=n["Data.String.Common"]||{}),function(t){"use strict";var r=n["Control.Applicative"],a=n["Control.Bind"],o=n["Data.Array"],e=n["Data.BigInt"],i=n["Data.Either"],u=n["Data.Eq"],c=n["Data.Foldable"],f=n["Data.Functor"],l=n["Data.HeytingAlgebra"],s=n["Data.Int"],D=n["Data.Maybe"],d=n["Data.Ord"],p=n["Data.Ring"],g=n["Data.Semiring"],m=(n["Data.String"],n["Data.String.Common"]),y=(n["Data.String.Pattern"],n["Partial.Unsafe"]),h=(n.Prelude,function(n){var t=m.split("\n")(m.trim(n));return a.bind(i.bindEither)(i.note("n")(a.bind(D.bindMaybe)(o.head(t))(s.fromString)))(function(n){var s=o.mapMaybe(function(n){var t=o.mapMaybe(e.fromString)(m.split(" ")(n));return 3===t.length?new D.Just({x:t[0],y:t[1],h:t[2]}):D.Nothing.value})(o.drop(1)(t));return a.bind(i.bindEither)(i.note("c")(function(n){return a.bind(D.bindMaybe)(c.find(c.foldableArray)(function(n){return d.greaterThanOrEq(e.ordBigInt)(n.h)(g.one(e.semiringBigInt))})(n))(function(t){var i=a.bind(a.bindArray)(f.map(f.functorArray)(e.fromInt)(o.range(0)(100)))(function(n){return a.bind(a.bindArray)(f.map(f.functorArray)(e.fromInt)(o.range(0)(100)))(function(a){return r.pure(r.applicativeArray)({x:n,y:a,h:(o=n,function(n){return g.add(e.semiringBigInt)(g.add(e.semiringBigInt)(t.h)(d.abs(e.ordBigInt)(e.ringBigInt)(p.sub(e.ringBigInt)(t.x)(o))))(d.abs(e.ordBigInt)(e.ringBigInt)(p.sub(e.ringBigInt)(t.y)(n)))})(a)});var o})});return c.find(c.foldableArray)(function(t){return c.all(c.foldableArray)(l.heytingAlgebraBoolean)(function(n){return u.eq(e.eqBigInt)(p.sub(e.ringBigInt)(p.sub(e.ringBigInt)(t.h)(d.abs(e.ordBigInt)(e.ringBigInt)(p.sub(e.ringBigInt)(n.x)(t.x))))(d.abs(e.ordBigInt)(e.ringBigInt)(p.sub(e.ringBigInt)(n.y)(t.y))))(n.h)})(n)})(i)})}(s)))(function(n){return r.pure(i.applicativeEither)(m.joinWith(" ")(f.map(f.functorArray)(e.toString)([n.x,n.y,n.h])))})})});t.solve=function(n){var t=h(n);if(t instanceof i.Left)return y.unsafeCrashWith(t.value0);if(t instanceof i.Right)return t.value0;throw new Error("Failed pattern match at AtCoder.ABC112.C (line 21, column 3 - line 23, column 24): "+[t.constructor.name])}}(n["AtCoder.ABC112.C"]=n["AtCoder.ABC112.C"]||{}),function(t){"use strict";(n["Effect.Console"]=n["Effect.Console"]||{}).log=function(n){return function(){return console.log(n),{}}}}(),function(t){"use strict";var r=n["Effect.Console"];n["Data.Show"],n["Data.Unit"],n.Effect;t.log=r.log}(n["Effect.Console"]=n["Effect.Console"]||{}),function(t){"use strict";n["Node.Encoding"];var r=n["Data.Show"],a=(n.Prelude,function(){function n(){}return n.value=new n,n}()),o=function(){function n(){}return n.value=new n,n}(),e=function(){function n(){}return n.value=new n,n}(),i=function(){function n(){}return n.value=new n,n}(),u=function(){function n(){}return n.value=new n,n}(),c=function(){function n(){}return n.value=new n,n}(),f=function(){function n(){}return n.value=new n,n}(),l=function(){function n(){}return n.value=new n,n}(),s=new r.Show(function(n){if(n instanceof a)return"ASCII";if(n instanceof o)return"UTF8";if(n instanceof e)return"UTF16LE";if(n instanceof i)return"UCS2";if(n instanceof u)return"Base64";if(n instanceof c)return"Latin1";if(n instanceof f)return"Binary";if(n instanceof l)return"Hex";throw new Error("Failed pattern match at Node.Encoding (line 19, column 1 - line 19, column 39): "+[n.constructor.name])});t.ASCII=a,t.UTF8=o,t.UTF16LE=e,t.UCS2=i,t.Base64=u,t.Latin1=c,t.Binary=f,t.Hex=l,t.showEncoding=s}(n["Node.Encoding"]=n["Node.Encoding"]||{}),function(t){"use strict";(n["Node.FS.Internal"]=n["Node.FS.Internal"]||{}).unsafeRequireFS=require("fs")}(),function(t){"use strict";var r=n["Node.FS.Internal"],a=(n.Effect,n.Prelude,n["Unsafe.Coerce"].unsafeCoerce);t.mkEffect=a,t.unsafeRequireFS=r.unsafeRequireFS}(n["Node.FS.Internal"]=n["Node.FS.Internal"]||{}),function(t){"use strict";n["Control.Bind"],n["Control.Semigroupoid"],n["Data.DateTime"],n["Data.DateTime.Instant"],n["Data.EuclideanRing"],n["Data.Function"],n["Data.Function.Uncurried"],n["Data.Functor"],n["Data.Int"],n["Data.Maybe"],n["Data.Nullable"];var r=n["Data.Show"],a=(n["Data.Time.Duration"],n.Effect,n["Node.Buffer"],n["Node.Encoding"]),o=(n["Node.FS"],n["Node.FS.Internal"]),e=(n["Node.FS.Perms"],n["Node.FS.Stats"],n["Node.Path"],n.Prelude,o.unsafeRequireFS);t.readTextFile=function(n){return function(t){return o.mkEffect(function(o){return e.readFileSync(t,{encoding:r.show(a.showEncoding)(n)})})}}}(n["Node.FS.Sync"]=n["Node.FS.Sync"]||{}),function(t){"use strict";var r=n["AtCoder.ABC112.C"],a=(n["Control.Applicative"],n["Control.Bind"],n.Effect,n["Effect.Console"]),o=n["Node.Encoding"],e=n["Node.FS.Sync"];n.Prelude;t.main=function(){var n=e.readTextFile(o.UTF8.value)("/dev/stdin")(),t=r.solve(n);return a.log(t)()}}(n.Main=n.Main||{}),n.Main.main();
},{"big-integer":"9xaU"}]},{},["Focm"], null)


function Main(input) {
  input = input.split("\n");
  N = parseInt(input[0]);
  x = new Array(N);
  y = new Array(N);
  h = new Array(N);
  for(i=0;i<N;i++){
    tmp=input[i+1].split(" ");
    x[i]=parseInt(tmp[0]);
    y[i]=parseInt(tmp[1]);
    h[i]=parseInt(tmp[2]);
  }
  for(i=0;i<N;i++){
    if(h[i]!=0){
      var x1=x[i];
      var y1=y[i];
      var h1=h[i];
      break;
        }
  }
  ans=0;
  for(i=0;i<101;i++){
    for(j=0;j<101;j++){
      var H =h1+Math.abs(i-x1)+Math.abs(j-y1);
      var count=0;
      for(k=0;k<N;k++){
        if(h[k]==H-Math.abs(i-x[k])-Math.abs(j-y[k])||h[k]==0){
          count++;
        }
      }

    if(count==x.length){
      ans=i+" "+j+" "+H;
      break;
    }
    }
  }
  console.log('%s', ans);
}

// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function getLines(input){
	return input.split("\n").map((s)=>s.trim())
}
function parseLine(line){
	return line.split(" ").map((s)=>s.trim());
}
function parseLineToInt(line){
	return line.split(" ").map((s)=>parseInt(s.trim()));
}
// parameter "input" gets all data
function Main(input) {
	// the first line is assigned to input[0], the second line is assigned to input[1] similarly.
	input = getLines(input).map(parseLineToInt);
	var n = input[0][0];
	input.shift()

	var calc = (e,i,j)=>(Math.abs(e[0]-i)+Math.abs(e[1]-j)+e[2])
	var verify = (e,H,i,j)=>{
		//console.log(e,H,i,j,(Math.max(H-Math.abs(e[0]-i)-Math.abs(e[1]-j),0)),e[2])
		return (Math.max(H-Math.abs(e[0]-i)-Math.abs(e[1]-j),0))==e[2]
	}
	var minx,miny,maxx,maxy;
	/*input.sort((a,b)=>a[0]-b[0]);
	minx=input[0][0];
	maxx=input[n-1][0];
	input.sort((a,b)=>a[1]-b[1]);
	miny=input[0][1];
	maxy=input[n-1][1];*/
	input.sort((a,b)=>a[2]-b[2])
	minx=0,miny=0,maxx=100,maxy=100;
	for (var i = minx; i <= maxx; i++) {
		for (var j = miny; j <= maxy; j++) {
			var h = -1;
			var go = false
			for (var k = 0; k <	n; k++) {
				if(h == -1){
					h = calc(input[k],i,j)
				//	console.log('---',h)
				}
				if(h<1 || !verify(input[k],h,i,j)){
					go = true
					break;
				}

			}
			if(!go){
				console.log([i,j,h].join(' '));
			}
		}

	}

}
// Don't edit this line!
//Main(require("fs").readFileSync(__dirname+'/in.txt', "utf8"));
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function main(input){
    abc=input.split(' ');
    abc=abc.sort();
    a=parseInt(abc[2],10)
    b=parseInt(abc[1],10)
    c=parseInt(abc[0],10)
    console.log(a*10+b+c)

}

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

Score : 100 points

Problem Statement

You have decided to give an allowance to your child depending on the outcome of the game that he will play now.

The game is played as follows:

There are three "integer panels", each with a digit between 1 and 9 (inclusive) printed on it, and one "operator panel" with a + printed on it.

The player should construct a formula of the form X + Y, by arranging the four panels from left to right. (The operator panel should not be placed at either end of the formula.)

Then, the amount of the allowance will be equal to the resulting value of the formula.

Given the values A, B and C printed on the integer panels used in the game, find the maximum possible amount of the allowance.

Constraints

All values in input are integers.

1 \leq A, B, C \leq 9

Input

Input is given from Standard Input in the following format:

A B C

Output

Print the maximum possible amount of the allowance.

Sample Input 1

1 5 2

Sample Output 1

53

The amount of the allowance will be 53 when the panels are arranged as 52+1, and this is the maximum possible amount.

Sample Input 2

9 9 9

Sample Output 2

108

Sample Input 3

6 6 7

Sample Output 3

82


function Main(input) {
	input = input.trim().split(" ");
  input.sort(function(a,b){
  	return parseInt(b) - parseInt(a);
  });
  console.log(parseInt(input[0] + input[1]) + parseInt(input[2]));
}

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