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(inputs){

    // ビンゴカード
    var bingoCard = [inputs[0].split(" "), inputs[1].split(" "), inputs[2].split(" ")];
    var hit = [[0,0,0],[0,0,0],[0,0,0]];
    // 選ばれた数
    var selectedNum = inputs[3];

    // 選ばれた数値の当たり判定
    for (var i = 0; i < selectedNum; i++) {

        if (bingoCard[0].indexOf(inputs[i + 4]) != -1) {

            hit[0][bingoCard[0].indexOf(inputs[i + 4])] = 1;
        } else if (bingoCard[1].indexOf(inputs[i + 4]) != -1) {

            hit[1][bingoCard[1].indexOf(inputs[i + 4])] = 1;
        } else if (bingoCard[2].indexOf(inputs[i + 4]) != -1) {

            hit[2][bingoCard[2].indexOf(inputs[i + 4])] = 1;
        }
    }

    // ビンゴ判定
    if (hit[0][0] + hit[0][1] + hit[0][2] === 3
       || hit[1][0] + hit[1][1] + hit[1][2] === 3
       || hit[2][0] + hit[2][1] + hit[2][2] === 3
       || hit[0][0] + hit[1][0] + hit[2][0] === 3
       || hit[0][1] + hit[1][1] + hit[2][1] === 3
       || hit[0][2] + hit[1][2] + hit[2][2] === 3
       || hit[0][0] + hit[1][1] + hit[2][2] === 3
       || hit[0][2] + hit[1][1] + hit[2][0] === 3) {

        console.log('Yes');
    } else {

        console.log('No');
    }
}


var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var list = new Array(3);
  list[0] = myconv(next(),4);
  list[1] = myconv(next(),4);
  list[2] = myconv(next(),4);
  var N = myconv(next(),1);
  for(var i = 0; i < N; i++){
    var tmp = myconv(next(),1);
    for(var j = 0; j < 3; j++){
      for(var k = 0; k < 3; k++){
        if(list[j][k] == tmp){
           list[j][k] = 0;
        }
      }
    }
  }
  if(list[0][0] == 0 && list[0][1] == 0 && list[0][2] == 0){
     myout("Yes");
    return;
  }
  if(list[1][0] == 0 && list[1][1] == 0 && list[1][2] == 0){
     myout("Yes");
    return;
  }
  if(list[2][0] == 0 && list[2][1] == 0 && list[2][2] == 0){
     myout("Yes");
    return;
  }
  if(list[0][0] == 0 && list[1][0] == 0 && list[2][0] == 0){
     myout("Yes");
    return;
  }
  if(list[0][1] == 0 && list[1][1] == 0 && list[2][1] == 0){
     myout("Yes");
    return;
  }
  if(list[0][2] == 0 && list[1][2] == 0 && list[2][2] == 0){
     myout("Yes");
    return;
  }
  if(list[0][0] == 0 && list[1][1] == 0 && list[2][2] == 0){
     myout("Yes");
    return;
  }
  if(list[0][2] == 0 && list[1][1] == 0 && list[2][0] == 0){
     myout("Yes");
    return;
  }
  myout("No");
}

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

Score : 200 points

Problem Statement

We have a bingo card with a 3\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.

The MC will choose N numbers, b_1, b_2, \cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.

Determine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.

Constraints

All values in input are integers.

1 \leq A_{i, j} \leq 100

A_{i_1, j_1} \neq A_{i_2, j_2} ((i_1, j_1) \neq (i_2, j_2))

1 \leq N \leq 10

1 \leq b_i \leq 100

b_i \neq b_j (i \neq j)

Input

Input is given from Standard Input in the following format:

A_{1, 1} A_{1, 2} A_{1, 3}
A_{2, 1} A_{2, 2} A_{2, 3}
A_{3, 1} A_{3, 2} A_{3, 3}
N
b_1
\vdots
b_N

Output

If we will have a bingo, print Yes; otherwise, print No.

Sample Input 1

84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30

Sample Output 1

Yes

We will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.

Sample Input 2

41 7 46
26 89 2
78 92 8
5
6
45
16
57
17

Sample Output 2

No

We will mark nothing.

Sample Input 3

60 88 34
92 41 43
65 73 48
10
60
43
88
11
48
73
65
41
92
34

