Harryxun/stf_run huggingface dataset:
from math import gcd
mod = 10**9+7
n = int(input())
dicn = {}
dicp = {}
dicz = {'a': 0, 'b': 0, 'z': 0}
for i in range(n):
  a, b = map(int, input().split())
  if a == 0 and b == 0:
    dicz['z'] += 1
  else:
    g = gcd(a,b)
    a //= g
    b //= g
    if a < 0:
      a *= -1
      b *= -1
    elif a == 0 and b < 0:
      b *= -1
    if a * b > 0:
      if a in dicp:
        if b in dicp[a]:
          dicp[a][b] += 1
        else:
          dicp[a][b] = 1
      else:
        dicp[a] = {b: 1}
    elif a * b < 0:
      if b in dicn:
        if a in dicn[b]:
          dicn[b][a] += 1
        else:
          dicn[b][a] = 1
      else:
        dicn[b] = {a: 1}
    else:
      if a == 0:
        dicz['a'] += 1
      else:
        dicz['b'] += 1

ans = 1

for a in dicp:
  for b in dicp[a]:
    if -a in dicn:
      if b in dicn[-a]:
        ans *= (pow(2, dicp[a][b], mod) + pow(2, dicn[-a][b], mod) - 1)
        dicn[-a][b] = 0
      else:
        ans *= pow(2, dicp[a][b], mod)
    else:
      ans *= pow(2, dicp[a][b], mod)
    ans %= mod

for b in dicn:
  for a in dicn[b]:
    ans *= pow(2, dicn[b][a], mod)
    ans %= mod
    
if dicz['a'] > 0 and dicz['b'] > 0:
  ans *= pow(2,dicz['a'],mod) + pow(2,dicz['b'],mod) - 1
elif dicz['a'] > 0:
  ans *= pow(2,dicz['a'],mod)
elif dicz['b'] > 0:
  ans *= pow(2,dicz['b'],mod)
  
ans += dicz['z']
print((ans-1)%mod)


### FIXED CODE ###

x = int(input()[-1])
if x in [2,4,5,7,9]:
  print('hon')
elif x == 3:
  print('bon')
else:
  print('pon')
import collections as col
import itertools as ite
import numpy as np
import math as ma
from scipy.special import comb

MOD = 10**9 + 7
def inv(a): return pow(a, MOD-2, MOD)
def cmb(n,r):
    ans = ma.factorial(n)%MOD * inv(ma.factorial(r)) * inv(ma.factorial(n-r))
    return ans%MOD

def prime(n):
    ans = []
    for i in range(2, int(n**0.5)+1):
        while not n%i: n //= i; ans.append(i)
    if n != 1: ans.append(n)
    return ans

n,m = map(int,input().split())
cnt = col.Counter(prime(m))

ans = 1
for key,val in cnt.items():
    #ans *= cmb(val + n-1, n-1)
    ans *= comb(val + n-1, n-1, exact=1)
    ans %= MOD
print(ans)


### FIXED CODE ###

import collections as col
import numpy as np
import math as ma
import scipy.misc as spm #miscellaneous

MOD = 10**9 + 7
def inv(a): return pow(a, MOD-2, MOD)
def comb(n,r):
    ans = ma.factorial(n)%MOD * inv(ma.factorial(r)) * inv(ma.factorial(n-r))
    return ans%MOD

def prime(n):
    ans = []
    for i in range(2, int(n**0.5)+1):
        while not n%i: n //= i; ans.append(i)
    if n != 1: ans.append(n)
    return ans

n,m = map(int,input().split())
cnt = col.Counter(prime(m))

ans = 1
for key,val in cnt.items():
    #ans *= comb(val + n-1, n-1)
    ans *= spm.comb(val + n-1, n-1, exact=1)
    ans %= MOD
print(ans)
def search_dist(g, dist, e):
    for b, c in g.get(e):
        if dist[b] is not None:
            continue
        dist[b] = dist[e] + c
        search_dist(g, dist, b)

