Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
長さ 3 の文字列 S が与えられます。
S に 1 度だけ含まれる文字を 1 つ出力してください。
但し、そのような文字が存在しない場合は代わりに -1 と出力してください。
制約
- S は英小文字のみからなる 3 文字の文字列
入力
入力は以下の形式で標準入力から与えられる。
S
出力
答えを出力せよ。正解が複数ある場合、どれを出力してもよい。
入力例 1
pop
出力例 1
o
pop に o は 1 度だけ含まれます。
入力例 2
abc
出力例 2
a
abc に a, b, c はどれも 1 度だけ含まれるので、どれを出力しても構いません。
入力例 3
xxx
出力例 3
-1
xxx に 1 度だけ含まれる文字はありません。
Score : 100 points
Problem Statement
You are given a string S of length 3.
Print a character that occurs only once in S.
If there is no such character, print -1 instead.
Constraints
- S is a string of length 3 consisting of lowercase English letters.
Input
Input is given from Standard Input in the following format:
S
Output
Print the answer. If multiple solutions exist, you may print any of them.
Sample Input 1
pop
Sample Output 1
o
o occurs only once in pop.
Sample Input 2
abc
Sample Output 2
a
a, b, and c occur once each in abc, so you may print any of them.
Sample Input 3
xxx
Sample Output 3
-1
No character occurs only once in xxx.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
正の整数 X について、レベル X の 龍文字列 とは、1 個の L, X 個の o, 1 個の n, 1 個の g をこの順に並べた長さ (X+3) の文字列です。
正の整数 N が与えられるので、レベル N の龍文字列を出力してください。
大文字と小文字は区別されることに注意してください。
制約
- 1\leq N\leq 2024
- N は整数
入力
入力は以下の形式で標準入力から与えられる。
N
出力
レベル N の龍文字列を出力せよ。
入力例 1
3
出力例 1
Looong
1 個の L, 3 個の o, 1 個の n, 1 個の g をこの順に並べた文字列は Looong です。
入力例 2
1
出力例 2
Long
Score: 100 points
Problem Statement
For a positive integer X, the Dragon String of level X is a string of length (X+3) formed by one L, X occurrences of o, one n, and one g arranged in this order.
You are given a positive integer N. Print the Dragon String of level N.
Note that uppercase and lowercase letters are distinguished.
Constraints
- 1 \leq N \leq 2024
- N is an integer.
Input
The input is given from Standard Input in the following format:
N
Output
Print the Dragon String of level N.
Sample Input 1
3
Sample Output 1
Looong
Arranging one L, three os, one n, and one g in this order yields Looong.
Sample Input 2
1
Sample Output 2
Long
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
1,\ldots,N の番号のついた N 人の選手がゲームを行いました。選手 i のスコアは A_i であり、スコアが小さい方が上位になります。
ブービー賞に該当する選手、すなわち、下位から 2 番目の選手の番号を求めてください。
制約
- 2 \leq N \leq 2\times 10^5
- 1 \leq A_i \leq 10^9
- A_i は相異なる
- 入力に含まれる値は全て整数である
入力
入力は以下の形式で標準入力から与えられる。
N A_1 \ldots A_N
出力
答えを出力せよ。
入力例 1
6 1 123 12345 12 1234 123456
出力例 1
3
6 人中 5 位になるのは、選手 3 です。
入力例 2
5 3 1 4 15 9
出力例 2
5
Score : 200 points
Problem Statement
N players, who are numbered 1, \ldots, N, have played a game. Player i has scored A_i, and a player with a smaller score ranks higher.
The player who ranks the second lowest will receive a booby prize. Who is this player? Answer with an integer representing the player.
Constraints
- 2 \leq N \leq 2\times 10^5
- 1 \leq A_i \leq 10^9
- A_i are distinct.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
N A_1 \ldots A_N
Output
Print the answer.
Sample Input 1
6 1 123 12345 12 1234 123456
Sample Output 1
3
It is Player 3 who ranks fifth among the six players.
Sample Input 2
5 3 1 4 15 9
Sample Output 2
5
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 150 点
問題文
健康に気を使っている高橋君は、M 種類の栄養素について、食事によって十分な量を摂取できているか気になりました。
i 番目の栄養素は 1 日あたり A_i 以上摂取することが目標です。
高橋君は今日 N 品の食品を食べ、i 品目の食品からは栄養素 j を X_{i,j} 摂取しました。
M 種類全ての栄養素で目標を達成しているかどうかを判定してください。
制約
- 1 \leq N \leq 100
- 1 \leq M \leq 100
- 0 \leq A_i,X_{i,j} \leq 10^7
- 入力は全て整数である
入力
入力は以下の形式で標準入力から与えられる。
N M
A_1 \ldots A_M
X_{1,1} \ldots X_{1,M}
\vdots
X_{N,1} \ldots X_{N,M}
出力
M 種類全ての栄養素で目標を達成しているなら Yes、そうでないならば No を出力せよ。
入力例 1
2 3 10 20 30 20 0 10 0 100 100
出力例 1
Yes
栄養素 1 は 1 品目から 20、2 品目から 0 摂取したため、合わせて 20 摂取しており、10 以上摂取するという目標を達成しています。
栄養素 2,3 についても同様に目標を達成しています。
入力例 2
2 4 10 20 30 40 20 0 10 30 0 100 100 0
出力例 2
No
栄養素 4 について目標を達成していません。
Score : 150 points
Problem Statement
Takahashi is health-conscious and concerned about whether he is getting enough of M types of nutrients from his diet.
For the i-th nutrient, his goal is to take at least A_i units per day.
Today, he ate N foods, and from the i-th food, he took X_{i,j} units of nutrient j.
Determine whether he has met the goal for all M types of nutrients.
Constraints
- 1 \leq N \leq 100
- 1 \leq M \leq 100
- 0 \leq A_i, X_{i,j} \leq 10^7
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N M
A_1 \ldots A_M
X_{1,1} \ldots X_{1,M}
\vdots
X_{N,1} \ldots X_{N,M}
Output
Print Yes if the goal is met for all M types of nutrients, and No otherwise.
Sample Input 1
2 3 10 20 30 20 0 10 0 100 100
Sample Output 1
Yes
For nutrient 1, Takahashi took 20 units from the 1-st food and 0 units from the 2-nd food, totaling 20 units, thus meeting the goal of taking at least 10 units.
Similarly, he meets the goal for nutrients 2 and 3.
Sample Input 2
2 4 10 20 30 40 20 0 10 30 0 100 100 0
Sample Output 2
No
The goal is not met for nutrient 4.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
正整数 x,y に対して f(x,y) を「(x+y) を 10^8 で割ったあまり」として定義します。
長さ N の正整数列 A=(A_1,\ldots,A_N) が与えられます。次の式の値を求めてください。
制約
- 2\leq N\leq 3\times 10^5
- 1\leq A_i < 10^8
- 入力される数値は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N A_1 \ldots A_N
出力
答えを出力せよ。
入力例 1
3 3 50000001 50000002
出力例 1
100000012
- f(A_1,A_2)=50000004
- f(A_1,A_3)=50000005
- f(A_2,A_3)=3
なので、答えは f(A_1,A_2)+f(A_1,A_3)+f(A_2,A_3) = 100000012 です。
総和を 10^8 で割ったあまりを求めるわけではないことに注意してください。
入力例 2
5 1 3 99999999 99999994 1000000
出力例 2
303999988
Score: 300 points
Problem Statement
For positive integers x and y, define f(x, y) as the remainder of (x + y) divided by 10^8.
You are given a sequence of positive integers A = (A_1, \ldots, A_N) of length N. Find the value of the following expression:
Constraints
- 2 \leq N \leq 3\times 10^5
- 1 \leq A_i < 10^8
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N A_1 \ldots A_N
Output
Print the answer.
Sample Input 1
3 3 50000001 50000002
Sample Output 1
100000012
- f(A_1,A_2)=50000004
- f(A_1,A_3)=50000005
- f(A_2,A_3)=3
Thus, the answer is f(A_1,A_2) + f(A_1,A_3) + f(A_2,A_3) = 100000012.
Note that you are not asked to compute the remainder of the sum divided by 10^8.
Sample Input 2
5 1 3 99999999 99999994 1000000
Sample Output 2
303999988
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 250 点
問題文
N 種類のビーンズが 1 粒ずつあります。 i 種類目のビーンズはおいしさが A_i で色が C_i です。ビーンズは混ぜられており、色でしか区別することができません。
あなたはビーンズの色を 1 つ選び、その色のビーンズをどれか 1 粒食べます。ビーンズの色をうまく選ぶことで、食べる可能性のあるビーンズのおいしさの最小値を最大化してください。
制約
- 1 \leq N \leq 2 \times 10^{5}
- 1 \leq A_i \leq 10^{9}
- 1 \leq C_i \leq 10^{9}
- 入力は全て整数である。
入力
入力は以下の形式で標準入力から与えられる。
N A_1 C_1 A_2 C_2 \vdots A_N C_N
出力
食べる可能性のあるビーンズのおいしさの最小値の最大値を整数として出力せよ。
入力例 1
4 100 1 20 5 30 5 40 1
出力例 1
40
同じ色のビーンズは互いに区別がつかないことに注意してください。
選ぶことができる色は 色 1 と 色 5 です。
- 色 1 のビーンズは 2 種類あり、美味しさはそれぞれ 100, 40 です。よって、色 1 を選んだときのおいしさの最小値は 40 です。
- 色 5 のビーンズは 2 種類あり、美味しさはそれぞれ 20, 30 です。よって、色 5 を選んだときのおいしさの最小値は 20 です。
おいしさの最小値を最大化するには 色 1 を選べばよいため、そのときの最小値である 40 を出力します。
入力例 2
10 68 3 17 2 99 2 92 4 82 4 10 3 100 2 78 1 3 1 35 4
出力例 2
35
Score: 250 points
Problem Statement
There are N types of beans, one bean of each type. The i-th type of bean has a deliciousness of A_i and a color of C_i. The beans are mixed and can only be distinguished by color.
You will choose one color of beans and eat one bean of that color. By selecting the optimal color, maximize the minimum possible deliciousness of the bean you eat.
Constraints
- 1 \leq N \leq 2 \times 10^{5}
- 1 \leq A_i \leq 10^{9}
- 1 \leq C_i \leq 10^{9}
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N A_1 C_1 A_2 C_2 \vdots A_N C_N
Output
Print as an integer the maximum value of the minimum possible deliciousness of the bean you eat.
Sample Input 1
4 100 1 20 5 30 5 40 1
Sample Output 1
40
Note that beans of the same color cannot be distinguished from each other.
You can choose color 1 or color 5.
- There are two types of beans of color 1, with deliciousness of 100 and 40. Thus, the minimum deliciousness when choosing color 1 is 40.
- There are two types of beans of color 5, with deliciousness of 20 and 30. Thus, the minimum deliciousness when choosing color 5 is 20.
To maximize the minimum deliciousness, you should choose color 1, so print the minimum deliciousness in that case: 40.
Sample Input 2
10 68 3 17 2 99 2 92 4 82 4 10 3 100 2 78 1 3 1 35 4
Sample Output 2
35
Time Limit: 4 sec / Memory Limit: 1024 MiB
配点 : 450 点
問題文
整数 N と A, B, C からなる長さ N の文字列 R,C が与えられるので、以下の問題を解いてください。
N \times N のマス目があり、最初全てのマスは空きマスです。
各マスに A, B, C のうち高々 1 文字を書き込みます。( 空きマスのままにすることも許されます )
以下の条件を全て満たすことが可能であるか判定し、可能であれば書き込み方を 1 つ出力して下さい。
- 各行 / 各列 に
A,B,Cがちょうど 1 個ずつ含まれる - i 行目に書かれた文字の中で最も左にある文字は R の i 文字目と一致する
- i 列目に書かれた文字の中で最も上にある文字は C の i 文字目と一致する
制約
- N は 3 以上 5 以下の整数
- R,C は
A,B,Cからなる長さ N の文字列
入力
入力は以下の形式で標準入力から与えられる。
N R C
出力
問題文中の条件を満たす書き込み方が存在しない場合、 No と 1 行に出力してください。
そうでない場合、以下の形式に従い書き込み方を出力してください。
Yes A_1 A_2 \vdots A_N
まず、 1 行目に Yes と出力してください。
続く N 行のうちの i 行目に、長さ N の文字列である A_i を出力してください。
- A_i の j 文字目が
.であるとき、上から i 行目、左から j 列目のマスは空きマスであることを示します。 - A_i の j 文字目が
Aであるとき、上から i 行目、左から j 列目のマスにAが書き込まれたことを示します。 - A_i の j 文字目が
Bであるとき、上から i 行目、左から j 列目のマスにBが書き込まれたことを示します。 - A_i の j 文字目が
Cであるとき、上から i 行目、左から j 列目のマスにCが書き込まれたことを示します。
正しい書き込み方が複数存在する場合、どれを出力しても構いません。
入力例 1
5 ABCBC ACAAB
出力例 1
Yes AC..B .BA.C C.BA. BA.C. ..CBA
出力例のマス目は以下の条件を全て満たすため、正解として扱われます。
- 全ての行に
A,B,Cがちょうど 1 個ずつ含まれる - 全ての列に
A,B,Cがちょうど 1 個ずつ含まれる - 各行に書かれた最も左の文字は上から順に
A,B,C,B,Cである - 各列に書かれた最も上の文字は左から順に
A,C,A,A,Bである
入力例 2
3 AAA BBB
出力例 2
No
この入力では、条件を満たす書き込み方は存在しません。
Score : 450 points
Problem Statement
You are given an integer N and strings R and C of length N consisting of A, B, and C. Solve the following problem.
There is a N \times N grid. All cells are initially empty.
You can write at most one character from A, B, and C in each cell. (You can also leave the cell empty.)
Determine if it is possible to satisfy all of the following conditions, and if it is possible, print one way to do so.
- Each row and each column contain exactly one
A, oneB, and oneC. - The leftmost character written in the i-th row matches the i-th character of R.
- The topmost character written in the i-th column matches the i-th character of C.
Constraints
- N is an integer between 3 and 5, inclusive.
- R and C are strings of length N consisting of
A,B, andC.
Input
The input is given from Standard Input in the following format:
N R C
Output
If there is no way to fill the grid to satisfy the conditions in the problem statement, print No in one line.
Otherwise, print one such way to fill the grid in the following format:
Yes A_1 A_2 \vdots A_N
The first line should contain Yes.
The i-th of the subsequent N lines should contain a string A_i of length N.
- If the j-th character of A_i is
., it indicates that the cell in the i-th row from the top and the j-th column from the left is empty. - If the j-th character of A_i is
A, it indicates thatAis written in the cell in the i-th row from the top and the j-th column from the left. - If the j-th character of A_i is
B, it indicates thatBis written in the cell in the i-th row from the top and the j-th column from the left. - If the j-th character of A_i is
C, it indicates thatCis written in the cell in the i-th row from the top and the j-th column from the left.
If there are multiple correct ways to fill the grid, you may print any of them.
Sample Input 1
5 ABCBC ACAAB
Sample Output 1
Yes AC..B .BA.C C.BA. BA.C. ..CBA
The grid in the output example satisfies all the following conditions, so it will be treated as correct.
- Each row contains exactly one
A, oneB, and oneC. - Each column contains exactly one
A, oneB, and oneC. - The leftmost characters written in the rows are
A,B,C,B,Cfrom top to bottom. - The topmost characters written in the columns are
A,C,A,A,Bfrom left to right.
Sample Input 2
3 AAA BBB
Sample Output 2
No
For this input, there is no way to fill the grid to satisfy the conditions.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 500 点
問題文
長さ N の数列 A=(A_1,A_2,\ldots,A_N) が与えられます。ここで、各 A_i (1\leq i\leq N) は 1\leq A_i \leq N をみたします。
高橋君と青木君が N 回ゲームを行います。i=1,2,\ldots,N 回目のゲームは次のようにして行われます。
- 青木君が正整数 K_i を指定する。
- 青木君の指定した K_i を聞いた後、高橋君は 1 以上 N 以下の整数 S_i を選び、黒板に書く。
-
その後、 K_i 回次の操作を繰り返す。
- 黒板に x が書かれているとき、それを消し、A_x を新しく書く。
K_i 回の操作の後で黒板に書かれている整数が i ならば i 回目のゲームは高橋君の勝ち、そうでないならば青木君の勝ちとなります。
ここで、K_i,S_i は i=1,2,\ldots,N に対して独立に選ぶ事ができます。
両者が、自身が勝つために最善の行動をとったとき、N 回のゲームのうち高橋君が勝つ回数を求めてください。
制約
- 1\leq N\leq 2\times 10^5
- 1\leq A_i\leq N
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N A_1 A_2 \ldots A_N
出力
両者が最善の行動をとったとき、N 回のゲームのうち高橋君が勝つ回数を出力せよ。
入力例 1
3 2 2 3
出力例 1
2
1 回目のゲームにおいて、青木君が K_1=2 を指定したとき、高橋君は S_1 として、1,2,3 のいずれを選んでも勝つことはできません。
例えば、高橋君が最初に黒板に S_1=1 と書いたとすると、2 回の操作で黒板に書かれている数は順に 1\to 2(=A_1) 、2\to 2(=A_2) と変化し、
最終的に黒板に書かれている数は 2(\neq 1) であるため、青木君の勝ちとなります。
一方、2,3 回目のゲームにおいては、青木君の指定した K_i の値によらず、高橋君はそれぞれ 2,3 を最初に黒板に書くことで勝つ事ができます。
よって、両者が、自分が勝つために最善の行動をとったとき、高橋君が勝つゲームは 2,3 回目の 2 回であるため、2 を出力します。
入力例 2
2 2 1
出力例 2
2
1 回目のゲームにおいて、高橋君は、青木君が指定した K_1 が奇数のときは 2、偶数のときは 1 を最初に黒板に書く事で勝つ事ができます。
同様に 2 回目のゲームにおいても勝つ方法が存在するため、1,2 回目のゲームのいずれでも高橋君は勝利する事ができ、2 が答えとなります。
Score : 500 points
Problem Statement
You are given a sequence of N numbers: A=(A_1,A_2,\ldots,A_N). Here, each A_i (1\leq i\leq N) satisfies 1\leq A_i \leq N.
Takahashi and Aoki will play N rounds of a game. For each i=1,2,\ldots,N, the i-th game will be played as follows.
- Aoki specifies a positive integer K_i.
- After knowing K_i Aoki has specified, Takahashi chooses an integer S_i between 1 and N, inclusive, and writes it on a blackboard.
-
Repeat the following K_i times.
- Replace the integer x written on the blackboard with A_x.
If i is written on the blackboard after the K_i iterations, Takahashi wins the i-th round; otherwise, Aoki wins.
Here, K_i and S_i can be chosen independently for each i=1,2,\ldots,N.
Find the number of rounds Takahashi wins if both players play optimally to win.
Constraints
- 1\leq N\leq 2\times 10^5
- 1\leq A_i\leq N
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
N A_1 A_2 \ldots A_N
Output
Find the number of rounds Takahashi wins if both players play optimally to win.
Sample Input 1
3 2 2 3
Sample Output 1
2
In the first round, if Aoki specifies K_1=2, Takahashi cannot win whichever option he chooses for S_1: 1, 2, or 3.
For example, if Takahashi writes S_1=1 on the initial blackboard, the two operations will change this number as follows: 1\to 2(=A_1), 2\to 2(=A_2). The final number on the blackboard will be 2(\neq 1), so Aoki wins.
On the other hand, in the second and third rounds, Takahashi can win by writing 2 and 3, respectively, on the initial blackboard, whatever value Aoki specifies as K_i.
Therefore, if both players play optimally to win, Takashi wins two rounds: the second and the third. Thus, you should print 2.
Sample Input 2
2 2 1
Sample Output 2
2
In the first round, Takahashi can win by writing 2 on the initial blackboard if K_1 specified by Aoki is odd, and 1 if it is even.
Similarly, there is a way for Takahashi to win the second round. Thus, Takahashi can win both rounds: the answer is 2.
Time Limit: 3 sec / Memory Limit: 1024 MiB
配点 : 525 点
問題文
xy 平面上に N 個の点 1,2,\dots,N があります。このうち点 i は座標 (X_i,Y_i) にあります。
あなたは、以下の操作を 0 回以上 K 回以下行うことができます。
- まず、 N 点の中からひとつを選択する。選ばれた点を k とし、この点が現在 (x,y) にあるものとする。
- 次に、以下の 4 つからひとつを選択し、実行する。
- 点 k を x 軸沿いに +1 だけ移動させる。点 k の座標は (x+1,y) となる。
- 点 k を x 軸沿いに -1 だけ移動させる。点 k の座標は (x-1,y) となる。
- 点 k を y 軸沿いに +1 だけ移動させる。点 k の座標は (x,y+1) となる。
- 点 k を y 軸沿いに -1 だけ移動させる。点 k の座標は (x,y-1) となる。
- 複数の点を同じ座標に存在させることも許されます。また、入力で複数の点が同じ座標に存在しうることに注意してください。
全ての操作が終わった後、 N 個全ての点を内部または周上に包含する、各辺が x 軸または y 軸に平行な正方形をひとつ書き込みます。
このとき、書き込む正方形の一辺の長さとしてありうる最小の値を求めてください。全ての点が常に格子点にあることから、この値は整数であることが示せます。
特に、全ての点を同じ座標に存在させられる時、答えは 0 であるものとします。
制約
- 入力は全て整数
- 1 \le N \le 2 \times 10^5
- 0 \le K \le 4 \times 10^{14}
- 0 \le X_i,Y_i \le 10^9
入力
入力は以下の形式で標準入力から与えられる。
N K X_1 Y_1 X_2 Y_2 \vdots X_N Y_N
出力
答えを整数として出力せよ。
入力例 1
6 5 2 0 5 2 0 3 3 2 3 4 1 5
出力例 1
3
このケースについて、横を x 軸、縦を y 軸として図示したものが以下です。

