// inputに入力データ全体が入る
function Main(input) {
//    input = input.split(' ');
    //文字列から10進数に変換するときはparseIntを使います
    var n = parseInt(input, 10);
    var ans = 0;

    var one_count = 0;

    var two_count = 0;

    var three_count = 0;
    var three_check = false;

    while (n != 0) {
        if (n % 2 == 0) {
            n /= 2;
            two_count++;
        } else if (n % 3 == 0) {
            n /= 3;
            three_count++;
        } else {
            n--+
            one_count++;
        }
    }

    if (two_count > 0 && three_count > 0) {
        if (two_count < three_count) {
            three_count -= two_count;
            two_count -= two_count;
        } else {
            two_count -= three_count;
            three_count -= three_count;
        }
        ans++;
    }

    while (three_count > 1) {
        three_count -= 2;
        if (!three_check) {
            three_check = true;
            ans++
        }
    }

    if (two_count > 0) {
        n = Math.pow(2, two_count);
        var nine_count = 1;
        var six_count = 1
        var nine_check = false;
        var six_check = false;
        while ( true ) {
            var nine_tmp = n - Math.pow(9, nine_count);
            if (nine_tmp < 0) {
                if (nine_count != 1) {
                    nine_count--;
                    nine_tmp = n - Math.pow(9, nine_count);
                    nine_count = 1;
                    six_check = false;
                } else {
                    nine_tmp = n;
                    nine_check = true;
                }
                while ( true ) {
                    var six_tmp = n - Math.pow(6, six_count);
                    if (six_tmp < 0) {
                        if (six_count != 1) {
                            six_count--;
                            six_tmp = n - Math.pow(6, six_count);
                            six_count = 1;
                            nine_check = false;
                        } else {
                            six_tmp = n;
                            six_check = true;
                        }
                        if (!nine_check || !six_check) {
                           if (nine_tmp < six_tmp) {
                                n = nine_tmp;
                            } else {
                                n = six_tmp;
                            }
                            ans++;
                        }
                        break;
                    } else {
                        six_count++;
                    }
                }
                if (nine_check && six_check) {
                    ans += n;
                    break;
                }
            } else {
                nine_count++;
            }
        }
    } else if (three_count > 0) {
        ans += 3;
    }

    if (one_count >= 6) {
        n = one_count;
        var nine_count = 1;
        var six_count = 1
        var nine_check = false;
        var six_check = false;
        while ( true ) {
            var nine_tmp = n - Math.pow(9, nine_count);
            if (nine_tmp < 0) {
                if (nine_count != 1) {
                    nine_count--;
                    nine_tmp = n - Math.pow(9, nine_count);
                    nine_count = 1;
                    six_check = false;
                } else {
                    nine_tmp = n;
                    nine_check = true;
                }
                while ( true ) {
                    var six_tmp = n - Math.pow(6, six_count);
                    if (six_tmp < 0) {
                        if (six_count != 1) {
                            six_count--;
                            six_tmp = n - Math.pow(6, six_count);
                            six_count = 1;
                            nine_check = false;
                        } else {
                            six_tmp = n;
                            six_check = true;
                        }
                        if (!nine_check || !six_check) {
                           if (nine_tmp < six_tmp) {
                                n = nine_tmp;
                            } else {
                                n = six_tmp;
                            }
                            ans++;
                        }
                        break;
                    } else {
                        six_count++;
                    }
                }
                if (nine_check && six_check) {
                    ans += n;
                    break;
                }
            } else {
                nine_count++;
            }
        }
    }

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


'use strict'
function main(input) {
  input = input.trim().replace(/(0+)/, '0').split('')
  if (input[input.length - 1] === '0') {
    console.log(Number(input.join('')))
  } else {
    console.log(input.reduce((r, c) => Number(r) + Number(c), 0))
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

Score : 200 points

Problem Statement

Takahashi has two positive integers A and B.

It is known that A plus B equals N.
Find the minimum possible value of "the sum of the digits of A" plus "the sum of the digits of B" (in base 10).

Constraints

2 ≤ N ≤ 10^5

N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the minimum possible value of "the sum of the digits of A" plus "the sum of the digits of B".

Sample Input 1

15

Sample Output 1

6

When A=2 and B=13, the sums of their digits are 2 and 4, which minimizes the value in question.

Sample Input 2

100000

Sample Output 2

10

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.


function main(input) {
  var digits = input.toString().length;
  var input = parseInt(input, 10);

  var divisor = Math.pow(10, digits - 1);
  var arr = [];
  for (var i = 0; i < digits; i++) {
  	arr.push(Math.floor(input / divisor))
  	input = input % divisor;
  	divisor /= 10;

  }
  var answer = arr.reduce((a, b) => a + b);
  if(answer == 1) {answer = 10;}

  console.log(answer);

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


// inputに入力データ全体が入る
function Main(input) {
	input = input.split("\n");
  	const row1 = input[0].split(" ");
  	const N = parseInt(row1[0]);
  const M = parseInt(row1[1]);
  const K = parseInt(row1[2]);
  var S = parseInt(input[1],2);
  var T = parseInt(input[2],2);
  for(var i=0; i < K; i++){
    var sANDt = S & T;
    S = S + sANDt;
    T = T + sANDt;
  }
  const sBinary = toBinary(S);
  const tBinary = toBinary(T);
  console.log(sBinary);
  console.log(tBinary);

 }

function toBinary( a ){
  var num = a, binary = '';
  while ( num > 0 ) {
    binary = ( num % 2 ) + binary;
    num = Math.floor( num / 2 );
  }
  return binary;
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Score : 2400 points

Problem Statement

Takahashi and Aoki love calculating things, so they will play with numbers now.

First, they came up with one positive integer each. Takahashi came up with X, and Aoki came up with Y.
Then, they will enjoy themselves by repeating the following operation K times:

Compute the bitwise AND of the number currently kept by Takahashi and the number currently kept by Aoki. Let Z be the result.

Then, add Z to both of the numbers kept by Takahashi and Aoki.

However, it turns out that even for the two math maniacs this is just too much work.
Could you find the number that would be kept by Takahashi and the one that would be kept by Aoki eventually?

Note that input and output are done in binary.
Especially, X and Y are given as strings S and T of length N and M consisting of 0 and 1, respectively, whose initial characters are guaranteed to be 1.

Constraints

1 ≤ K ≤ 10^6

1 ≤ N,M ≤ 10^6

The initial characters of S and T are 1.

Input

Input is given from Standard Input in the following format:

N M K
S
T

Output

In the first line, print the number that would be kept by Takahashi eventually; in the second line, print the number that would be kept by Aoki eventually.
Those numbers should be represented in binary and printed as strings consisting of 0 and 1 that begin with 1.

Sample Input 1

2 3 3
11
101

Sample Output 1

10000
10010

The values of X and Y after each operation are as follows:

After the first operation: (X,Y)=(4,6).

After the second operation: (X,Y)=(8,10).

After the third operation: (X,Y)=(16,18).

Sample Input 2

5 8 3
10101
10101001

Sample Output 2

100000
10110100

Sample Input 3

10 10 10
1100110011
1011001101

Sample Output 3

10000100000010001000
10000100000000100010


function main(lines) {
  const lin = lines[0].split(" ");
  const a = Number(lin[0]);
  const b = Number(lin[1]);
  var m = a + b;
  if (a - b > m) m = a - b;
  if (a * b > m) m = a * b;
  console.log(m);
}
main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));

Score : 100 points

Problem Statement

You are given two integers A and B.
Find the largest value among A+B, A-B and A \times B.

Constraints

-1000 \leq A,B \leq 1000

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B

Output

Print the largest value among A+B, A-B and A \times B.

Sample Input 1

3 1

Sample Output 1

4

3+1=4, 3-1=2 and 3 \times 1=3. The largest among them is 4.

Sample Input 2

4 -2

Sample Output 2

6

The largest is 4 - (-2) = 6.

Sample Input 3

0 0

Sample Output 3

0


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

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

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    var ab = input[0].split(' ');
    var a = parseInt(ab[0], 10);
    var b = parseInt(ab[1], 10);

    var ans = Math.max(a + b, a - b, a * b);

    if (ans === -0) {
        ans = 0;
    }

    console.log(ans);

    return 0;
}


function Main(input) {
  	input = input.split("\n");
  	var n = parseInt(input[0], 10);
  	s = input[1];
  	var char=new Array(26);
  	var l=new Array(26);
  	var r=new Array(26);
  	for (var i=0; i<26; i++){

      for (l[i]=0; l[i]<n; l[i]++){
          if (s.charCodeAt(l[i])==i+97){
           break;
          }
      }

      for (r[i]=n; r[i]>=l[i]; r[i]+=-1){
          if (s.charCodeAt(r[i])==i+97){
           break;
          }
       }
      console.log(String.fromCharCode(i+97)+" "+'%d'+"~"+'%d',l[i],r[i]);

    }
  var counter;
  var max=0;
  for (var j=0;j<n;j++){
    counter=0;
    for (var k=0; k<26; k++){
      if (j>=l[k] && j<r[k]){
       counter++;
      }
    }
    if (counter>max){
     max=counter;
    }
  }
  console.log('%d',max);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Score : 200 points

Problem Statement

You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y.
Here, we would like to maximize the number of different letters contained in both X and Y.
Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.

Constraints

2 \leq N \leq 100

|S| = N

S consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

N
S

Output

Print the largest possible number of different letters contained in both X and Y.

Sample Input 1

6
aabbca

Sample Output 1

2

If we cut the string between the third and fourth letters into X = aab and Y = bca, the letters contained in both X and Y are a and b.
There will never be three or more different letters contained in both X and Y, so the answer is 2.

Sample Input 2

10
aaaaaaaaaa

Sample Output 2

1

However we divide S, only a will be contained in both X and Y.

Sample Input 3

45
tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir

Sample Output 3

9


'use strict';

const DELIMITER = " ";
const A_INDEX = 0;
const B_INDEX = 1;
const K_INDEX = 3;
const LIMIT = Math.pow(10, 18);

const process = input => {
    const indexArr = input.split(DELIMITER);
    const ans = parseInt(indexArr[A_INDEX]) - parseInt(indexArr[B_INDEX]);
    const KString = indexArr[K_INDEX];
    // JS rounds up large numbers; simply get last digit for modulo
    const K = parseInt(KString.charAt(KString.length-1));

    if (Math.abs(ans) > LIMIT) {
        console.log('Unfair')
    } else {
        console.log(K % 2 === 0 || ans === 0 ? ans : -ans);
    }
}

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

Score : 300 points

Problem Statement

Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively.
After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get:

Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result.

However, if the absolute value of the answer exceeds 10^{18}, print Unfair instead.

Constraints

1 \leq A,B,C \leq 10^9

0 \leq K \leq 10^{18}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B C K

Output

Print the integer Takahashi will get minus the integer Nakahashi will get, after repeating the following operation K times.
If the absolute value of the answer exceeds 10^{18}, print Unfair instead.

Sample Input 1

1 2 3 1

Sample Output 1

1

After one operation, Takahashi, Nakahashi and Hikuhashi have 5, 4 and 3, respectively. We should print 5-4=1.

Sample Input 2

2 3 2 0

Sample Output 2

-1

Sample Input 3

1000000000 1000000000 1000000000 1000000000000000000

Sample Output 3

0


let [a, b, c, d] = require("fs").readFileSync("/dev/stdin", "utf8").split(" ").map(Number);
let [f1, f2, f3] = [a - c, a - b, b - c].map(n => Math.abs(n) <= d)
console.log(f1 || f2 && f3 ? "Yes" : "No");

Score : 100 points

Problem Statement

Three people, A, B and C, are trying to communicate using transceivers.
They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively.
Two people can directly communicate when the distance between them is at most d meters.
Determine if A and C can communicate, either directly or indirectly.
Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.

Constraints

1 ≤ a,b,c ≤ 100

1 ≤ d ≤ 100

All values in input are integers.

Input

Input is given from Standard Input in the following format:

a b c d

Output

If A and C can communicate, print Yes; if they cannot, print No.

Sample Input 1

4 7 9 3

Sample Output 1

Yes

A and B can directly communicate, and also B and C can directly communicate, so we should print Yes.

Sample Input 2

100 10 1 2

Sample Output 2

No

They cannot communicate in this case.

Sample Input 3

10 10 10 1

Sample Output 3

Yes

There can be multiple people at the same position.

Sample Input 4

1 100 2 10

Sample Output 4

Yes


function main(input) {
	const args = input.split(' ');
	const a = parseInt(args[0], 10);
	const b = parseInt(args[1], 10);
	const c = parseInt(args[2], 10);
	const d = parseInt(args[3], 10);
	var t = 0;
	if(Math.abs(a-c)<=d){
		t = 1;
	} else if(Math.abs(a-b)<=d && Math.abs(b-c)<=d){
		t = 1;
	}
	if(t == 1){
		console.log('Yes');
	} else {
		console.log('No');
	}
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


'use strict'

function main(s) {

  const x = Number(s);

  let i = 0;
  let ans = 0;
  while (ans <= x) {
    i += 1;
    ans = i * i;
  }
  ans = (i - 1) * (i - 1);
  console.log(ans);
}

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

Score : 200 points

Problem Statement

You are given a positive integer X.
Find the largest perfect power that is at most X.
Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.

Constraints

1 ≤ X ≤ 1000

X is an integer.

Input

Input is given from Standard Input in the following format:

X

Output

Print the largest perfect power that is at most X.

Sample Input 1

10

Sample Output 1

9

There are four perfect powers that are at most 10: 1, 4, 8 and 9.
We should print the largest among them, 9.

Sample Input 2

1

Sample Output 2

1

Sample Input 3

999

Sample Output 3

961


'use strict';

function Main(input) {
  const X = Number(input);
  let list = [];

  for(let i=1; i<32; i++) {
    for(let j=2; j<11; j++) {
      if(Math.pow(i,j) <= 1000) {
        list.push(Math.pow(i,j))
      }
    }
  }
  list.sort(function(a,b) {return a<b ? 1:-1;});

  let listleng = list.length;

  for(let k=0; k<listleng; k++) {
    if(list[k] <= X) {
      console.log(list[k]);
      break;
    }
  }

}

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


"use strict"

const main = arg => {
  arg = arg.trim().split("\n");
  const str = arg[0];
  const len = str.length;
  const k   = parseInt(arg[1]);

  const initials = [...new Set(str.split(''))].sort();
  let index = 0;
  const dic = new Set();

  while(dic.size < k) {
    for(let i=0; i<len; i++) {
      let j = 1;
      if(str.slice(i, i + j) !== initials[index]) continue;

      while(i + j <= len && j <= 5) {
        dic.add(str.slice(i, i + j));
        j += 1;
      }
    }

    index++;
  }

  const ans = [...dic].sort()[k - 1];
  console.log(ans);
}

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

Score : 300 points

Problem Statement

You are given a string s.
Among the different substrings of s, print the K-th lexicographically smallest one.

A substring of s is a string obtained by taking out a non-empty contiguous part in s.
For example, if s = ababc, a, bab and ababc are substrings of s, while ac, z and an empty string are not.
Also, we say that substrings are different when they are different as strings.

Let X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \neq y_{j}.

Constraints

1 ≤ |s| ≤ 5000

s consists of lowercase English letters.

1 ≤ K ≤ 5

s has at least K different substrings.

Partial Score

200 points will be awarded as a partial score for passing the test set satisfying |s| ≤ 50.

Input

Input is given from Standard Input in the following format:

s
K

Output

Print the K-th lexicographically smallest substring of K.

Sample Input 1

aba
4

Sample Output 1

b

s has five substrings: a, b, ab, ba and aba.
Among them, we should print the fourth smallest one, b.
Note that we do not count a twice.

Sample Input 2

atcoderandatcodeer
5

Sample Output 2

andat

Sample Input 3

z
1

Sample Output 3

z


var lines = []; var result = 0;
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
})

rl.on('close', function () {
    var S = lines[0].split("");
    var K = Number(lines[1]);

    var str = Array(S.length).fill("").map(value => value = Array(S.length).fill(""));
    str[0][0] = ""

    var dictionary = [];
    for (var i = 0; i < S.length; i++) {
        for (var j = i; j < S.length; j++) {
            str[i][j + 1] = str[i][j] + S[j];
            dictionary.push(str[i][j + 1])
        }
    }
    dictionary = dictionary.filter((value, index, array) => {
        return (array.indexOf(value) === index);
    });

    dictionary.sort()
    console.log(dictionary[K - 1]);
});


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}({"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,e=t.length,u=new Array(r*e),i=0,o=0;o<r;o++)for(var a=n[o],f=0;f<e;f++)u[i++]=a(t[f]);return u}}}(),function(n){"use strict";n["Control.Semigroupoid"]=n["Control.Semigroupoid"]||{};var t=n["Control.Semigroupoid"],r=function(n){this.compose=n},e=new r(function(n){return function(t){return function(r){return n(t(r))}}});t.compose=function(n){return n.compose},t.Semigroupoid=r,t.semigroupoidFn=e}(n),function(n){"use strict";n["Control.Category"]=n["Control.Category"]||{};var t=n["Control.Category"],r=n["Control.Semigroupoid"],e=function(n,t){this.Semigroupoid0=n,this.identity=t},u=new e(function(){return r.semigroupoidFn},function(n){return n});t.Category=e,t.identity=function(n){return n.identity},t.categoryFn=u}(n),function(n){"use strict";n["Data.Function"]=n["Data.Function"]||{};var t=n["Data.Function"];t.flip=function(n){return function(t){return function(r){return n(r)(t)}}},t.const=function(n){return function(t){return n}}}(n),function(t){"use strict";(n["Data.Functor"]=n["Data.Functor"]||{}).arrayMap=function(n){return function(t){for(var r=t.length,e=new Array(r),u=0;u<r;u++)e[u]=n(t[u]);return e}}}(),function(t){"use strict";(n["Data.Unit"]=n["Data.Unit"]||{}).unit={}}(),function(n){"use strict";n["Data.Unit"]=n["Data.Unit"]||{};var t=n["Data.Unit"],r=n["Data.Unit"];t.unit=r.unit}(n),function(n){"use strict";n["Data.Functor"]=n["Data.Functor"]||{};var t=n["Data.Functor"],r=n["Data.Functor"],e=n["Data.Function"],u=n["Data.Unit"],i=function(n){this.map=n},o=function(n){return n.map},a=new i(r.arrayMap);t.Functor=i,t.map=o,t.void=function(n){return o(n)(e.const(u.unit))},t.functorArray=a}(n),function(n){"use strict";n["Control.Apply"]=n["Control.Apply"]||{};var t=n["Control.Apply"],r=n["Control.Apply"],e=n["Control.Category"],u=n["Data.Function"],i=n["Data.Functor"],o=function(n,t){this.Functor0=n,this.apply=t},a=new o(function(){return i.functorArray},r.arrayApply),f=function(n){return n.apply};t.Apply=o,t.apply=f,t.applySecond=function(n){return function(t){return function(r){return f(n)(i.map(n.Functor0())(u.const(e.identity(e.categoryFn)))(t))(r)}}},t.applyArray=a}(n),function(n){"use strict";n["Control.Applicative"]=n["Control.Applicative"]||{};var t=n["Control.Applicative"],r=n["Control.Apply"],e=function(n){return n.pure};t.Applicative=function(n,t){this.Apply0=n,this.pure=t},t.pure=e,t.liftA1=function(n){return function(t){return function(u){return r.apply(n.Apply0())(e(n)(t))(u)}}}}(n),function(t){"use strict";(n["Control.Bind"]=n["Control.Bind"]||{}).arrayBind=function(n){return function(t){for(var r=[],e=0,u=n.length;e<u;e++)Array.prototype.push.apply(r,t(n[e]));return r}}}(),function(n){"use strict";n["Control.Bind"]=n["Control.Bind"]||{};var t=n["Control.Bind"],r=n["Control.Bind"],e=n["Control.Apply"],u=n["Data.Function"],i=function(n,t){this.Apply0=n,this.bind=t},o=new i(function(){return e.applyArray},r.arrayBind),a=function(n){return n.bind},f=function(n){return u.flip(a(n))};t.Bind=i,t.bind=a,t.bindFlipped=f,t.composeKleisliFlipped=function(n){return function(t){return function(r){return function(e){return f(n)(t)(r(e))}}}},t.bindArray=o}(n),function(n){"use strict";n["Data.Maybe"]=n["Data.Maybe"]||{};var t=n["Data.Maybe"],r=n["Control.Applicative"],e=n["Control.Apply"],u=n["Control.Bind"],i=n["Data.Functor"],o=function(){function n(){}return n.value=new n,n}(),a=function(){function n(n){this.value0=n}return n.create=function(t){return new n(t)},n}(),f=new i.Functor(function(n){return function(t){return t instanceof a?new a(n(t.value0)):o.value}}),c=new e.Apply(function(){return f},function(n){return function(t){if(n instanceof a)return i.map(f)(n.value0)(t);if(n instanceof o)return o.value;throw new Error("Failed pattern match at Data.Maybe (line 67, column 1 - line 67, column 35): "+[n.constructor.name,t.constructor.name])}}),l=new u.Bind(function(){return c},function(n){return function(t){if(n instanceof a)return t(n.value0);if(n instanceof o)return o.value;throw new Error("Failed pattern match at Data.Maybe (line 125, column 1 - line 125, column 33): "+[n.constructor.name,t.constructor.name])}}),s=new r.Applicative(function(){return c},a.create);t.Nothing=o,t.Just=a,t.maybe=function(n){return function(t){return function(r){if(r instanceof o)return n;if(r instanceof a)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=f,t.applyMaybe=c,t.applicativeMaybe=s,t.bindMaybe=l}(n),function(n){"use strict";n["Data.Array"]=n["Data.Array"]||{};var t=n["Data.Array"],r=n["Control.Bind"],e=n["Data.Function"],u=n["Data.Maybe"],i=function(n){return[n]},o=e.flip(r.bind(r.bindArray));t.singleton=i,t.concatMap=o,t.mapMaybe=function(n){return o(function(t){return u.maybe([])(i)(n(t))})}}(n),function(n){"use strict";n["Data.Either"]=n["Data.Either"]||{};var t=n["Data.Either"],r=n["Control.Applicative"],e=n["Control.Apply"],u=n["Control.Bind"],i=n["Data.Functor"],o=n["Data.Maybe"],a=function(){function n(n){this.value0=n}return n.create=function(t){return new n(t)},n}(),f=function(){function n(n){this.value0=n}return n.create=function(t){return new n(t)},n}(),c=new i.Functor(function(n){return function(t){if(t instanceof a)return new a(t.value0);if(t instanceof f)return new f(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 a)return n(r.value0);if(r instanceof f)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 e.Apply(function(){return c},function(n){return function(t){if(n instanceof a)return new a(n.value0);if(n instanceof f)return i.map(c)(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])}}),p=new u.Bind(function(){return s},l(function(n){return function(t){return new a(n)}})(function(n){return function(t){return t(n)}})),d=new r.Applicative(function(){return s},f.create);t.Left=a,t.Right=f,t.either=l,t.note=function(n){return o.maybe(new a(n))(f.create)},t.functorEither=c,t.applyEither=s,t.applicativeEither=d,t.bindEither=p}(n),function(n){"use strict";n.fromStringAsImpl=function(n){return function(t){return function(r){var e;e=r<11?"[0-"+(r-1).toString()+"]":11===r?"[0-9a]":"[0-9a-"+String.fromCharCode(86+r)+"]";var u=new RegExp("^[\\+\\-]?"+e+"+$","i");return function(e){if(u.test(e)){var i=parseInt(e,r);return(0|i)===i?n(i):t}return t}}}},n.pow=function(n){return function(t){return 0|Math.pow(n,t)}}}(n["Data.Int"]=n["Data.Int"]||{}),function(n){"use strict";n["Data.Int"]=n["Data.Int"]||{};var t=n["Data.Int"],r=n["Data.Int"],e=n["Data.Maybe"],u=r.fromStringAsImpl(e.Just.create)(e.Nothing.value),i=u(10);t.fromString=i,t.fromStringAs=u,t.pow=r.pow}(n),function(n){"use strict";n["Data.Monoid"]=n["Data.Monoid"]||{};var t=n["Data.Monoid"];t.Monoid=function(n,t){this.Semigroup0=n,this.mempty=t},t.mempty=function(n){return n.mempty}}(n),function(t){"use strict";(n["Data.Eq"]=n["Data.Eq"]||{}).refEq=function(n){return function(t){return n===t}}}(),function(n){"use strict";n["Data.Eq"]=n["Data.Eq"]||{};var t=n["Data.Eq"],r=function(n){this.eq=n},e=new r(n["Data.Eq"].refEq);t.Eq=r,t.eq=function(n){return n.eq},t.eqInt=e}(n),function(t){"use strict";(n["Data.Ord.Unsafe"]=n["Data.Ord.Unsafe"]||{}).unsafeCompareImpl=function(n){return function(t){return function(r){return function(e){return function(u){return e<u?n:e===u?t:r}}}}}}(),function(n){"use strict";n["Data.Ordering"]=n["Data.Ordering"]||{};var t=n["Data.Ordering"],r=function(){function n(){}return n.value=new n,n}(),e=function(){function n(){}return n.value=new n,n}(),u=function(){function n(){}return n.value=new n,n}();t.LT=r,t.GT=e,t.EQ=u}(n),function(n){"use strict";n["Data.Ord.Unsafe"]=n["Data.Ord.Unsafe"]||{};var t=n["Data.Ord.Unsafe"],r=n["Data.Ord.Unsafe"],e=n["Data.Ordering"],u=r.unsafeCompareImpl(e.LT.value)(e.EQ.value)(e.GT.value);t.unsafeCompare=u}(n),function(n){"use strict";n["Data.Ord"]=n["Data.Ord"]||{};var t=n["Data.Ord"],r=n["Data.Eq"],e=n["Data.Ord.Unsafe"],u=n["Data.Ordering"],i=function(n,t){this.Eq0=n,this.compare=t},o=new i(function(){return r.eqInt},e.unsafeCompare),a=function(n){return n.compare};t.Ord=i,t.compare=a,t.max=function(n){return function(t){return function(r){var e=a(n)(t)(r);if(e instanceof u.LT)return r;if(e instanceof u.EQ)return t;if(e instanceof u.GT)return t;throw new Error("Failed pattern match at Data.Ord (line 128, column 3 - line 131, column 12): "+[e.constructor.name])}}},t.ordInt=o}(n),function(t){"use strict";(n["Data.Show"]=n["Data.Show"]||{}).showIntImpl=function(n){return n.toString()}}(),function(n){"use strict";n["Data.Show"]=n["Data.Show"]||{};var t=n["Data.Show"],r=function(n){this.show=n},e=new r(n["Data.Show"].showIntImpl);t.Show=r,t.show=function(n){return n.show},t.showInt=e}(n),function(n){"use strict";n.split=function(n){return function(t){return t.split(n)}},n.trim=function(n){return n.trim()}}(n["Data.String.Common"]=n["Data.String.Common"]||{}),function(n){"use strict";n["Data.String.Common"]=n["Data.String.Common"]||{};var t=n["Data.String.Common"],r=n["Data.String.Common"];t.split=r.split,t.trim=r.trim}(n),function(n){"use strict";n.pureE=function(n){return function(){return n}},n.bindE=function(n){return function(t){return function(){return t(n())()}}}}(n.Effect=n.Effect||{}),function(n){"use strict";n["Control.Monad"]=n["Control.Monad"]||{};var t=n["Control.Monad"],r=n["Control.Applicative"],e=n["Control.Bind"];t.Monad=function(n,t){this.Applicative0=n,this.Bind1=t},t.ap=function(n){return function(t){return function(u){return e.bind(n.Bind1())(t)(function(t){return e.bind(n.Bind1())(u)(function(e){return r.pure(n.Applicative0())(t(e))})})}}}}(n),function(n){"use strict";n.Effect=n.Effect||{};var t=n.Effect,r=n.Effect,e=n["Control.Applicative"],u=n["Control.Apply"],i=n["Control.Bind"],o=n["Control.Monad"],a=n["Data.Functor"],f=new o.Monad(function(){return s},function(){return c}),c=new i.Bind(function(){return l},r.bindE),l=new u.Apply(function(){return p},o.ap(f)),s=new e.Applicative(function(){return l},r.pureE),p=new a.Functor(e.liftA1(s));t.functorEffect=p,t.applyEffect=l,t.applicativeEffect=s,t.bindEffect=c,t.monadEffect=f}(n),function(n){"use strict";var t=function(){var n={},t="Pure",r="Throw",e="Catch",u="Sync",i="Async",o="Bind",a="Bracket",f="Fork",c="Sequential",l="Map",s="Apply",p="Alt",d="Cons",h="Resume",m="Release",w="Finalizer",v="Finalized",E="Forked";function y(n,t,r,e){this.tag=n,this._1=t,this._2=r,this._3=e}function g(n){var t=function(t,r,e){return new y(n,t,r,e)};return t.tag=n,t}function C(n){return new y(t,void 0)}function D(n){try{n()}catch(t){setTimeout(function(){throw t},0)}}function A(n,t,r){try{return t(r())}catch(e){return n(e)}}function _(n,t,r){try{return t(r)()}catch(e){return r(n(e))(),C}}var b=function(){var n=1024,t=0,r=0,e=new Array(n),u=!1;function i(){var i;for(u=!0;0!==t;)t--,i=e[r],e[r]=void 0,r=(r+1)%n,i();u=!1}return{isDraining:function(){return u},enqueue:function(o){var a;t===n&&(a=u,i(),u=a),e[(r+t)%n]=o,t++,u||i()}}}();var S=0,F=1,P=2,M=3,k=4,B=5,U=6;function I(n,l,s){var p=0,E=S,g=s,C=null,N=null,q=null,R=null,O=null,T=0,x=0,W=null,G=!0;function J(s){for(var x,K,Q;;)switch(x=null,K=null,Q=null,E){case P:E=F,g=q(g),null===R?q=null:(q=R._1,R=R._2);break;case M:n.isLeft(g)?(E=B,C=g,g=null):null===q?E=B:(E=P,g=n.fromRight(g));break;case F:switch(g.tag){case o:q&&(R=new y(d,q,R)),q=g._2,E=F,g=g._1;break;case t:null===q?(E=B,g=n.right(g._1)):(E=P,g=g._1);break;case u:E=M,g=A(n.left,n.right,g._1);break;case i:return E=k,void(g=_(n.left,g._1,function(n){return function(){p===s&&(p++,b.enqueue(function(){p===s+1&&(E=M,g=n,J(p))}))}}));case r:E=B,C=n.left(g._1),g=null;break;case e:O=new y(d,g,null===q?O:new y(d,new y(h,q,R),O,N),N),q=null,R=null,E=F,g=g._1;break;case a:T++,O=new y(d,g,null===q?O:new y(d,new y(h,q,R),O,N),N),q=null,R=null,E=F,g=g._1;break;case f:E=M,x=I(n,l,g._2),l&&l.register(x),g._1&&x.run(),g=n.right(x);break;case c:E=F,g=L(n,l,g._1)}break;case B:if(q=null,R=null,null===O)E=U,g=N||C||g;else switch(x=O._3,Q=O._1,O=O._2,Q.tag){case e:N&&N!==x?E=B:C&&(E=F,g=Q._2(n.fromLeft(C)),C=null);break;case h:N&&N!==x||C?E=B:(q=Q._1,R=Q._2,E=P,g=n.fromRight(g));break;case a:T--,null===C&&(K=n.fromRight(g),O=new y(d,new y(m,Q._2,K),O,x),(N===x||T>0)&&(E=F,g=Q._3(K)));break;case m:T++,O=new y(d,new y(v,g,C),O,N),E=F,g=N&&N!==x?Q._1.killed(n.fromLeft(N))(Q._2):C?Q._1.failed(n.fromLeft(C))(Q._2):Q._1.completed(n.fromRight(g))(Q._2),C=null;break;case w:T++,O=new y(d,new y(v,g,C),O,N),E=F,g=Q._1;break;case v:T--,E=B,g=Q._1,C=Q._2}break;case U:for(var z in W)W.hasOwnProperty(z)&&(G=G&&W[z].rethrow,D(W[z].handler(g)));return W=null,void(N&&C?setTimeout(function(){throw n.fromLeft(C)},0):n.isLeft(g)&&G&&setTimeout(function(){if(G)throw n.fromLeft(g)},0));case S:E=F;break;case k:return}}function K(n){return function(){if(E===U)return G=G&&n.rethrow,n.handler(g)(),function(){};var t=x++;return(W=W||{})[t]=n,function(){null!==W&&delete W[t]}}}return{kill:function(t,r){return function(){if(E===U)return r(n.right(void 0))(),function(){};var e=K({rethrow:!1,handler:function(){return r(n.right(void 0))}})();switch(E){case S:N=n.left(t),E=U,g=N,J(p);break;case k:null===N&&(N=n.left(t)),0===T&&(E===k&&(O=new y(d,new y(w,g(t)),O,N)),E=B,g=null,C=null,J(++p));break;default:null===N&&(N=n.left(t)),0===T&&(E=B,g=null,C=null)}return e}},join:function(n){return function(){var t=K({rethrow:!1,handler:n})();return E===S&&J(p),t}},onComplete:K,isSuspended:function(){return E===S},run:function(){E===S&&(b.isDraining()?J(p):b.enqueue(function(){J(p)}))}}}function N(t,r,e,u){var o=0,a={},f=0,c={},h=new Error("[ParAff] Early exit"),m=null,w=n;function v(r,e,u){var i,o,f=e,c=null,h=null,m=0,w={};n:for(;;)switch(i=null,f.tag){case E:if(f._3===n&&(i=a[f._1],w[m++]=i.kill(r,function(n){return function(){0===--m&&u(n)()}})),null===c)break n;f=c._2,null===h?c=null:(c=h._1,h=h._2);break;case l:f=f._2;break;case s:case p:c&&(h=new y(d,c,h)),c=f,f=f._1}if(0===m)u(t.right(void 0))();else for(o=0,i=m;o<i;o++)w[o]=w[o]();return w}function g(r){return function(e){return function(){delete a[r._1],r._3=e,function r(e,i,o){var a,d,w,E,y,g;for(t.isLeft(e)?(a=e,d=null):(d=e,a=null);;){if(w=null,E=null,y=null,g=null,null!==m)return;if(null===i)return void u(a||d)();if(i._3!==n)return;switch(i.tag){case l:null===a?(i._3=t.right(i._1(t.fromRight(d))),d=i._3):i._3=a;break;case s:if(w=i._1._3,E=i._2._3,a){if(i._3=a,y=!0,g=f++,c[g]=v(h,a===w?i._2:i._1,function(){return function(){delete c[g],y?y=!1:null===o?r(a,null,null):r(a,o._1,o._2)}}),y)return void(y=!1)}else{if(w===n||E===n)return;d=t.right(t.fromRight(w)(t.fromRight(E))),i._3=d}break;case p:if(w=i._1._3,E=i._2._3,w===n&&t.isLeft(E)||E===n&&t.isLeft(w))return;if(w!==n&&t.isLeft(w)&&E!==n&&t.isLeft(E))a=d===w?E:w,d=null,i._3=a;else if(i._3=d,y=!0,g=f++,c[g]=v(h,d===w?i._2:i._1,function(){return function(){delete c[g],y?y=!1:null===o?r(d,null,null):r(d,o._1,o._2)}}),y)return void(y=!1)}null===o?i=null:(i=o._1,o=o._2)}}(e,r._2._1,r._2._2)}}}return function(){var u,i,f=F,c=e,h=null,m=null;n:for(;;)switch(u=null,i=null,f){case F:switch(c.tag){case l:h&&(m=new y(d,h,m)),h=new y(l,c._1,n,n),c=c._2;break;case s:h&&(m=new y(d,h,m)),h=new y(s,n,c._2,n),c=c._1;break;case p:h&&(m=new y(d,h,m)),h=new y(p,n,c._2,n),c=c._1;break;default:i=o++,f=B,u=c,c=new y(E,i,new y(d,h,m),n),(u=I(t,r,u)).onComplete({rethrow:!1,handler:g(c)})(),a[i]=u,r&&r.register(u)}break;case B:if(null===h)break n;h._1===n?(h._1=c,f=F,c=h._2,h._2=n):(h._2=c,c=h,null===m?h=null:(h=m._1,m=m._2))}for(w=c,i=0;i<o;i++)a[i].run()}(),function(n){return new y(i,function(r){return function(){return function(n,r){var e;for(var u in m=t.left(n),c)if(c.hasOwnProperty(u))for(u in e=c[u])e.hasOwnProperty(u)&&e[u]();c=null;var o=v(n,w,r);return function(n){return new y(i,function(n){return function(){for(var n in o)o.hasOwnProperty(n)&&o[n]();return C}})}}(n,r)}})}}function L(n,t,r){return new y(i,function(e){return function(){return N(n,t,r,e)}})}return y.EMPTY=n,y.Pure=g(t),y.Throw=g(r),y.Catch=g(e),y.Sync=g(u),y.Async=g(i),y.Bind=g(o),y.Bracket=g(a),y.Fork=g(f),y.Seq=g(c),y.ParMap=g(l),y.ParApply=g(s),y.ParAlt=g(p),y.Fiber=I,y.Supervisor=function(n){var t={},r=0,e=0;return{register:function(n){var u=r++;n.onComplete({rethrow:!0,handler:function(n){return function(){e--,delete t[u]}}}),t[u]=n,e++},isEmpty:function(){return 0===e},killAll:function(i,o){return function(){var a=0,f={};function c(r){f[r]=t[r].kill(i,function(t){return function(){delete f[r],a--,n.isLeft(t)&&n.fromLeft(t)&&setTimeout(function(){throw n.fromLeft(t)},0),0===a&&o()}})()}for(var l in t)t.hasOwnProperty(l)&&(a++,c(l));return t={},r=0,e=0,function(n){return new y(u,function(){for(var n in f)f.hasOwnProperty(n)&&f[n]()})}}}}},y.Scheduler=b,y.nonCanceler=C,y}();n._pure=t.Pure,n._map=function(n){return function(r){return r.tag===t.Pure.tag?t.Pure(n(r._1)):t.Bind(r,function(r){return t.Pure(n(r))})}},n._bind=function(n){return function(r){return t.Bind(n,r)}},n._liftEffect=t.Sync,n._parAffMap=function(n){return function(r){return t.ParMap(n,r)}},n._parAffApply=function(n){return function(r){return t.ParApply(n,r)}},n.makeAff=t.Async,n._makeFiber=function(n,r){return function(){return t.Fiber(n,null,r)}},n._sequential=t.Seq}(n["Effect.Aff"]=n["Effect.Aff"]||{}),function(n){"use strict";n["Control.Parallel.Class"]=n["Control.Parallel.Class"]||{};var t=n["Control.Parallel.Class"];t.parallel=function(n){return n.parallel},t.sequential=function(n){return n.sequential},t.Parallel=function(n,t,r,e){this.Applicative1=n,this.Monad0=t,this.parallel=r,this.sequential=e}}(n),function(n){"use strict";n.foldrArray=function(n){return function(t){return function(r){for(var e=t,u=r.length-1;u>=0;u--)e=n(r[u])(e);return e}}},n.foldlArray=function(n){return function(t){return function(r){for(var e=t,u=r.length,i=0;i<u;i++)e=n(e)(r[i]);return e}}}}(n["Data.Foldable"]=n["Data.Foldable"]||{}),function(n){"use strict";n["Data.Semigroup"]=n["Data.Semigroup"]||{};var t=n["Data.Semigroup"];t.Semigroup=function(n){this.append=n},t.append=function(n){return n.append}}(n),function(n){"use strict";n["Data.Foldable"]=n["Data.Foldable"]||{};var t=n["Data.Foldable"],r=n["Data.Foldable"],e=n["Control.Applicative"],u=n["Control.Apply"],i=n["Data.Monoid"],o=n["Data.Semigroup"],a=n["Data.Unit"],f=function(n,t,r){this.foldMap=n,this.foldl=t,this.foldr=r},c=function(n){return n.foldr},l=function(n){return function(t){return function(r){return c(n)(function(n){return function(e){return o.append(t.Semigroup0())(r(n))(e)}})(i.mempty(t))}}},s=new f(function(n){return l(s)(n)},r.foldlArray,r.foldrArray);t.Foldable=f,t.foldr=c,t.foldl=function(n){return n.foldl},t.foldMap=function(n){return n.foldMap},t.foldMapDefaultR=l,t.traverse_=function(n){return function(t){return function(r){return c(t)(function(t){return u.applySecond(n.Apply0())(r(t))})(e.pure(n)(a.unit))}}},t.foldableArray=s}(n),function(n){"use strict";n["Control.Parallel"]=n["Control.Parallel"]||{};var t=n["Control.Parallel"],r=n["Control.Category"],e=n["Control.Parallel.Class"],u=n["Data.Foldable"],i=function(n){return function(t){return function(r){return function(i){return e.sequential(n)(u.traverse_(n.Applicative1())(t)(function(t){return e.parallel(n)(r(t))})(i))}}}};t.parTraverse_=i,t.parSequence_=function(n){return function(t){return i(n)(t)(r.identity(r.categoryFn))}}}(n),function(n){"use strict";n["Effect.Class"]=n["Effect.Class"]||{};var t=n["Effect.Class"];t.liftEffect=function(n){return n.liftEffect},t.MonadEffect=function(n,t){this.Monad0=n,this.liftEffect=t}}(n),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(n){"use strict";n.Partial=n.Partial||{};var t=n.Partial,r=n.Partial;t.crashWith=r.crashWith}(n),function(n){"use strict";n["Partial.Unsafe"]=n["Partial.Unsafe"]||{};var t=n["Partial.Unsafe"],r=n["Partial.Unsafe"],e=n.Partial;t.unsafeCrashWith=function(n){return r.unsafePartial(function(t){return e.crashWith(t)(n)})}}(n),function(t){"use strict";(n["Unsafe.Coerce"]=n["Unsafe.Coerce"]||{}).unsafeCoerce=function(n){return n}}(),function(n){"use strict";n["Unsafe.Coerce"]=n["Unsafe.Coerce"]||{};var t=n["Unsafe.Coerce"],r=n["Unsafe.Coerce"];t.unsafeCoerce=r.unsafeCoerce}(n),function(n){"use strict";n["Effect.Aff"]=n["Effect.Aff"]||{};var t=n["Effect.Aff"],r=n["Effect.Aff"],e=n["Control.Applicative"],u=n["Control.Apply"],i=n["Control.Bind"],o=n["Control.Monad"],a=n["Control.Parallel"],f=n["Control.Parallel.Class"],c=n["Data.Either"],l=n["Data.Foldable"],s=n["Data.Function"],p=n["Data.Functor"],d=n["Data.Monoid"],h=n["Data.Semigroup"],m=n["Data.Unit"],w=n.Effect,v=n["Effect.Class"],E=n["Partial.Unsafe"],y=n["Unsafe.Coerce"],g=new p.Functor(r._parAffMap),C=new p.Functor(r._map),D={isLeft:function(n){if(n instanceof c.Left)return!0;if(n instanceof c.Right)return!1;throw new Error("Failed pattern match at Effect.Aff (line 390, column 12 - line 392, column 20): "+[n.constructor.name])},fromLeft:function(n){if(n instanceof c.Left)return n.value0;if(n instanceof c.Right)return E.unsafeCrashWith("unsafeFromLeft: Right");throw new Error("Failed pattern match at Effect.Aff (line 395, column 20 - line 399, column 3): "+[n.constructor.name])},fromRight:function(n){if(n instanceof c.Right)return n.value0;if(n instanceof c.Left)return E.unsafeCrashWith("unsafeFromRight: Left");throw new Error("Failed pattern match at Effect.Aff (line 400, column 21 - line 402, column 31): "+[n.constructor.name])},left:c.Left.create,right:c.Right.create},A=function(n){return function(){var t=function(n){return r._makeFiber(D,n)}(n)();return t.run(),t}},_=new u.Apply(function(){return g},r._parAffApply),b=new o.Monad(function(){return P},function(){return S}),S=new i.Bind(function(){return F},r._bind),F=new u.Apply(function(){return C},o.ap(b)),P=new e.Applicative(function(){return F},r._pure),M=new v.MonadEffect(function(){return b},r._liftEffect),k=new f.Parallel(function(){return B},function(){return b},y.unsafeCoerce,r._sequential),B=new e.Applicative(function(){return _},function(n){return f.parallel(k)(e.pure(P)(n))}),U=new h.Semigroup(function(n){return function(t){return function(r){return a.parSequence_(k)(l.foldableArray)([n(r),t(r)])}}}),I=s.const(e.pure(P)(m.unit)),N=new d.Monoid(function(){return U},I);t.launchAff=A,t.launchAff_=function(n){return p.void(w.functorEffect)(A(n))},t.nonCanceler=I,t.functorAff=C,t.applyAff=F,t.applicativeAff=P,t.bindAff=S,t.monadAff=b,t.monadEffectAff=M,t.functorParAff=g,t.applyParAff=_,t.applicativeParAff=B,t.parallelAff=k,t.semigroupCanceler=U,t.monoidCanceler=N,t.makeAff=r.makeAff}(n),function(n){"use strict";n.new=function(n){return function(){return{value:n}}},n.read=function(n){return function(){return n.value}},n.write=function(n){return function(t){return function(){return t.value=n,{}}}}}(n["Effect.Ref"]=n["Effect.Ref"]||{}),function(n){"use strict";n["Effect.Ref"]=n["Effect.Ref"]||{};var t=n["Effect.Ref"],r=n["Effect.Ref"];t.new=r.new,t.read=r.read,t.write=r.write}(n),function(n){"use strict";n["Node.Encoding"]=n["Node.Encoding"]||{};var t=n["Node.Encoding"],r=n["Data.Show"],e=function(){function n(){}return n.value=new n,n}(),u=function(){function n(){}return n.value=new n,n}(),i=function(){function n(){}return n.value=new n,n}(),o=function(){function n(){}return n.value=new n,n}(),a=function(){function n(){}return n.value=new n,n}(),f=function(){function n(){}return n.value=new n,n}(),c=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 e)return"ASCII";if(n instanceof u)return"UTF8";if(n instanceof i)return"UTF16LE";if(n instanceof o)return"UCS2";if(n instanceof a)return"Base64";if(n instanceof f)return"Latin1";if(n instanceof c)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=e,t.UTF8=u,t.UTF16LE=i,t.UCS2=o,t.Base64=a,t.Latin1=f,t.Binary=c,t.Hex=l,t.encodingToNode=function(n){if(n instanceof e)return"ascii";if(n instanceof u)return"utf8";if(n instanceof i)return"utf16le";if(n instanceof o)return"ucs2";if(n instanceof a)return"base64";if(n instanceof f)return"latin1";if(n instanceof c)return"binary";if(n instanceof l)return"hex";throw new Error("Failed pattern match at Node.Encoding (line 31, column 1 - line 31, column 37): "+[n.constructor.name])},t.showEncoding=s}(n),function(t){"use strict";(n["Node.Process"]=n["Node.Process"]||{}).process=process}(),function(n){"use strict";n["Node.Process"]=n["Node.Process"]||{};var t=n["Node.Process"],r=n["Node.Process"],e=r.process.stdout,u=r.process.stdin;t.stdin=u,t.stdout=e}(n),function(n){"use strict";n.readChunkImpl=function(n){return function(t){return function(r){if(r instanceof Buffer)return t(r);if("string"==typeof r)return n(r);throw new Error("Node.Stream.readChunkImpl: Unrecognised chunk type; expected String or Buffer, got: "+r)}}},n.onDataEitherImpl=function(n){return function(t){return function(r){return function(){t.on("data",function(t){r(n(t))()})}}}},n.onEnd=function(n){return function(t){return function(){n.on("end",t)}}},n.write=function(n){return function(t){return function(r){return function(){return n.write(t,null,r)}}}},n.writeStringImpl=function(n){return function(t){return function(r){return function(e){return function(){return n.write(r,t,e)}}}}}}(n["Node.Stream"]=n["Node.Stream"]||{}),function(n){"use strict";n.error=function(n){return new Error(n)},n.throwException=function(n){return function(){throw n}}}(n["Effect.Exception"]=n["Effect.Exception"]||{}),function(n){"use strict";n["Effect.Exception"]=n["Effect.Exception"]||{};var t=n["Effect.Exception"],r=n["Effect.Exception"];t.throw=function(n){return r.throwException(r.error(n))}}(n),function(t){"use strict";(n["Node.Buffer"]=n["Node.Buffer"]||{}).toStringImpl=function(n){return function(t){return function(){return t.toString(n)}}}}(),function(n){"use strict";n["Node.Buffer"]=n["Node.Buffer"]||{};var t=n["Node.Buffer"],r=n["Node.Buffer"],e=n["Node.Encoding"];t.toString=function(n){return r.toStringImpl(e.encodingToNode(n))}}(n),function(n){"use strict";n["Node.Stream"]=n["Node.Stream"]||{};var t=n["Node.Stream"],r=n["Node.Stream"],e=n["Control.Applicative"],u=n["Control.Bind"],i=n["Data.Either"],o=n["Data.Show"],a=n.Effect,f=n["Effect.Exception"],c=n["Node.Buffer"],l=n["Node.Encoding"],s=r.readChunkImpl(i.Left.create)(i.Right.create),p=function(n){return function(t){return r.onDataEitherImpl(s)(n)(t)}},d=function(n){return function(t){return p(n)(u.composeKleisliFlipped(a.bindEffect)(t)(function(n){if(n instanceof i.Left)return f.throw("Stream encoding should not be set");if(n instanceof i.Right)return e.pure(a.applicativeEffect)(n.value0);throw new Error("Failed pattern match at Node.Stream (line 94, column 5 - line 98, column 17): "+[n.constructor.name])}))}};t.onData=d,t.onDataString=function(n){return function(t){return function(r){return d(n)(u.composeKleisliFlipped(a.bindEffect)(r)(c.toString(t)))}}},t.onDataEither=p,t.writeString=function(n){return function(t){return r.writeStringImpl(n)(o.show(l.showEncoding)(t))}},t.onEnd=r.onEnd}(n),function(n){"use strict";n.ABC096B=n.ABC096B||{};var t=n.ABC096B,r=n["Control.Applicative"],e=n["Control.Bind"],u=n["Control.Category"],i=n["Data.Array"],o=n["Data.Either"],a=n["Data.Functor"],f=n["Data.Int"],c=n["Data.Maybe"],l=n["Data.Monoid"],s=n["Data.Ord"],p=n["Data.Show"],d=n["Data.String.Common"],h=n["Data.Unit"],m=n.Effect,w=n["Effect.Aff"],v=n["Effect.Class"],E=n["Effect.Ref"],y=n["Node.Encoding"],g=n["Node.Process"],C=n["Node.Stream"],D=n["Partial.Unsafe"],A=function(n){return o.either(function(n){return D.unsafeCrashWith(n)})(u.identity(u.categoryFn))(e.bind(o.bindEither)((t=n,2===(a=d.split("\n")(d.trim(t))).length?o.note("int")(e.bind(c.bindMaybe)(function(){var n,t=i.mapMaybe(f.fromString)((n=a[0],d.split(" ")(n)));return 3===t.length?new c.Just({a:t[0],b:t[1],c:t[2]}):c.Nothing.value}())(function(n){return e.bind(c.bindMaybe)(f.fromString(a[1]))(function(t){return r.pure(c.applicativeMaybe)({a:n.a,b:n.b,c:n.c,k:t})})})):new o.Left("lines")))(function(n){return r.pure(o.applicativeEither)(p.show(p.showInt)((t=n.a,function(n){return function(r){return function(e){var u=s.max(s.ordInt)(t)(s.max(s.ordInt)(n)(r));return((t+n|0)+r|0)+(u*(f.pow(2)(e)-1|0)|0)|0}}})(n.b)(n.c)(n.k))+"\n");var t}));var t,a},_=w.makeAff(function(n){return function(){var t=E.new("")();return C.onDataString(g.stdin)(y.UTF8.value)(function(n){return function(){var r=E.read(t)();return E.write(r+n)(t)()}})(),C.onEnd(g.stdin)(function(){var e=E.read(t)();return n(r.pure(o.applicativeEither)(e))()})(),l.mempty(w.monoidCanceler)}}),b=w.launchAff_(e.bind(w.bindAff)(_)(function(n){return e.bind(w.bindAff)(r.pure(w.applicativeAff)(A(n)))(function(n){return v.liftEffect(w.monadEffectAff)((t=n,a.void(m.functorEffect)(C.writeString(g.stdout)(y.UTF8.value)(t)(r.pure(m.applicativeEffect)(h.unit)))));var t})}));t.main=b,t.solve=A}(n),n.ABC096B.main();
},{}]},{},["Focm"], null)