Sample Output 3

Yes

We will mark all the squares.

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){
    inputI = input.split('\n');
    number = parseInt(inputI[3]);
    inputA = inputI[0].split(' ');
    inputB = inputI[1].split(' ');
    inputC = inputI[2].split(' ');
    out='No';
    for(i=4;i<4+number;i++){
        for(j=0;j<3;j++){
            if(inputA[j]==inputI[i]){
                inputA[j]='x';
                break;
            }
            if(inputB[j]==inputI[i]){
                inputB[j]='x';
                break;
            }
            if(inputC[j]==inputI[i]){
                inputC[j]='x';
                break;
            }
        }
    }

    for(i=0;i<3;i++){
        if(inputA[i]==inputB[i] && inputB[i]==inputC[i]){
            out='Yes';
        }
    }
    if(inputA[0]==inputA[1] && inputA[1]==inputA[2]){
        out='Yes';
    }

    if(inputB[0]==inputB[1] && inputB[1]==inputB[2]){
        out='Yes';
    }

    if(inputC[0]==inputC[1] && inputC[1]==inputC[2]){
        out='Yes';
    }
    if(inputA[0]==inputB[1] && inputB[1]==inputC[2]){
        out='Yes';
    }

    if(inputC[0]==inputB[1] && inputB[1]==inputA[2]){
        out='Yes';
    }

    console.log(out);

}

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


