Harryxun/stf_run huggingface dataset:
X, K, D = map(int, input().split())
ans = 0
if X == 0:
    if K % 2 != 0:
        ans = D
elif X > 0:
    a = int(X/D)
    if K > a:
        diff = K - a
        X_temp = X - a * D
        if abs(X_temp - D) < X_temp:
            if (diff - 1) % 2 == 0:
                ans = abs(X_temp - D)
            else:
                ans = X_temp
        else:
            if diff % 2 == 0:
                ans = X_temp
            else:
                ans = abs(X_temp - D)
    else:
        ans = X - K * D
else:
    if K > a:
        diff = K - a
        X_temp = X + a * D
        if abs(X_temp + D) < abs(X_temp):
            if (diff - 1) % 2 == 0:
                ans = abs(X_temp + D)
            else:
                ans = abs(X_temp)
        else:
            if diff % 2 == 0:
                ans = abs(X_temp)
            else:
                ans = abs(X_temp + D)
    else:
        ans = abs(X + K * D)
print(ans)

### FIXED CODE ###

X, K, D = map(int, input().split())
ans = 0
if X == 0:
    if K % 2 != 0:
        ans = D
elif X > 0:
    a = int(X/D)
    if K > a:
        diff = K - a
        X_temp = X - a * D
        if abs(X_temp - D) < X_temp:
            if (diff - 1) % 2 == 0:
                ans = abs(X_temp - D)
            else:
                ans = X_temp
        else:
            if diff % 2 == 0:
                ans = X_temp
            else:
                ans = abs(X_temp - D)
    else:
        ans = X - K * D
else:
    a = int(abs(X)/D)
    if K > a:
        diff = K - a
        X_temp = X + a * D
        if abs(X_temp + D) < abs(X_temp):
            if (diff - 1) % 2 == 0:
                ans = abs(X_temp + D)
            else:
                ans = abs(X_temp)
        else:
            if diff % 2 == 0:
                ans = abs(X_temp)
            else:
                ans = abs(X_temp + D)
    else:
        ans = abs(X + K * D)
print(ans)
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True) #これで実行される(new_A = A.sortとかしても返り値はnon-type)

ans = 0
for i in range(1, N+1):
    if i % 2 == 0:
        ans += A[i]
    if i % 2 == 1:
        ans -= A[i]

print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)

ans = 0
for i in range(N):
    if i % 2 == 0:
        ans += A[i]
    if i % 2 == 1:
        ans -= A[i]

