Harryxun/stf_run huggingface dataset:
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


n = 0
N = read_a_int()
A = []
for a in read().split():
    A.append(int(a))
    n = max(n, len(bin(a)) - 2)


def ret_binary(a: int):  # 逆順で返すことに注意
    tmp = bin(a)[2:]
    ret_r = [0] * n
    for i, t in enumerate(tmp[::-1]):
        ret_r[i] = int(t)
    return ret_r


def calc_sum(a_binary, n_1_ls, n_1_max):
    '''
    a_binaryはxorしてから和を取りたい数
    n_1_lsは各桁の1の数
    n_1_maxは最大1は何個あり得るか
    '''
    ret = 0
    for i, (aa, n_1) in enumerate(zip(a_binary, n_1_ls)):
        if aa == 0:
            ret += (((2**i) % MOD) * n_1) % MOD
        else:
            ret += (((2**i) % MOD) * (n_1_max - n_1)) % MOD
    return ret


def add_koko(lsa, lsb):
    return [a + b for a, b in zip(lsa, lsb)]


MOD = 10**9 + 7

n_1_max = 0
n_1_ls = [0] * n
ans = 0
a_pre = A[N - 1]
a_pre_binary = ret_binary(a_pre)
for a in A[-2::-1]:
    a_binary = ret_binary(a)
    n_1_ls = add_koko(n_1_ls, a_pre_binary)
    n_1_max += 1
    tmp = calc_sum(a_binary, n_1_ls, n_1_max)
    ans += tmp
    ans %= MOD
    a_pre_binary = a_binary

print(ans)


### FIXED CODE ###

import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


n = 60
N = read_a_int()
A = read_ints()


def ret_binary(a: int):  # 逆順で返すことに注意
    ret_r = [0] * n
    for i in range(n):
        bit = a % 2
        a = a // 2
        ret_r[i] = bit
    return ret_r


MOD = 10**9 + 7

n_1_max = 0
n_1_ls = [0] * n
ans = 0
for a in A:
    tmp = ret_binary(a)
    for i in range(n):
        n_1_ls[i] += tmp[i]


for i, n_1 in enumerate(n_1_ls):
    num_sonoketa = n_1 * (N - n_1)
    ans += (((2**i) % MOD) * num_sonoketa)
    ans %= MOD
print(ans)
import decimal
import math
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


n = I()
t = IR(n)
t.sort()
ans = t[0]


for i in t[1:]:
    gcd = math.gcd(ans, i)
    ans = int((decimal.Decimal(ans) * decimal.Decimal(i)) //
              decimal.Decimal(gcd))
print(ans)


### FIXED CODE ###

from functools import reduce
import math
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


n = I()
t = IR(n)


def lcm_base(a, b):
    return (a * b) // math.gcd(a, b)


def lcm_list(l): return reduce(lcm_base, l, 1)


ans = lcm_list(t)
print(ans)
n=int(input)

print(n*(n-1)/2)

### FIXED CODE ###

n=int(input())