def main():
    g = {}
    N = int(input())
    abc = []
    for _ in range(N-1):
        abc.append(list(map(int, input().split(' '))))
    for a, b, c in abc:
        g[a] = g.get(a, []) + [(b, c)]
        g[b] = g.get(b, []) + [(a, c)]
    Q, K = list(map(int, input().split(' ')))
    dist = [None]*(N+1)
    dist[K] = 0
    search_dist(g, dist, K)
    cood = []
    for _ in range(Q):
        cood.append(list(map(int, input().split(' '))))

    for x, y in cood:
        print(dist[x]+dist[y])

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(int(1e5+10))

def search_dist(g, dist, e):
    for b, c in g.get(e):
        if dist[b] is not None:
            continue
        dist[b] = dist[e] + c
        search_dist(g, dist, b)

def main():
    g = {}
    N = int(input())
    for i in range(N+1):
        g[i] = []
    for _ in range(N-1):
        a, b, c = list(map(int, input().split(' ')))
        g[a] += [(b, c)]
        g[b] += [(a, c)]
    Q, K = list(map(int, input().split(' ')))
    dist = [None]*(N+1)
    dist[K] = 0
    search_dist(g, dist, K)
    cood = []
    for _ in range(Q):
        cood.append(list(map(int, input().split(' '))))

    for x, y in cood:
        print(dist[x]+dist[y])

if __name__ == '__main__':
    main()
def main():
    N = int(input())
    P = []
    M = []
    for i in range(N):
        s = input()
        left = 0
        right = 0
        rightmax = 0
        for c in s:
            if c == "(":
                left += 1
            else:
                right += 1
            rightmax = max(rightmax, right - left)
        leftdiff = left - right       
        if leftdiff >= 0:
            P.append((leftdiff, rightmax, s))
        else:
            M.append((leftdiff, rightmax, s))

    R = []
    for e in sorted(P, key=lambda _e: _e[1]):
        R.push(e[2])
    for e in sorted(M, key=lambda _e: _e[1], reverse=True):
        R.push(e[2])

    left = 0    
    for c in "".join(R):
        if c == "(":
            left += 1
        else:
            left -= 1
        if left < 0:
            print("No")
            return
    if left == 0:
        print("Yes")
    else:
        print("No")


main()


### FIXED CODE ###

def main():
    N = int(input())
    P = []
    M = []
    for i in range(N):
        s = input()
        left = 0
        right = 0
        rightmax = 0
        for c in s:
            if c == "(":
                left += 1
            else:
                right += 1
            rightmax = max(rightmax, right - left)
        leftdiff = left-right
        if leftdiff >= 0:
            P.append((leftdiff, rightmax, 0, s))
            continue
            
        left = 0
        right = 0
        leftmax = 0
        for c in reversed(s):
            if c == "(":
                left += 1
            else:
                right += 1
            leftmax = max(leftmax, left - right)
        M.append((leftdiff, 0, leftmax, s))

    R = []
    for e in sorted(P, key=lambda _e: _e[1]):
        R.append(e[3])
    for e in sorted(M, key=lambda _e: _e[2], reverse=True):
        R.append(e[3])

    nleft = 0
    for c in "".join(R):
        if c == "(":
            nleft += 1
        else:
            nleft -= 1
        if nleft < 0:
            print("No")
            return
        
    if nleft == 0:
        print("Yes")
    else:
        print("No")


main()
while 1:
   x, y = map(int, raw_input().split())
   if x == 0 and y == 0:
      break
   if y < x:
      print '%s %s' %(y, x)
   else:
      print '%s %s' %(x, y)
    

### FIXED CODE ###

while 1:
   x, y = map(int, raw_input().split())
   if x == 0 and y == 0:
      break
   elif x > y:
      print '%s %s' % (y,x)
   else:
      print '%s %s' % (x,y)
n,k=int(input())

count=0

while n//k>0:
  n//k
  count+=1
  
  

### FIXED CODE ###

n,k=map(int,input().split())
        
count=1
 
while n//k>0:
  n=n//k
  count+=1
  