Score: 200 points

Problem Statement

There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:

Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.

What is the largest possible sum of the integers written on the blackboard after K operations?

Constraints

A, B and C are integers between 1 and 50 (inclusive).

K is an integer between 1 and 10 (inclusive).

Input

Input is given from Standard Input in the following format:

A B C
K

Output

Print the largest possible sum of the integers written on the blackboard after K operations by E869220.

Sample Input 1

5 3 11
1

Sample Output 1

30

In this sample, 5, 3, 11 are initially written on the blackboard, and E869120 can perform the operation once.

There are three choices:

Double 5: The integers written on the board after the operation are 10, 3, 11.

Double 3: The integers written on the board after the operation are 5, 6, 11.

Double 11: The integers written on the board after the operation are 5, 3, 22.

If he chooses 3., the sum of the integers written on the board afterwards is 5 + 3 + 22 = 30, which is the largest among 1. through 3.

Sample Input 2

3 3 4
2

Sample Output 2

22

E869120 can perform the operation twice. The sum of the integers eventually written on the blackboard is maximized as follows:

First, double 4. The integers written on the board are now 3, 3, 8.

Next, double 8. The integers written on the board are now 3, 3, 16.

Then, the sum of the integers eventually written on the blackboard is 3 + 3 + 16 = 22.