print(n*(n-1)//2)
n = int(input())
plst = list(map(int,input().split()))
plst_sort = sorted(plst)
cnt = 0
for i in range(N):
    if plst[i] != plst_sort[i]:
        cnt += 1
if cnt == 2 or cnt == 0:
    print("YES")
else:
    print("NO")


### FIXED CODE ###

n = int(input())
plst = list(map(int,input().split()))
plst_sort = sorted(plst)
cnt = 0
for i in range(len(plst)):
    if plst[i] != plst_sort[i]:
        cnt += 1
if cnt == 2 or cnt == 0:
    print("YES")
else:
    print("NO")
a = input()
b = input()
c = input()

abc = [a,b,c]
abc.sort()
print(abc)

### FIXED CODE ###

a = list(map(int, input().split()))
a.sort()
print(a[0],a[1],a[2])
N = int(input())
list = [int(i) for i in input().split()]

forward = 0
backward = N-1

sum = list[forward]
sum2 = list[backward]
while (True):
    if sum < sum2:
        forward += 1
        sum += list[forward]
    else:
        backward -= 1
        sum2 += list[backward]
    if backward - forward == 1:
        break
print(abs(sum - sum2))

### FIXED CODE ###

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

forward = 0
backward = N-1

sum = list[forward]
sum2 = list[backward]
while (True):
    if backward - forward == 1:
        break
    if sum < sum2:
        forward += 1
        sum += list[forward]
    else:
        backward -= 1
        sum2 += list[backward]
print(abs(sum - sum2))
a = int(input().split())

print(len(list(set(a)))    


### FIXED CODE ###

a = input().split()

print(len(list(set(a))))
n,k = [int(x) for x in input().split()]
s = {}
for i in input().split():
    if(i in s):
        s[i] += 1
    else:
        s[i] = 1


t = list(s.values())
t.sort()
a = 0

while len(t) > k:
    a += t.pop(0)[1]

print(a)


### FIXED CODE ###

n,k = [int(x) for x in input().split()]
s = {}

for i in input().split():
    if(i in s):
        s[i] += 1
    else:
        s[i] = 1


t = list(s.values())
t.sort()
a = sum(t[0:-k])

print(a)
n = int(input())
As = list(map(str, input().split()))

from collections import deque
b = []
b = deque(b)

for i, a in enumerate(As):
    if i%2==0:
        b.append(a)
    else:
        b.appendleft(a)

if n%2==0:
    print(' '.join(b))
else:
    print(' '.join(b[::-1]))

### FIXED CODE ###

n = int(input())
As = list(map(str, input().split()))

from collections import deque
b = []
b = deque(b)

for i, a in enumerate(As):
    if i%2==0:
        b.append(a)
    else:
        b.appendleft(a)

if n%2==0:
    print(' '.join(b))
else:
    print(' '.join(reversed(b)))
H, W = map(int, input().split())
S = [list(input()) for i in range(H)]
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

for i in range(H):
  for j in range(W):
    if s[i][j] == '.':
      cnt = 0
      for n in range(8):
        ni = i + dx[n]
        nj = j + dy[n]
        if ni < 0 or ni >= H:
          continue
        if nj < 0 or nj >= W:
          continue
        if s[ni][nj] == '#':
          cnt += 1
      S[i][j] = str(cnt)

print(S)
    


### FIXED CODE ###

H, W = map(int, input().split())
S = []
for i in range(H):
    S.append(list(input()))
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

for i in range(H):
  for j in range(W):
    if S[i][j] == '#':
      continue
    cnt = 0
    for n in range(8):
      ni = i + dx[n]
      nj = j + dy[n]
      if ni < 0 or H <= ni or nj < 0 or W <= nj:
        continue
      if S[ni][nj] == '#':
        cnt += 1
    S[i][j] = str(cnt)


    
for i in range(H):
    print("".join(S[i]))
h,w = map(int, input().split())
listA = []
while True:
  try:
    listA.append(list(map(int,input().split())))
  except:
    break;
for i in range(n):
  print(listA[i-1]"\n"listA[i-1])

### FIXED CODE ###

h,w = map(int, input().split())
listA = [input() for i in range(h)]
for i in range(h):
  print(listA[i]+"\n"+listA[i])
N = int(input())
surveys = [list(map(int, input().split())) for _ in range(N)]
for x in range(101):
  for y in range(101):
    before = -1
    identified = True
    for survey in surveys:
      height = survey[2] + abs(x-survey[0]) + abs(y-survey[1])
      if before != -1 and before != height:
        if survey[2] == 0:
          continue
        identified = False
        break
      if before == -1:
        before = height
    if identified:
      print(x, y, before)


### FIXED CODE ###

N = int(input())
if N == 1:
  print('Hello World')
else:
  A = int(input())
  B = int(input())
  print(A+B)
from math import gcd
num_clock = int(input())
times = [int(input()) for i in range(num_clock)]
spent_time = times[0]
for time in times[1:]:
    spent_time = (spent_time * time) // gcd(spent_time, time)
print(spent_time)

### FIXED CODE ###

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#from math import gcd
num_clock = int(input())
times = [int(input()) for i in range(num_clock)]
spent_time = times[0]
for time in times[1:]:
    spent_time = (spent_time * time) // gcd(spent_time, time)
print(spent_time)
while True:
    n = int(input())
    if n == 0:
        break
    data = input().split()
    import math
    sum = 0
    for i in range(n):
    sum = sum + int(data[i])
    average = sum / n
    a = 0
    for i in range(n):
    a = a + (int(data[i]) - average)**2
    print('{}'.format(math.sqrt(a/n)))


### FIXED CODE ###

while True:
    n = int(input())
    if n == 0:
        break
    data = input().split()
    import math
    sum = 0
    for i in range(n):
        sum = sum + int(data[i])
    average = sum / n
    a = 0
    for i in range(n):
        a = a + (int(data[i]) - average)**2
    print('{}'.format(math.sqrt(a/n)))
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

A = [0], B = [0]
for i in range(n):
    A.append(A[i] + a[i])
for i in range(m):
    B.append(B[i] + b[i])

ans, j = 0, m
for i in range(n+1):
    if A[i] > k:
        break
    while B[j] > k - A[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)

### FIXED CODE ###

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

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])