print(count)
S = int(input())
A = S // 100
B = S % 100
MMA = False
MMB = False
if 1 <= A and A <= 12:
  MMA = True
if 1 <= B and B <= 12:
  MMB = True

if MMA and MMB:
  print(AMBIGUOUS)
elif MMA and not(MMB):
  print('MMYY')
elif not(MMA) and MMB:
  print('YYMM')
else:
  print('NA')

### FIXED CODE ###

S = int(input())
A = S // 100
B = S % 100
MMA = False
MMB = False
if 1 <= A and A <= 12:
  MMA = True
if 1 <= B and B <= 12:
  MMB = True

if MMA and MMB:
  print('AMBIGUOUS')
elif MMA and not(MMB):
  print('MMYY')
elif not(MMA) and MMB:
  print('YYMM')
else:
  print('NA')
n=-int(input())
a=""
while n:
    a+=str(n%2)
    n//=-2
print(a[::-1] if a else 0)

### FIXED CODE ###

a,b=map(int,input().split())
print("0"if a%b == 0 else "1")
a = [[int(i) for i in input().split()] for i in range(N)]
menseki = a[0]*a[1]/2
print(menseki)

### FIXED CODE ###

a = [int(i) for i in input().split()]
menseki = int(a[0]*a[1]/2)
print(menseki)
def coloring(v, p, vs, cs, color):
	cs[v] = color
	for e in vs[v]:
		if e[0] == p:
			continue
		nc = color if e[1] % 2 == 0 else 1 - color
		coloring(e[0], v, vs, cs, nc)

def resolve():
	n = int(input())
	vs = [[] for _ in range(n)]
	cs = [None]*n
	for i in range(n-1):
		u, v, w = map(int, input().split())
		vs[u-1].append([v-1, w])
		vs[v-1].append([u-1, w])
	coloring(0, None, vs, cs, 1)
	for i in cs:
		print(i)
resolve()

### FIXED CODE ###

import sys
sys.setrecursionlimit(100**4)

class Edge():
	def __init__(self, v, w):
		self._v = v
		self._w = w
	def v(self):
		return self._v
	def w(self):
		return self._w

def dfs(v, g, colors, color = 0):
	colors[v] = color
	if not len(g[v]):
		return
	for nv in g[v]:
		if colors[nv.v()] != -1:
			continue
		nc = color if nv.w() % 2 == 0 else 1 - color
		dfs(nv.v(), g, colors, nc)

def resolve():
	n = int(input())
	colors = [-1]*n
	g = [list() for _ in range(n)]
	for _ in range(n-1):
		u, v, w = map(int, input().split())
		g[v-1].append(Edge(u-1, w))
		g[u-1].append(Edge(v-1, w))
	for i in range(n):
		if colors[i] != -1:
			continue
		dfs(i, g, colors)
	for c in colors:
		print(c)
resolve()
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

cost=[0]*200010
G=[[] for _ in range(200010)]
visited=[False]*200010
visited[0]=True

def dfs(s):
  global cost
  global G
  global visited
  for e in G[s]:
    if visited[e]==False:
      cost[e]+=cost[s]
      visited[e]=True
      dfs(e)
      visited[e]=False

def main():
  global cost
  global G
  global visited
  n,q=LI()
  for _ in range(n-1):
    a,b=LI()
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)

  for i in range(q):
    p,x=LI()
    p-=1
    cost[p]+=x
  dfs(0)

  return ' '.join([str(x) for x in cost[:n]])

# main()
print(main())


### FIXED CODE ###

import math,itertools,fractions,heapq,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

nmax=2*10**5+10
graph=[[] for _ in range(nmax)]
level=[-1]*nmax

def dfs(n,s,l):
  if len(graph[s])==0:
    return
  for e in graph[s]:
    if level[e]==-1:
      level[e]=level[s]+1
    if level[e]>level[s]:
      l[e]+=l[s]
      dfs(n,e,l)

def main():
  n,q=LI()
  for _ in range(n-1):
    a,b=LI()
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
  l=[0]*n
  for _ in range(q):
    a,b=LI()
    l[a-1]+=b

  level[0]=0
  dfs(n,0,l)

  return ' '.join([str(x) for x in l])