// inputに入力データ全体が入る
function Main(input) {
	var toping = 0;
	for(var i = 0;i<3;i++){
		if(input[i] == 'o'){
			toping = toping + 100
		}
	}

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

Score : 100 points

Problem Statement

In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions).

A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is o, it means the ramen should be topped with boiled egg; if that character is x, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen.

Write a program that, when S is given, prints the price of the corresponding bowl of ramen.

Constraints

S is a string of length 3.

Each character in S is o or x.

Input

Input is given from Standard Input in the following format:

S

Output

Print the price of the bowl of ramen corresponding to S.

Sample Input 1

oxo

Sample Output 1

900

The price of a ramen topped with two kinds of toppings, boiled egg and green onions, is 700 + 100 \times 2 = 900 yen.

Sample Input 2

ooo

Sample Output 2

1000

The price of a ramen topped with all three kinds of toppings is 700 + 100 \times 3 = 1000 yen.

Sample Input 3

xxx

Sample Output 3

700

The price of a ramen without any toppings is 700 yen.


function main(input) {
    var N = input[0].split(" ")[0]-0;
    var X = input[0].split(" ")[1]-0;
    var list = [];
    var sum = 0;
    for(var i=1;i<=N;i++) {sum += (input[i]-0); list.push(input[i]-0);}
    list.sort((a,b)=>a-b);
    X-=sum;
    console.log(N+Math.floor(X/list[0]));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))