ans, j = 0, m
for i in range(n+1):
    if A[i] > k:
        break
    while B[j] > k - A[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)
a,b = map(int,input())
if a%3==0 or b%3==0 or (a+b)%3==0:
    print('Possible')
else:
    print('Impossible')

### FIXED CODE ###

a,b = map(int,input().split())
if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0:
    print("Possible")
else:
    print("Impossible")
n = int(input())
h = list(map(int,input().split()))

i = 0
flag = 0
for i in range(1,n-1):
    print(h)
    if(h[i] > h[i+1]+2):
        break
        flag = 1
    elif(h[i] >= h[i+1]+1):
        if(h[i-1] == h[i]):
            break
            flag = 1
        else:
            h[i] -= 1
    elif(h[i-1] != h[i]):
        h[i] -= 1

if(h[n-2] > h[n-1]):
    flag = 1    



if(flag == 0 or n == 1):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n = int(input())
h = list(map(int,input().split()))

i = 0
flag = 0

if(n > 2):
    for i in range(1,n-1):
        #print(h)
        if(h[i] > h[i+1] + 1):
            flag = 1
            break
        elif(h[i] == h[i+1]+1):
            if(h[i-1] == h[i]):
                flag = 1
                break
            else:
                h[i] -= 1
        elif(h[i-1] != h[i]):
            h[i] -= 1
    
    if(h[-2] > h[-1]):
        flag = 1   
elif(n == 2):
    if(h[0]-1 > h[1]):
        flag = 1


if(flag == 0 or n == 1):
    print("Yes")
else:
    print("No")
n, m = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(n)]
t = [[] for _ in range(n)]
for p, y in data:
  t[p - 1].append(y)
for i in range(n):
  t[i].sort()
for p, y in data:
  nth = t[p - 1].index(y) + 1
  print("%06d%06d" % (p, nth))


### FIXED CODE ###

from bisect import bisect_left
n, m = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(m)]
t = [[] for _ in range(n)]
for p, y in data:
  t[p - 1].append(y)
for i in range(n):
  t[i].sort()
for p, y in data:
  nth = bisect_left(t[p - 1], y) + 1
  print("%06d%06d" % (p, nth))
n = int(input())
odd = 0
for i in range(n+1):
  odd += 1 if i%2
print(odd/n)

### FIXED CODE ###

n = int(input())
odd = 0
for i in range(n+1):
  if i%2:
    odd += 1
print(odd/n)
a,b,c,d=map(int,input().split())
def gcd(x,y):
  if x%y==0:
    print(y)
  else:
    gcd(x%y,y)
    