# main()
print(main())
N = [int(i) for i in input().split()][0]
P = [i for i in input().split()]

count=0
for i in range(0,N-2):
  tmp = [P[i],P[i+1],P[i+2]]
  tmp.sort()
  if P[i+1]==tmp[1]:
    count+=1

print(count)

### FIXED CODE ###

N = [int(i) for i in input().split()][0]

balls=[]
for i in range(N):
  balls.append( [int(i) for i in input().split()])

ans=0
for i in range(0,N-1):
  for j in range(i+1,N):
    sax = balls[j][0]-balls[i][0]
    say = balls[j][1]-balls[i][1]
    merge=0
    for k in range(0,N):
      if([balls[k][0]+sax,balls[k][1]+say] in balls):
          merge+=1
    ans=max(ans,merge)
print(N-ans)
N,K,L = map(int,input().split())

root_road = list(range(N))
root_rail = list(range(N))
depth_road = [1 for _ in range(N)]
depth_rail = [1 for _ in range(N)]

def find(a,root):
    if root[a] == a:
        return a
    else:
        root[a] = find(root[a],root)
        return root[a]

def unite(a,b,root,depth):
    A = find(a,root)
    B = find(b,root)
    if A == B:
        return
    elif depth[A] > depth[B]:
        root[B] = A
        depth[A] += depth[B]
    else:
        root[A] = B
        depth[B] += depth[A]

for i in range(K):
    p,q = map(int,input().split())
    unite(p-1,q-1,root_road,depth_road)
for i in range(L):
    r,s = map(int,input().split())
    unite(r-1,s-1,root_rail,depth_rail)
d = defaultdict(int)
pairs = []
for i in range(N):
    road = find(i,root_road)
    rail = find(i,root_rail)
    pairs.append((road,rail))
    d[(road,rail)] += 1
for p in pairs:
    print(d[p],end = " ")

### FIXED CODE ###

from collections import defaultdict
N,K,L = map(int,input().split())

root_road = list(range(N))
root_rail = list(range(N))
depth_road = [1 for _ in range(N)]
depth_rail = [1 for _ in range(N)]

def find(a,root):
    if root[a] == a:
        return a
    else:
        root[a] = find(root[a],root)
        return root[a]

def unite(a,b,root,depth):
    A = find(a,root)
    B = find(b,root)
    if A == B:
        return
    elif depth[A] > depth[B]:
        root[B] = A
        depth[A] += depth[B]
    else:
        root[A] = B
        depth[B] += depth[A]

for i in range(K):
    p,q = map(int,input().split())
    unite(p-1,q-1,root_road,depth_road)
for i in range(L):
    r,s = map(int,input().split())
    unite(r-1,s-1,root_rail,depth_rail)
d = defaultdict(int)
pairs = []
for i in range(N):
    road = find(i,root_road)
    rail = find(i,root_rail)
    pairs.append((road,rail))
    d[(road,rail)] += 1
for p in pairs:
    print(d[p],end = " ")
s=input()
print(['YES','NO'][int(s.replace(' ',''))%4])

### FIXED CODE ###

s=input().split()
s=int(''.join(s))
if s%4==0:
  print('YES')
else:
  print('NO')
# coding: utf-8
import math

num_N = int(input())

min_num = math.inf