'use strict'
const Main=input=>{
    input=input.split("\n");
    for(let i=0;i<input.length;i++){
        input[i]=input[i].split(" ");
    }
    const humanNum=parseInt(input[0][0]);

    let sheet=new Array(humanNum);
    for(let i=0;i<humanNum;i++){
        sheet[i]=new Array(humanNum).fill(true);
    }

    for(let i=1;i<input.length;i++){
        sheet[input[i][0]-1][input[i][1]-1]=false;
        sheet[input[i][1]-1][input[i][0]-1]=false;

    }
    for(let i=0;i<humanNum;i++){
        if(i!=0)sheet[i][i-1]=false;
        if(i!=humanNum-1)sheet[i][i+1]=false;
        sheet[i][i]=false;
    }

    for(let i=0;i<humanNum;i++){
        let count=0;
        for(let j=0;j<humanNum;j++){
            if(sheet[i][j])count++;
        }
        sheet[i]=count;
    }

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

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

Score : 400 points

Problem Statement

An SNS has N users - User 1, User 2, \cdots, User N.

Between these N users, there are some relationships - M friendships and K blockships.

For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i.

For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User C_i and User D_i.

We define User a to be a friend candidate for User b when all of the following four conditions are satisfied:

a \neq b.

There is not a friendship between User a and User b.

There is not a blockship between User a and User b.

There exists a sequence c_0, c_1, c_2, \cdots, c_L consisting of integers between 1 and N (inclusive) such that c_0 = a, c_L = b, and there is a friendship between User c_i and c_{i+1} for each i = 0, 1, \cdots, L - 1.

For each user i = 1, 2, ... N, how many friend candidates does it have?

Constraints

All values in input are integers.

2 ≤ N ≤ 10^5

0 \leq M \leq 10^5

0 \leq K \leq 10^5

1 \leq A_i, B_i \leq N

A_i \neq B_i

1 \leq C_i, D_i \leq N

C_i \neq D_i

(A_i, B_i) \neq (A_j, B_j) (i \neq j)

(A_i, B_i) \neq (B_j, A_j)

(C_i, D_i) \neq (C_j, D_j) (i \neq j)

(C_i, D_i) \neq (D_j, C_j)

(A_i, B_i) \neq (C_j, D_j)

(A_i, B_i) \neq (D_j, C_j)

Input

Input is given from Standard Input in the following format:

N M K
A_1 B_1
\vdots
A_M B_M
C_1 D_1
\vdots
C_K D_K

Output

Print the answers in order, with space in between.

Sample Input 1

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

Sample Output 1

0 1 0 1

There is a friendship between User 2 and 3, and between 3 and 4. Also, there is no friendship or blockship between User 2 and 4. Thus, User 4 is a friend candidate for User 2.

However, neither User 1 or 3 is a friend candidate for User 2, so User 2 has one friend candidate.

Sample Input 2

5 10 0
1 2
1 3
1 4
1 5
3 2
2 4
2 5
4 3
5 3
4 5

Sample Output 2

0 0 0 0 0

Everyone is a friend of everyone else and has no friend candidate.

Sample Input 3

10 9 3
10 1
6 7
8 2
2 5
8 4
7 3
10 9
6 4
5 8
2 6
7 5
3 1

Sample Output 3

1 3 5 4 3 3 3 3 1 0


function main(input) {
 args = input.split(' ');
 let n = parseInt(args[0], 10);
 let r = parseInt(args[1], 10);

 if ( join >= 10) {
   let hiddenRating = r;
  } else {
   let argument = 100*(10 - n);
   let hiddenRating = r - argument;
  }
 }

console.log(hiddenRating);

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

Score : 100 points

Problem Statement

Takahashi is a member of a programming competition site, ButCoder.

Each member of ButCoder is assigned two values: Inner Rating and Displayed Rating.

The Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \times (10 - K) when the member has participated in K contests.

Takahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.

Constraints

All values in input are integers.

1 \leq N \leq 100

0 \leq R \leq 4111

Input

Input is given from Standard Input in the following format:

N R

Output

Print his Inner Rating.

Sample Input 1

2 2919

Sample Output 1

3719

Takahashi has participated in 2 contests, which is less than 10, so his Displayed Rating is his Inner Rating minus 100 \times (10 - 2) = 800.

Thus, Takahashi's Inner Rating is 2919 + 800 = 3719.

Sample Input 2

22 3051

Sample Output 2

3051


function main(input) {
    const args = input.split(' ');
    var n = parseInt(args[0], 10);
    const r = parseInt(args[1], 10);

  	if (n >= 10) n = 10;
    console.log(r + 100 * (10 - n));
}

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


function main(input) {
    input = input.trim().split(" ");
    var n = parseInt(input[0]);
    var k = parseInt(input[1]);
    var cnt = 0;
    while (true) {
        n /= k;
        cnt ++;
        if (n < 1) {
            break;
        }
    }
    console.log(cnt);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Score : 200 points

Problem Statement

Given is an integer N. Find the number of digits that N has in base K.

Notes

For information on base-K representation, see Positional notation - Wikipedia.

Constraints

All values in input are integers.

1 \leq N \leq 10^9

2 \leq K \leq 10

Input

Input is given from Standard Input in the following format:

N K

Output

Print the number of digits that N has in base K.

Sample Input 1

11 2

Sample Output 1

4

In binary, 11 is represented as 1011.

Sample Input 2

1010101 10

Sample Output 2

7

Sample Input 3

314159265 3

Sample Output 3

18


var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = myconv(next(),1);
  var list = myconv(next(),4);
  list.sort(function(a,b){
  	return a - b;
  });
  var output = 10000000000;
  for(var i = 1; i <= 100; i++){
    var sum = 0;
    for(var j = 0; j < N; j++){
      sum += Math.pow(i - list[j],2);
    }
    output = Math.min(output,sum);
  }
  myout(output);
}

Score : 300 points

Problem Statement

There are N people living on a number line.

The i-th person lives at coordinate X_i.

You are going to hold a meeting that all N people have to attend.

The meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.

Find the minimum total points of stamina the N people have to spend.

Constraints

All values in input are integers.

1 \leq N \leq 100

1 \leq X_i \leq 100

Input

Input is given from Standard Input in the following format:

N
X_1 X_2 ... X_N

Output

Print the minimum total stamina the N people have to spend.

Sample Input 1

2
1 4

Sample Output 1

5

Assume the meeting is held at coordinate 2. In this case, the first person will spend (1 - 2)^2 points of stamina, and the second person will spend (4 - 2)^2 = 4 points of stamina, for a total of 5 points of stamina. This is the minimum total stamina that the 2 people have to spend.

Note that you can hold the meeting only at an integer coordinate.

Sample Input 2

7
14 14 2 13 56 2 37

Sample Output 2

2354


function parseInput(input) {
  const values = []
  input.split('\n').forEach(row => {
    const list = row.split(' ')
    list.forEach(v => values.push(v))
  })

  return values
}

function getInput() {
  const dummy = `1000000000 141421 173205`
  return parseInput(dummy || require('fs').readFileSync('/dev/stdin', 'utf8'))
}

function factorial(num) {
  var number = 1
  for (var i = 1; i <= num; i++) {
    console.log(number);
    number *= i
  }
  return number
}

function combination(n, r) {
  return factorial(n) / (factorial(r) * factorial(n - r))
}

;(function main() {
  const input = getInput()
  const n = +input[0]
  const a = +input[1]
  const b = +input[2]

  var sum = 0
  for (var r = 1; r <= n; r++) {
    if (r === a || r === b) {
      continue
    }

    sum += combination(n, r)
  }

  const c = Math.pow(10, 9) + 7
  console.log(sum % c)
})()

Score : 400 points

Problem Statement

Akari has n kinds of flowers, one of each kind.

She is going to choose one or more of these flowers to make a bouquet.

However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.

How many different bouquets are there that Akari can make?

Find the count modulo (10^9 + 7).

Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.

Constraints

All values in input are integers.

2 \leq n \leq 10^9

1 \leq a < b \leq \textrm{min}(n, 2 \times 10^5)

Input

Input is given from Standard Input in the following format:

n a b

Output

Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print 0.)