r=gcd(c,d)    
s=(b//c)-((a-1)//c)
t=(b//d)-((a-1)//d)
u=(b//r)-((a-1)//r)

print(b-a+1-s-t+u)

### FIXED CODE ###

a,b,c,d=map(int,input().split())
def gcd(x,y):
  if x%y==0:
    return y
  else:
    return gcd(y,x%y)
    
r=int((c*d)/gcd(c,d)) 
s=(b//c)-((a-1)//c)
t=(b//d)-((a-1)//d)
u=(b//r)-((a-1)//r)

print(int(b-a+1-s-t+u))
g_m=0
g_G=[]
g_cnt=0
A=[]
n = int(input())
for i in range(n):
    A.append(int(input()))
def insertionSort(A,n,g):
    global g_cnt
    for i in range(g,n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j-g
            g_cnt += 1
        A[j+g]=v
    


def shellSort(A,n):
    cnt = 0
    m = int(n**0.5)
    g_m=m
    G=[]
    j=1
    for i in range(1,n,3*j):
        G.append(i)
        j=3*j
    G=G.reverse()
    for i in range(0,m):
        insertionSort(A,n,G[i])
    return A,m,G
A,g_m,g_G=shellSort(A,n)
print(g_m)
print(" ".join(map(str,g_G)))
print(g_cnt)
print(" ".join(map(str,A)))

### FIXED CODE ###

g_m=0
g_G=[]
g_cnt=0
A=[]
n = int(input())
for i in range(n):
    A.append(int(input()))
def insertionSort(A,n,g):
    global g_cnt
    for i in range(g,n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j-g
            g_cnt += 1
        A[j+g]=v
    
def shellSort(A,n):
    m=1
    G=[]
    j=1
    for i in range(0,100):
        G.append(j)
        j=3*j+1
    
    while G[m]<=n:
        m+=1
    G=G[:m]
    G.reverse()
    for i in range(0,m):
        insertionSort(A,n,G[i])
    return A,m,G
A,g_m,g_G=shellSort(A,n)
print(g_m)
print(" ".join(map(str,g_G)))
print(g_cnt)
print(*A,sep="\n")
import sys
import bisect
input = sys.stdin.readline

def main():
    n, q = map(int, input().split())
    a = list(map(int, input().split()))
    
    s = [0]*(n+1)
    odd = [0]*(n+1)
    even = [0]*(n+1)
    for i in range(n):
        s[i+1] += s[i]+a[i]
        odd[i+1] += odd[i]
        even[i+1] += even[i]
        if i%2:
            odd[i+1] += a[i]
        else:
            even[i+1] += a[i]
    
    key = []
    value = dict()
    v = 0
    for i in range(n):
        if i == n-1:
            k = pow(10, 9)
            key.append(k)
            value[k] = v
        k = (a[i+(n-i)//2]+a[i])//2
        v = s[i+(n-i)//2]-s[i]
        if (n-i)%2:
            if i%2:
                v += even[max(0, i)]
            else:
                v += odd[max(0, i)]
        else:
            if i%2:
                v += odd[max(0, i-1)]
            else:
                v += even[max(0, i-1)]
        
        key.append(k)
        value[k] = v
    
    sum_a = s[n]
    
    for i in range(q):
        x = int(input())
        k = key[bisect.bisect_left(key, x)]
        ans = sum_a-value[k]
        print(ans)
    
    
if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
import bisect
input = sys.stdin.readline

def main():
    n, q = map(int, input().split())
    a = list(map(int, input().split()))
    
    s = [0]*(n+1)
    odd = [0]*(n+1)
    even = [0]*(n+1)
    for i in range(n):
        s[i+1] += s[i]+a[i]
        odd[i+1] += odd[i]
        even[i+1] += even[i]
        if i%2:
            odd[i+1] += a[i]
        else:
            even[i+1] += a[i]
    
    key = []
    value = dict()
    v = 0
    for i in range(n):
        if i == n-1:
            k = pow(10, 9)
            key.append(k)
            value[k] = v
            continue
            
        k = (a[i+(n-i)//2]+a[i])//2
        v = s[i+(n-i)//2]-s[i]
        if (n-i)%2:
            if i%2:
                v += even[max(0, i)]
            else:
                v += odd[max(0, i)]
        else:
            if i%2:
                v += odd[max(0, i-1)]
            else:
                v += even[max(0, i-1)]
        
        key.append(k)
        value[k] = v
    
    sum_a = s[n]
    
    for i in range(q):
        x = int(input())
        k = key[bisect.bisect_left(key, x)]
        ans = sum_a-value[k]
        print(ans)
    
    
if __name__ == "__main__":
    main()
mycode = '''
# distutils: language=c++
# cython: language_level=3, boundscheck=False, wraparound=False
# cython: cdivision=True

ctypedef long long LL
import numpy as np
cimport numpy as cp
cdef LL MOD = 10**9 + 7
cdef LL N = int(input())
cdef LL ans = 1

cdef i
for i in range(2, N + 1):
    ans *= i
    ans %= MOD
print(ans)
'''
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':  # コンパイル時
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    import os
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode


### FIXED CODE ###

MOD = 10**9 + 7
N = int(input())
ans = 1
for i in range(2, N + 1):
    ans *= i
    ans %= MOD
print(ans)
# C - Welcome to AtCoder
# https://atcoder.jp/contests/abc151/tasks/abc151_c

n,m = map(int,input().split())
submits = [list(input().split()) for i in range(0,m)]
print(submits)
ac = 0
wa = 0

AC = "AC"
WA = "WA"

tmp_wa = 0
tmp_ac = ""


for i in range(len(submits)):
    # ACなら正解数をカウントアップ
    if submits[i][1] == AC:
        # 同じ問題に正解してないかチェック
        if submits[i][0] == tmp_ac:
            continue
        ac += 1
        # WAの数をカウント
        wa += tmp_wa
        # WAを初期化
        tmp_wa = 0
        tmp_ac = submits[i][0]
    else:
        # WAならwa+1
        tmp_wa += 1

print(f"{ac} {wa}")

### FIXED CODE ###

N, M = map(int, input().split())

ac = [False] * N
wa = [0] * N
for _ in range(M):
    p, S = input().split()
    p = int(p) - 1
    if S == 'AC':
        ac[p] = True
    else:
        if not ac[p]:
            wa[p] += 1

a = 0
b = 0
for i in range(N):
    if ac[i]:
        a += 1
        b += wa[i]
print(*[a, b])
N = input()
a=list(map(int,input().split()))
print(a)
for i in range(1,N):
    v = a[i]
    j = i-1
    while j >= 0 and a[j] > v:
        a[j+1] = a[j]
        j-=1
    a[j+1]=v
    print(a)

### FIXED CODE ###

N = int(input())
a = [int(x) for x in input().split()]
for i in range(N):
    v = a[i]
    j = i-1
    while j >= 0 and a[j] > v:
        a[j+1] = a[j]
        j-=1
    a[j+1]=v
    print(*a)
from sys import stdin
N=int(stdin.readline().rstrip())
data=[int(x) for x in stdin.readline().rstrip().split()]
if set(np.diff(sorted(data))) != {0,1} and data[0] != 1:
    print(-1)
else:

### FIXED CODE ###

from sys import stdin
N = int(stdin.readline().rstrip())
data = [int(x) for x in stdin.readline().rstrip().split()]

ans = []
for _ in range(N):
    for i in range(len(data) - 1, -1, -1):
        #print(data,i)
        if data[i] == i+1:
            #print(data[i-1],i,data)
            ans.append(data.pop(-(len(data)-i)))
            break
if data:
    print(-1)
else:
    for j in reversed(ans):
        print(j)
N, M = map(int, input().split())

if(N = M):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N, M = map(int, input().split())

if(N == M):
  print("Yes")
else:
  print("No")
K=int(input())
A,B=map(int,input().split())
a=0
for i in range(A,B+1):
  if i%k==0:
    a=1
if a=1:
  print("OK")
else:
  print("NG")
    

### FIXED CODE ###

K=int(input())
A,B=map(int,input().split())
a=0
for i in range(A,B+1):
  if i%K==0:
    a=1
if a==1:
  print("OK")
else:
  print("NG")
N = int(input())
A = list(map(int, input().split(" ")))
abs_list = list(map(abs, A))
abs_list.sort()
pos = list(filter(lambda x: x > 0, A))
neg = list(filter(lambda x: x < 0, A))
pos.sort()
neg.sort()

# A has 0
if abs_list[0] == 0:
	print(sum(abs_list))
elif len(neg) % 2 == 0:
	print(sum(abs_list))
elif abs(pos[0]) < abs(neg[-1]):
	print(sum(abs_list) - 2*pos[0])
else:
	print(sum(pos) - sum(neg[:-1]))



### FIXED CODE ###

N = int(input())
A = list(map(int, input().split(" ")))
abs_list = list(map(abs, A))
abs_list.sort()
pos = list(filter(lambda x: x > 0, A))
neg = list(filter(lambda x: x < 0, A))
pos.sort()
neg.sort()

# A has 0
if abs_list[0] == 0:
	print(sum(abs_list))
elif len(neg) % 2 == 0:
	print(sum(abs_list))
elif len(pos) > 0 and abs(pos[0]) < abs(neg[-1]):
	print(sum(abs_list) - 2*pos[0])
else:
	print(sum(abs_list[1:])-abs_list[0])
# -*- coding: utf-8 -*-

H,W = map(int, input().split())
Ch,Cw = map(int, input().split())
Dh,Dw = map(int, input().split())
S = [input() for _ in range(H)]

A = [[-1 for _ in range(W)] for _ in range(H)]
A[Ch-1][Cw-1] = 0

def isValid(h,w):
  return h>=0 and h<H and w>=0 and w<W and S[h][w]=='.' and A[h][w]==-1

warp = 0
BFS_now = set()
BFS_now.add((Ch-1, Cw-1))
BFS_search = set()
BFS_search.add((Ch-1, Cw-1))
ij = [(-1,0),(0,-1),(0,1),(1,0)]

while len(BFS_now)>0:
  while len(BFS_search)>0:
    BFS_search_tmp = set()
    for h,w in BFS_search:
      for i,j in ij:
        if isValid(h+i,w+j):
          BFS_search_tmp.add((h+i,w+j))
          BFS_now.add((h+i,w+j))
          A[h+i][w+j] = warp
    BFS_search = BFS_search_tmp
  BFS_now_tmp = set()
  for h,w in BFS_now:
    for i in range(-2,3):
      for j in range(-2,3):
        if isValid(h+i,w+j):
          BFS_now_tmp.add((h+i,w+j))
          A[h+i][w+j] = warp + 1
  BFS_now = BFS_now_tmp
  BFS_search = BFS_now_tmp
  warp += 1

print(A[Dh-1][Dw-1])

### FIXED CODE ###

# -*- coding: utf-8 -*-

H,W = map(int, input().split())
Ch,Cw = map(int, input().split())
Dh,Dw = map(int, input().split())
S = [input() for _ in range(H)]

A = [[-1 for _ in range(W)] for _ in range(H)]
A[Ch-1][Cw-1] = 0

def isValid(h,w):
  if h>=0 and h<H and w>=0 and w<W and S[h][w]=='.' and A[h][w]==-1:
    return True
  else:
    return False

warp = 0
BFS_now = [(Ch-1, Cw-1)]
BFS_search = [(Ch-1, Cw-1)]
ij = [(-1,0),(0,-1),(0,1),(1,0)]
while len(BFS_now)>0:
  while len(BFS_search)>0:
    BFS_search_tmp = []
    for h,w in BFS_search:
      for i,j in ij:
        if isValid(h+i,w+j):
          BFS_search_tmp.append((h+i,w+j))
          A[h+i][w+j] = warp
    BFS_now += BFS_search_tmp
    BFS_search = BFS_search_tmp
  BFS_now_tmp = []
  for h,w in BFS_now:
    for i in range(-2,3):
      for j in range(-2,3):
        if isValid(h+i,w+j):
          BFS_now_tmp.append((h+i,w+j))
          A[h+i][w+j] = warp + 1
  BFS_now = BFS_now_tmp
  BFS_search = BFS_now_tmp
  warp += 1

print(A[Dh-1][Dw-1])
n,a,b,c=map(int,input().split())
l=[]
for _ in range(n):
  x=int(input())
  l.append(x)

def dfs(cur,x,y,z):
  if cur==n and min(x,y,z)>0:
    return abs(a-x)+abs(b-y)+abs(c-z)-30
  elif cur==n:
    return inf
  ret0=dfs(cur+1,x,y,z)
  ret1=dfs(cur+1,x+l[cur],y,z)+10
  ret2=dfs(cur+1,x,y+l[cur],z)+10
  ret3=dfs(cur+1,x,y,z+l[cur])+10
  return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))


### FIXED CODE ###

n,a,b,c=map(int,input().split())
l=[]
for _ in range(n):
  d=int(input())
  l.append(d)

def dfs(cur,x,y,z):
  if cur==n and min(x,y,z)>0:
    return abs(a-x)+abs(b-y)+abs(c-z)-30
  elif cur==n:
    return 100000000000000000000
  ret0=dfs(cur+1,x,y,z)
  ret1=dfs(cur+1,x+l[cur],y,z)+10
  ret2=dfs(cur+1,x,y+l[cur],z)+10
  ret3=dfs(cur+1,x,y,z+l[cur])+10
  return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))
a,b=int(input(),input())

if a <= b or a <= 2*b:
  print(0)

if a>b:
  c=a-2*b
  print(c)

### FIXED CODE ###

num1,num2=input().split()

a=int(num1)
b=int(num2)

if a <= b or a <= 2*b:
  print(0)

elif a>b:
  c=a-2*b
  print(c)
n,t=map(int,input().split())
l=list(map(int,input().split()))
time=t
m=[0]
i=1
if len(l)==1:
    print(t)
else:
    while True:
        if l[i]-(time-m[-1])<0:
            time=time-(l[i]-(time-m[1]))+t
        else:
            m.append(time)
            time=t
        if i==n-1:
            break
        i+=1
    print(time if len(m)==1 else sum(m)+time)

### FIXED CODE ###

n,t=map(int,input().split())
l=list(map(int,input().split()))
ans=0
for i in range(1,n):
    ans+=min(t,l[i]-l[i-1])
print(ans+t)
a=list(map(int,input().split()))
a.sort()
print(" ".join(a))
a=list(map(int,input().split()))
a.sort()
alist=[]
for i in a:
    alist+=str(i)
print(" ".join(alist))

### FIXED CODE ###

a=list(map(int,input().split()))
a.sort()
print(a[0],a[1],a[2])