Score : 200 points

Problem Statement

Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.

Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:

For each of the N kinds of doughnuts, make at least one doughnut of that kind.

At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.

Constraints

2 ≤ N ≤ 100

1 ≤ m_i ≤ 1000

m_1 + m_2 + ... + m_N ≤ X ≤ 10^5

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N X
m_1
m_2
:
m_N

Output

Print the maximum number of doughnuts that can be made under the condition.

Sample Input 1

3 1000
120
100
140

Sample Output 1

9

She has 1000 grams of Moto and can make three kinds of doughnuts. If she makes one doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360 grams of Moto. From the 640 grams of Moto that remains here, she can make additional six Doughnuts 2. This is how she can made a total of nine doughnuts, which is the maximum.

Sample Input 2

4 360
90
90
90
90

Sample Output 2

4

Making one doughnut for each of the four kinds consumes all of her Moto.

Sample Input 3

5 3000
150
130
150
130
110

Sample Output 3

26


function main (input) {
	var input = input.split('\n');
    var input1 = input[0].split(' ');
    N = input1[0];
	var X = parseInt(input1[1], 10);
    var m =[];
	for (var i = 0; i < input.length - 1; i++) {
	    m.push(parseInt(input[i + 1], 10));
	}
	var count = 0;
	var min = Math.min.apply(1e9, m);

	/* まず一つずつカウント*/
	for (var n = 0; n < m.length; n++) {
		X = X - m[n]
		count++
	}
	count = count + Math.floor(X / min);

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


function Main(input) {
  	var A = parseInt(input.split(" ")[0]);
  var B = parseInt(input.split(" ")[1]);
  var C = parseInt(input.split(" ")[2]);
  var X = parseInt(input.split(" ")[3]);
  var Y = parseInt(input.split(" ")[4]);

  var getABcount = Math.min(X,Y) * 2;
  if(Math.min(A,B) < C){
  if(X > Y){
     console.log(Math.min((X - Y) * A + C * getABcount,A * X + B * Y));
  }else if(Y > X){
     console.log(Math.min((Y - X) * B + C * getABcount,A * X + B * Y));
  }else{
     console.log(Math.min(C * getABcount,A * X + B * Y));
  }
  }else{
    console.log(C * Math.max(X,Y) * 2);
  }
}

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

Score : 300 points

Problem Statement

"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.

Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Constraints

1 ≤ A, B, C ≤ 5000

1 ≤ X, Y ≤ 10^5

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B C X Y

Output

Print the minimum amount of money required to prepare X A-pizzas and Y B-pizzas.

Sample Input 1

1500 2000 1600 3 2

Sample Output 1

7900

It is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.

Sample Input 2

1500 2000 1900 3 2

Sample Output 2

8500

It is optimal to directly buy three A-pizzas and two B-pizzas.

Sample Input 3

1500 2000 500 90000 100000

Sample Output 3

100000000

It is optimal to buy 200000 AB-pizzas and rearrange them into 100000 A-pizzas and 100000 B-pizzas. We will have 10000 more A-pizzas than necessary, but that is fine.


A, B, C, X, Y = gets.strip.split.map(&:to_i)

maximum_price =
  if X < Y
    C*2*Y
  else
    C*2*X
  end

reduced_price =
  if X < Y
    maximum_price-(C*2*(Y-X))+(B*(Y-X))
  else
    maximum_price-(C*2*(X-Y))+(A*(X-Y))
  end

result =
  if reduced_price < maximum_price
    reduced_price
  else
    maximum_price
  end

single_price = A*X+B*Y

result = single_price if single_price < result

#  puts(maximum_price)
#  puts(reduced_price)
  puts(result)


function main(input) {
  input = input.trim();
  const a = input.split("").map(Number);
  const gou = a[0]+a[1];
  if(gou < a[2]){
    cosole.log("NO");
  }else{
    console.log("YES");
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Score : 100 points

Problem Statement

There are a total of A + B cats and dogs.
Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs.

Determine if it is possible that there are exactly X cats among these A + B animals.

Constraints

1 \leq A \leq 100

1 \leq B \leq 100

1 \leq X \leq 200

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B X

Output

If it is possible that there are exactly X cats, print YES; if it is impossible, print NO.

Sample Input 1

3 5 4

Sample Output 1

YES

If there are one cat and four dogs among the B = 5 animals, there are X = 4 cats in total.

Sample Input 2

2 2 6

Sample Output 2

NO

Even if all of the B = 2 animals are cats, there are less than X = 6 cats in total.

Sample Input 3

5 3 2

Sample Output 3

NO

Even if all of the B = 3 animals are dogs, there are more than X = 2 cats in total.


'use strict'
let maxnum = 10e9 //Math.pow(10,9)
function countingSort(arr) {
  let sorted = []
  let tmp = [] //Array.apply(null, { length: maxnum + 1 }).map(v => 0)
  // console.log(tmparr.length)
  for (let i in arr) {
      if (tmp[arr[i]]) tmp[arr[i]] += 1
      else tmp[arr[i]] = 1
  }
  for (let i in tmp) {
    while (tmp[i] > 0) {
      sorted.push(~~i)
      tmp[i]--
    }
  }
  return sorted
}

function main(input) {
  input = input.split(/\n|\s/).map(v => ~~v)
  const n = input.shift()
  const arr = input.slice(0, -1)
  //   let sorted =  [...arr].slice(0)
  //   mergeSort(sorted, 0, n) //arr.slice(0).sort((a, b) => a - b) //countingSort(arr)
  const sorted = countingSort([...arr])
  //   const sorted = [...arr].sort((a, b) => a - b) //countingSort(arr)
  const mid = sorted[n / 2]
  const mid2 = sorted[n / 2 - 1]
  //   console.log(arr, sorted, mid)

  const ans = []
  for (let i = 0; i < n; i++) {
    ans.push(arr[i] < mid ? mid : mid2)
  }
  console.log(ans.join('\n'))
}

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

Score : 300 points

Problem Statement

When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.

You are given N numbers X_1, X_2, ..., X_N, where N is an even number.
For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.

Find B_i for each i = 1, 2, ..., N.

Constraints

2 \leq N \leq 200000

N is even.

1 \leq X_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
X_1 X_2 ... X_N

Output

Print N lines.
The i-th line should contain B_i.

Sample Input 1

4
2 4 4 3

Sample Output 1

4
3
3
4

Since the median of X_2, X_3, X_4 is 4, B_1 = 4.

Since the median of X_1, X_3, X_4 is 3, B_2 = 3.

Since the median of X_1, X_2, X_4 is 3, B_3 = 3.

Since the median of X_1, X_2, X_3 is 4, B_4 = 4.

Sample Input 2

2
1 2

Sample Output 2

2
1

Sample Input 3

6
5 5 4 4 3 3

Sample Output 3

4
4
4
4
4
4


'use strict'

function main(input) {
  input = input.split('\n')
  let n = ~~input[0]
  let x = input[1].split(' ').map(v => ~~v).sort((a, b) => a - b)
  let mid = x[n / 2]
  for (let i = 0; i < n; i++) {

      //
      if (x[i] < mid) {
          console.log(x[(n) / 2])

      } else {
          console.log(x[(n) / 2-1])
      }

  }
}

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


"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let N = cin.getInt(), A = cin.getIntArray(N);
    const P = function(n, r) {
        let ans = 1;
        for (let m = n; r > 0; m--, r--) ans *= m;
        return ans;
    }
    const C = function(n, r) {
        let ans = P(n, r);
        for (; r > 0; r--) ans /= r;
        return ans;
    }
    A.sort((a, b) => b - a);
    A.push(0);
    let a = A[0], h = a / 2;
    let max = 0, b1 = 0, b2 = 0;
    for (let n = 1; n < N; n++) {
        if (h <= A[n]) {
            b1 = A[n];
            b2 = A[n+1];
        }
    }
    if (C(a, b1) > C(a, b2))
        console.log(`${a} ${b1}`);
    else
        console.log(`${a} ${b2}`);
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Score : 400 points

Problem Statement

Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order.
From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized.
If there are multiple pairs that maximize the value, any of them is accepted.

Constraints

2 \leq n \leq 10^5

0 \leq a_i \leq 10^9

a_1,a_2,...,a_n are pairwise distinct.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

n
a_1 a_2 ... a_n

Output

Print a_i and a_j that you selected, with a space in between.

Sample Input 1

5
6 9 4 2 11

Sample Output 1

11 6

\rm{comb}(a_i,a_j) for each possible selection is as follows:

\rm{comb}(4,2)=6

\rm{comb}(6,2)=15

\rm{comb}(6,4)=15

\rm{comb}(9,2)=36

\rm{comb}(9,4)=126

\rm{comb}(9,6)=84

\rm{comb}(11,2)=55

\rm{comb}(11,4)=330

\rm{comb}(11,6)=462

\rm{comb}(11,9)=55

Thus, we should print 11 and 6.

Sample Input 2

2
100 0

Sample Output 2

100 0


function main(input) {
  input = input.trim();
  const s = input.split("");

  var count1 = s.match( /a/g ).length;
  var count2 = s.match( /b/g ).length;
  var count3 = s.match( /c/g ).length;

  console.log((count1==1 && count2==1 && count3==1) ? 'Yes' : 'No');
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Score : 100 points

Problem Statement

You are given a string S of length 3 consisting of a, b and c. Determine if S can be obtained by permuting abc.

Constraints

|S|=3

S consists of a, b and c.

Input

Input is given from Standard Input in the following format:

S

Output

If S can be obtained by permuting abc, print Yes; otherwise, print No.

Sample Input 1

bac

Sample Output 1

Yes

Swapping the first and second characters in bac results in abc.

Sample Input 2

bab

Sample Output 2

No

Sample Input 3

abc

Sample Output 3

Yes

Sample Input 4

aaa

Sample Output 4

No


'use strict';

function Main(INPUT) {
    const input = INPUT.split("");
    const ary = input.filter((x, i, self) => self.indexOf(x) === i);
    console.log(ary.length == 3 ? "Yes" : "No");
}

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


function main (input) {
  S = input.split('').sort();
  ans = S[0] + S[1] + S[2];

  if (ans === 'abc') {
    console.log('Yes');
  } else {
    console.log('No');
  }
}

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


'use strict'

const main = (input) => {
    input = input.split(' ').map(i => parseInt(i))
    const A = input[0]
    const B = input[1]
    const K = input[2]

    let nums = new Set()
    for(let i = A; i <= Math.min(A + K - 1, B); i++){
        nums.add(i)
    }
    for(let i = Math.max(B - K + 1, A + K); i <= b; i++){
        nums.add(i)
    }
    nums.forEach(v => console.log(v))
}

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

Score : 200 points

Problem Statement

Print all the integers that satisfies the following in ascending order:

Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.

Constraints

1 \leq A \leq B \leq 10^9

1 \leq K \leq 100

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B K

Output

Print all the integers that satisfies the condition above in ascending order.

Sample Input 1

3 8 2

Sample Output 1

3
4
7
8

3 is the first smallest integer among the integers between 3 and 8.

4 is the second smallest integer among the integers between 3 and 8.

7 is the second largest integer among the integers between 3 and 8.

8 is the first largest integer among the integers between 3 and 8.

Sample Input 2

4 8 3

Sample Output 2

4
5
6
7
8

Sample Input 3

2 9 100

Sample Output 3

2
3
4
5
6
7
8
9


let [a, b, c, d] = require("fs").readFileSync("/dev/stdin", "utf8").split("\n").map(Number);
console.log(Math.min(a, b) + Math.min(c, d));

Score : 100 points

Problem Statement

You planned a trip using trains and buses.
The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket.
Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket.

Find the minimum total fare when the optimal choices are made for trains and buses.

Constraints

1 \leq A \leq 1 000

1 \leq B \leq 1 000

1 \leq C \leq 1 000

1 \leq D \leq 1 000

All input values are integers.

Input

Input is given from Standard Input in the following format:

A
B
C
D

Output

Print the minimum total fare.

Sample Input 1

600
300
220
420

Sample Output 1

520

The train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you buy an unlimited ticket.
Thus, the optimal choice for trains is to buy an unlimited ticket for 300 yen.
On the other hand, the optimal choice for buses is to buy ordinary tickets for 220 yen.

Therefore, the minimum total fare is 300 + 220 = 520 yen.

Sample Input 2

555
555
400
200

Sample Output 2

755

Sample Input 3

549
817
715
603

Sample Output 3

1152


function Main(input) {
  input = input.trim()
 input = input.split("\n").map(Number);
 var sum =0;
 if(input[0]>input[1]){
sum+=input[1]
 }else{
sum+=input[0]
 }
 if(input[2]>input[3]){
sum+=input[3]
 }else{
sum+=input[2]
 }
 console.log(sum)
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));


"use strict";

function main(arg) {
    arg     = arg.split("\n");
    const A = parseInt(arg[0]);
    const B = parseInt(arg[1]);
    const C = parseInt(arg[2]);
    const D = parseInt(arg[3]);

    console.log(Math.min(A,B) + Math.min(C,D));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


"use strict";

function main(arg) {
    arg         = arg.split("\n");
    const train = arg.slice(0, 2).map(n=>parseInt(n));
    const bus   = arg.slice(-2).map(n=>parseInt(n));

    const trainFare = train.reduce((m,n)=>m>n?n:m);
    const busFare   = bus.reduce((m,n)=>m>n?n:m);

    console.log(parseInt(trainFare) + parseInt(busFare));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


"use strict"

const Main =(input)=>{
const Array=input.trim().split("")
const A=parseInt(Array[0],10)
const B=parseInt(Array[1],10)
const C=parseInt(Array[2],10)
const Answer= ((A+B)>=C) ? "Yes" : "No"
console.log(Answer)
}

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

Score : 100 points

Problem Statement

An elementary school student Takahashi has come to a variety store.

He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it?

Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.

Constraints

All input values are integers.

1 \leq A, B \leq 500

1 \leq C \leq 1000

Input

Input is given from Standard Input in the following format:

A B C

Output

If Takahashi can buy the toy, print Yes; if he cannot, print No.

Sample Input 1

50 100 120

Sample Output 1

Yes

He has 50 + 100 = 150 yen, so he can buy the 120-yen toy.

Sample Input 2

500 100 1000

Sample Output 2

No

He has 500 + 100 = 600 yen, but he cannot buy the 1000-yen toy.

Sample Input 3

19 123 143

Sample Output 3

No

There are 19-yen and 123-yen coins in Takahashi Kingdom, which are rather hard to use.

Sample Input 4

19 123 142

Sample Output 4

Yes


'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const a = parseInt(args[0][0], 10)
	const b = parseInt(args[0][1], 10)
	const c = parseInt(args[0][2], 10)
	if (a + b >= c) console.log('Yes')
	else console.log('No')
}

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


'use strict'

function main(s) {

  s = s.split('\n')[0].split(' ');
  const a = Number(s[0]);
  const b = Number(s[1]);
  const c = Number(s[2]);

  const ans = ((a + b) >= c) ? 'Yes' : 'No';
  console.log(ans);
}

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


function Main (input) {
  input = input.split('\n');
  console.log(input[0][0]+input[1][1]+input[2][2]);
}

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

Score : 100 points

Problem Statement

We have a 3×3 square grid, where each square contains a lowercase English letters.
The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}.

Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.

Constraints

Input consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

c_{11}c_{12}c_{13}
c_{21}c_{22}c_{23}
c_{31}c_{32}c_{33}

Output

Print the string of length 3 that can be obtained by concatenating the letters on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.

Sample Input 1

ant
obe
rec

Sample Output 1

abc

The letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid are a, b and c from top-right to bottom-left. Concatenate these letters and print abc.

Sample Input 2

edu
cat
ion

Sample Output 2

ean


// inputに入力データ全体が入る
function Main(input) {
	var line = input.split("\n");
	var tmp = line[0].split(" ");
	var N = Number(tmp[0]);
	var M = Number(tmp[1]);
	var ans = Math.abs((M-2)*(N-2));
	if(ans > 1000000000000000){
		var MM = M-2;
		var NN = N-2;
		var MMtop = Math.floor(MM/10000);
		var MMbottom = MM%10000;
		var NNtop = Math.floor(NN/10000);
		var NNbottom = NN%10000;
		var MN1 = MMtop * NNtop;
		var MN2 = MMbottom * NNtop + NNbottom * MMtop;
		var MN3 = MMbottom * NNbottom;
      console.log("MN1 = " + MN1);
      console.log("MN2 = " + MN2);
      console.log("MN3 = " + MN3);
		var MNbottom = (MN2 + Math.floor(MN3/10000)) + "";
      console.log(MNbottom);
		MNbottom += ("00000" + MN3%10000).slice(-4);
      console.log(MNbottom);
		var ans = (MN1 + Math.floor(Number(MNbottom)/100000000)) + "";
		ans += ("000000000" + MNbottom%100000000).slice(-8);
	}
	console.log(ans);
}

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

Score : 300 points

Problem Statement

There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region.
The front and back sides of these cards can be distinguished, and initially every card faces up.

We will perform the following operation once for each square contains a card:

For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.

It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed.
Find the number of cards that face down after all the operations.

Constraints

1 \leq N,M \leq 10^9

All input values are integers.

Input

Input is given from Standard Input in the following format:

N M

Output

Print the number of cards that face down after all the operations.

Sample Input 1

2 2

Sample Output 1

0

We will flip every card in any of the four operations. Thus, after all the operations, all cards face up.

Sample Input 2

1 7

Sample Output 2

5

After all the operations, all cards except at both ends face down.

Sample Input 3

314 1592

Sample Output 3

496080


function Main(input) {
	input = input.split(" ").map(a => parseInt(a));
	var N = input[0];
	var K = input[1];

	var ans = 0;
	if(K === 0) ans = N * N;
	else
	for(var b = K + 1; b <= N; b++){
		var t = Math.floor(N / b);
		ans += (b - K) * t;
		ans += Math.max((N - t * b) - K + 1, 0);
	}

	console.log(ans);
}

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

Score : 400 points

Problem Statement

Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten.
He remembers that the remainder of a divided by b was greater than or equal to K.
Find the number of possible pairs that he may have had.

Constraints

1 \leq N \leq 10^5

0 \leq K \leq N-1

All input values are integers.

Input

Input is given from Standard Input in the following format:

N K

Output

Print the number of possible pairs that he may have had.

Sample Input 1

5 2

Sample Output 1

7

There are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).

Sample Input 2

10 0

Sample Output 2

100

Sample Input 3

31415 9265

Sample Output 3

287927211


module.exports = (number) => {
    return Math.floor(number / 3);
}

process.stdin.on('data', (data) => {
    process.stdout.write(module.exports(Number(data)).toString());
})

Score : 100 points

Problem Statement

There are N students in a school.

We will divide these students into some groups, and in each group they will discuss some themes.

You think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible.

Divide the students so that the number of groups consisting of three or more students is maximized.

Constraints

1 \leq N \leq 1000

All input values are integers.

Input

Input is given from Standard Input in the following format:

N

Output

If you can form at most x groups consisting of three or more students, print x.

Sample Input 1

8

Sample Output 1

2

For example, you can form a group of three students and another of five students.

Sample Input 2

2

Sample Output 2

0

Sometimes you cannot form any group consisting of three or more students, regardless of how you divide the students.

Sample Input 3

9

Sample Output 3

3


function Main(input){
input  = input.slice(‘¥n’);
arare = input[1].slice(‘ ’);

if(arare.indexOf(‘Y’) != -1)
  console.log(‘Four’);
else
console.log(‘Three’);
}

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

Score : 200 points

Problem Statement

In Japan, people make offerings called hina arare, colorful crackers, on March 3.

We have a bag that contains N hina arare. (From here, we call them arare.)

It is known that the bag either contains arare in three colors: pink, white and green, or contains arare in four colors: pink, white, green and yellow.

We have taken out the arare in the bag one by one, and the color of the i-th arare was S_i, where colors are represented as follows - pink: P, white: W, green: G, yellow: Y.

If the number of colors of the arare in the bag was three, print Three; if the number of colors was four, print Four.

Constraints

1 \leq N \leq 100

S_i is P, W, G or Y.

There always exist i, j and k such that S_i=P, S_j=W and S_k=G.

Input

Input is given from Standard Input in the following format:

N
S_1 S_2 ... S_N

Output

If the number of colors of the arare in the bag was three, print Three; if the number of colors was four, print Four.

Sample Input 1

6
G W Y P Y W

Sample Output 1

Four

The bag contained arare in four colors, so you should print Four.

Sample Input 2

9
G W W G P W P G G

Sample Output 2

Three

The bag contained arare in three colors, so you should print Three.

Sample Input 3

8
P Y W G Y W Y Y

Sample Output 3

Four


"use strict";

//　組み合わせ(被りなし)
const combineWithoutRepetitions = (comboOptions, comboLength) => {
  if (comboLength === 1) {
    return comboOptions.map(comboOption => [comboOption]);
  }

  // Init combinations array.
  const combos = [];

  // Eliminate characters one by one and concatenate them to
  // combinations of smaller lengths.
  comboOptions.forEach((currentOption, optionIndex) => {
    const smallerCombos = combineWithoutRepetitions(
      comboOptions.slice(optionIndex + 1),
      comboLength - 1
    );

    smallerCombos.forEach((smallerCombo) => {
      combos.push([currentOption].concat(smallerCombo));
    });
  });

  return combos;
}

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const names = arg.splice(1, N + 1);

    const p = [0, 0, 0, 0, 0, 0, 1, 1, 1, 2];
    const q = [1, 1, 1, 2, 2, 3, 2, 2, 3, 3];
    const r = [2, 3, 4, 3, 4, 4, 3, 4, 4, 4];

    let march = [0, 0, 0, 0, 0];

    for(let i in names) {
        if(names[i][0] === "M") {
            march[0]++;
        }

        if(names[i][0] === "A") {
            march[1]++;
        }

        if(names[i][0] === "R") {
            march[2]++;
        }

        if(names[i][0] === "C") {
            march[3]++;
        }

        if(names[i][0] === "H") {
            march[4]++;
        }
    }

    let answer = 0;

    for(let i=0; i<10; i++) {
        answer += march[p[i]] * march[q[i]] * march[r[i]];
    }

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

Score : 300 points

Problem Statement

There are N people. The name of the i-th person is S_i.

We would like to choose three people so that the following conditions are met:

The name of every chosen person begins with M, A, R, C or H.

There are no multiple people whose names begin with the same letter.

How many such ways are there to choose three people, disregarding order?

Note that the answer may not fit into a 32-bit integer type.

Constraints

1 \leq N \leq 10^5

S_i consists of uppercase English letters.

1 \leq |S_i| \leq 10

S_i \neq S_j (i \neq j)

Input

Input is given from Standard Input in the following format:

N
S_1
:
S_N

Output

If there are x ways to choose three people so that the given conditions are met, print x.

Sample Input 1

5
MASHIKE
RUMOI
OBIRA
HABORO
HOROKANAI

Sample Output 1

2

We can choose three people with the following names:

MASHIKE, RUMOI, HABORO

MASHIKE, RUMOI, HOROKANAI

Thus, we have two ways.

Sample Input 2

4
ZZ
ZZZ
Z
ZZZZZZZZZZ

Sample Output 2

0

Note that there may be no ways to choose three people so that the given conditions are met.

Sample Input 3

5
CHOKUDAI
RNG
MAKOTO
AOKI
RINGO

Sample Output 3

7


function main(input){
  input = input.split('\n');
  var N = parseInt(input[0],10);
  var A = parseInt(input[1],10);
  var tmp = N % 500;
  if(tmp <= A){
    console.log('YES');
  }else{
    console.log('NO');
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Score: 100 points

Problem Statement

E869120 has A 1-yen coins and infinitely many 500-yen coins.

Determine if he can pay exactly N yen using only these coins.

Constraints

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

A is an integer between 0 and 1000 (inclusive).

Input

Input is given from Standard Input in the following format:

N
A

Output

If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print Yes; otherwise, print No.

Sample Input 1

2018
218

Sample Output 1

Yes

We can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer is Yes.

Sample Input 2

2763
0

Sample Output 2

No

When we have no 1-yen coins, we can only pay a multiple of 500 yen using only 500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.

Sample Input 3

37
514

Sample Output 3

Yes


function main(input) {
  input = input.trim();
  const a = input.split("\n").map(Number);

  console.log((a[0]%500<=a[1])?"Yes":"No");

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


console.log((args=>{
  const [N,A] = args.trim().split('\n').map(v=>v|0);
  return (A>(N%500))?'Yes':'No';
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


function main (input) {
  var line = input.split('\n');
  line[0] = line[0].substr(-1*line[0].length ,3);
   while(line[0] > 500) line[0] -= 500;

  line[0]<=line[1] ? console.log('Yes') : console.log('No');

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


'use strict'

const main = (input) => {
    input = input.split('\n')
    const As = input[1].split(' ').map(i => parseInt(i)).sort((a, b) => b - a)
    let A = []
    let B = []
    As.forEach((v, i) => {
        if(i % 2 === 0){
            A.push(v)
        }else{
            B.push(v)
        }
    })
    console.log(A.reduce((p, c) => p + c) - B.reduce((p, c) => p + c))
}

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

Score: 200 points

Problem Statement

We have N cards. A number a_i is written on the i-th card.

Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.

The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.

Constraints

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

a_i \ (1 \leq i \leq N) is an integer between 1 and 100 (inclusive).

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 a_3 ... a_N

Output

Print Alice's score minus Bob's score when both players take the optimal strategy to maximize their scores.

Sample Input 1

2
3 1

Sample Output 1

2

First, Alice will take the card with 3. Then, Bob will take the card with 1.
The difference of their scores will be 3 - 1 = 2.

Sample Input 2

3
2 7 4

Sample Output 2

5

First, Alice will take the card with 7. Then, Bob will take the card with 4. Lastly, Alice will take the card with 2. The difference of their scores will be 7 - 4 + 2 = 5. The difference of their scores will be 3 - 1 = 2.

Sample Input 3

4
20 18 2 18

Sample Output 3

18


function Main(input) {
  input = input.split(/\n/);
  balance = input[0] - input[1];

  console.log(balance % input[2]);
}

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

Score : 100 points

Problem Statement

You went shopping to buy cakes and donuts with X yen (the currency of Japan).

First, you bought one cake for A yen at a cake shop.
Then, you bought as many donuts as possible for B yen each, at a donut shop.

How much do you have left after shopping?

Constraints

1 \leq A, B \leq 1 000

A + B \leq X \leq 10 000

X, A and B are integers.

Input

Input is given from Standard Input in the following format:

X
A
B

Output

Print the amount you have left after shopping.

Sample Input 1

1234
150
100

Sample Output 1

84

You have 1234 - 150 = 1084 yen left after buying a cake.
With this amount, you can buy 10 donuts, after which you have 84 yen left.

Sample Input 2

1000
108
108

Sample Output 2

28

Sample Input 3

579
123
456

Sample Output 3

0

Sample Input 4

7477
549
593

Sample Output 4

405


const fs = require('fs');

const input = Buffer.alloc(0x10000);
fs.readSync(0, input, 0, 0x10000);

const [X, A, B] = input.toString().split('\n').map((n) => parseInt(n));
console.log((X - A) % B);


"use strict";

const main = arg => {
    arg = arg.split("\n");
    const N     = ~~arg[0];
    const table = arg.slice(1, 3).map(n=>n.split(" ").map(l=>~~l));

    const topLowSum    = table[0].reduce((m,n)=>m+n);
    const bottomLowSum = table[1].reduce((m,n)=>m+n);

    let answer = 0;
    let pivot;

    for(let i=0; i<N; i++) {
        let top  = topLowSum - table[0].slice(0, i + ~~1).reduce((m,n)=>m+n) + table[1][N-1];
        let down = i === 0 ? bottomLowSum : bottomLowSum - table[1].slice(0, i).reduce((m,n)=>m+n);

        if(down > top) {
            pivot = i;
            break;
        }
    }

    if(pivot !== undefined) {
        const beforePivot = table[0].slice(0, pivot + 1).reduce((m,n)=>m+n);
        const afterPivot  = table[1].slice(pivot, N).reduce((m,n)=>m+n);

        console.log(beforePivot + afterPivot);
    } else {
        console.log(topLowSum + table[1][N-1]);
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Score : 300 points

Problem Statement

We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j).

You are initially in the top-left square, (1, 1).
You will travel to the bottom-right square, (2, N), by repeatedly moving right or down.

The square (i, j) contains A_{i, j} candies.
You will collect all the candies you visit during the travel.
The top-left and bottom-right squares also contain candies, and you will also collect them.

At most how many candies can you collect when you choose the best way to travel?

Constraints

1 \leq N \leq 100

1 \leq A_{i, j} \leq 100 (1 \leq i \leq 2, 1 \leq j \leq N)

Input

Input is given from Standard Input in the following format:

N
A_{1, 1} A_{1, 2} ... A_{1, N}
A_{2, 1} A_{2, 2} ... A_{2, N}

Output

Print the maximum number of candies that can be collected.

Sample Input 1

5
3 2 2 4 1
1 2 2 2 1

Sample Output 1

14

The number of collected candies will be maximized when you:

move right three times, then move down once, then move right once.

Sample Input 2

4
1 1 1 1
1 1 1 1

Sample Output 2

5

You will always collect the same number of candies, regardless of how you travel.

Sample Input 3

7
3 3 4 5 4 5 3
5 3 4 4 2 3 2

Sample Output 3

29

Sample Input 4

1
2
3

Sample Output 4

5


'use strict'

const Main = (input) => {
  const Str = parseInt(input.trim().replace(/ /g, ''))

  let result = Number.isInteger(Math.sqrt(Str)) ? 'Yes' : 'No'

  console.log(result)
  return result
}

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

Score : 200 points

Problem Statement

AtCoDeer the deer has found two positive integers, a and b.
Determine whether the concatenation of a and b in this order is a square number.

Constraints

1 ≤ a,b ≤ 100

a and b are integers.

Input

Input is given from Standard Input in the following format:

a b

Output

If the concatenation of a and b in this order is a square number, print Yes; otherwise, print No.

Sample Input 1

1 21

Sample Output 1

Yes

As 121 = 11 × 11, it is a square number.

Sample Input 2

100 100

Sample Output 2

No

100100 is not a square number.

Sample Input 3

12 10

Sample Output 3

No


function Main(input) {
	const inputStrings = input.split(' ');
	const verifyNum = parseInt(inputStrings[0] + inputStrings[1]);

	let answer = 'No';
	for(let i = 1; i <= 100100; i++){
		if((i * i) === verifyNum){
			answer = 'Yes';
			break;
		}
	}
	console.log(answer);
}

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


function main(input) {
  input=input.trim();
  const a = input.split(" ")[0];
  const b = input.split(" ")[1];
  var tsunagi=Number(a+b);
  if(Number.isInteger(Math.pow(tsunagi,0.5))==true){
    console.log("Yes");
  }else{
    console.log("No");
  }

}

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


function main(input) {
  var In = input.split(' ');
  var str = In[0] + In[1];
  var num = parseInt(str, 10);
  var sqrt = Math.sqrt(num);

  if(Number.isInteger(sqrt)) {
    console.log('Yes');
  } else {
    console.log('No');
  }

}

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


function main(input) {
	input = input.split(" ");
	x = input[0];
	a = input[1];
	String(Math.sqrt(Number(String(x)+a))).indexOf('.') != -1?console.log('Yes'):console.log('No');
}

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


// inputに入力データ全体が入る
function Main(input) {
	var line = input.split("\n");
	var tmp = line[0].split(" ");
	var str1 = tmp[0] + "";
	var str2 = tmp[1] + "";
	var str = str1 + str2;
	var num = Number(str);
	var sq = Math.sqrt(num);
	var sqint = Math.floor(sq);
	if(sq === sqint) console.log("Yes");
	else console.log("No");
	return false;
}

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


function main(input) {
    input = input.split("\n").map(e => e.split(" ").map(ee => Number(ee)))
    const N = input[0][0]
    input.shift()
    let T = 0, X = 0, Y = 0
    let count = 0
    for (arr of input) {
        let t = arr[0], x = arr[1], y = arr[2]
        const diffx = Math.abs(x - X)
        const diffy = Math.abs(y - Y)
        const difft = Math.abs(t - T)
        const sum = Math.abs(x + y)
        if ((diffx + diffy <= difft) && (t % 2 == sum % 2)) {
            count += 1
        }
        T = t
        X = x
        Y = y
    }
    const mes = count==N ? "Yes" : "No"
    console.log(mes)
}

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

Score : 300 points

Problem Statement

AtCoDeer the deer is going on a trip in a two-dimensional plane.
In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.

If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).
Note that he cannot stay at his place.
Determine whether he can carry out his plan.

Constraints

1 ≤ N ≤ 10^5

0 ≤ x_i ≤ 10^5

0 ≤ y_i ≤ 10^5

1 ≤ t_i ≤ 10^5

t_i < t_{i+1} (1 ≤ i ≤ N-1)

All input values are integers.

Input

Input is given from Standard Input in the following format:

N
t_1 x_1 y_1
t_2 x_2 y_2
:
t_N x_N y_N

Output

If AtCoDeer can carry out his plan, print Yes; if he cannot, print No.

Sample Input 1

2
3 1 2
6 1 1

Sample Output 1

Yes

For example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).

Sample Input 2

1
2 100 100

Sample Output 2

No

It is impossible to be at (100,100) two seconds after being at (0,0).

Sample Input 3

2
5 1 1
100 1 1

Sample Output 3

No


const main = () => {
  const txys = getParams()
      , txys_with_init = [[0,0,0], ...txys];
  console.log(solve(txys_with_init));
};

const getParams = () =>
  getStdin().split('\n').slice(1).map(s => s.split(' ').map(Number));

const getStdin = () =>
  require('fs').readFileSync('/dev/stdin', 'utf8').trim();

const solve = txys => {
  const pairs = zip(txys, txys.slice(1));
  return pairs.every(p => reachable(p[0], p[1])) ? 'Yes' : 'No';
};

const zip = (xs, ys) => {
  const minlen = Math.min(xs.length, ys.length);
  return [...Array(minlen).keys()].map(i => [xs[i], ys[i]]);
};

const reachable = (txy1, txy2) => {
  const t1 = txy1[0]
      , t2 = txy2[0]
      , x1 = txy1[1]
      , x2 = txy2[1]
      , y1 = txy1[2]
      , y2 = txy2[2]
      , difft = t2 - t1
      , distance = manhattanDistance(x1, x2, y1, y2);
  return enoughTime(difft, distance) && sameParity(difft, distance);
};

const manhattanDistance = (x1, x2, y1, y2) =>
  Math.abs(x1 - x2) + Math.abs(y1 - y2);

const enoughTime = (difft, distance) =>
  difft >= distance;

const sameParity = (m, n) =>
  m % 2 === n % 2;

main();


function main(input) {
  const lines = input.split('\n').splice(1)
  const trips = lines.map(l => l.split(' ').map(n => Number(n)))

  var i = 0;
  var t = 0;
  var x = 0;
  var y = 0;
  while(i < trips.length) {
    const trip = trips[i];
    const dt = trip[0] - t
    const dx = Math.abs(trip[1] - x)
    const dy = Math.abs(trip[2] - y)
    if (dt < dx + dy) return console.log('No')
    if (dt % 2 != (dx + dy) % 2) return console.log('No')
    t = trip[0]
    i++;
  }
  return console.log('Yes')
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function main(input) {
    console.log( input.replace('2017', '2018') );
}

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

Score : 100 points

Problem Statement

On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in yyyy/mm/dd format. For example, January 23, 2018 should be written as 2018/01/23.

After finishing the document, she noticed that she had mistakenly wrote 2017 at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to 2018 and prints it.

Constraints

S is a string of length 10.

The first eight characters in S are 2017/01/.

The last two characters in S are digits and represent an integer between 1 and 31 (inclusive).

Input

Input is given from Standard Input in the following format:

S

Output

Replace the first four characters in S with 2018 and print it.

Sample Input 1

2017/01/07

Sample Output 1

2018/01/07

Sample Input 2

2017/01/31

Sample Output 2

2018/01/31


// https://atcoder.jp/contests/abc085/tasks/abc085_b
"use strict"
function Main(input) {
  const args = input.split('\n');
  const n = args[0];
  const kagamiMoti = [];

  for(let i = 1;i<=n; i++) {
    const moti = args[i];
    // if(!kagamiMoti.includes(moti))
    if(kagamiMoti.indexOf(moti) === -1) {
      kagamiMoti.push(moti);
    }
  }

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

Score : 200 points

Problem Statement

An X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.

Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?

Constraints

1 ≤ N ≤ 100

1 ≤ d_i ≤ 100

All input values are integers.

Input

Input is given from Standard Input in the following format:

N
d_1
:
d_N

Output

Print the maximum number of layers in a kagami mochi that can be made.

Sample Input 1

4
10
8
8
6

Sample Output 1

3

If we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, we have a 3-layered kagami mochi, which is the maximum number of layers.

Sample Input 2

3
15
15
15

Sample Output 2

1

When all the mochi have the same diameter, we can only have a 1-layered kagami mochi.

Sample Input 3

7
50
30
50
100
50
80
30

Sample Output 3

4


function main(arg) {
  var input = arg.trim().split('\n').map(i => parseInt(i));
  input.shift();

  var b = input.sort((a, b) => b - a).filter((x, i, self) => {
    return self.indexOf(x) === i;
  });
  console.log(b.length);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


'use strict'
// inputに入力データ全体が入る
function Main(input) {
  // Setで値をとるだけでユニークにできる
  const a = new Set(input.split("\n").slice(1));
  console.log(a.size);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function main(input) {
  	var input = input.split("\n")
    input = input.slice(1, input.length + 1);
    var input_rmdup = input.filter((n, i, array) => {
      return array.indexOf(n) == i;
    });
    console.log(parseInt(input_rmdup.length));
};
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


'use strict';
let fn = val => {
  return val % 2 == 0 ? val / 2 : val * 3 + 1;
};
let execute = input => {
  let mochies = input.split('\n').map(str => +str);
  mochies.shift();
  return new Set(mochies).size;
};

function Main(input) {
  console.log(execute(input));
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


'use strict';

function Main(INPUT) {
    let input = INPUT.split("\n").map(n => Number(n));
    const N = input[0];
    input.shift();
    input = input.filter((x, i, self) => self.indexOf(x) === i);
    console.log(input.length);
}

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


function main(argString) {
  	console.log(argString.split('\n').slice(1).filter((x, i, self) => self.indexOf(x) === i).length);
}

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