Sample Input 1

4 1 3

Sample Output 1

7

In this case, Akari can choose 2 or 4 flowers to make the bouquet.

There are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so there are a total of 7 different bouquets that Akari can make.

Sample Input 2

1000000000 141421 173205

Sample Output 2

34076506

Print the count modulo (10^9 + 7).


function isPoor(A, B, C)
{

   if ( (A === B) && ( A === C) )
  {
   return "No";
  }

else if ( (A === B) || ( A === C) )
  {
    return "Yes";
   }

else if( (B === C) || (B ===A) )
  {
      return "Yes";
   }

else if( ( (C===A) || (C===B) )

       {
            return "Yes";
       }

else
{
return "No";
}

}

Score: 100 points

Problem Statement

A triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.

You will be given three integers A, B, and C. If this triple is poor, print Yes; otherwise, print No.

Constraints

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

Input

Input is given from Standard Input in the following format:

A B C

Output

If the given triple is poor, print Yes; otherwise, print No.

Sample Input 1

5 7 5

Sample Output 1

Yes

A and C are equal, but B is different from those two numbers, so this triple is poor.

Sample Input 2

4 4 4

Sample Output 2

No

A, B, and C are all equal, so this triple is not poor.

Sample Input 3

4 9 6

Sample Output 3

No

Sample Input 4

3 3 4

Sample Output 4

Yes


'use strict'

// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
  let line1 = input[0].split(" ");
  let n = line1[0];

  let array = [];

  for(let i=0; i<n; i++) {
    let index = array.findIndex(item => item.name === input[i+1]);
    // arrayに単語が存在しない時
    if( index === -1 ) {
      array.push( {name: input[i+1], n: 1} );
    }
    else {
      array[index].n += 1;
    }
  }

  array.sort(function(a, b) {
    if (a.n < b.n) {
      return 1;
    } else {
      return -1;
    }
  })

  let max = array[0].n;
  let ans = [];

  for(let i=0; array[i].n=== max; i++) {
    ans.push(array[i].name);
  }

  ans.sort();

  for(let i=0; i<ans.length; i++) {
    console.log(ans[i]);
  }
}

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

Score: 300 points

Problem Statement

We have N voting papers. The i-th vote (1 \leq i \leq N) has the string S_i written on it.

Print all strings that are written on the most number of votes, in lexicographical order.

Constraints

1 \leq N \leq 2 \times 10^5

S_i (1 \leq i \leq N) are strings consisting of lowercase English letters.

The length of S_i (1 \leq i \leq N) is between 1 and 10 (inclusive).

Input

Input is given from Standard Input in the following format:

N
S_1
:
S_N

Output

Print all strings in question in lexicographical order.

Sample Input 1

7
beat
vet
beet
bed
vet
bet
beet

Sample Output 1

beet
vet

beet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.

Sample Input 2

8
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo

Sample Output 2

buffalo

Sample Input 3

7
bass
bass
kick
kick
bass
kick
kick

Sample Output 3

kick

