Harryxun/stf_run huggingface dataset:
import sys
import decimal
import numpy as np
input = sys.stdin.readline

N = int(input())
kizyun = 1e-9
A = []
C2 = np.array([[0 for j in range(14)] for i in range(14)])  # 10countは9タス
C5 = np.array([[0 for j in range(14)] for i in range(14)])
for _ in range(N):
    i = decimal.Decimal(input())
    c10, c2, c5 = 0, 0, 0
    while i%1!=0:
        c10 -= 1
        i *= 10
    while i % 10 == 0:
        c10 += 1
        i /= 10
    while i % 2 == 0:
        c2 += 1
        i /= 2
    while i % 5 == 0:
        c5 += 1
        i /= 5
    c2 = min(c2, 13)
    c5 = min(c5, 13)
    A.append((c10, c2, c5))
    C2[c10+9][c2] += 1
    C5[c10+9][c5] += 1

ans = 0
for c10, c2, c5 in A:
    if c10 >= 0:
        ans -= 1
    ans += np.sum(C2[-c10 + 9:])
    if c5 == 0:
        for i in range(-c10 + 9):
            shouldhave = (-c10+9) - i
            if shouldhave <= c2:
                ans += np.sum(C5[i][shouldhave:])
    elif c2 == 0:
        for i in range(-c10 + 9):
            shouldhave = (-c10 + 9) - i
            if shouldhave <= c5:
                ans += np.sum(C2[i][shouldhave:])