for i in range(1, math.floor(math.sqrt(num_N)) + 1):
    if num_N % i == 0:
        num_A = i
        num_B = int(num_N // i)
        len_num_A = len(list(str(num_A)))
        len_num_B = len(list(str(num_B)))
        min_num = min(min_num, max(len_num_A, len_num_B))

print(min_num)

### FIXED CODE ###

# coding: utf-8
import math

num_N = int(input())

min_num = 999999
sqrt_N = math.floor(math.sqrt(num_N))

for i in range(1, sqrt_N + 1):
    if num_N % i == 0:
        len_num_A = len(str(i))
        len_num_B = len(str(int(num_N / i)))
        min_num = min(min_num, max(len_num_A, len_num_B))

print(min_num)
import math
N, D = map(int, input().split())
a = []
for i in range(N):
  b = map(int, input().split())
  a += b
print(a)
res = 0
for i in range(N-1):
  j = i + 1
  while(j < N):
    x = []
    y = []
    for k in range(D):
      x.append(a[i * D + k])
      y.append(a[j * D + k])
    tmp = 0
    for k in range(D):
      tmp += (x[k] - y[k]) ** 2
    if tmp = int(tmp ** 0.5) * int(tmp ** 0.5):
      res += 1
    j += 1
print(res)
      

### FIXED CODE ###

import math
N, D = map(int, input().split())
a = []
for i in range(N):
  b = map(int, input().split())
  a += b
res = 0
for i in range(N-1):
  j = i + 1
  while(j < N):
    x = []
    y = []
    for k in range(D):
      x.append(a[i * D + k])
      y.append(a[j * D + k])
    tmp = 0
    for k in range(D):
      tmp += (x[k] - y[k]) ** 2
    if tmp == int(tmp ** 0.5) * int(tmp ** 0.5):
      res += 1
    j += 1
print(res)
a,b,c,d = map(int, input().split())

if a >= 0 and c >= 0:
  print(b*d)
elif b <= 0 and d <= 0:
  print(a*c)
elif a < 0 and c < 0:
  if b<=0 or d<=0:
    print(a*c)  
  elif abs(a)>=abs(b) and abs(c)>=abs(d):
    print(a*c)
  else:
    print(b*d)
elif (b<0 and c>=0):
  print(b*c)
elif (a>=0 and d<0):
  print(a*d)
else:
  print(b*d)

### FIXED CODE ###

MOD = 10 ** 9 + 7

N = int(input())

ans = pow(10, N, MOD)
ans -= 2 * pow(9, N, MOD)
ans += pow(8, N, MOD)
ans %= MOD # 最後にMODを取り忘れないように気をつけましょう

print(ans)
M, N = map(int, input().split())
if M > 2 and N > 2:
    print(M - 2) * (N - 2)
elif M==1 or N==1:
    print(N * M - 2)
else:
    print(0)


### FIXED CODE ###

M, N = map(int, input().split())
if M==1 and N==1:
    print(1)
elif M > 2 and N > 2:
    print((M - 2) * (N - 2))
elif M==1 or N==1:
    print(N * M - 2)
else:
    print(0)
N=int(input())
S = {}
for i in range(n):
    let = input()
    try:
        S[let] += 1
    except:
        S[let] = 1
max_val = max(S.values())
key for key in d:
    if S[key] == max_val:
        print('\d'.join(S[key]))

### FIXED CODE ###

N=int(input())
S = {}
for i in range(N):
    let = input()
    try:
        S[let] += 1
    except:
        S[let] = 1
max_val = max(S.values())
answers = []
for k,v in S.items():
    if v == max_val:
        answers.append(k)
answers.sort()
for ans in answers:
    print(ans)
A,B=int(input())
if A*B<=81:
    print("A*B")
else:
    print("-1")

### FIXED CODE ###

A, B = map(int, input().split())
if A <= 9 and B <= 9:
    print(A * B)
else:
    print(-1)
H,N = map(int,input().split())
AB = []
 
for i in range(N):
    a,b = map(int,input().split())
    AB.append([a,b])
INF = 10**15
dp = [[INF]*(2*10**4+1) for i in range(N+1)]
for i in range(N+1):
    dp[i][0] = 0
 
for i in range(N):
    for j in range(1,2*10**4+1):
        dp[i+1][j] = min(dp[i][j],dp[i+1][j-AB[i][0]]+AB[i][1])
        
ans = float('inf')
for i in range(H,2*10**4+1):
    ans = min(ans,dp[N][i])
print(ans)

### FIXED CODE ###

N,D,A = map(int,input().split())
XH = []
X = []

for i in range(N):
    x,h = map(int,input().split())
    XH.append([x,h,0])
    X.append(x)
    
XH.sort(key = lambda a:a[0])
XH.append([float('inf'),0,0])
X.sort()
X.append(float('inf'))

import bisect
ans = 0

for i in range(N):
    x,h,k = XH[i]
    dk = max(-(-(h-k*A)//A),0)
    #print(x,h,k,dk)
    ans += dk
    
    XH[i][2] += dk
    j = bisect.bisect_right(X,x+2*D)
    XH[j][2] -= dk

    XH[i+1][2] += XH[i][2]
    
print(ans)
# ABC 157 C
list_s=[]
list_c=[]
Flag=0
N,M= map(int,input().split())

for i in range(M):
    s,c= map(int,input().split())
    list_s.append(s)
    list_c.append(c)
    if s in list_s:
        x=list_s.index(s)
        n=list_c[x]

        if n!=c:
            Flag=1

if 1 in list_s:
    in1=list_s.index(1)
    n1=list_c[in1]
    if n1==0:
        Flag=1
else :
    n1=1

if 2 in list_s:
    in2=list_s.index(2)
    n2=list_c[in2]
else :
    n2=0

if 3 in list_s:
    in3=list_s.index(3)
    n3=list_c[in3]
else :
    n3=0

if N==1 and n1==0:
    Flag=0
    
if Flag==0:
    if N==1:
        if M==0:
            print(0)
        else:
            print(n1)
    if N==2:
        print(10*n1+n2)
    if N==3:
        print(100*n1+10*n2+n3)
else :
    print(-1)


### FIXED CODE ###

N = int(input())
print((N+1)//2)
def count():
    a, b, x = map(int, input().split())
    count = 0
    for i in range(a, b+1):
        if i % x == 0:
            count += 1

    print(count)


if __name__ == "__main__":
    count()

### FIXED CODE ###


def contest(x):

    x = x.split()
    print(x[0][0] + x[1][0] + x[2][0])

if __name__ == "__main__":
    
    x = input()
    contest(x)
n, k = map(int, raw_input().split())
a = map(int, raw_input().split())
a.sort(reverse = True)
ans = 0:
for i in xrange(k):
    ans += a[i]
print ans


### FIXED CODE ###

n, k = map(int, raw_input().split())
a = map(int, raw_input().split())
a.sort(reverse = True)
ans = 0
for i in xrange(k):
    ans += a[i]
print ans
# -*- coding: utf-8 -*-
import sys

N=int(input())

ans_l=[1]*N

if N == 1:
    print("1")
else:
    for i in range(N):
        A=int(input())
        for j in range(A):
            a,b=map(int,input().split())
            ans_l[a-1]=ans_l[a-1]*b
    print(sum(ans_l))


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
a = [int(x) for x in sys.stdin.readline().rstrip().split()]
if sum(a) < 22:
    print("win")
else:
    print("bust")
def main():
  if 'get_ipython' not in globals():  
    # For Subsession
    N = int(input())
    # b = list(map(int, input().split()))
    b = [int(i) for i in input().split()] 
  else:
    # b = [1,2,1]
    # b = [2,2]
    b = [1,1,1,2,2,1,2,3,2]
    N = len(b)
    
  if check(b) != True:
    print(-1)
    
def check(B):
  # if 'get_ipython' in globals(): print(B)
  lenB = len(B)
  if lenB == 0 :
    return True
  else :
    maxB = max(B)    
  # for i in reversed(range(lenB)):
  for i in reversed(range(0,maxB)):
    if B[i] == i+1:
      if check(B[:i]+B[(i+1):]) == True:
        print(B[i])
        return True
        break
    
main()

### FIXED CODE ###

import sys

def main():
  if 'get_ipython' not in globals():  
    # For Subsession
    N = int(input())
    b = [int(i) for i in input().split()] 
  else:
    # b = [1,2,1]
    # b = [2,2]
    b = [1,1,1,2,2,1,2,3,2]
    N = len(b)

  ans = []
  while True:
    for i in range(N-1,-1,-1):
      if b[i] == i+1:
        ans.append(i+1)
        del b[i]
        N = N -1
        break
      if i == 0:
        print(-1)
        sys.exit()
    if N == 0:
      break

  for i in reversed(ans):
    print(i)
    
main()
A,B = int(input())
ans = -1
for i in range(1010):
    if int(i*0.08) == A and int(i*0.1) == B:
        ans = i
        break

print(ans)

### FIXED CODE ###

A,B = map(int, input().split())
for i in range(1010):
    if int(i*0.08) == A and int(i*0.1) == B:
        print(i)
        exit()

print(-1)
N,M = map(int,input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

cnt = 0
if A < B:
    print('No')
else:
    for i in range(M):
        if B[i] in A[i]:
            cnt+=1
            flag = True
        else:
            cnt = 0
            flag = False
        if cnt == M:
            break
if flag:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

N,M = map(int,input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

def comp(x,y):
    for i in range(M):
        for j in range(M):
            if A[x+i][y+j] != B[i][j]:
                return False
    return True
flag = False
for i in range(N-M+1):
    for j in range(N-M+1):
        if comp(i,j):
            flag = True
            break
if flag:
    print('Yes')
else:
    print('No')
judge = True
while judge:
    a,b = map(int, input().split(" "))
    if a == None:
        judge = False
    else:
        c = a+b
        print(len(str(c)))

### FIXED CODE ###

import fileinput

if __name__ == '__main__':
    for line in fileinput.input():
        tokens = line.strip().split()
        a, b = int(tokens[0]), int(tokens[1])
        c = a+b
        print(len(str(c)))
N, K = map(int, input().split())
arr = list(map(int, input().split()))

if 0 in arr:
    K -= 1

if K==0:
    print(0)
    exit()

left =[]
right= []
for i in arr:
    if i<0:
        left.append(i*(-1))
    if i>0:
        right.append(i)

left = left[::-1]
if len(left)==0:
    print(right[K-1])
    exit()

if len(right)==0:
    print(left[K-1])
    exit()


if len(left)>=K and len(right)>=K:
    print(min(abs(left[K-1]),abs(right[K-1])))
    exit()

if len(left)<K and len(right)>=K:
    ans =[]
    ans.append(right[K-1])
    for i in range(K-2):
        ans.append(2*right[i]+left[K-i-2])
    for i in range(len(left)-1):
        ans.append(2*left[i]+right[K-i-2])
    print(min(ans))
    exit()

if len(right)<K and len(left)>=K:
    ans =[]
    ans.append(left[K-1])
    for i in range(K-2):
        ans.append(2*left[i]+right[K-i-2])
    for i in range(len(right)-1):
        ans.append(2*right[i]+left[K-i-2])
    print(min(ans))
    exit()

if len(right)<K and len(left)<K:
    ans =[]
    for i in range(len(left)-1):
        ans.append(2*left[i]+right[K-i-2])
    for i in range(len(right)-1):
        ans.append(2*right[i]+left[K-i-2])
    print(min(ans))
    exit()





### FIXED CODE ###

N, K = map(int, input().split())
arr = list(map(int, input().split()))

ans =[]
if arr[0]>0:
    ans.append(arr[K-1])

if arr[-1]<0:
    ans.append(abs(arr[-1*(K)]))

for i in range(N-K+1):
    if arr[i]*arr[i+K-1]<=0:
        left =2*abs(arr[i])+abs(arr[i+K-1])
        right=2*abs(arr[i+K-1])+abs(arr[i])
        ans.append(min(left,right))

print(min(ans))
mport numpy as np

N = int(input())
X = [int(i) for i in input().split()]

arrayX = np.array(X)
num = arrayX.size

for i in range(num):
    arrayX = np.delete(arrayX,i)
    print(int(np.median(arrayX)))
    arrayX = np.array(X)

### FIXED CODE ###

N = int(input())
X = [int(i) for i in input().split()]

sortedX = X[:]
sortedX.sort()
lenX = len(X)

for i in X:
    if i > sortedX[int(lenX/2) - 1]:
        print(sortedX[int(lenX/2)-1])
    else:
        print(sortedX[int(lenX/2)])