Sample Input 4

4
ushi
tapu
nichia
kun

Sample Output 4

kun
nichia
tapu
ushi


'use strict'

function main(inp) {
  inp = inp.trim().split('\n')
  const N = inp.shift()
  inp = inp.sort()

  let ans = []
  let num = 0
  let count = 0
  for (let i = 0; i < inp.length; i++) {
    count++;
    if ((i + 1 === N) || inp[i] !== inp[i+1]) {
      if (count === num) {
        ans.push(inp[i])
      } else if (count > num) {
        num = count
        ans = [inp[i]]
      }
      count = 0
    }
  }

  console.log(ans.join('\n'))
}

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


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

var input = '';
process.stdin.on('data', (chunk) => {
  input += chunk;
});
process.stdin.on('end', () => {
  main(input.split(/\r?\n/));
});

var main = (lines) => {
  var array = [];
  var max = 0;
  for(var i=1; i<lines.length; i++) {
    var found = array.find((e) => {return e.name === lines[i];});
    if(found === undefined) {
      found = {'name':lines[i],'count':1};
      array.push(found);
    }
    else {
      found.count++;
    }
    if(found.count > max) {
      max = found.count;
    }
  }
  array.filter((e) => {return e.count === max;}).map((e) => {return e.name;}).sort().forEach((e) => {console.log(e);});
}


Score : 200 points

Problem Statement

Given is a string S. Replace every character in S with x and print the result.

Constraints

S is a string consisting of lowercase English letters.

The length of S is between 1 and 100 (inclusive).

Input

Input is given from Standard Input in the following format:

S

Output

Replace every character in S with x and print the result.

Sample Input 1

sardine

Sample Output 1

xxxxxxx

Replacing every character in S with x results in xxxxxxx.

Sample Input 2

xxxx

Sample Output 2

xxxx

Sample Input 3

gone

Sample Output 3

xxxx


