input stringlengths 20 127k | target stringlengths 20 119k | problem_id stringlengths 6 6 |
|---|---|---|
x, a, b = list(map(int, input().split()))
ans = 'A'
if abs(x-a)>abs(x-b):
ans='B'
print(ans)
#print(*ans, sep='\n')
| A, B, C = list(map(int, input().split()))
def check():
if abs(B-A)<abs(C-A):
return 'A'
return 'B'
print((check())) | p03623 |
x,a,b=input().split()
x=int(x)
a=int(a)
b=int(b)
y1=x-a
y2=x-b
y1=abs(y1)
y2=abs(y2)
if y1<y2:
print("A")
else:
print("B") | x, a, b = input().split()
x = int(x)
a = int(a)
b = int(b)
#print("x =", x)
#print("a =", a)
#print("b =", b)
if x < a:
xa = a - x
else:
xa = x - a
if x < b:
xb = b - x
else:
xb = x - b
if xa > xb:
print('B')
else:
print('A') | p03623 |
x,a,b=list(map(int,input().split()));print(('AB'[abs(a-x)>abs(b-x)])) | x,a,b=list(map(int,input().split()))
print(('AB'[(x+x>a+b)^(a>b)])) | p03623 |
x,a,b=list(map(int,input().split()))
if abs(x-a)<abs(x-b):
print("A")
else:
print("B")
| x,a,b=list(map(int,input().split()))
flg=0
if b<a:
b,a=a,b
flg=1
ans = ["A","B"]
if 2*x<b+a:
print((ans[flg]))
else:
print((ans[-1+flg]))
| p03623 |
x, a, b = list(map(int,input().split()))
A = abs(x - a)
B = abs(x - b)
if(A < B):
print('A')
else:
print('B') | x, a, b = list(map(int,input().split()))
if(abs(x-a) < abs(x-b)):
print('A')
else:
print('B') | p03623 |
x,a,b=list(map(int,input().split()))
if abs(x-a)<abs(x-b):
print("A")
else:
print("B")
| x,a,b=list(map(int,input().split()))
print(("A" if abs(x-a)<abs(x-b) else "B")) | p03623 |
import math
MOD = pow(10, 9)+7
N, M = list(map(int, input().split()))
if abs(N - M) > 1:
print(0)
else:
if N == M:
res = ( math.factorial(N) * math.factorial(N) * 2 )%MOD
else:
res = ( math.factorial(N) * math.factorial(M) )%MOD
print(res) | MOD = pow(10, 9)+7
N, M = list(map(int, input().split()))
def myfact(num):
res = 1
for i in range(num+1)[1:]:
res *= i
if res > MOD:
res %= MOD
return res
if abs(N - M) > 1:
print(0)
else:
if N == M:
res = ( myfact(N) * myfact(N) * 2 )%MOD
else:
res = ( myfact(N) * myfact(M) )%MOD
... | p03683 |
M,N=input().split(' ')
M=int(M)
N=int(N)
res=1
if M==N:
for i in range(1, M+1):
res*=i
res=res*res*2
elif M-N==1:
for i in range(1, N+1):
res*=i
res*=res*M
elif M-N==-1:
for i in range(1, M+1):
res*=i
res*=res*N
else:
res=0
print((res%(10**9+7)))... | from math import *
M,N=input().split(' ')
M=int(M)
N=int(N)
res=1
if M==N:
res=factorial(M)
res=res*res*2
elif M-N==1:
res=factorial(N)
res*=res*M
elif M-N==-1:
res=factorial(M)
res*=res*N
else:
res=0
print((res%(10**9+7)))
| p03683 |
from math import factorial
n, m = list(map(int, input().split()))
if abs(n - m) > 1:
print((0))
elif n == m:
print(((factorial(n) * factorial(m) * 2) % (10 ** 9 + 7)))
else:
print((factorial(n) * factorial(m))) | def factorial(x):
res = 1
for i in range(1, x):
res *= i + 1
res %= 10 ** 9 + 7
return res
n, m = list(map(int, input().split()))
if abs(n - m) > 1:
print((0))
elif n == m:
print(((factorial(n) * factorial(m) * 2) % (10 ** 9 + 7)))
else:
print((factorial(n) * factor... | p03683 |
import math
n, m = list(map(int,input().split()))
sum = 0
if -2<n-m<2:
if n<m:
n,m = m,n
sum = math.factorial(n)*math.factorial(m)*2**(m-n+1)
sum %= 1000000007
print(sum) | n, m = list(map(int,input().split()))
MOD = 1000000007
def f(n):
ans = 1
for i in range(1,n+1):
ans*=i
ans%=MOD
return ans
sum = 0
if -2<n-m<2:
if n<m:
n,m = m,n
sum = f(n)*f(m)*2**(m-n+1)
sum %= MOD
print(sum)
| p03683 |
MOD = 10 ** 9 + 7
def kaijo(n):
k = 1
for i in range(1, n + 1):
k *= i % MOD
return k
n, m = list(map(int, input().split()))
if n == m:
print(((kaijo(n) ** 2 * 2) % MOD))
elif abs(n - m) > 1:
print((0))
else:
if n < m:
print(((kaijo(n) ** 2 * m) % MOD))
else... | MOD = 10 ** 9 + 7
def kaijo(n):
k = 1
for i in range(1, n + 1):
k = k * i % MOD
return k
n, m = list(map(int, input().split()))
if n == m:
print(((kaijo(n) ** 2 * 2) % MOD))
elif abs(n - m) > 1:
print((0))
else:
if n < m:
print(((kaijo(n) ** 2 * m) % MOD))
e... | p03683 |
import math
n, m = list(map(int, input().split()))
mod = 10 ** 9 + 7
if abs(n-m) > 1:
print((0))
exit()
if abs(n-m) == 0:
ans = math.factorial(n) * math.factorial(m) * 2 % mod
print(ans)
else:
ans = math.factorial(n) % mod * math.factorial(m) % mod
print(ans) | import math
n, m = list(map(int, input().split()))
mod = 10 ** 9 + 7
if abs(n-m) > 1:
print((0))
else:
ans = 1
for i in range(1, n+1):
ans = ans * i % mod
for j in range(1, m+1):
ans = ans * j % mod
if abs(n-m) == 0:
print((2 * ans % mod))
else:
... | p03683 |
n, m = list(map(int, input().split()))
def fac(x):
ans = 1
for i in range(1, x + 1):
ans = ans * i
return(ans)
if n < m:
n, m = m, n
if n - m >= 2:
print((0))
elif n - m == 1:
print(((fac(m)) ** 2 * n % (10 ** 9 + 7) ))
else:
print(((fac(n)) ** 2 * 2 % (10 ** 9 + 7... | n, m = list(map(int, input().split()))
def fac(x):
ans = 1
for i in range(1, x + 1):
ans = (ans * i) % (10 ** 9 + 7)
return(ans)
if n < m:
n, m = m, n
if n - m >= 2:
print((0))
elif n - m == 1:
print(((fac(m)) ** 2 * n % (10 ** 9 + 7) ))
else:
print(((fac(n)) ** 2 ... | p03683 |
from functools import reduce
from operator import mul
def main():
N,M = list(map(int,input().split()))
if N == M:
L = [i for i in range(1,N + 1)]
ans = (reduce(mul,L) ** 2) * 2 % (10 ** 9 + 7)
print(ans)
elif N + 1 == M or M + 1 == N:
L1 = [i for i in range(1,N + 1)]
L2 = [i for ... | import sys
from functools import reduce,lru_cache
import math
from operator import mul
def main():
#sys.setrecursionlimit(10 ** 5 + 1)
N,M = list(map(int,input().split()))
@lru_cache(maxsize = None)
def recur(n):
if n == 0:
return 1
else:
m = n * recur(n - 1)
return ... | p03683 |
N = str(eval(input()))
if '9' in N:
flag = 'Yes'
else:
flag = 'No'
print(flag)
| N = eval(input())
if '9' in str(N):
x = 'Yes'
else:
x = 'No'
print(x) | p03605 |
print((input().count("9")and"Yes"or"No")) | print(("YNeos"[input().count("9")<1::2])) | p03605 |
import heapq
n,k=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(n)]
x=[l[i][0] for i in range(n)]
x.sort()
y=[l[i][1] for i in range(n)]
y.sort()
ans=[]
for i1 in range(n):
for i2 in range(i1+1,n):
for i3 in range(n):
for i4 in range(i3+1,n):
ct=0
... | n,k=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(n)]
x=[l[i][0] for i in range(n)]
x.sort()
y=[l[i][1] for i in range(n)]
y.sort()
ans=[]
for i1 in range(n):
for i2 in range(i1+1,n):
for i3 in range(n):
for i4 in range(i3+1,n):
ct=0
for i5 in ra... | p03576 |
N,K=list(map(int,input().split()))
point=[]
answer=10**19
for i in range(N):
point.append(list(map(int,input().split())))
sorted(point)
for left in range(N):
for right in range(N):
dx=point[right][0]-point[left][0]
for ceil in range(N):
for bottom in range(N):
if point[bottom][1] ... | #https://atcoder.jp/contests/abc075/submissions/2242350
N,K=list(map(int,input().split()))
points=[tuple(map(int,input().split())) for i in range(N)]
answer=10**19
sortx=sorted(points)
numberx = list(enumerate(sortx))
#n-k+1以降を左の頂点とすると点の数が明らかに足りない
for left,(x1,y1) in numberx[:N-K+1]:
#left+K-1以降を右の頂点にしないと... | p03576 |
n,k = list(map(int,input().split()))
ary = [list(map(int,input().split())) for _ in range(n)]
ary_x = sorted(ary)
ary_y = sorted(ary,key=lambda x:(x[1],x[0]))
ans = float("Inf")
for xi in range(n):
for xj in range(1,n):
for yi in range(n):
for yj in range(1,n):
count =... | n,k = list(map(int,input().split()))
ary = [list(map(int,input().split())) for _ in range(n)]
ary.sort()
ans = float("Inf")
for i in range(n-k+1):
for j in range(k,n-i+1):
xmin = ary[i][0]
xmax = ary[i+j-1][0]
ary_y = sorted(ary[i:i+j], key=lambda x: (x[1]))
for l in range... | p03576 |
n,k = list(map(int,input().split()))
ary = [list(map(int,input().split())) for _ in range(n)]
ary.sort()
ans = float("Inf")
for i in range(n-k+1):
for j in range(k,n-i+1):
xmin = ary[i][0]
xmax = ary[i+j-1][0]
ary_y = sorted(ary[i:i+j], key=lambda x: (x[1]))
for l in range... | N,K = list(map(int,input().split()))
ary = [list(map(int,input().split())) for _ in range(N)]
a = sorted(ary)
ans = float("Inf")
for i in range(N-K+1):
for j in range(i,N-K+1):
lx = a[i][0]; rx = a[K+j-1][0]
b = a[i:K+j]
c = sorted(b,key=lambda x:(x[1]))
for k in range(len(c... | p03576 |
from itertools import combinations
n, k = [int(item) for item in input().split()]
xy = [[int(item) for item in input().split()] for _ in range(n)]
xsort = sorted(xy, key=lambda x: x[0])
ysort = sorted(xy, key=lambda x: x[1])
l = [i for i in range(n)]
def count_points_in_rec(x0, x1, y0, y1):
count = ... | from itertools import combinations
n, k = [int(item) for item in input().split()]
xy = [[int(item) for item in input().split()] for _ in range(n)]
xsort = sorted(xy, key=lambda x: x[0])
ysort = sorted(xy, key=lambda x: x[1])
l = [i for i in range(n)]
cum = [[0 for _ in range(n+1)] for _ in range(n+1)]
f... | p03576 |
N, K = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(N)]
x = sorted(v for v, _ in X)
y = sorted(v for _, v in X)
ans = 10 ** 20
for x1 in x:
for x2 in x:
for y1 in y:
for y2 in y:
num = 0
for i in range(N):
... | N, K = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(N)]
x = sorted(v for v, _ in X)
y = sorted(v for _, v in X)
ans = 10 ** 20
for i in range(N - 1):
for j in range(i + 1, N):
for k in range(N - 1):
for l in range(k + 1, N):
x1 = ... | p03576 |
from itertools import product,combinations
N,K=list(map(int,input().split()))
L=[tuple(map(int,input().split())) for i in range(N)]
ans=10**37
def f(i,j,k,l):
n=0
s=min(L[j][0],L[i][0])
t=max(L[j][0],L[i][0])
u=min(L[k][1],L[l][1])
w=max(L[k][1],L[l][1])
for e in L:
if s<=e[0]... | N,K=list(map(int,input().split()))
L=[tuple(map(int,input().split())) for i in range(N)]
L.sort()
ans=10**37
for i in range(N):
for j in range(i+1,N):
t=L[j][0]-L[i][0]
S=sorted(x[1] for x in L[i:j+1])
for k in range(len(S)-K+1):
u=S[K+k-1]-S[k]
ans=min(ans,... | p03576 |
N, K = list(map(int, input().split()))
dots = []
for _ in range(N):
x, y = list(map(int, input().split()))
dots.append((x, y))
import sys
INT_MAX = sys.maxsize
ans = INT_MAX
import itertools
for ((left_x, _), (right_x, _)) in itertools.combinations(dots, 2):
if left_x > right_x:
... | N, K = list(map(int, input().split()))
XY = []
for _ in range(N):
x, y = list(map(int, input().split()))
XY.append((x, y))
dots = XY[:]
import sys
INT_MAX = sys.maxsize
ans = INT_MAX
import itertools
for ((left_x, _), (right_x, _)) in itertools.combinations(dots, 2):
if left_x > rig... | p03576 |
from itertools import combinations
n,k = list(map(int,input().split()))
P = sorted([list(map(int,input().split())) for i in range(n)])
area = float('inf')
for x1,x2 in combinations(list(range(n)),2):
for y1,y2 in combinations(list(range(n)),2):
point = 0
for i in range(n):
if (min(P[... | from itertools import combinations
n,k = list(map(int,input().split()))
Px = sorted([list(map(int,input().split())) for i in range(n)])
Py = sorted(Px,key=lambda p:p[1])
area = float('inf')
for x1 in range(n-1):
for x2 in range(x1+1,n):
for y1 in range(n-1):
point = 0
... | p03576 |
N, K = (int(x) for x in input().split())
Plot = [tuple(int(x) for x in input().split()) for _ in range(N)]
X = [p[0] for p in Plot]
Y = [p[1] for p in Plot]
X.sort()
Y.sort()
#全2点間で長方形の辺を作り、その内内部点がK個のものだけ面積を比較する。
ans = 10e20
from itertools import combinations
for x1, x2 in combinations(X, 2):
for y1, y2 i... | N, K = (int(x) for x in input().split())
Plot = [tuple(int(x) for x in input().split()) for _ in range(N)]
X = [p[0] for p in Plot]
Y = [p[1] for p in Plot]
X.sort()
Y.sort()
#全2点間で長方形の辺を作り、その内内部点がK個のものだけ面積を比較する。
ans = 10e20
from itertools import combinations
for x1, x2 in combinations(X, 2):
for y1 in Y:... | p03576 |
from itertools import combinations, product
from functools import reduce
import bisect as bs
from collections import namedtuple
Area = namedtuple('Area', ['xinf', 'xsup', 'yinf', 'ysup'])
def tuple_int(iterable):
return tuple(map(int, iterable.split()))
def insert_xy(line):
x, y = list(map(int, li... | from itertools import combinations, product
import bisect as bs
def tuple_int(iterable):
return tuple(map(int, iterable.split()))
def S_with_K_plots(plots, K):
result = []
X, Y = sorted([x for x,y in plots]), sorted([y for x,y in plots])
for xinf, xsup in combinations(X,2):
for yinf ... | p03576 |
import itertools
from functools import lru_cache
N,K = list(map(int, input().split()))
XY = [[int(x) for x in input().split()] for _ in range(N)]
XY.sort()
X,Y = list(zip(*XY))
@lru_cache(None)
def cnt(x,y):
c = 0
for x1,y1 in XY:
if x1 > x:
break
if y1 <= y:
c += 1
return ... | import itertools
N,K = list(map(int, input().split()))
XY = [[int(x) for x in input().split()] for _ in range(N)]
XY.sort()
X,Y = list(zip(*XY))
min_area = 5*10**18
for left,right in itertools.combinations(list(range(N)),2):
width = X[right] - X[left]
pts = sorted(XY[left:right+1], key = lambda xy: ... | p03576 |
import sys
def LI(): return([int(x) for x in sys.stdin.readline().split()])
N,K = LI()
XY = [LI() for _ in range(N)]
X = []
Y = []
for x,y in XY:
if not(x in X):
X.append(x)
if not(y in Y):
Y.append(y)
X.sort()
Y.sort()
ans = []
for xl in range(len(X)-1):
for xr in range... | import sys
def LI(): return([int(x) for x in sys.stdin.readline().split()])
N,K = LI()
XY = [LI() for _ in range(N)]
X = []
Y = []
for x,y in XY:
if not(x in X):
X.append(x)
if not(y in Y):
Y.append(y)
X.sort()
Y.sort()
dic_XoYo = {}
dic_XcYo = {}
dic_XoYc = {}
dic_... | p03576 |
import sys
def LI(): return([int(x) for x in sys.stdin.readline().split()])
N,K = LI()
XY = [LI() for _ in range(N)]
X = []
Y = []
for x,y in XY:
if not(x in X):
X.append(x)
if not(y in Y):
Y.append(y)
X.sort()
Y.sort()
dic_XoYo = {}
dic_XcYo = {}
dic_XoYc = {}
dic_... | import sys
I = lambda:[int(x) for x in sys.stdin.readline().split()]
N,K = I()
Z = [I() for _ in range(N)]
Z.sort()
INF = 10**20
ans = INF
for i in range(N):
for j in range(i+K-1,N):
l = sorted(t[1] for t in Z[i:j+1])
ans_tmp = [(Z[j][0]-Z[i][0])*(v-u) for u,v in zip(l,l[K-1:])]
... | p03576 |
n, k = list(map(int,input().split()))
xs = []
ys = []
points = []
for _ in range(n):
x, y = list(map(int, input().split()))
xs.append(x)
ys.append(y)
points.append((x, y))
min_ = float('inf')
for leftx in xs:
for rightx in xs:
if leftx >= rightx:
... | n, k = list(map(int,input().split()))
ps = [tuple(map(int,input().split())) for i in range(n)]
sx = sorted(ps,key = lambda x: x[0]) # x座標でソート
nx = list(enumerate(sx)) # 頂点番号を付加
ans = 5e18
for f, (x1,y1) in nx[:n-k+1]: # 左辺の頂点
for e, (x2,y2) in nx[f+k-1:]: # 右辺の頂点
dx = x2 - x1 # 横
sy = so... | p03576 |
n, k = list(map(int, input().split()))
lst = [list(map(int, input().split())) for i in range(n)]
min_area = 10**100
for a in lst:
for b in lst:
for c in lst:
for d in lst:
count = 0
for e in lst:
if a[0] <= e[0] <= b[0] or a[0] >= e[... | n, k = list(map(int, input().split()))
lst = [list(map(int, input().split())) for i in range(n)]
answer = 10**100
sortx = sorted(lst, key = lambda x: x[0])
for a, pt1 in enumerate(sortx[:n-k+1]):
for b, pt2 in enumerate(sortx[a+k-1:]):
#print(a,b)
sorty = sorted(sortx[a:a+k+b], key = lambda... | p03576 |
# 全縦線と全横線を全探索するとO(N^5)
# 50 ** 5 = 312500000
# 縦線の選び方は50 C 2だから2分の1になるのを考慮しても、78125000
# いや無理だろ……と思ったら公式がこの解法だった。衝撃。
# 二次元累積和を使うと各回の計算がO(1)になるので、O(N^4)となる。
# まず O(N^5)解法を作ってみよう。通るのかこれ?
n, k = list(map(int, input().split()))
coords = [list(map(int, input().split())) for _ in range(n)]
ans = (3 * 10 ** 9)... | # 全縦線と全横線を全探索するとO(N^5)
# 50 ** 5 = 312500000
# 縦線の選び方は50 C 2だから2分の1になるのを考慮しても、78125000
# いや無理だろ……と思ったら公式がこの解法だった。衝撃。
# 二次元累積和を使うと各回の計算がO(1)になるので、O(N^4)となる。
# まず O(N^5)解法を作ってみよう。通るのかこれ?
# Python 3.8.2 ではTLE、PyPyではAC(1.2秒)
n, k = list(map(int, input().split()))
coords = [list(map(int, input().split())) for _ ... | p03576 |
n,k = list(map(int,input().split()))
xy = [list(map(int,input().split())) for _ in range(n)]
ans = float('inf')
for i in range(len(xy)):
for j in range(i+1,len(xy)):
x1 = min(xy[i][0],xy[j][0])
x2 = max(xy[i][0],xy[j][0])
for m in range(len(xy)):
for l in range(m+1,len(xy... | n,k = list(map(int,input().split()))
x_y = [list(map(int,input().split())) for _ in range(n)]
x_y = sorted(x_y,key=lambda x:(x[0],x[1]))
ans = float('inf')
for i in range(n-1):
for j in range(i+1,n):
if j-i+1<k:
continue
dis_x = x_y[j][0]-x_y[i][0]
y_x = x_y[i:j+1]
... | p03576 |
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき,A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutat... | import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき,A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutat... | p03576 |
#!/usr/bin/env python3
#ABC75 D
import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import item... | #!/usr/bin/env python3
#ABC75 D
import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import item... | p03576 |
#!/usr/bin/env python3
#ABC75 D
import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import item... | #!/usr/bin/env python3
#ABC75 D
import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import item... | p03576 |
import sys
input = sys.stdin.readline
N, K=list(map(int,input().strip().split(' ')))
x=[]
y=[]
p=[]
for i in range(N):
xt,yt=list(map(int,input().strip().split(' ')))
x.append(xt)
y.append(yt)
p.append([xt,yt])
ans=10**20
x.sort()
y.sort()
p.sort(key=lambda xt:xt[0])
for i in range(N)... | import sys
input = sys.stdin.readline
N, K=list(map(int,input().strip().split(' ')))
x=[]
y=[]
point=[]
for i in range(N):
xt,yt=list(map(int,input().strip().split(' ')))
x.append(xt)
y.append(yt)
point.append([xt,yt])
ans=10**20
x.sort()
y.sort()
point.sort(key=lambda x:x[1])
for i... | p03576 |
n, k = list(map(int, input().split()))
xy = []
for i in range(n):
xy.append(list(map(int, input().split())))
s = []
x = [xy[i][0] for i in range(n)]
y = [xy[i][1] for i in range(n)]
x.sort()
y.sort()
for i in range(n):
for j in range(n):
for l in range(i + 1, n):
x1 = x[i]
... | n, k = list(map(int, input().split()))
xy = []
X = []
Y = []
for i in range(n):
x, y = list(map(int, input().split()))
X.append(x)
Y.append(y)
xy.append([x, y])
X.sort()
Y.sort()
ans = float("inf")
for i in range(n):
for j in range(i + 1, n):
for l in range(n):
for... | p03576 |
N,K=list(map(int,input().split()))
xlist,ylist,xylist=[],[],[]
for i in range(N):
x,y=list(map(int,input().split()))
xlist.append(x)
ylist.append(y)
xylist.append((x,y))
xy_prod_list=[]
for x in xlist:
for y in ylist:
xy_prod_list.append((x,y))
xy_prod_list.sort()
#print(xy_prod_list)
... | N,K=list(map(int,input().split()))
xlist,ylist,xylist=[],[],[]
xyset=set()
xydic={}
yxdic={}
for i in range(N):
x,y=list(map(int,input().split()))
xlist.append(x)
ylist.append(y)
xylist.append((x,y))
xyset.add((x,y))
xydic[x]=y
yxdic[y]=x
xy_prod_list=[]
for x in xlist:
for y in ylist... | p03576 |
N,K = list(map(int,input().split()))
XY = list(list(map(int,input().split()))for i in range(N))
ans = float('inf')
for lx, _ in XY:
for rx, _ in XY:
if lx > rx:
continue
for _, dy in XY:
for _, uy in XY:
if dy > uy:
continue
... | N,K = list(map(int,input().split()))
XY = []
for i in range(N):
x,y = list(map(int,input().split()))
XY.append((x,y))
ans = float('inf')
for lx, _ in XY:
for rx, _ in XY:
if lx > rx:
continue
for _, dy in XY:
for _, uy in XY:
if dy ... | p03576 |
from itertools import product, combinations
n, k = list(map(int, input().split()))
dots = [list(map(int, input().split())) for _ in range(n)]
ans = float("inf")
for a, b in combinations(dots, 2):
for c, d in combinations(dots, 2):
upper = max(a[1], b[1], c[1], d[1])
lower = min(a[1], b[1], c[1], d[1])
... | from itertools import combinations
n, k = list(map(int, input().split()))
dots = sorted([list(map(int, input().split())) for _ in range(n)])
ans = float("inf")
for x1, x2 in combinations(list(range(n)), 2):
wid = dots[x2][0] - dots[x1][0]
dots_cand = sorted(dots[x1: x2 + 1], key=lambda x: x[1])
for y1, y2 i... | p03576 |
n, k = list(map(int, input().split()))
p = sorted([tuple(map(int, input().split())) for i in range(n)])
ans = 4 * 10**18
for i in range(k, n + 1):
for j in range(n - i + 1): # x座標に関して j から i + j まで含む
x = p[i + j - 1][0] - p[j][0]
s = sorted([p[a][1] for a in range(j, i + j)])
y = min... | n, k = list(map(int, input().split()))
p = [tuple(map(int, input().split())) for i in range(n)]
p.sort()
ans = 4000000000000000000
for i in range(k, n + 1):
for j in range(n - i + 1):
x = p[i + j - 1][0] - p[j][0]
s = [p[a][1] for a in range(j, i + j)]
s.sort()
y = 400000000... | p03576 |
n,h=list(map(int,input().split()))
p,x,y=[],[],[]
z=float("inf")
for i in range(n):
a,b=list(map(int,input().split()))
p.append((a,b))
x.append(a)
y.append(b)
x.sort()
y.sort()
for i in range(n-1):
for j in range(i,n):
for k in range(n-1):
lx,rx,dy=x[i],x[j],y[k]
c=0
t=[]
... | n,k=list(map(int,input().split()))
x=[]
y=[]
xy=[]
for _ in range(n):
xx,yy=list(map(int,input().split()))
xy.append((xx,yy))
x.append(xx)
y.append(yy)
xx=sorted(x)
yy=sorted(y)
ans=10**20
for sxi in range(n-1):
for syi in range(n-1):
for tyi in range(1,n):
sx,sy,ty=xx[sxi],yy[syi],yy... | p03576 |
N,K=list(map(int,input().split()))
Points=[[int(i) for i in input().split()] for i in range(N)]
List_x=[Points[i][0] for i in range(N)]
List_x.sort(key=lambda x:x)
List_y=[Points[i][1] for i in range(N)]
List_y.sort(key=lambda x:x)
n=0
S=[]
for x1 in range(N-1):
for x2 in range(x1+K-1,N):
for y1 in rang... | N,K=list(map(int,input().split()))
Points=[[int(i) for i in input().split()] for i in range(N)]
List_x=[Points[i][0] for i in range(N)]
List_x.sort(key=lambda x:x)
List_y=[Points[i][1] for i in range(N)]
List_y.sort(key=lambda x:x)
n=0
Y=0
S=[]
for x1 in range(N-1):
for x2 in range(x1+K-1,N):
for y1 in... | p03576 |
N, K = list(map(int, input().split()))
X = [0] * N
Y = [0] * N
for i in range(N):
x, y = list(map(int, input().split()))
X[i] = x
Y[i] = y
def count(x_min, x_max, y_min, y_max):
cnt = 0
for i in range(N):
if x_min <= X[i] <= x_max and y_min <= Y[i] <= y_max:
cnt += 1... | #PythonだとTLEする
N, K = list(map(int, input().split()))
X = [0] * N
Y = [0] * N
for i in range(N):
x, y = list(map(int, input().split()))
X[i] = x
Y[i] = y
def count(x_min, x_max, y_min, y_max):
cnt = 0
for i in range(N):
if x_min <= X[i] <= x_max and y_min <= Y[i] <= y_max:
... | p03576 |
n, k = list(map(int, input().split()))
s = []
for i in range(n):#h:高さ
s.append([int(m) for m in input().split()])
count = 0
recli = []
if k == 2:
for i in range(n):
for j in range(i + 1, n):
larx = max(s[i][0], s[j][0])
smax = min(s[i][0], s[j][0])
lary =... | n, k = list(map(int, input().split()))
s = []
for i in range(n):#h:高さ
s.append([int(m) for m in input().split()])
s.sort(key=lambda x:(x[0]))
count = 0
recli = []
if k == 2:
for i in range(n):
for j in range(i + 1, n):
larx = max(s[i][0], s[j][0])
smax = min(s[i][0], s... | p03576 |
from itertools import combinations
N, K = list(map(int, input().split()))
points = []
for i in range(N):
points.append(list(map(int, input().split())))
xl = list([p[0] for p in points])
yl = list([p[1] for p in points])
def contained(point, xmin, xmax, ymin, ymax):
return (xmin <= point[0] <= xmax... | from itertools import combinations
N, K = list(map(int, input().split()))
points = []
for i in range(N):
points.append(list(map(int, input().split())))
points.sort(key=lambda p:p[0])
min_area = 10**20
for k in range(K, N+1):
for l in range(0, N-k+1):
points_tmp = points[l:l+k]
... | p03576 |
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemge... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemge... | p03576 |
from itertools import accumulate
from operator import add
N, K = list(map(int, input().split()))
xs, ys = [], []
for _ in range(N):
x, y = list(map(int, input().split()))
xs.append(x)
ys.append(y)
iXs = list(range(N))
iXs.sort(key=lambda iX: xs[iX])
odrXs = [0]*(N)
for odrX, iX in enumerate(i... | N, K = list(map(int, input().split()))
pts = []
ys = []
for _ in range(N):
x, y = list(map(int, input().split()))
pts.append((x, y))
ys.append(y)
pts.sort()
ys.sort()
ans = 10**20
for i, y1 in enumerate(ys):
for y2 in ys[i+1:]:
for j, (x1, _) in enumerate(pts):
num =... | p03576 |
N,K = list(map(int,input().split()))
X = []
Y = []
Z = []
for i in range(N):
x,y = list(map(int,input().split()))
X.append(x)
Y.append(y)
Z.append([x,y])
T = max(Y)
U = min(Y)
R = max(X)
L = min(X)
Y.sort()
X.sort()
ans = 10**100
for t in range(N):
for u in range(N):
for r in r... | N,K = list(map(int,input().split()))
X = []
Y = []
Z = []
for i in range(N):
x,y = list(map(int,input().split()))
X.append(x)
Y.append(y)
Z.append([x,y])
Y.sort()
X.sort()
ans = 10**100
for t in range(N):
for u in range(N):
for r in range(N):
for l in range(N):
T = ... | p03576 |
N, K = list(map(int, input().split()))
XY = [tuple(map(int, input().split())) for _ in range(N)]
ans = 10 ** 20
for x1 in range(N):
for x2 in range(x1 + 1, N):
for y1 in range(N):
for y2 in range(y1 + 1, N):
u = max(XY[x1][0], XY[x2][0])
d = min(XY[x1]... | N, K = list(map(int, input().split()))
XY = sorted([tuple(map(int, input().split())) for _ in range(N)])
ans = 10 ** 20
for xl in range(N):
for xr in range(xl + 1, N):
Ysub = sorted([y for x, y in XY[xl:xr + 1]])
for i in range(xr - xl - K + 2):
Yk = Ysub[i:i + K] + [XY[xr][1], ... | p03576 |
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
N,K = inpl()
xys = []
xx = set()
yy = set()
for i... | from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
N,K = inpl()
xys = []
xx = set()
for i in range(N)... | p03576 |
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, produc... | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutati... | p03576 |
n, k = list(map(int, input().split()))
sx, sy = [], []
for i in range(n):
x, y = list(map(int, input().split()))
sx.append((x, i))
sy.append((y, i))
sx.sort()
sy.sort()
px = [[0] for _ in range(n)]
for cx, (x, i) in enumerate(sx):
px[i] = cx
acm = [[0] * (n + 1) for _ in range(n + 1)]
for ... | n, k = list(map(int, input().split()))
sx, sy = [], []
for i in range(n):
x, y = list(map(int, input().split()))
sx.append((x, i))
sy.append((y, i))
sx.sort()
sy.sort()
px = [[0] for _ in range(n)]
for cx, (x, i) in enumerate(sx):
px[i] = cx
acm = [[0] * (n + 1) for _ in range(n + 1)]
for ... | p03576 |
n, k = list(map(int, input().split()))
sx, sy = [], []
for i in range(n):
x, y = list(map(int, input().split()))
sx.append((x, i))
sy.append((y, i))
sx.sort()
sy.sort()
px = [[0] for _ in range(n)]
for cx, (x, i) in enumerate(sx):
px[i] = cx
acm = [[0] * (n + 1) for _ in range(n + 1)]
for ... | n, k = list(map(int, input().split()))
ps = [tuple(map(int, input().split())) for i in range(n)]
sx = sorted(ps)
nx = list(enumerate(sx))
ans = 5e18
for l, (x1, y1) in nx[:n - k + 1]:
for r, (x2, y2) in nx[l + k - 1:]:
dx = x2 - x1
sy = sorted(y for x, y in sx[l:r + 1])
for y3, y4... | p03576 |
n,k=list(map(int,input().split()))
dot=[]
xxx=[]
yyy=[]
ans=float('inf')
for i in range(n):
x,y=list(map(int,input().split()))
dot.append([x,y])
xxx.append(x)
yyy.append(y)
for sx in xxx:
for sy in yyy:
for gx in xxx:
for gy in yyy:
if sx==gx or sy==gy:
conti... | n,k=list(map(int,input().split()))
dot=[]
xxx=[]
yyy=[]
ans=float('inf')
for i in range(n):
x,y=list(map(int,input().split()))
dot.append([x,y])
xxx.append(x)
yyy.append(y)
xxx.sort()
yyy.sort()
for sx in range(n):
for sy in range(n):
for gx in range(sx+1,n):
for gy in range... | p03576 |
n,k = list(map(int,input().split()))
l = [list(map(int,input().split())) for i in range(n)]
l.sort()
ans = float("INF")
for i in range(n-k+1):
for j in range(i+1,n):
for s in range(n):
for m in range(n):
wl = l[i][0]
wh = l[j][0]
hl = m... | n,k = list(map(int,input().split()))
l = [list(map(int,input().split())) for i in range(n)]
l.sort()
l1 = sorted(l,key=lambda x:x[1])
ans = float("INF")
for i in l:
for j in l:
if i[0] >= j[0]:
continue
for s in l1:
count = 0
for w,h in l1:
... | p03576 |
from itertools import combinations
N, K = (list)(list(map(int, input().split())))
pos_x = []
pos_y = []
for _ in range(N):
a, b = list(map(int, input().split()))
pos_x.append(a)
pos_y.append(b)
def count_point(x, y):
ret = 0
x_min = min(x)
x_max = max(x)
y_min = min(y)
... | from itertools import combinations
N, K = (list)(list(map(int, input().split())))
pos_x = []
pos_y = []
for _ in range(N):
a, b = list(map(int, input().split()))
pos_x.append(a)
pos_y.append(b)
def count_point(x, y):
ret = 0
x_min = min(x)
x_max = max(x)
y_min = min(y)
... | p03576 |
N,K=list(map(int,input().split()))
A=[]
for i in range(N):
a=[int(x) for x in input().split()]
A.append(a)
ans=float('inf')
for i in range(N):
for j in range(i+1,N):
for k in range(N):
for l in range(k+1,N):
miX=10000000000
maX=-10000000000
miY=10000000000
ma... | N,K=list(map(int,input().split()))
XY=[]
for i in range(N):
x,y=list(map(int,input().split()))
XY.append((x,y))
XY.sort()
ans=10**50
for i in range(N-(K-1)):
for j in range(i+(K-1),N):
x,y=XY[i]
x1,y1=XY[j]
YX=sorted(XY[i:j+1], key=lambda x:x[1])
for k in range(len(YX)-(K-1)):
... | p03576 |
N,K = list(map(int,input().split()))
XY = [list(map(int,input().split())) for _ in [0]*N]
iX = sorted(x for x,y in XY)
iY = sorted(y for x,y in XY)
X = {x:i for i,x in enumerate(iX)}
Y = {y:i for i,y in enumerate(iY)}
c = [[0]*(N+1) for i in [0]*(N+1)]
for x,y in XY:
c[Y[y]+1][X[x]+1] = 1
for i in ra... | N,K = list(map(int,input().split()))
XY = [list(map(int,input().split())) for _ in [0]*N]
iX = sorted(x for x,y in XY)
iY = sorted(y for x,y in XY)
X = {x:i for i,x in enumerate(iX)}
Y = {y:i for i,y in enumerate(iY)}
c = [[0]*(N+1) for i in [0]*(N+1)]
for x,y in XY:
c[Y[y]+1][X[x]+1] = 1
for i in ra... | p03576 |
N,K = list(map(int,input().split()))
XY = [list(map(int,input().split())) for _ in [0]*N]
iX = sorted(x for x,y in XY)
iY = sorted(y for x,y in XY)
X = {x:i for i,x in enumerate(iX)}
Y = {y:i for i,y in enumerate(iY)}
c = [[0]*(N+1) for i in [0]*(N+1)]
for x,y in XY:
c[Y[y]+1][X[x]+1] = 1
for i in ra... | N,K = list(map(int,input().split()))
XY = [list(map(int,input().split())) for _ in [0]*N]
iX = sorted(x for x,y in XY)
iY = sorted(y for x,y in XY)
X = {x:i for i,x in enumerate(iX)}
Y = {y:i for i,y in enumerate(iY)}
c = [[0]*(N+1) for i in [0]*(N+1)]
for x,y in XY:
c[Y[y]+1][X[x]+1] = 1
for i in ra... | p03576 |
N,K = list(map(int,input().split()))
XY = [list(map(int,input().split())) for _ in [0]*N]
iX = sorted(x for x,y in XY)
iY = sorted(y for x,y in XY)
X = {x:i for i,x in enumerate(iX)}
Y = {y:i for i,y in enumerate(iY)}
c = [[0]*(N+1) for i in [0]*(N+1)]
for x,y in XY:
c[Y[y]+1][X[x]+1] = 1
for i in ra... | def main():
N,K = list(map(int,input().split()))
XY = [list(map(int,input().split())) for _ in [0]*N]
iX = sorted(x for x,y in XY)
iY = sorted(y for x,y in XY)
X = {x:i for i,x in enumerate(iX)}
Y = {y:i for i,y in enumerate(iY)}
c = [[0]*(N+1) for i in [0]*(N+1)]
for x,y... | p03576 |
def main():
N,K = list(map(int,input().split()))
XY = [list(map(int,input().split())) for _ in [0]*N]
iX = sorted(x for x,y in XY)
iY = sorted(y for x,y in XY)
X = {x:i for i,x in enumerate(iX)}
Y = {y:i for i,y in enumerate(iY)}
c = [[0]*(N+1) for i in [0]*(N+1)]
for x,y... | def main():
N,K = list(map(int,input().split()))
XY = [list(map(int,input().split())) for _ in [0]*N]
iX = [x for x,y in XY]
iY = [y for x,y in XY]
iX.sort()
iY.sort()
X = {x:i for i,x in enumerate(iX)}
Y = {y:i for i,y in enumerate(iY)}
c = [[0]*(N+1) for i in [0]*(... | p03576 |
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
... | #!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
... | p03576 |
N,K=list(map(int,input().split()))
nodes=[]
for i in range(N):
x,y=list(map(int,input().split()))
nodes.append((x,y))
import math
ans=math.inf
count=0
for i in range(N):
for j in range(N):
for k in range(N):
for l in range(N):
count=0
for m in range(N):
if nodes[i... | N,K=list(map(int,input().split()))
nodes=[]
for i in range(N):
x,y=list(map(int,input().split()))
nodes.append((x,y))
nodes.sort()
import math
ans=math.inf
count=0
for i in range(N):
for j in range(i+1,N):
for k in range(N):
for l in range(i+1,N):
count=0
for m in range(N):... | p03576 |
N, K = list(map(int, input().split()))
x = []
for i in range(N):
x.append(list(map(int, input().split())))
ans = []
for i in range(N):
for j in range(N):
for l in range(N):
for m in range(N):
count = 0
x1 = min(x[i][0], x[j][0])
x2 =... | N, K = list(map(int, input().split()))
x = []
for i in range(N):
x.append(list(map(int, input().split())))
ans = []
for i in range(N):
for j in range(i+1, N):
for l in range(N):
for m in range(l+1, N):
count = 0
x1 = min(x[i][0], x[j][0])
... | p03576 |
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=sys.stdin.readline
def resolve():
n,k=list(map(int,input().split()))
X=[0]*n
Y=[0]*n
for i in range(n):
X[i],Y[i]=list(map(int,input().split()))
ans=INF
for a in range(n):
for b in range(... | import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=sys.stdin.readline
def resolve():
n,k=list(map(int,input().split()))
X=[0]*n
Y=[0]*n
for i in range(n):
X[i],Y[i]=list(map(int,input().split()))
ans=INF
for a in range(n):
for b in range(... | p03576 |
N, K = list(map(int, input().split()))
S = []
T = []
A = []
for i in range(N):
x, y = list(map(int, input().split()))
S.append(x)
T.append(y)
A.append([x, y])
ans = float("inf")
for i in S:
for j in S:
for k in T:
for l in T:
c = 0
... | N, K = list(map(int, input().split()))
S = []
T = []
A = []
for i in range(N):
x, y = list(map(int, input().split()))
S.append(x)
T.append(y)
A.append([x, y])
S.sort()
T.sort()
ans = float("inf")
for i in range(N):
for j in range(i+1, N):
for k in range(N):
for l... | p03576 |
from itertools import combinations
N, K = list(map(int, input().split()))
P = [list(map(int, input().split())) for _ in range(N)]
ans = 1<<62
for t in combinations(P, min(4, K)):
xs, ys = list(zip(*t))
xmin = min(xs)
xmax = max(xs)
ymin = min(ys)
ymax = max(ys)
area = (xmax-xmin) * (ym... | from itertools import combinations
def main():
N, K = list(map(int, input().split()))
P = [list(map(int, input().split())) for _ in range(N)]
ans = 1<<62
for t in combinations(P, min(4, K)):
xs, ys = list(zip(*t))
xmin = min(xs)
xmax = max(xs)
ymin = min(ys)
... | p03576 |
N, K = list(map(int, input().split()))
XY = [list(map(int, input().split())) for _ in range(N)]
X, Y = list(zip(*XY))
X_s = sorted(X)
Y_s = sorted(Y)
r = 10**20
for xi0 in range(N):
for xi1 in range(xi0, N):
for yi0 in range(N):
for yi1 in range(yi0, N):
x0 = X_s[xi0]
x1 = X_s[x... | N, K = list(map(int, input().split()))
XY = [list(map(int, input().split())) for _ in range(N)]
XY.sort()
r = 10**20
for xi0 in range(N - K + 1):
for xi1 in range(K + xi0 - 1, N):
x = XY[xi1][0] - XY[xi0][0]
XY_ys = sorted(XY[xi0:xi1 + 1], key=lambda a: a[1])
for yi0 in range(len(XY_ys) - K + 1):
... | p03576 |
#!/usr/bin/env python3
import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random # random, uniform, r... | #!/usr/bin/env python3
import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random # random, uniform, r... | p03576 |
#!/usr/bin/env python3
import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random # random, uniform, r... | #!/usr/bin/env python3
import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random # random, uniform, r... | p03576 |
import sys
input = sys.stdin.readline
def main():
n, k = list(map(int, input().split()))
X, Y = [], []
for _ in range(n):
x, y = list(map(int, input().split()))
X.append(x)
Y.append(y)
x_min, x_max = min(X), max(X)
y_min, y_max = min(Y), max(Y)
res = abs(x_... | import sys
input = sys.stdin.readline
def main():
n, k = list(map(int, input().split()))
X, Y = [], []
for _ in range(n):
x, y = list(map(int, input().split()))
X.append(x)
Y.append(y)
X_s = sorted(X)
Y_s = sorted(Y)
f_inf = float("inf")
res = f_inf
... | p03576 |
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
n, k = list(map(int, input().split()))
X, Y = [], []
for _ in range(n):
x, y = list(map(int, input().split()))
X.append(x)
Y.append(y)
X_s ... | import sys
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
n, k = list(map(int, input().split()))
X, Y = [], []
XY = []
for _ in range(n):
x, y = list(map(int, input().split()))
X.append(x)
Y.append(y)
XY.append([x, y... | p03576 |
from itertools import combinations
N, K = list(map(int, input().split()))
coord = [tuple(map(int, input().split())) for _ in range(N)]
ans = float('inf')
for points in combinations(coord, K):
x_coords, y_coords = [x for x, _ in points], [y for _, y in points]
x_min, x_max, y_min, y_max = min(x_coords), ... | from itertools import combinations
N, K = list(map(int, input().split()))
coord = sorted([tuple(map(int, input().split())) for _ in range(N)])
ans = float('inf')
for left, right in combinations(list(range(N)), 2):
n_points = right - left + 1
if n_points < K: continue
width = coord[right][0] - coord... | p03576 |
#n,kが小さい
#xi,yi全て試す
n,k = list(map(int, input().split( )))
p = []
x = []
y = []
for i in range(n):
xi,yi = list(map(int, input().split( )))
p.append((xi,yi))
x.append(xi)
y.append(yi)
y = list(set(y))
x = list(set(x))
x.sort()
y.sort()
lx = len(x)
ly = len(y)
ans = 10**20
for ix ... | #n,kが小さい
#xi,yi全て試す
#for ループ変更
import itertools
n,k = list(map(int, input().split( )))
p = []
x = []
y = []
for i in range(n):
xi,yi = list(map(int, input().split( )))
p.append((xi,yi))
x.append(xi)
y.append(yi)
y = list(set(y))
x = list(set(x))
x.sort()
y.sort()
lx = len(x)
ly =... | p03576 |
N, K = list(map(int, input().split()))
X = []
Y = []
P = []
for i in range(N):
coor = tuple(map(int, input().split()))
P.append(coor)
X.append(coor[0])
Y.append(coor[1])
X.sort()
Y.sort()
answer = (X[-1] - X[0])*(Y[-1] - Y[0])
for xmin in range(N):
for xmax in range(xmin+1, N):
for ymin i... | import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
N,K = LI()
p = []
for i in range(N):
a,b = LI()
p.append((a,b))
sx = sorted(p)
ans = 10**50
for x,y in sx:
for x2,y2 in sx:
if x2 <= x:
continue
points = sx.index((x2,y2)) - sx.index((x,y))... | p03576 |
"""
座標圧縮
2D累積和
全探索
勝利
"""
n, k = list(map(int,input().split()))
xs = set()
ys = set()
ps = []
# 座圧
for _ in range(n):
x,y = list(map(int,input().split()))
ps.append((x,y))
xs.add(x)
ys.add(y)
xdic = {x:i for i,x in enumerate(sorted(list(xs)))}
ydic = {y:i for i,y in enumerate(sorted(lis... | n,k = list(map(int, input().split()))
xs = []
ys = []
ps = []
for i in range(n):
x,y = list(map(int, input().split()))
xs.append(x)
ys.append(y)
ps.append((x,y))
# 座圧
xs = sorted(list(set(xs)))
ys = sorted(list(set(ys)))
xdic = {x:i for i, x in enumerate(xs)}
ydic = {y:i for i, y in enumera... | p03576 |
# -*- coding: utf-8 -*-
N, K = list(map(int, input().split(' ')))
points = [list(map(int, input().split(' '))) for i in range(N)]
X = list(set([x for x, y in points]))
Y = list(set([y for x, y in points]))
ans = float('inf')
import itertools
all_indices = list(range(N))
for part_x in itertools.combination... | # -*- coding: utf-8 -*-
N, K = list(map(int, input().split(' ')))
points = [list(map(int, input().split(' '))) for i in range(N)]
X = list(set([x for x, y in points]))
Y = list(set([y for x, y in points]))
X.sort()
Y.sort()
ans = float('inf')
for i, min_x in enumerate(X):
for max_x in X[i+1:]:
... | p03576 |
N,K = list(map(int,input().split()))
p = [list(map(int,input().split())) for i in range(N)]
used = [False for i in range(N)]
def dfs(p,K,d=0,ans=[[],[]],s=float('inf')):
if K==d:
s = abs(max(ans[0])-min(ans[0]))*abs(max(ans[1])-min(ans[1]))
return s
for i in range(len(p)):
if use... | N,K = list(map(int,input().split()))
X,Y = [],[]
p = []
for i in range(N):
x,y = list(map(int,input().split()))
X.append(x)
Y.append(y)
p.append([x,y])
X.sort(),Y.sort()
ans = abs(X[N-1]-X[0])*abs(Y[N-1]-Y[0])
for xi in range(N):
for xj in range(xi+1,N):
for yi in range(N):
... | p03576 |
# -*- coding: utf-8 -*-
"""
参考:https://img.atcoder.jp/abc075/editorial.pdf
・自力ACしたのがO(N^4)でこれはO(N^5)の愚直解
・制約からして何とかなりそうだし、こっちのが実装全然軽いし実戦向きぽいね。
"""
N, K = list(map(int, input().split()))
X, Y = [0]*N, [0]*N
for i in range(N):
X[i], Y[i] = list(map(int, input().split()))
X2 = sorted(set(X))
Y2 = so... | # -*- coding: utf-8 -*-
"""
参考:https://img.atcoder.jp/abc075/editorial.pdf
・自力ACしたのがO(N^4)でこれはO(N^5)の愚直解
・制約からして何とかなりそうだし、こっちのが実装全然軽いし実戦向きぽいね。
→O(N^5)=50^5=3億1250万はpypyでも無理だったわ。
・添字見づらくなったけど定数倍改善。多分半分で約1憶5000万かと。
"""
N, K = list(map(int, input().split()))
X, Y = [0]*N, [0]*N
for i in range(N):
X[i... | p03576 |
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")
memo1 = {}
memo2 = {}
def ok(y1, y2, x1, x2, yd, yd2, xd, x... | from collections import defaultdict, Counter
from itertools import combinations
INF = float("inf")
memo1 = {}
memo2 = {}
def ok(y1, y2, x1, x2, yd, yd2, xd, xd2, K):
if (y1, y2) in memo1:
y = memo1[(y1, y2)]
else:
a = yd2[y1]
b = yd[y2]
y = b.difference(a)
... | p03576 |
import sys
import itertools
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, K = lr()
XY = [lr() for _ in range(N)]
XY.sort()
answer = float('inf')
# 端の4点、まずはx軸の2点を選ぶ
for left,right in itertools.combinations(list(range(N)),2):
width = XY[rig... | import sys
import itertools
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, K = lr()
XY = [lr() for _ in range(N)]
XY.sort()
answer = float('inf')
# 端の4点、まずはx軸の2点を選ぶ
for left,right in itertools.combinations(list(range(N)),2):
width = XY[rig... | p03576 |
import sys
import itertools
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, K = lr()
XY = [lr() for _ in range(N)]
XY.sort()
answer = float('inf')
# 端の4点、まずはx軸の2点を選ぶ
for left,right in itertools.combinations(list(range(N)),2):
xleft = XY[lef... | import sys
import itertools
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, K = lr()
XY = [lr() for _ in range(N)]
XY.sort()
answer = float('inf')
# 端の4点、まずはx軸の2点を選ぶ
for i, j in itertools.combinations(list(range(N)), 2):
xleft = XY[i][0]
... | p03576 |
from functools import reduce
import math
def main():
# 文字列の2進数を数値にする
# '101' → '5'
# 文字列の頭に'0b'をつけてint()にわたす
# binary = int('0b'+'101',0)
# 2進数で立っているbitを数える
# 101(0x5) → 2
# cnt_bit = bin(5).count('1')
# N! を求める
# f = math.factorial(N)
# N の逆元
# N_inv... | from functools import reduce
import math
def main():
# 文字列の2進数を数値にする
# '101' → '5'
# 文字列の頭に'0b'をつけてint()にわたす
# binary = int('0b'+'101',0)
# 2進数で立っているbitを数える
# 101(0x5) → 2
# cnt_bit = bin(5).count('1')
# N! を求める
# f = math.factorial(N)
# N の逆元
# N_inv... | p03576 |
import sys
input = sys.stdin.readline
N,K=[int(val) for val in input().split()]
list_x=list()
list_y=list()
list_z=list()
ans=float('inf')
for i in range(N):
x,y=(int(val) for val in input().split())
list_x.append(x)
list_y.append(y)
list_z.append((x,y))
list_x.sort()
list_y.sort()
for... | import sys
input = sys.stdin.readline
N,K=[int(val) for val in input().split()]
list_x=list()
list_y=list()
list_z=list()
ans=float('inf')
for i in range(N):
x,y=(int(val) for val in input().split())
list_x.append(x)
list_y.append(y)
list_z.append((x,y))
# heapq.heappush(list_x, x)
# heap... | p03576 |
import itertools
N,K=list(map(int,input().split()))
x=[]
y=[]
sx=[]
sy=[]
for i in range(N):
a1,a2=list(map(int,input().split()))
x.append(a1)
sx.append(a1)
y.append(a2)
sy.append(a2)
#print "# x,y"
#print x
#print y
ans=10**20
#print ans
for i in range(N):
for j in range(N):
for k in... | import itertools
N,K=list(map(int,input().split()))
x=[]
y=[]
pts=[]
for i in range(N):
a1,a2=list(map(int,input().split()))
x.append(a1)
y.append(a2)
pts.append([a1,a2])
#print "# x,y"
x.sort()
y.sort()
#print x
#print y
#print "# pts"
#print pts
pts.sort(key=lambda x:x[0])
#print pts
an... | p03576 |
import sys
import itertools
N,K=list(map(int, sys.stdin.readline().split()))
X=[]
Y=[]
XY=[]
for _ in range(N):
x,y=list(map(int, sys.stdin.readline().split()))
X.append(x)
Y.append(y)
XY.append( (x,y) )
X.sort()
Y.sort()
L=list( itertools.product(X,Y ) )
ans=float("inf")
for x1,y1 in L:
... | import sys
N,K=list(map(int, sys.stdin.readline().split()))
X=[]
Y=[]
XY=[]
for _ in range(N):
x,y=list(map(int, sys.stdin.readline().split()))
X.append(x)
Y.append(y)
XY.append( (x,y) )
ans=float("inf")
for x1 in X:
for y1 in Y:
for x2 in X:
for y2 in Y:
if x1<x2 and y1<y2:
cnt... | p03576 |
n,k = list(map(int,input().split()))
xy = [list(map(int,input().split())) for _ in range(n)]
ans = 10 ** 20
for i in range(n):
for j in range(i+1, n):
for ii in range(n):
for jj in range(ii+1, n):
l = min(xy[i][0], xy[j][0])
r = max(xy[i][0], xy[j][0])... | def main():
n,k = list(map(int,input().split()))
xy = [list(map(int,input().split())) for _ in range(n)]
ans = 10 ** 20
for i in range(n):
for j in range(i+1, n):
for ii in range(n):
for jj in range(ii+1, n):
l = min(xy[i][0], xy[j][0])... | p03576 |
def main():
n,k = list(map(int,input().split()))
xy = [list(map(int,input().split())) for _ in range(n)]
ans = 10 ** 20
for i in range(n):
for j in range(i+1, n):
for ii in range(n):
for jj in range(ii+1, n):
l = min(xy[i][0], xy[j][0])... | n,k = list(map(int,input().split()))
xy = [list(map(int,input().split())) for _ in range(n)]
xy.sort()
ans = 10**20
for i in range(n):
for j in range(i,n):
xy_tmp = xy[i:j+1]
if len(xy_tmp) >= k:
l1 = xy_tmp[0][0]
r1 = xy_tmp[-1][0]
xy_tmp.sort(key =... | p03576 |
import itertools
n, k = list(map(int, input().split()))
p_list = [[0] * 2 for i in range(n)]
for i in range(n):
x, y = list(map(int, input().split()))
p_list[i] = [x, y]
k_list = list(itertools.combinations(list(range(n)), k))
min_area = ((10 ** 9) * 2) ** 2
for ki in k_list:
x_list = []
... | N, K = list(map(int, input().split()))
p_list = [[0] * 2 for i in range(N)]
for i in range(N):
x, y = list(map(int, input().split()))
p_list[i] = [x, y]
p_list.sort()
ans = float('inf')
for i in range(N - K + 1):
for j in range(i + K - 1, N):
x = abs(p_list[j][0] - p_list[i][0])
... | p03576 |
N,K = list(map(int,input().split()))
x = []
y = []
l = []
for i in range(N):
xx,yy = list(map(int,input().split()))
x.append(xx)
y.append(yy)
l.append((xx,yy))
x = sorted(x)
y = sorted(y)
import itertools
ans = float("inf")
for xx in itertools.combinations(x,2):
for i in range(N)... | N,K = list(map(int,input().split()))
x = []
y = []
l = []
for i in range(N):
xx,yy = list(map(int,input().split()))
x.append(xx)
y.append(yy)
l.append((xx,yy))
x = sorted(x)
y = sorted(y)
import itertools
ans = float("inf")
for xx in itertools.combinations(x,2):
for i in range(N)... | p03576 |
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
from decimal import Decimal
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin... | from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
from decimal import Decimal
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin... | p03576 |
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
from decimal import Decimal
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin... | from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def ... | p03576 |
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def ... | from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def ... | p03576 |
import collections, itertools, sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(eval(input()))
def F(): return float(eval(input()))
def S(): return eval(input())
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 f... | import collections, itertools, sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(eval(input()))
def F(): return float(eval(input()))
def S(): return eval(input())
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 f... | p03576 |
n, k = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(n)]
MAX = 10**9
MIN = -1 * MAX
def check(x_r, x_l, y_t, y_b):
tl = [MIN, MAX]
br = [MAX, MIN]
if x_r == x_l or y_t == y_b:
return False, -1
tl[0] = max(tl[0], xy[x_l][0])
tl[1] = min(tl[... | n, k = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(n)]
MAX = 10**9
MIN = -1 * MAX
def check(x_r, x_l, y_t, y_b):
tl = [MIN, MAX]
br = [MAX, MIN]
if x_r == x_l or y_t == y_b:
return False, -1
tl[0] = max(tl[0], xy[x_l][0])
tl[1] = min(tl[... | p03576 |
N,K=list(map(int,input().split()))
px = [0 for _ in range(N)]
py = [0 for _ in range(N)]
for i in range(N):
px[i],py[i] = list(map(int,input().split()))
a=10**20
for xi in range(N):
for xj in range(xi+1,N):
for yi in range(N):
for yj in range(yi+1,N):
x0,x1,y0,y1=px[xi],px[xj],py[yi],py[... | N,K=list(map(int,input().split()))
p = sorted([[int(_) for _ in input().split()] for i in range(N)])
a=10**20
for xi in range(N-K+1):
for xj in range(xi+K-1,N):
q = sorted(y for x,y in p[xi:xj+1])
for yi in range(xj-(xi+K-1)+1):
yj = yi+K-1 #Is the number always K?
if q[yi]<=p[xi][1] and p... | p03576 |
n,k = list(map(int,input().split()))
x = []
y = []
for i in range(n):
a,b = list(map(int,input().split()))
x.append(a)
y.append(b)
ans = 10 ** 40
for i in range(n):
for j in range(n):
for l in range(n):
for h in range(n):
lx = min(x[i],x[j])
... | n,k = list(map(int,input().split()))
x = []
y = []
xx = []
yy = []
for i in range(n):
a,b = list(map(int,input().split()))
x.append(a)
y.append(b)
xx.append(a)
yy.append(b)
ans = 10 ** 40
x.sort()
y.sort()
for i in range(n):
for j in range(i+1,n):
for l in range(n):
... | p03576 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.