例えば、図中の矢印に従って 4 度の移動を行った後、図中に示した一辺が 3 の正方形で全ての点を内部または周上に含むことができ、これが最小値であることが示せます。
入力例 2
4 400000000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
出力例 2
0
最初から全ての点が同じ座標に存在します。
例えば操作を 0 回行う (即ち、全く行わない) ことにより、全ての点を同じ座標に存在させられるので、この入力に対する答えは 0 です。
入力例 3
10 998244353 489733278 189351894 861289363 30208889 450668761 133103889 306319121 739571083 409648209 922270934 930832199 304946211 358683490 923133355 369972904 539399938 915030547 735320146 386219602 277971612
出力例 3
484373824
Score : 525 points
Problem Statement
There are N points labeled 1, 2, \dots, N on the xy-plane. Point i is located at coordinates (X_i, Y_i).
You can perform the following operation between 0 and K times, inclusive.
- First, choose one of the N points. Let k be the selected point, and assume it is currently at (x, y).
- Next, choose and execute one of the following four actions:
- Move point k along the x-axis by +1. The coordinates of point k become (x+1, y).
- Move point k along the x-axis by -1. The coordinates of point k become (x-1, y).
- Move point k along the y-axis by +1. The coordinates of point k become (x, y+1).
- Move point k along the y-axis by -1. The coordinates of point k become (x, y-1).
- It is allowed to have multiple points at the same coordinates. Note that the input may already have multiple points at the same coordinates.
After all your operations, draw one square that includes all the N points inside or on the circumference, with each side parallel to the x- or y-axis.
Find the minimum possible value for the length of a side of this square. This value can be shown to be an integer since all points are always on lattice points.
In particular, if all points can be made to exist at the same coordinates, the answer is considered to be 0.
Constraints
- All input values are integers.
- 1 \le N \le 2 \times 10^5
- 0 \le K \le 4 \times 10^{14}
- 0 \le X_i, Y_i \le 10^9
Input
Input is given from Standard Input in the following format:
N K X_1 Y_1 X_2 Y_2 \vdots X_N Y_N
Output
Print the answer as an integer.
Sample Input 1
6 5 2 0 5 2 0 3 3 2 3 4 1 5
Sample Output 1
3
The figure below illustrates this case with the horizontal x-axis and the vertical y-axis.

For example, after performing four moves following the arrows in the figure, you can include all points inside or on the circumference of the square shown in the figure with a side length of 3, and this can be shown to be the minimum value.
Sample Input 2
4 400000000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
Sample Output 2
0
All points already exist at the same coordinates from the beginning.
For example, by performing zero operations, all points can be made to exist at the same coordinates, so the answer for this input is 0.
Sample Input 3
10 998244353 489733278 189351894 861289363 30208889 450668761 133103889 306319121 739571083 409648209 922270934 930832199 304946211 358683490 923133355 369972904 539399938 915030547 735320146 386219602 277971612
Sample Output 3
484373824