print(ans)
n, m = map(int,input().split())
ps = [1]
nw = 1
mi = m//n
while nw**2 < m:
    if m%nw == 0:
        if mi >= nw:
            ps.append(nw)
        if mi >= m//nw:
            ps.append(m//nw)
    nw += 1
if nw**2 == m and nm <= mi:
    ps.append(nw)

print(max(ps))


### FIXED CODE ###

n, m = map(int,input().split())
ps = [1]
nw = 1
mi = m//n
while nw**2 < m:
    if m%nw == 0:
        if mi >= nw:
            ps.append(nw)
        if mi >= m//nw:
            ps.append(m//nw)
    nw += 1
if nw**2 == m and nw <= mi:
    ps.append(nw)

print(max(ps))
a,b,c=input().split()
d=a*b
if d<=c:
  print(d)
else:
  print(c)

### FIXED CODE ###

a,b,c=input().split()
a1=int(a)
b1=int(b)
c1=int(c)
d=a1*b1
if d<=c1:
  print(d)
else:
  print(c1)
def main():
    n, m = [int(x) for x in input().split()]
    pattern = [1]
    broken = -1
    brokencnt = 0
    if brokencnt < m:
        broken = int(input())
        brokencnt += 1
    for i in range(1, n + 1):
        if i == broken:
            pattern.append(0)
            if brokencnt < m:
                broken = int(input())
                brokencnt += 1
            continue
        if i == 1:
            pattern.append(pattern[i - 1])
        if i > 1:
            pattern.append((pattern[i - 1] + pattern[i - 2]) % MOD)
    print(pattern[n])
main()


### FIXED CODE ###

MOD = 1000000007
def main():
    n, m = [int(x) for x in input().split()]
    pattern = [1]
    broken = -1
    brokencnt = 0
    if brokencnt < m:
        broken = int(input())
        brokencnt += 1
    for i in range(1, n + 1):
        if i == broken:
            pattern.append(0)
            if brokencnt < m:
                broken = int(input())
                brokencnt += 1
            continue
        if i == 1:
            pattern.append(pattern[i - 1])
        if i > 1:
            pattern.append((pattern[i - 1] + pattern[i - 2]) % MOD)
    print(pattern[n])
main()
X,Y=map(int,input().split)
print(int(X+Y/2))


### FIXED CODE ###

X,Y=map(int,input().split())
print(int(X+Y/2))
n,k = map(int, input().split())
A = [int(x) for x in input().split()]
d = {}
for a in A:
  	if a in d:
    	d[a] +=1
  	eles:
    	d[a] =1
    
d =sorted(d.values())
if len(d) > k:
  	ans = 0
  	for i in range(len(d)-k):
    	ans += d[i]
  	print(ans)
else:
  	print(0)


### FIXED CODE ###

n,k = map(int, input().split())
A = [int(x) for x in input().split()]
d = {}
for a in A:
  if a in d:
    d[a] +=1
  else:
    d[a] =1
    
d =sorted(d.values())
if len(d) > k:
  ans = 0
  for i in range(len(d)-k):
    ans += d[i]
  print(ans)
else:
  print(0)
from cmath import pi, exp

def convolve(a, b):
    """配列a, bの畳み込みをFFT(fast Fourier transform)によって計算する
    res[k] = sum{i=0...n}a[i]*b[k-i]
    """
    def fft(a, inverse=False):
        # バタフライ演算用の配置入れ替え
        for i in range(n):
            j = 0
            for k in range(h):
                j |= (i >> k & 1) << (h - 1 - k)
            if i < j:
                a[i], a[j] = a[j], a[i]
 
        # バタフライ演算
        sign = 1.0 if inverse else -1.0
        b = 1
        while b < n:
            for j in range(b):
                w = exp(sign * 2.0j * pi / (2.0 * b) * j)
                for k in range(0, n, b*2):
                    s = a[j + k]
                    t = a[j + k + b] * w
                    a[j + k] = s + t
                    a[j + k + b] = s - t
            b *= 2
 
        # 逆変換時には配列のサイズで割る
        if inverse:
            for i in range(n):
                a[i] /= n
        return a
 
    def ifft(a):
        return fft(a, inverse=True)
 
    n = 1 << (len(a) + len(b) - 1).bit_length()
    h = n.bit_length() - 1
    a += [0] * (n - len(a))
    b += [0] * (n - len(b))
    
    # in-placeで計算を進めることに注意
    fft(a), fft(b)
    for i in range(n):
        a[i] *= b[i]
    ifft(a)
 
    res = [int(abs(v) + 0.5) for i, v in enumerate(a)]
    return res[1:]

import sys
input = sys.stdin.readline
n,m = map(int, input().split())
a = list(map(int, input().split()))
 
cnt = [0] * (10001)
for i in a:
    cnt[i] += 1 

c = convolve(cnt[0:], cnt[0:])
ans = 0
for i in range(20001)[::-1]:
    if c[i] > 0:
      p = min(m,c[i])
      m -= p
      ans += i*p+p
      if m == 0:
        break
print(ans)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from bisect import bisect_left

n,m = map(int,readline().split())
a = list(map(int,readline().split()))

b = [0]*(n+1)
a.sort()
for i in range(n):
  b[i+1] = b[i]+a[i]

def is_ok(arg):
    c = 0
    f = False
    for i in a:
      if c >= m:
        break
      c += (n-bisect_left(a,arg-i))
    if c >= m:
      f = True
    return f

def bisect_ok(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

x = bisect_ok(2*a[-1]+1,1)
ans = 0
cnt = 0
for i in a:
  ind = n-bisect_left(a,x-i)
  cnt += ind
  ans += i*ind+(b[-1]-b[n-ind])
if cnt > m:
  ans -= x*(cnt-m)
print(ans)
N, M = map(int, input().split())
mod = 10**9 + 7

def comb(n, r, mod):
    if r<0 or r>n:
        return 0
    r = min(r, n-r)
    return fac[n] * (finv[r] * finv[n-r] % mod) % mod

def perm(n, r, mod):
    if r<0 or r>n:
        return 0
    return (fac[n] * finv[n-r]) % mod

fac = [1, 1]
finv = [1, 1]
inv = [0, 1]
for i in range(2, max(N + 1, M + 1)):
    fac.append((fac[-1] * i) % mod)
    inv.append((-inv[mod%i] * (mod//i)) % mod)
    finv.append((finv[-1] * inv[-1]) % mod)
for i in range(N+1):
    ans += (-1)**i * ((comb(N, i, mod) * perm(M, i, mod))%mod * (perm(M-i, N-i, mod)**2)%mod)%mod
    ans %= mod
print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
mod = 10**9 + 7

def comb(n, r, mod):
    if r<0 or r>n:
        return 0
    r = min(r, n-r)
    return fac[n] * (finv[r] * finv[n-r] % mod) % mod

def perm(n, r, mod):
    if r<0 or r>n:
        return 0
    return (fac[n] * finv[n-r]) % mod

fac = [1, 1]
finv = [1, 1]
inv = [0, 1]
for i in range(2, max(N + 1, M + 1)):
    fac.append((fac[-1] * i) % mod)
    inv.append((-inv[mod%i] * (mod//i)) % mod)
    finv.append((finv[-1] * inv[-1]) % mod)
c = comb(M, N, mod)
ans = ((fac[N] * c % mod) ** 2) % mod

for i in range(1, N+1):
    ans += (-1)**i * ((comb(N, i, mod) * perm(M, i, mod))%mod * (perm(M-i, N-i, mod)**2)%mod)%mod
    ans %= mod
print(ans)
l = [2, 1]

def l(x):
  if len(l) > x:
    return l[x]
  else:
    return l(x-1) + l(x-2)
  
print(l(int(input()))

### FIXED CODE ###

lu = [2, 1]
x = int(input())
for i in range(2, x+1):
    lu.append(lu[i-1] + lu[i - 2])  
print(lu[x])
w = input()
w_list = list(w)
w_set = set(w_list)
for val in w_set:
    if w_list.count(val) % 2 == 0:
        continue
    else:
        print('No')
        break
else:
    continue
    print('Yes')

### FIXED CODE ###

w = input()
w_list = list(w)
w_set = set(w_list)
for val in w_set:
    if w_list.count(val) % 2 == 0:
        continue
    else:
        print('No')
        break
else:
    print('Yes')
list_num = input().split(" ") #A,B,M
list_ref = input().split(" ") #冷蔵庫の値段
list_ren = input().split(" ") #レンジの値段
list2 = [] #割引できるやつの組み
for i in range(int(list_num[2])):
    list_c = input().split(" ")
    list2.append(list_c)
A = int(list_num[0])
B = int(list_num[1])
M = int(list_num[2])
 
#割引なしで総当たり
list_price = []
for i in range(A):
    for j in range(B):
        list_price.append(int(list_ref[i]) + int(list_ren[j]))
 
#割引きを総当たり
for k in range(M):
    price = int(list_ref[int(list2[k][0])-1]) + int(list_ren[int(list2[k][1])-1]) - int(int(list2[k][2])-1) - 1
    list_price.append(price)
 
 
print(min(list_price))

### FIXED CODE ###

import math
import sys
#読み込み
s = input()
num = len(s)

#偶数個の文字でなければno
if num % 2 != 0:
    print("No")
    sys.exit()

#偶数番目がhか判定
for i in range(math.floor(num/2)):
    if s[2 * i] != "h":
        print("No")
        sys.exit()

#奇数番目がiか判定
for j in range(math.floor(num/2)):
    if s[2 * j + 1]  != "i":
        print("No")
        sys.exit()
        
print("Yes")
import itertools
L=[input() for i in range(input())]
S=[1000000000,1000000000,1000000000]
for i in itertools.permutations(L,2):
    S.append(int("".join(map(str,i))))
    S=sorted(S)[:3]
print S[2]

### FIXED CODE ###

n = input()
h = sorted(input() for i in range(n))[:4]
h = map(str, h)
ans = []
for i in range(3):
    for j in range(i+1, 4):
        ans.append(int(h[i]+h[j]))
        ans.append(int(h[j]+h[i]))
print sorted(ans)[2]
N = int(input())

g = [[0] * (N + 1) for _ in range(N + 1)]
for i in range(1, N + 1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    g[a][b] += 1
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += g[i][j]*g[j][i]

print(ans)

### FIXED CODE ###

N = int(input())

g = [[0] * (10) for _ in range(10)]
for i in range(1, N + 1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    g[a][b] += 1
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += g[i][j]*g[j][i]

print(ans)
while True:
    (a, op, b) = input().split()
    a = int(a)
    b = int(b)

    if op = '?':
        break
    elif op = '+':
        print(a + b)
    elif op = '-':
        print(a - b)
    elif op = '*':
        print(a * b)
    elif op = '/':
        print(a // b)
    else:
        break

### FIXED CODE ###

while True:
    (a, op, b) = input().split()
    a = int(a)
    b = int(b)
    if op == '?':
        break
    elif op == '+':
        print(a + b)
        pass
    elif op == '-':
        print(a - b)
        pass
    elif op == '*':
        print(a * b)
        pass
    else:
        print(a // b)
d = {1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6}
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
d_ = {}
for i in range(M):
    d_[d[A[i]]] = A[i]
diff = [(d_[key],key) for key in d_]
diff.sort()

DP = ['']*(N+1)
for a,l in diff:
    DP[l] = str(a)
    
for i in range(N+1):
    for a,l in diff:
        if i-l >= 0:
            if len(DP[i-l])+1>=len(DP[i]) and DP[i-l]!='':
                    DP[i] = str(a)+DP[i-l]

ans = list(DP[N])
ans.sort()
ans.reverse()
ans = ''.join(ans)
print(ans)

### FIXED CODE ###

d = {1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6}
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
d_ = {}
for i in range(M):
    d_[d[A[i]]] = A[i]
diff = [(d_[key],key) for key in d_]
diff.sort()

DP = ['']*(10**4+1)
for a,l in diff:
    DP[l] = str(a)
    
for i in range(N+1):
    for a,l in diff:
        if i-l >= 0:
            if len(DP[i-l])+1>=len(DP[i]) and DP[i-l]!='':
                    DP[i] = str(a)+DP[i-l]

ans = list(DP[N])
ans.sort()
ans.reverse()
ans = ''.join(ans)
print(ans)
# 入力
s=input()

a=''
for x in s:
  if x=='0':
    a+='0'
  elif x=='1'
    a+='1'
  else:
    # 文字列が空でない場合、末尾を削除
    if a!='':
      a=a[:-1]

# 出力
print(a)

### FIXED CODE ###

s=list(input())
a=''
for i in s:
  if i=='0' or i=='1':
    a+=i
  else:
    if len(a)!=0:
      a=a[:len(a)-1]
print(a)
S = input()
s = list(map(int, S))
t = s.copy()
x = 0
y = 1

if t[0] == 0:
    t[0]=1
else:
    t[0]=0

for i in s:
    if s[i]==0 and s[i+1] == s[i]:
    	s[i+1]=1
    	x +=1
    elif s[i]==1 and s[i+1]==s[i]:
    	s[i+1]=0
    	x +=1

for i in t:
    if t[i]==0 and t[i+1] == t[i]:
    	t[i+1]=1
    	y +=1
    elif t[i]==1 and t[i+1]==t[i]:
    	t[i+1]=0
    	y +=1

print(min([x,y]))

### FIXED CODE ###

S = input()
s = list(map(int, S))
t = s.copy()
n = len(s)
x = 0
y = 1

if t[0] == 0:
    t[0]=1
else:
    t[0]=0

for i in range(n-1):
    if s[i+1]==0 and s[i+1] == s[i]:
    	s[i+1]=1
    	x +=1
    elif s[i+1]==1 and s[i+1]==s[i]:
    	s[i+1]=0
    	x +=1
    
for i in range(n-1):
    if t[i+1]==0 and t[i+1] == t[i]:
    	t[i+1]=1
    	y +=1
    elif t[i+1]==1 and t[i+1]==t[i]:
    	t[i+1]=0
    	y +=1

print(min([x,y]))
x=int(input())
if x>=30 :  
  put('Yes')   
else :    
  put('No')

### FIXED CODE ###

x=int(input())
if x>=30:
  print('Yes')   
else:
  print('No')
temp=list(map(int,input().rstrip().split()))
a=temp[0]
b=temp[1]
n=temp[2]
if (b-1)<n :
  x=(b-1)
else :
  x=n
v=((a*x)//b)-(a*(x//b))
print v
  
  

### FIXED CODE ###

temp=list(map(int,input().rstrip().split()))
a=temp[0]
b=temp[1]
n=temp[2]
if (b-1)<n :
  x=(b-1)
else :
  x=n
v=((a*x)//b)-(a*(x//b))
print(v)
from collections import Counter

class Bit:
  def __init__(self, n):
    self.size = n
    self.tree = [0] * (n + 1)
  
  def sum(self, i):
    s = 0
    while i > 0:
      s += self.tree[i]
      i -= i & -1
    return s
  
  def add(self, i, x):
    while i <= self.size:
      self.tree[i] += x
      i += i & -i

n,k = map(int, input().split())
aaa = list(map(int, input().split()))
MOD = 10**9 + 7
bit = Bit(2001)
single = 0
for a in reversed(aaa):
  single += bit.sum(a)
  bit.add(a + 1, 1)
ans = single * k % MOD
coef = k * (k - 1) // 2 % MOD
cnt = Counter(aaa)
before = 0
for a,c in sorted(cnt.items()):
  ans = (ans + c * before * conf) % MOD
  before += c
print(ans)





### FIXED CODE ###

N,K = map(int,input().split())
A = list(map(int,input().split()*2))
base1 = 0
base2 = 0
for i in range(N):
  count1=0
  count2=0
  for j in range(i+1,i+N+1):
    if A[i] > A[j]:
      if j < N:
        count1+=1
      else:
        count2+=1
  base1+=count1
  base2+=count2

ans = (base1*K*(K+1) + base2*K*(K-1))//2
div = 10**9 + 7
print(ans%div)
a1, a2, a3 = map(int, input(), split())
 
if a1 + a2 + a3 >= 22:
  print("bust")
else:
  print("win")

### FIXED CODE ###

a1, a2, a3 = map(int, input().split())
 
if a1 + a2 + a3 >= 22:
  print('bust')
else:
  print('win')
string=input

string=string.split(' ')
A= int(A[0])
B= int(A[1])

if A in range(1,10):
else:
    print(-1) break
if B in range(1,10):
else:
    print(-1 break)
print(A*B)

### FIXED CODE ###


string=input()
string=string.split(' ')
A= int(string[0])
B= int(string[1])

if A>9 or B>9:
    print(-1)
else:
        print(A*B)
import heapq
n,m,k=map(int,input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
time=0
ans=0
if sum(a)+sum(b)<=k:
    print(n+m)
    exit()
heapq.heapify(a)
heapq.heapify(b)
a0=heapq.heappop(a)
b0=heapq.heappop(b)
while True:
  if a0>=b0:
    time+=b0
    if time>k:
      print(ans)
      exit()
    else:
      ans+=1
      b0=heapq.heappop(b)
  else:
    time+=a0
    if time>k:
      print(ans)
      exit()
    else:
      ans+=1
      a0=heapq.heappop(a)

### FIXED CODE ###

n,m,k=map(int,input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
ans=0
a, b=[0], [0]
for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])
j=m
for i in range(n+1):
    if k<a[i]:
        break
    while b[j]>k-a[i]:
        j-=1
    ans=max(ans,i+j)
print(ans)
N = int(input().strip())

n_list = [[] for i in range(N)]
d = [0] * N

for i in range(N-1):
    a, b = map(int, input().strip().split())
    a -= 1
    b -= 1
    n_list[a].append([b,i])
    n_list[b].append([a,i])
    d[a] += 1
    d[b] += 1


#print(n_list)
#print(d)

d_dict = {}
for i in range(N):
    d_dict[i] = d[i]
tmp = sorted(d_dict.items(), key = lambda x:x[1], reverse = True)

colors = [0] * (N-1)

root = tmp[0][0]

def paint(node, parent_edge_id):
    #print(node, parent_edge_id)
    tmp_color = 1
    for edge in n_list[node]:
        #print("ege:", edge)
        if edge[1] != parent_edge_id:
            if tmp_color == colors[parent_edge_id]:
                tmp_color += 1
            colors[edge[1]] = tmp_color
            paint(edge[0], edge[1])
            tmp_color += 1

paint(tmp[0][0], -1)

print(tmp[0][1]) # color num 
for i in range(N-1):
    print(colors[i])

### FIXED CODE ###

import sys
N = int(input().strip())

n_list = [[] for i in range(N)]
d = [0] * N

for i in range(N-1):
    a, b = map(int, input().strip().split())
    a -= 1
    b -= 1
    n_list[a].append([b,i])
    n_list[b].append([a,i])
    d[a] += 1
    d[b] += 1


#print(n_list)
#print(d)

d_dict = {}
for i in range(N):
    d_dict[i] = d[i]
tmp = sorted(d_dict.items(), key = lambda x:x[1], reverse = True)

colors = [0] * (N)

root = tmp[0][0]

def paint(node, parent_edge_id):
    #print(node, parent_edge_id)
    tmp_color = 1
    for edge in n_list[node]:
        #print("ege:", edge)
        if edge[1] != parent_edge_id:
            if parent_edge_id != -1 and tmp_color == colors[parent_edge_id]:
                tmp_color += 1
            colors[edge[1]] = tmp_color
            paint(edge[0], edge[1])
            tmp_color += 1

    
sys.setrecursionlimit(10**7)
paint(tmp[0][0], -1)
print(tmp[0][1]) # color num 
for i in range(N-1):
    print(colors[i])
from collections import Counter
N=int(input())
balls=[tuple(map(int, input().split())) for _ in range(N)]

#2ボールの相対座標をぜんぶ調べる
R=[(x[0]-y[0],x[1]-y[1]) for x in balls for y in balls]
C=Counter(R).most_common(2)

#いちばん多い相対座標を(p,q)とする
#C[0]は(0,0)なので除外
print(N-(C[1][1]))

### FIXED CODE ###

from collections import Counter
N=int(input())
balls=[tuple(map(int, input().split())) for _ in range(N)]

#2ボールの相対座標をぜんぶ調べる
R=[(x[0]-y[0],x[1]-y[1]) for x in balls for y in balls]
C=Counter(R).most_common()

#いちばん多い相対座標を(p,q)とする
#C[0]は(0,0)なので除外
if len(C)<=1:
    print(N)
else:
    print(N-(C[1][1]))
n, k = map(int, input().split())
x_list = [0]*n
y_list = [0]*n
for i in range(n):
    x_list[i], y_list[i] = map(int, input().split())

x_element = set(x_list)
y_element = set(y_list)
ans = float("inf")

for i in range(len(x_element)):
    for j in range(len(y_element)):
        for k in range(i+1, len(x_element)):
            for l in range(j+1, len(y_element)):
                num = 0
                for m in range(n):
                    x_left = x_element[i]
                    x_right = x_element[k]
                    y_bottom = y_element[j]
                    y_upper = y_element[l]
                    if x_left <= x_list[m] <= x_right and y_bottom <= y_list[m] <= y_upper:
                        num += 1
                    if num >= k:
                        ans = min((x_right - x_left) * (y_upper - y_bottom), ans)

print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
x_list = [0]*N
y_list = [0]*N
for i in range(N):
    x_list[i], y_list[i] = map(int, input().split())

x_element = sorted(set(x_list))
y_element = sorted(set(y_list))
ans = float("inf")

for i in range(len(x_element)):
    for j in range(len(y_element)):
        for k in range(i+1, len(x_element)):
            for l in range(j+1, len(y_element)):
                num = 0
                for m in range(N):
                    if x_element[i] <= x_list[m] <= x_element[k] and y_element[j] <= y_list[m] <= y_element[l]:
                        num += 1
                if num >= K:
                    ans = min((x_element[k] - x_element[i]) * (y_element[l] - y_element[j]), ans)

print(ans)
def factorial(n):
    if n == 1:
        return n
    return n*factorial(n-1)

x,y = map(int, input().split())

if (x+y)%3 != 0:
    print(0)

ans = factorial((x+y)/3)/factorial((4*x-2*y)/6)*factorial((4*y-2*x)/6)

print(ans)

### FIXED CODE ###

#組み合わせの計算
def combi(n, r, mod):
    r = min(r, n-r)
    numer = denom = 1

    for i in range(r):
        numer = numer * (n-i) % mod
        denom = denom * (i+1) % mod
    return numer * pow(denom, mod-2, mod) % mod #逆元

x, y = map(int, input().split())
mod  = 10**9+7

n = (-x + 2*y)/3
m = (2*x -  y)/3

if (x+y)%3 != 0:
    print(0)
    exit()

if n < 0 or m < 0:
    print(0)
    exit()

ans = combi(int(n+m), int(n), mod)
print(ans)
H,W = map(int,input().split())
a = [list(map(int,input().split())) for i in range(H)]
def next(i,j):
    if i%2==0:
        if j == W-1:
            return i+1,j
        else:
            return i,j+1
    else:
        if j == 0:
            return i+1,j
        else:
            return i,j-1
ans = []
i,j = 0,0
while i < H:
    i_,j_ = next(i,j)
    if a[i][j]%2==1:
        a[i][j] -= 1
        a[i_][j_] += 1
        ans.append('{} {} {} {}'.format(i+1,j+1,i_+1,j_+1))
    i,j = i_,j_
print(len(ans))
for s in ans:
    print(s)

### FIXED CODE ###

H,W = map(int,input().split())
a = [list(map(int,input().split())) for i in range(H)]
def next(i,j):
    if i%2==0:
        if j == W-1:
            return i+1,j
        else:
            return i,j+1
    else:
        if j == 0:
            return i+1,j
        else:
            return i,j-1
ans = []
i,j = 0,0
while True:
    i_,j_ = next(i,j)
    if i_ == H:
        break
    if a[i][j]%2==1:
        a[i][j] -= 1
        a[i_][j_] += 1
        ans.append('{} {} {} {}'.format(i+1,j+1,i_+1,j_+1))
    i,j = i_,j_
print(len(ans))
for s in ans:
    print(s)