print(ans//2)

### FIXED CODE ###

import sys
import decimal
import numpy as np
input = sys.stdin.readline

N = int(input())
A = []
C2 = np.array([[0 for j in range(30)] for i in range(14)])  # 10countは9タス
C5 = np.array([[0 for j in range(30)] for i in range(14)])
C10 = np.zeros(14)
for _ in range(N):
    i = decimal.Decimal(input())
    c10, c2, c5 = 0, 0, 0
    while i % 1 != 0:
        c10 -= 1
        i *= 10
    while i % 10 == 0:
        c10 += 1
        i /= 10
    while i % 2 == 0:
        c2 += 1
        i /= 2
    while i % 5 == 0:
        c5 += 1
        i /= 5
    c2 = min(c2, 30)
    c5 = min(c5, 30)
    A.append((c10, c2, c5))
    C2[c10+9][c2] += 1
    C5[c10+9][c5] += 1
    C10[c10+9] += 1

ans = 0
for i in range(14):
    ans += C10[i]*np.sum(C10[18-i:])
    if i >= 9:
        ans -= C10[i]
    for j in range(18-i):
        if j >= 14:
            continue
        for k in range(1, 30):
            shouldhave = 18 - i - j
            if k >= shouldhave:
                ans += C2[i][k] * np.sum(C5[j][shouldhave:])
                ans += C5[i][k] * np.sum(C2[j][shouldhave:])

print(int(ans//2))
Sx = input()
T = input()

offset = len(Sx) - len(T) + 1
check = [1] * offset

ans = 'UNRESTORABLE'
if len(Sx) >= len(T):
    for d in range(offset):
        for j in range(len(T)):
            check[d] &= (Sx[j + d] == T[j] or Sx[j + d] == '?')
    
    if any(check):
        k = max(k for k, c in enumerate(check) if c)
        ans = ''
        for i in range(len(Sx)):
            if i < k or k + len(T) < i:
                c = Sx[i]
            else:
                c = T[i - k]
            c = 'a' if c == '?' else c

            ans += c

print(ans)


### FIXED CODE ###

import re


S_ = input()
T = input()

S_ = S_[::-1]
T = T[::-1]

t = ''
for c in T:
    t += '[?' + c + ']'
regex = re.compile(t)

S, cnt = regex.subn(T, S_, count=1)
if cnt:
    S = S.replace('?', 'a')
    print(S[::-1])
else:
    print('UNRESTORABLE')
from collections import deque
N = int(input())

alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
unvisited = deque(alphabet[0 : N])
visited = deque()
st = deque([["a", visited, unvisited]]) # stack

while len(st) > 0:
    str, visited, unvisited = st.popleft()

    if str[-1] not in visited:
        visited.append(str[-1])
        unvisited.popleft()

    if len(str) == N:
        print(str)
    else:
        # すでに使った文字を使う
        for x in visited:
            st.append([str + x, visited.copy(), unvisited.copy()])
        # まだ使っていない文字を使う
        if len(unvisited) > 0:
            x = unvisited[0]
            st.append([str + x, visited.copy(), unvisited.copy()])


### FIXED CODE ###

from collections import deque
N = int(input())

alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
unvisited = deque(alphabet[0 : N])
visited = deque()
st = deque([["a", visited, unvisited]]) # stack

while len(st) > 0:
    str, visited, unvisited = st.popleft()

    if str[-1] not in visited:
        visited.append(str[-1])
        unvisited.popleft()

    if len(str) == N:
        print(str)
    else:
        # すでに使った文字を使う
        for x in visited:
            st.append([str + x, deque(visited), deque(unvisited)])
        # まだ使っていない文字を使う
        if len(unvisited) > 0:
            x = unvisited[0]
            st.append([str + x, deque(visited), deque(unvisited)])
n = int(input())
vals = map(int, input().split(" "))
cur_vals = [-1, -1, -1]

M = 1000000007
out = 1
for val in vals:
    before_val = val-1
    before_val_num = sum([1 for cur_val in cur_vals if cur_val == before_val])
    out = (out * before_val_num) % M
    tar_i = cur_vals.index(before_val)
    cur_vals[tar_i] = val

print(out)

### FIXED CODE ###

n = int(input())
vals = map(int, input().split(" "))
cur_vals = [-1, -1, -1]

M = 1000000007
out = 1
for val in vals:
    before_val = val-1
    before_val_num = sum([1 for cur_val in cur_vals if cur_val == before_val])
    if before_val_num == 0:
        out = 0
        break
    out = (out * before_val_num) % M
    tar_i = cur_vals.index(before_val)
    cur_vals[tar_i] = val

print(out)
import math
A,B,C,D = map(int,input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

LCM = lcm(C,D)
BC = B // C
BD = B // D
BCD = B // LCM
AC = (A-1) // C
AD = (A-1) // D
ACD = (A-1) // LCM
x = B - BC - BD + BCD
y = (A-1) - AC - AD + ACD
print(x - y)

### FIXED CODE ###

import fractions
A,B,C,D = map(int,input().split())

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

LCM = lcm(C,D)
BC = B // C
BD = B // D
BCD = B // LCM
AC = (A-1) // C
AD = (A-1) // D
ACD = (A-1) // LCM
x = B - BC - BD + BCD
y = (A-1) - AC - AD + ACD
print(x - y)
ab = a * b
if ab % 2 == 0:
  print('Even')
else:
  print('Odd')

### FIXED CODE ###

a, b = map(int, input().split())
ab = a * b
if ab % 2 == 0:
  print('Even')
else:
  print('Odd')
a, b = map(int,raw_input().split())

if a<b:
    print "a < b"
elif a>b:
    print "a > b"
elif a==b:
    print "a == b"
else:
    print "none"


### FIXED CODE ###

a, b = map(int, input().split())
if a < b:
    print('a < b')
elif a > b:
    print('a > b')
else:
    print('a == b')
import numpy
import sys
input = sys.stdin.readline
H,W = map(int,input().split())
INF = H * W
S = numpy.array([[INF if i == '.' else 0 for i in input().strip()] for _ in range(H)])

for h in range(1, H):
    S[h, :] = numpy.minimum(S[h,:],S[h-1,:] + 1)
for h in range(H - 2, -1, -1):
    S[h, :] = numpy.minimum(S[h,:],S[h+1,:] + 1)
for w in range(1, W):
    S[:, w] = numpy.minimum(S[:,w],S[:,w-1] + 1)
for w in range(w - 2, -1, -1):
    S[:, w] = numpy.minimum(S[:,w],S[:,w+1] + 1)

print(numpy.max(S))

### FIXED CODE ###

import numpy
import sys
input = sys.stdin.readline
H,W = map(int,input().split())
INF = H * W
S = numpy.array([[INF if i == '.' else 0 for i in input().strip()] for _ in range(H)])

for h in range(1, H):
    S[h, :] = numpy.minimum(S[h,:],S[h-1,:] + 1)
for h in range(H - 2, -1, -1):
    S[h, :] = numpy.minimum(S[h,:],S[h+1,:] + 1)
for w in range(1, W):
    S[:, w] = numpy.minimum(S[:,w],S[:,w-1] + 1)
for w in range(W - 2, -1, -1):
    S[:, w] = numpy.minimum(S[:,w],S[:,w+1] + 1)

print(numpy.max(S))
import itertools

N = int(input())
A = list(int(x) for x in input().split())

mod = 10**9+7
ans = 0
summ = 0

for i in range(N):
    summ += A[i]
    summ %= mod

for i in range(N):
    summ -= A[i]
    print(summ)
    if summ < 0:
        sum += mod
    ans += A[i] * summ
    print(ans)
    ans %= mod
    print(ans)
print(ans)


### FIXED CODE ###

import itertools

N = int(input())
A = list(int(x) for x in input().split())

mod = 10**9+7

sum_ = 0
ans = 0

for i in range(N):
    ans += sum_ * A[i]
    ans %= mod
    sum_ += A[i]
    sum_ %= mod

print(ans)
def main():
    n=int(input())
    a=list(map(int,input().split()))
    if 0 in a:
        print(0)
        return
    ans=1
    for i in a:
        ans=ans*i
        if pro>1000000000000000000:
            print(-1)
            return    
    print(ans)
    return
main()            

### FIXED CODE ###

def main():
    n=int(input())
    a=list(map(int,input().split()))
    if 0 in a:
        print(0)
        return
    ans=1
    for i in a:
        ans=ans*i
        if ans>1000000000000000000:
            print(-1)
            return    
    print(ans)
    return
main()
def main():
    a,b,t = map(int,input().split())
    ans = 0
    for i in range(t + 0.51, 1):
        if i % a == 0:
            ans += b
    print(ans)
main()

### FIXED CODE ###

def main():
    a,b,t = map(int,input().split())
    ans = 0
    for i in range(1,t + 1, 1):
        if i % a == 0:
            ans += b
    print(ans)
main()
X, Y = map(int, input().split())

for i in range(1, X+1):
    for j in range(1, X-i):
        if 2*i + 4*j == Y:
            print('Yes')
            exit(0)
print('No')


### FIXED CODE ###

x = list(map(int, input().split()))
print(15 - sum(x))
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

count = Counter(a)
t = 4
s = []
for i in sorted(count.items(), key=lambda x: x[0], reverse=True):
  if i[1] >= 4 and t == 4:
    print(i**2)
    exit()
  if i[1] >= 2 and t != 0:
    t -= 2
    s.append(i[0])
  elif t == 0: break
    
if len(s) != 0: print(s[0]*s[1])
else: print(0)

### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))

count = Counter(a)
t = 4
s = []
for i in sorted(count.items(), key=lambda x: x[0], reverse=True):
  if i[1] >= 4 and t == 4:
    print(i[0]**2)
    exit()
  if i[1] >= 2 and t != 0:
    t -= 2
    s.append(i[0])
  elif t == 0: break
    
if len(s) != 0: print(s[0]*s[1])
else: print(0)
import math

prime = {}

N = int(input())

isPrime = [True]*(N+1)
isPrime[0] = False
isPrime[1] = False
for i in range(2,int(math.sqrt(N))+2):
    if isPrime[i]:
        n = 2*i
        while n<=N:
            isPrime[n] = False
            n += i

for i in range(N+1):
    if isPrime[i]:
        prime[i] = 0

key_list = list(prime.keys())

for num in range(2,N+1):
    res = num
    idx = 0
    while res>1:
        k = key_list[idx]
        if res%k == 0:
            prime[k] += 1
            res = res//k
        else:
            idx += 1
    
ans = 1
for v in prime.values():
    ans *= (v+1) 
    ans = ans % (10**9+7)
    
print(ans)

### FIXED CODE ###

import math

prime = {}

N = int(input())

def judge(N):

    if N==1:
        print(1)
        return 0

    isPrime = [True]*(N+1)
    isPrime[0] = False
    isPrime[1] = False
    for i in range(2,int(math.sqrt(N))+2):
        if isPrime[i]:
            n = 2*i
            while n<=N:
                isPrime[n] = False
                n += i
    
    for i in range(N+1):
        if isPrime[i]:
            prime[i] = 0
    
    key_list = list(prime.keys())
    
    for num in range(2,N+1):
        res = num
        idx = 0
        while res>1:
            k = key_list[idx]
            if res%k == 0:
                prime[k] += 1
                res = res//k
            else:
                idx += 1
        
    ans = 1
    for v in prime.values():
        ans *= (v+1) 
        ans = ans % (10**9+7)
        if ans==0:
            ans = 1
        
    print(ans)
    return 0

judge(N)
N = int(input())
d = len(str(N))
if d==1:
    print(N)
elif d==2:
    print(9)
elif d==3:
    print(9+N-99)
elif d==4:
    print(909)
elif d==5:
    print(909+n-9999)
elif d==6:
    print(90909)

### FIXED CODE ###

N = int(input())
d = len(str(N))
if d==1:
    print(N)
elif d==2:
    print(9)
elif d==3:
    print(9+N-99)
elif d==4:
    print(909)
elif d==5:
    print(909+N-9999)
elif d==6:
    print(90909)
D,N=map(int,input().split())
print((100**D)*N if N<100 else print((N+1)*(100**D))

### FIXED CODE ###

D,N=map(int,input().split())
print(((100**D)*N) if N<100 else ((N+1)*(100**D)))
a,b,c,d = map(int,input().split())
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

count_b = b - b//c - b//d + b//lcm(c,d)
count_a = a-1 - (a-1)//c - (a-1)//d + (a-1)//lcm(c,d)
print(count_b-count_a)

### FIXED CODE ###

a,b,c,d = map(int,input().split())
from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

count_b = b - b//c - b//d + b//lcm(c,d)
count_a = a-1 - (a-1)//c - (a-1)//d + (a-1)//lcm(c,d)
print(count_b-count_a)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import heapq as hq

def bfs(x,y,t,Map,depth):
    queue = [(depth,(x,y))]
    while len(queue) != 0:
        p = hq.heappop(queue)
        x,y = p[1]
        if p[0] < t and Map[y][x] == 0:
            Map[y][x] = 1
            dxdy = [(1,0),(-1,0),(0,1),(0,-1),(1,1),(-1,-1)]
            for dx,dy in dxdy:
                if 0 <= x + dx < 60 and 0 <= y + dy < 60:
                    hq.heappush(queue,(p[0] + 1, (x + dx, y + dy)))

while True:
    t,n = map(int,input().split())
    if t == 0 and n == 0:
        break

    Map = [[0 for j in range(60)] for i in range(60)]
    for _ in range(n):
        x,y = map(lambda x:int(x) + 30,input().split())
        Map[y][x] = -1
    x,y = map(lambda x:int(x) + 30,input().split())
    bfs(x,y,t + 1,Map,0)

    print(sum([0 if Map[i][j] == -1 else Map[i][j] for i in range(60) for j in range(60)]))

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import heapq as hq

def bfs(x,y,t,Map):
    queue = []
    hq.heappush(queue,(0,(x,y)))
    while len(queue) != 0:
        p = hq.heappop(queue)
        x,y = p[1]
        if p[0] <= t and Map[y][x] == 0:
            Map[y][x] = 1
            dxdy = [(1,0),(-1,0),(0,1),(0,-1),(1,1),(-1,-1)]
            for dx,dy in dxdy:
                hq.heappush(queue,(p[0] + 1, (x + dx, y + dy)))

while True:
    t,n = map(int,input().split())
    if t == 0 and n == 0:
        break

    Map = [[0 for j in range(200)] for i in range(200)]
    for _ in range(n):
        x,y = map(lambda x:int(x) + 100,input().split())
        Map[y][x] = -1
    x,y = map(lambda x:int(x) + 100,input().split())
    bfs(x,y,t,Map)

    print(sum([0 if Map[i][j] == -1 else Map[i][j] for i in range(200) for j in range(200)]))
a = int(input())
n = input()

if a >= 3200:
  print(s)
else:
  print("red")

### FIXED CODE ###

a = int(input())
s = input()

if a >=3200:
  print(s)
else:
  print("red")
N = int(input())
 
t = [int(input().split()) for i in range(N)]
 
M = int(input())
 
a = []
for k in range(M):
    a.append(map(int, input().split()))       
 
cal = sum(t)
 
for j in range(M):
    print(cal - t[a[j][0] - 1] + a[j][1])

### FIXED CODE ###

N = int(input())
 
t = list(map(int, input().split()))
 
M = int(input())
 
cal = sum(t)
 
for j in range(M):
    p, x = map(int, input().split())
    print(cal - t[p - 1] + x)
import sys
sys.setrecursionlimit

n = int(input())
edge = [[] for _ in range(n)]
e = []
for i in range(n - 1):
    a, b = map(int, input().split())
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)
    e.append((a - 1, b - 1))
c = list(map(int, input().split()))
c.sort(reverse=True)

def point(x, prev, turn=0):
    if turn > n:
        return
    dp[x] = c[n - dp.count(0)]
    for i in edge[x]:
        if dp[i] != 0:
            continue
        if i == prev:
            continue
        else:
            point(i, x, turn + 1)
    return

for i in range(n):
    if len(edge[i]) > 1:
        continue
    else:
        dp = [0] * n
        point(i, -1)
        break

ans = sum(c) - max(c)

print(ans)
print(" ".join(map(str, dp)))

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

n = int(input())
edge = [[] for _ in range(n)]
e = []
for i in range(n - 1):
    a, b = map(int, input().split())
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)
c = list(map(int, input().split()))
c.sort(reverse=True)

num = 0
def point(x, prev, turn=0):
    global num
    if turn > n:
        return
    dp[x] = c[num]
    num += 1
    for i in edge[x]:
        if dp[i] != 0:
            continue
        if i == prev:
            continue
        else:
            point(i, x, turn + 1)
    return

for i in range(n):
    if len(edge[i]) > 1:
        continue
    else:
        dp = [0] * n
        point(i, -1)
        break

ans = sum(c) - max(c)

print(ans)
print(" ".join(map(str, dp)))
h,w,d = map(int,input().split())
a = [list(map(int,input().split())) for i in range(h)]
lis = [[0,0] for i in range(h * w)]
num = [[0] * math.ceil((h * w) // d + 1) for i in range(d)]
for i in range(h):
    for j in range(w):
        lis[a[i][j]-1] = [i,j]
for i in range(h * w-d):
    num[i%d][i//d+1] = num[i%d][i//d]+abs(lis[i][0]-lis[i+d][0])+abs(lis[i][1]-lis[i+d][1])
q = int(input())
for _ in range(q):
    now,goal = map(int,input().split())
    if now % d == 0:
        print(num[now%d-1][(goal-now%d)//d-1]-num[now%d-1][(now-now%d)//d-1])
    else:
        print(num[now%d-1][(goal-now%d)//d]-num[now%d-1][(now-now%d)//d])

### FIXED CODE ###

import math
h,w,d = map(int,input().split())
a = [list(map(int,input().split())) for i in range(h)]
lis = [[0,0] for i in range(h * w)]
num = [[0] * math.ceil((h * w) // d + 1) for i in range(d)]

for i in range(h):
    for j in range(w):
        lis[a[i][j]-1] = [i,j]

for i in range(h * w-d):
    num[i%d][i//d+1] = num[i%d][i//d]+abs(lis[i][0]-lis[i+d][0])+abs(lis[i][1]-lis[i+d][1])

q = int(input())
for _ in range(q):
    now,goal = map(int,input().split())
    if now % d == 0:
        print(num[now%d-1][(goal-now%d)//d-1]-num[now%d-1][(now-now%d)//d-1])
    else:
        print(num[now%d-1][(goal-now%d)//d]-num[now%d-1][(now-now%d)//d])
r,g=map(int,input().split());print(g*2-r)

### FIXED CODE ###

r,g=map(int,open(0).read().split());print(g*2-r)
import math
A, B = [int(A) for A in raw_input().split()]  
if float(B) >= 1:
    print(math.trunc(A * B))
elif 1 > float(B) > 0:
    print(0)
else:
    print(A * B)


### FIXED CODE ###

import decimal
s = input().split()
a = int(s[0])
b = round(decimal.Decimal(s[1]), 2)
print(int(a * b))
h,n=map(int,input().split())
a=[0]*n
b=[0]*n
inf=10**10
for i in range(n):
    a[i],b[i]=map(int,input().split())
dp = [[inf for i in range(h+1)] for j in range(n+1)]
for i in range(n):
    cnt=1
    for j in range(h+1):
            if j-a[i]<0:
                dp[i+1][j]=min(dp[i][j],dp[i][j-a[i]]+b[i],b[i]*cnt)
            else:
                dp[i+1][j]=min(dp[i][j],dp[i+1][j-a[i]]+b[i],dp[i][j-a[i]]+b[i],b[i]*cnt)
                cnt+=1
"""
for i in range(1,n+1):
    for j in range(h+1):
        if j+a[i]<=h:
            dp[i+1][j+a[i]]=min(dp[i+1][a[i]],dp[i][j]+b[i])"""
print(dp[n][h])
#print(dp)


### FIXED CODE ###

h,n=map(int,input().split())
a=[0]*n
b=[0]*n
inf=10**10
for i in range(n):
    a[i],b[i]=map(int,input().split())
dp = [[inf for i in range(h+1)] for j in range(n+1)]
for i in range(n):
    cnt=1
    for j in range(h+1):
            if j-a[i]<0:
                dp[i+1][j]=min(dp[i][j],dp[i][0]+b[i],b[i]*cnt)
            else:
                dp[i+1][j]=min(dp[i][j],dp[i+1][j-a[i]]+b[i],dp[i][j-a[i]]+b[i],b[i]*cnt)
                cnt+=1
"""
for i in range(1,n+1):
    for j in range(h+1):
        if j+a[i]<=h:
            dp[i+1][j+a[i]]=min(dp[i+1][a[i]],dp[i][j]+b[i])"""
print(dp[n][h])
#print(dp)
n = int(raw_input())
s = map(int, raw_input().split())
m = int(raw_input())
t = map(int, raw_input().split())

s = list(set(s))
s.sort()
a = [0 for i in range(s[len(s)-1])]
for i in s:
    a[i] += 1

count = 0
for i in t:
    count += a[i] 
print count

### FIXED CODE ###

n = int(raw_input())
s = map(int, raw_input().split())
m = int(raw_input())
t = map(int, raw_input().split())

s = list(set(s))
s.sort()
l = len(s)-1

count = 0
for i in t:
    low = 0
    high = l
    while low <= high:
        mid = (low+high)/2
        if s[mid] == i:
            count += 1
            break
        if s[mid] < i:
            low = mid+1
        else:
            high = mid-1

print count
N,K=map(int,input().split())
A=[]
for i in range(N):
    a=int(input())
    A.append(a)

def segfunc(x, y):
    return max(x,y)
ide_ele =0

class SegTree:
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res
Ma=max(A)
Tree=[0]*(Ma+1)
seg = SegTree(Tree, segfunc, ide_ele)
ans=0
for i in range(N):
    a=A[i]
    l=max(0,a-K)
    r=min(a+K,Ma)
    Ans=seg.query(l,r+1)
    seg.update(a, Ans+1)
    ans=max(ans,Ans+1)
print(ans)

### FIXED CODE ###

N,M=map(int,input().split())
road=[[] for _ in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    road[a-1].append(b-1)
    road[b-1].append(a-1)
ischecked=[0]*(N)
ans=0
for i in range(N):
    if ischecked[i]==1:
        continue
    ischecked[i]=1
    q=[i]
    while q:
        now=q.pop()
        nex=road[now]
        for j in nex:
            if ischecked[j]!=0:
                continue
            q.append(j)
            ischecked[j]=1
    ans+=1
print(ans-1)
a, b, c, d = map(int, input().split)
xmx = max([a, b])
xmin = min([a, b])
#xabsmx = max([a, b], key = abs)
#xabsmin = min([a, b],key = abs)
ymx = max([c, d])
ymin = min([c, d])
#yabsmx = max([c,d], key = abs)
#yabsmin = min([c, d],key = abs)
if xmin >= 0:#all X plus
    if ymx <= 0:#all Y minas
        print(xmin * ymx)
    else:
        print(xmx * ymx)

if xmx <= 0:#all X minas
    if ymin >= 0:#all Y plus
        print(xmx * ymin)
    else:
        print(xmin * ymin)
else:#X plus and minas
    if ymx <= 0:#all Y minas
        print(xmin * ymx)
    else:
        print(xmx * ymx)

### FIXED CODE ###

a, b, c, d = map(int, input().split())
xmx = max([a, b])
xmin = min([a, b])
#xabsmx = max([a, b], key = abs)
#xabsmin = min([a, b],key = abs)
ymx = max([c, d])
ymin = min([c, d])
#yabsmx = max([c,d], key = abs)
#yabsmin = min([c, d],key = abs)
if xmin >= 0:#all X plus
    if ymx <= 0:#all Y minas
        print(xmin * ymx)
    else:
        print(xmx * ymx)

elif xmx <= 0:#all X minas
    if ymin >= 0:#all Y plus
        print(xmx * ymin)
    else:
        print(xmin * ymin)
else:#X plus and minas
    if ymx <= 0:#all Y minas
        print(xmin * ymin)
    elif ymin >= 0:#all Y plus
        print(xmx * ymx)
    else:#Y plus and minas
        if xmx * ymx > xmin * ymin:
            print(xmx * ymx)
        else:
            print(xmin * ymin)
S = input().split()
T = input().split()
C = 0
for i in range(3):
    if S[i] == T[i]:
        C += 1
print(C)

### FIXED CODE ###

S = input()
T = input()
C = 0
for i in range(len(S)):
    if S[i] == T[i]:
        C += 1
print(C)
import bisect
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
zero = bisect.bisect_left(a,0)
cnt = (10**8)*(10**5)
cnt = min(sum(a[zero:n]),-sum(a[0:zero]))
for i in range(1,zero):
    if cnt > -2*a[zero-i]+a[n-1-i]:
        cnt = -2*a[zero-i]+a[n-1-i]
    else:
        break
for i in range(1,zero):
    if cnt > -a[i]+2*a[zero+i]:
        cnt = -a[i]+2*a[zero+i]
    else:
        break
print(cnt)

### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
c=10**10
for i in range(n-k+1):
    c=min(c,-a[i]+a[i+k-1]\
          +min(abs(a[i]),abs(a[i+k-1])))
print(c)