function Main(input) {
	input = input.split("\n");
	var ans = '';
	for(var i=0; i<input[0].length; i++){
    	ans = ans + 'x';
    }
	console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function Main(input){
  input=input.split("\n");
  num = input[0];
  var a = input[1].split(" ");
  a.sort(function(a,b){
    return parseInt(a,10) - parseInt(b,10);
  });
  for(var n = 0; n < num-1; n++){
    if(a[n]===a[n+1]){
      console.log("NO");
      return;
    }
  }
  console.log("YES");
}

Score : 300 points

Problem Statement

Given is a sequence of integers A_1, A_2, ..., A_N.
If its elements are pairwise distinct, print YES; otherwise, print NO.

Constraints

2 ≤ N ≤ 200000

1 ≤ A_i ≤ 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 ... A_N

Output

If the elements of the sequence are pairwise distinct, print YES; otherwise, print NO.

Sample Input 1

5
2 6 1 4 5

Sample Output 1

YES

The elements are pairwise distinct.

Sample Input 2

6
4 1 3 1 6 2

Sample Output 2

NO

The second and fourth elements are identical.

Sample Input 3

2
10000000 10000000

Sample Output 3

NO


"use strict"
function Main(input) {
  input = input.trim().split('\n');
  const N = Number(input[0].trim());
  const A = input[1].trim().split(' ').map(Number);

  let ret = 'YES';
  for(let i=0; i<N; i++){
    let r = A.filter((val) => {
      return val === A[i];
    })
    if(r.length > 1){
      ret = 'NO';
      break;
    }
  }

  console.log(ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


"use strict";
function main(input) {
  let k = input[0].split(" ");
  k = k[1];
  let n = input[1].split(" ");

  //期待値の前計算
  let exp = [];
  for(let i=0;i<n.length;i++){
    exp[i] = (2 + parseInt(n[i],10)) / 2;
  }

  //累積和の計算
  let sum = [0];
  for(let i=0;i<n.length;i++){
    sum[i+1] = sum [i] + exp[i];
  }

  //隣接するk項の和の計算
  let max = 0;
  for(let i=k-1;i<n.length;i++){
    let max_n = sum[i] - sum[i-k];
    max = (max<max_n)?max_n:max;
  }
  console.log(max);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Score : 400 points

Problem Statement

We have N dice arranged in a line from left to right. The i-th die from the left shows p_i numbers from 1 to p_i with equal probability when thrown.

We will choose K adjacent dice, throw each of them independently, and compute the sum of the numbers shown. Find the maximum possible value of the expected value of this sum.

Constraints

1 ≤ K ≤ N ≤ 200000

1 ≤ p_i ≤ 1000

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
p_1 ... p_N

Output

Print the maximum possible value of the expected value of the sum of the numbers shown.

Your output will be considered correct when its absolute or relative error from our answer is at most 10^{-6}.

Sample Input 1

5 3
1 2 2 4 5

Sample Output 1

7.000000000000

When we throw the third, fourth, and fifth dice from the left, the expected value of the sum of the numbers shown is 7. This is the maximum value we can achieve.

Sample Input 2

4 1
6 6 6 6

Sample Output 2

3.500000000000

Regardless of which die we choose, the expected value of the number shown is 3.5.

Sample Input 3

10 4
17 13 13 12 15 20 10 13 17 11

Sample Output 3

32.000000000000


"use strict"

function func(val){
  return 1/2 * val * (1+val);
}

function Main(input) {
  input = input.trim().split('\n');
  const N = input[0].trim().split(' ').map(Number)[0];
  const K = input[0].trim().split(' ').map(Number)[1];
  const p = input[1].trim().split(' ').map(Number);

  let max = N - K;
  let ret = 0;
  let obj = {}
  for(let i=0; i<=max; i++){
    let tmp = p.slice(i, K+i);
    obj[i] = tmp;
  }

  for(let k in obj){
    let tmp = obj[k];
    let cnt = 0;
    for(let i=0; i<K; i++){
      let s = tmp[i];
      let expect = func(s)/s;
      cnt += expect;
    }
    if(ret < cnt) ret = cnt;
  }

  console.log(ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var fs = __importStar(require("fs"));
// 210 5
// 31 41 59 26 53
var input = fs.readFileSync('/dev/stdin', 'utf8').split('\n');
var line1 = input[0];
var line2 = input[1];
var h = parseInt(line1.split(' ')[0], 10);
var n = parseInt(line1.split(' ')[1], 10);
var tech = line2.split(' ').map(function (n) { return parseInt(n, 10); });
for (var i = 0; i < tech.length; i++) {
    h -= tech[i];
}
if (h <= 0) {
    console.log('Yes');
}
else {
    console.log('No');
}

Score : 200 points

Problem Statement

Raccoon is fighting with a monster.

The health of the monster is H.

Raccoon can use N kinds of special moves. Using the i-th move decreases the monster's health by A_i.
There is no other way to decrease the monster's health.

Raccoon wins when the monster's health becomes 0 or below.

If Raccoon can win without using the same move twice or more, print Yes; otherwise, print No.

Constraints

1 \leq H \leq 10^9

1 \leq N \leq 10^5

1 \leq A_i \leq 10^4

All values in input are integers.

Input

Input is given from Standard Input in the following format:

H N
A_1 A_2 ... A_N

Output

If Raccoon can win without using the same move twice or more, print Yes; otherwise, print No.

Sample Input 1

10 3
4 5 6

Sample Output 1

Yes

The monster's health will become 0 or below after, for example, using the second and third moves.

Sample Input 2

20 3
4 5 6

Sample Output 2

No

Sample Input 3

210 5
31 41 59 26 53

Sample Output 3

Yes

Sample Input 4

211 5
31 41 59 26 53

Sample Output 4

No


// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    tmp = input[0].split(" ");
    var hp = parseInt(tmp[0], 10);
    var n = parseInt(tmp[1], 10);
	//文字列から10進数に変換するときはparseIntを使います
    var command = input[1].split(" ");
    command.sort(function(a,b){
        return (a < b ? 1 : -1);
      });
    var maps = {};
    var m = command.length;
    for(var i=0;i<m;i++){
        if((!maps[command[i]])){
            maps[command[i]]=1;
        }else if( maps[command[i]] > 0){
            maps[command[i]]++;
            continue;
        }
        if(command[i]>0){
            hp = hp - command[i];
        }
        if(hp<=0){
            console.log("Yes");
            break;
        }
    }
    if(hp>0){
        console.log("No");
    }
}
// *この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));