Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

from collections import deque
_in = list(open(0))
h, w = list(map(int, _in[0].split()))

s = deque()
for i, y in enumerate(_in[1:]):
    for j, x in enumerate(y):
        if x == '#':
            s.append((i+1,j+1))

a = [[False]*(w+2)]
a += [[False] + [True]*w + [False] for _ in range(h)]
a += [[False]*(w+2)]

ans = -1
while s:
    ns = deque()
    for i, j in s:
        a[i][j] = False

        if a[i-1][j]:
            a[i-1][j] = False
            ns.append((i-1, j))
        if a[i+1][j]:
            a[i+1][j] = False
            ns.append((i+1, j))
        if a[i][j-1]:
            a[i][j-1] = False
            ns.append((i, j-1))
        if a[i][j+1]:
            a[i][j+1] = False
            ns.append((i, j+1))
        
    s = ns
    ans += 1
    
print(ans)

### FIXED CODE ###

def main():
    H, W = map(int, input().split())
    m = []
    m.append([True] * (W + 2))
    for _ in range(H):
        m.append([True] + [c == '#' for c in input()] + [True])
    m.append([True] * (W + 2))
    queue = []
    for i in range(1, H + 1):
        for j in range(1, W + 1):
            if m[i][j]:
                queue.append((i, j))
    ans = -1
    while queue:
        ans += 1
        tmp = []
        for x, y in queue:
            if not m[x - 1][y]:
                m[x - 1][y] = True
                tmp.append((x - 1, y))
            if not m[x + 1][y]:
                m[x + 1][y] = True
                tmp.append((x + 1, y))
            if not m[x][y - 1]:
                m[x][y - 1] = True
                tmp.append((x, y - 1))
            if not m[x][y + 1]:
                m[x][y + 1] = True
                tmp.append((x, y + 1))
        queue = tmp
    print(ans)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

num = int(input())

strs = [[] for i in range(num)]
for i in range(num):
    strs[i] = input()

def conv(str):
    str_arr = list(str)
    str_arr.sort()
    return ''.join(str_arr)

new_strs = list(map(lambda v: conv(v), strs))
shorten_strs = list(set(new_strs))

cnt = 0

import math
def comb_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for str in shorten_strs:
    nums = new_strs.count(str)
    if nums >= 2:
        cnt += comb_count(nums, 2)

print(cnt)


### FIXED CODE ###

from collections import Counter

num = int(input())
range_arr = range(num)

strs = [[] for i in range_arr]
for i in range_arr:
    strs[i] = input()

def sort(str):
    str_arr = list(str)
    str_arr.sort()
    return ''.join(str_arr)

new_strs = list(map(lambda v: sort(v), strs))
strs_length = len(new_strs)

sum = 0
counter = Counter()
for tmp_str in new_strs:
    sum += counter[tmp_str]
    counter[tmp_str] += 1

print(sum)
### BUGGY CODE ###

N=int(input())
S=[input()for _ in'_'*N]
x=[[0]*(2*N+1)for _ in'_'*N]
y=[[0]*N for _ in'_'*(2*N+1)]
T=333331
M=1333333333333333
for i in range(N):
	for j in range(2*N):
		x[i][j+1]=(x[i][j]*T+ord(S[i][j-N]))%M
		y[j+1][i]=(y[j][i]*T+ord(S[j-N][i]))%M
t=pow(T,N,M)
z=0
for a in range(N):
	for b in range(N):
		for i in range(N):
			if(x[a-N+i][b+N]-y[a+N][b-N+i]-(x[a-N+i][b]-y[a][b-N+i])*t)%M:
				break
		else:
			z+=1
print(z)


### FIXED CODE ###

N=int(input())
S=[input()for _ in'_'*N]
z=0
for k in range(-N,0):
	for t in range(N*N):
		i=t//N
		j=t%N
		if S[i][j+k]!=S[j][i+k]:
			break
	else:
		z+=N
print(z)
### BUGGY CODE ###

N, K = input().split()
N = int(N)
K = int(K)
A = [(int(x)+1)/2 for x in input().split()]

print(max([sum(A[i:i+K]) for i in range(0,N,1)]))

### FIXED CODE ###

from itertools import accumulate
import numpy as np
N, K = list(map(int, input().split()))
A = np.array(list(map(int, input().split())))
A = (A+1)/2

B = np.insert(A,0,0)
B = list(accumulate(B))
answer = []
for i in range(N-K+1):
    answer.append(B[i+K]-B[i])

print(max(answer))
### BUGGY CODE ###

h,w = map(int,input().split(" "))
s = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    tmp = list(input())
    for j in range(w):
        s[i][j] = tmp[j]
dp1 = [[-1 for i in range(w)] for j in range(h)]
dp2 = [[-1 for i in range(w)] for j in range(h)]
dp3 = [[-1 for i in range(w)] for j in range(h)]
dp4 = [[-1 for i in range(w)] for j in range(h)]
dp=[dp1,dp2,dp3,dp4]

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            dp1[i][j] = 0
        elif j == 0:
            dp1[i][j] = 1
        else:
            dp1[i][j] = 1 + dp1[i][j-1]

for i in range(h):
    for j in range(w-1,-1,-1):
        if s[i][j] == "#":
            dp2[i][j] = 0
        elif j == w-1:
            dp2[i][j] = 1
        else:
            dp2[i][j] = 1 + dp2[i][j+1]

for i in range(w):
    for j in range(h):
        if s[j][i] == "#":
            dp3[j][i] = 0
        elif j == 0:
            dp3[j][i] = 1
        else:
            dp3[j][i] = 1 + dp3[j-1][i]

for i in range(w):
    for j in range(h-1,-1,-1):
        if s[j][i] == "#":
            dp4[j][i] = 0
        elif j == h-1:
            dp4[j][i] = 1
        else:
            dp4[j][i] = 1 + dp4[j+1][i]

a = 1
for i in range(h):
    for j in range(w):
        a = max(a,dp1[i][j]+dp2[i][j]+dp3[i][j]+dp4[i][j]-3)

print(a)

### FIXED CODE ###

h,w = map(int,input().split(" "))
s = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    tmp = list(input())
    for j in range(w):
        s[i][j] = tmp[j]

dp1= []
dp2= [[-1 for i in range(w)] for j in range(h)]
dp3=[]
dp4=[[-1 for i in range(w)] for j in range(h)]


for i in range(h):
    dp1.append([])
    dp3.append([])
    for j in range(w):
        dp1[i].append(-1)
        dp3[i].append(-1)

        if s[i][j] == "#":
            dp1[i][j] = 0
        elif j == 0:
            dp1[i][j] = 1
        else:
            dp1[i][j] = 1 + dp1[i][j-1]

        if s[i][w-j-1] == "#":
            dp2[i][w-j-1] = 0
        elif w-j-1 == w-1:
            dp2[i][w-j-1] = 1
        else:
            dp2[i][w-j-1] = 1 + dp2[i][w-j]

        if s[i][j] == "#":
            dp3[i][j] = 0
        elif i == 0:
            dp3[i][j] = 1
        else:
            dp3[i][j] = 1 + dp3[i-1][j]

        if s[h-i-1][j] == "#":
            dp4[h-i-1][j] = 0
        elif h-i-1 == h-1:
            dp4[h-i-1][j] = 1
        else:
            dp4[h-i-1][j] = 1 + dp4[h-i][j]



        

a = 1
for i in range(h):
    for j in range(w):
        a = max(a,dp1[i][j]+dp2[i][j]+dp3[i][j]+dp4[i][j]-3)


print(a)
### BUGGY CODE ###

n,k = map(int, input().split())
s = input()

if s[0]=='1':
    l = [1]
else:
    l = [0,1]

for i in range(1,n):
    if s[i] ==s[i-1]:
        l[-1]+=1
    else:
        l.append(1)

ans = 0
for i in range(len(l)//2+1):
    ans = max(ans, sum(l[2*i:2*i+2*k+1]))

print(ans)


### FIXED CODE ###

n,k = map(int, input().split())
s = input()

if s[0]=='1':
    l = [1]
else:
    l = [0,1]

for i in range(1,n):
    if s[i] ==s[i-1]:
        l[-1]+=1
    else:
        l.append(1)

prev = sum(l[0:2*k+1])
ans = prev
for i in range(len(l)//2+1):
    prev = prev-sum(l[2*i:2*i+2]) + sum(l[2*i+2*k+1:2*i+2*k+3])
    ans = max(ans, prev)

print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
for i in range(m):
    a[0] = a[0] // 2
    a.sort(reverse=True)
print(sum(a))

### FIXED CODE ###

import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = list(map(lambda x: x*(-1), a))
heapq.heapify(a)
for i in range(m):
    heapq.heappush(a, ((heapq.heappop(a)*-1//2)*(-1)))
print(sum(a)*-1)
### BUGGY CODE ###

#restoring read network
import numpy as np
from scipy.sparse import csr_matrix 
from scipy.sparse.csgraph import floyd_warshall
def main():
    n=int(input())
    mat=np.array([[0 for i in range(n)] for j in range(n)],dtype=np.int)
    data=np.array([[0 for i in range(n)] for j in range(n)],dtype=np.int)
    for _ in range(n):
        x=list(map(int,input().split()))
        for j in range(n):
            mat[_][j]=x[j]
            data[_][j]=x[j]

    csr=csr_matrix(mat)
    csr=floyd_warshall(csr)
    if np.array_equal(csr,data):
        ans=0
        for i in range(n):
            for j in range(i+1,n):
                ans+=data[i][j]*int(all(data[i][j]<data[i][k]+data[k][j] for k in range(i))&all(data[i][j]<data[i][k]+data[k][j] for k in range(i+1,j))&all(data[i][j]<data[i][k]+data[k][j] for k in range(j+1,n)))     
        print(ans)            
    else:
        print(-1)
if __name__=="__main__":
    main()


### FIXED CODE ###

n=int(input())

mat=[[0 for i in range(n)] for j in range(n)]
data=[[0 for i in range(n)] for j in range(n)]
for _ in range(n):
    x=list(map(int,input().split()))
    for j in range(n):
        mat[_][j]=x[j]
        data[_][j]=x[j]
def warshall_floyd(d):
    #d[i][j]=i番目の頂点からj番目の頂点までの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

newmat=warshall_floyd(mat)
if newmat==data:
    ans=0
    for i in range(n):
        for j in range(i+1,n):
            ans+=data[i][j]*int(all(data[i][j]<data[i][k]+data[k][j] for k in range(i))&all(data[i][j]<data[i][k]+data[k][j] for k in range(i+1,j))&all(data[i][j]<data[i][k]+data[k][j] for k in range(j+1,n)))     
    print(ans)      
else:
    print(-1)
### BUGGY CODE ###

a,b=map(int,input().split())
i=1
small = min(a,b)
ab=[]
j=0
while i <= small :
    if b%i==0 and a%i==0 :
        flag = 0
        j=0
        while j < len(ab):
            if ab[j]!=1 and i % ab[j] == 0:
                flag=1
            j+=1
        if flag == 0:
            ab.append(i)

    i+=1


print(len(ab))

### FIXED CODE ###

def main():
    x,y = map(int,input().split())
    tmp = [1]
    i = 2
    ans = 0
    # if x == y:
    #     ans += 1
    # a = factorization(x)
    # print(a)
    tempx = x

    for i in range(2, int(-(-x**0.5//1))+1):
        if tempx % i == 0:
            tmp.append(i)
            while tempx % i == 0:

                tempx //= i
    if tempx!=1:
        tmp.append(tempx)
    # print(tmp)

    for i,a in enumerate(tmp):
        if y % a == 0:
            tmp[i] = 1
        else:
            tmp[i] = 0
    print(sum(tmp))


if __name__=='__main__':
    main()
### BUGGY CODE ###

import queue
n,k=map(int,input().split())
l=list(map(int,input().split()))
el=queue.deque(maxlen=k)
ans = 0
for i in l[:]:
    el.append((1+i)/2)
    ans = sum(el) if sum(el)>ans else ans
print(ans)

### FIXED CODE ###

import queue
n,k=map(int,input().split())
l=list(map(int,input().split()))
el=queue.deque(maxlen=k)
ans = 0
m = 0
for i in l[:]:
    if len(el) == k:
        el.append((1+i)/2)
        m = m-m_e+el[-1]
    else:
        el.append((1+i)/2)
        m +=el[-1]
    ans = m if m>ans else ans
    m_e = el[0]
print(ans)
### BUGGY CODE ###

import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    a,b,n = inpm()
    ans = 0
    for i in range(min(b+1,n+1)):
        ans = max(ans,int(a*i/b)-a*int(i/b))
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    a,b,n = map(int,input().split())
    print(int(a*min((b-1),n)/b) - a*int(min((b-1),n)/b))

if __name__ == "__main__":
    main()
### BUGGY CODE ###

L,R = map(int,input().split())
ans = 2019
while True:
  for i in range(L,R-1):
    a = (i*(i+1))%2019
    ans = min(ans,a)
print(a)


### FIXED CODE ###

L,R = map(int,input().split())
ans = float('inf')
for i in range(L,R):
  for j in range(i+1,R+1):
    if (i*j)%2019==0:
      print(0)
      exit()
    ans = min(ans,(i*j)%2019)
print(ans)
### BUGGY CODE ###

import numpy as np
n,k = list(map(int,input().split()))
p = np.array(list(map(int,input().split())))

P = 0
for i in range(n-k+1):
  if P < p[i:i+k].sum():
    P = p[i:i+k].sum()
    mp = p[i:i+k]

ans = 0

for i in mp:
  if i%2 == 0:
    ans += ((i+1) * i//2)/i
  else:
    ans += ((i+1) * (i//2) + (i//2) + 1)/i
print(ans)


### FIXED CODE ###

from itertools import accumulate
n,k = list(map(int,input().split()))
p = list(map(int,input().split()))

P = list(accumulate([(i+1)/2 for i in p]))
P = [0] + P
ans = max([P[i+k]-P[i] for i in range(n-k+1)])
print(ans)
### BUGGY CODE ###

N = input()
A = [int(a) for a in input().split()]

ans = 1

for i in range(len(A)):
    ans *= A[i]


if ans > 10 ** 18:
    print(-1)
    exit()
print(ans)

### FIXED CODE ###

N = input()
A = [int(a) for a in input().split()]

ans = 1

if 0 in A:
    print(0)
    exit()

for i in range(len(A)):
    if ans > 10 ** 18:
        print(-1)
        exit()
    ans *= A[i]


if ans > 10 ** 18:
    print(-1)
    exit()
print(ans)
### BUGGY CODE ###

s=input()
a=int(s)
list=[]
list.append(1)
list.append(6)
list.append(9)
list.append(36)
list.append(81)
list.append(216)
list.append(729)
list.append(1296)
list.append(6561)
list.append(7776)
list.append(59049)
list.append(46656)
pp=[]
def money(x,y):
  for i in range(12):
    b=x//list[i]
    if b==0:
      continue
    if i%2==1:
      if 0<b<6:
        if x%list[i]==0:
          pp.append(y+b)
        else:
          money(x-list[i],y+1)
    elif i%2==0 and i!=0:
      if 0<b<9:
        if x%list[i]==0:
          pp.append(y+b)
        else:
          money(x-list[i],y+1)
    else:
      if 0<b<6:
        pp.append(y+b)
money(a,0)
print(min(pp))

### FIXED CODE ###

s=input()
a=int(s)
list=[]
list.append(1)
list.append(6)
list.append(9)
list.append(36)
list.append(81)
list.append(216)
list.append(729)
list.append(1296)
list.append(6561)
list.append(7776)
list.append(59049)
list.append(46656)
pp=[]
def money(x,y):
  for i in range(12):
    b=x//list[i]
    if b==0:
      continue
    if i%2==1:
      if 0<b<6:
        if x%list[i]==0:
          pp.append(y+b)
        else:
          if y>20:
            break
          money(x-list[i],y+1)
    elif i%2==0:
      if i!=0:
        if 0<b<9:
          if x%list[i]==0:
            pp.append(y+b)
          else:
            if y>20:
              break
            money(x-list[i],y+1)
      else:
        if 0<b<6:
          pp.append(y+b)
money(a,0)
print(min(pp))
### BUGGY CODE ###

H, N = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(N)]

DP = [float('inf')]*(H+1)  # Dp[i] = : min used MP when mosterHP==i

DP[-1] = 0
for i in reversed(range(H+1)):
    for a, b in L:
        if i-a >= 0:
            DP[i-a] = min(DP[i] + b, DP[i-a])
        else:
            DP[0] = min(DP[0], DP[i]+b)
print(DP[0])


### FIXED CODE ###

H, N = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(N)]

DP = [float('inf')]*(H+1)  # Dp[i] = : min used MP when mosterHP==i

DP[-1] = 0
for i in reversed(range(H+1)):
    for a, b in L:
        if i-a >= 0:
            DP[i-a] = min(DP[i] + b, DP[i-a])
        else:
            DP[0] = min(DP[0], DP[i]+b)
print(DP[0])
### BUGGY CODE ###

class Unionfind:

    __slots__ = ['parents','sizes']

    def __init__(self, n):
        self.parents = list(range(n))
        self.sizes = [1]*n

    def root(self, x):
        if self.parents[x] == x:
            return x
        else:
            root_x = self.root(self.parents[x])
            self.parents[x] = root_x
            return root_x

    def unite(self, x, y):
        x = self.root(x); y = self.root(y)
        if x == y:
            return
        if self.sizes[x] < self.sizes[y]:
            x, y = y, x
        self.sizes[x] += self.sizes[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.root(x) == self.root(y)

    # 集合自体の数 ({1,2}, {3}, {4} : kind -> 3)
    def kind(self):
        for v in range(N):
            self.root(v)
        return len(list(set(self.parents)))

    # xが属する集合の要素の数　({1,2,3} : size(2) -> 3)
    def size(self, x):
        self.sizes[x] = self.sizes[self.root(x)]
        return self.sizes[x]

N, K, L = map(int,input().split())
road = Unionfind(N)
train = Unionfind(N)

for _ in range(K):
    p, q = map(int,input().split())
    p -= 1; q -= 1
    road.unite(p, q)

for _ in range(L):
    r, s = map(int,input().split())
    r -= 1; s -= 1
    train.unite(r, s)

ans_list = []

r = dict()
for i in range(N):
    r[i] = set()
for i in range(N):
    r[road.root(i)].add(i)

t = dict()
for i in range(N):
    t[i] = set()
for i in range(N):
    t[train.root(i)].add(i)

ans_list = []

for i in range(N):
    ans = len(r[road.root(i)] & t[train.root(i)])
    ans_list.append(ans)

print(*ans_list)

### FIXED CODE ###

from collections import defaultdict

class Unionfind:

    __slots__ = ['parents','sizes']

    def __init__(self, n):
        self.parents = list(range(n))
        self.sizes = [1]*n

    def root(self, x):
        if self.parents[x] == x:
            return x
        else:
            root_x = self.root(self.parents[x])
            self.parents[x] = root_x
            return root_x

    def unite(self, x, y):
        x = self.root(x); y = self.root(y)
        if x == y:
            return
        if self.sizes[x] < self.sizes[y]:
            x, y = y, x
        self.sizes[x] += self.sizes[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.root(x) == self.root(y)

    # 集合自体の数 ({1,2}, {3}, {4} : kind -> 3)
    def kind(self):
        for v in range(N):
            self.root(v)
        return len(list(set(self.parents)))

    # xが属する集合の要素の数　({1,2,3} : size(2) -> 3)
    def size(self, x):
        self.sizes[x] = self.sizes[self.root(x)]
        return self.sizes[x]

N, K, L = map(int,input().split())
road = Unionfind(N)
train = Unionfind(N)

for _ in range(K):
    p, q = map(int,input().split())
    p -= 1; q -= 1
    road.unite(p, q)

for _ in range(L):
    r, s = map(int,input().split())
    r -= 1; s -= 1
    train.unite(r, s)

cnt = defaultdict(int)

for i in range(N):
    key = (road.root(i), train.root(i))
    cnt[key] += 1

ans_list = []
for i in range(N):
    key = (road.root(i), train.root(i))
    ans = cnt[key]
    ans_list.append(ans)

print(*ans_list)
### BUGGY CODE ###

n, a = map(int, input().split())
x = list(map(int, input().split()))

MAX = 2501

x = sorted(x)

z = 0
p = []
m = []
for i in range(n):
    x[i] -= a
    if x[i] == 0:
        z += 1
    elif x[i] > 0:
        p.append(x[i])
    else:
        m.append(-1 * x[i])

plus = [0 for _ in range(MAX)]
#minus = [0 for _ in range(MAX)]

ans = 2 ** z - 1

#print(p, m, z)

def calc_plus(temp_sum, i):
    if i >= len(p):
        plus[temp_sum] += 1
        return
    else:
        calc_plus(temp_sum, i + 1)
        calc_plus(temp_sum + p[i], i + 1)

calc_plus(0,0)

#print(plus)

def calc_minus(temp_sum, i):
    if i >= len(m):
        if temp_sum > 0 and plus[temp_sum] > 0:
            global ans
            ans += plus[temp_sum] * (2 ** z)
        return
    else:
        calc_minus(temp_sum, i + 1)
        calc_minus(temp_sum + m[i], i + 1)


calc_minus(0,0)

print(ans)


### FIXED CODE ###

n, a = map(int, input().split())
x = list(map(int, input().split()))

max_x = max(x)
dp = [[0 for _  in range(n * 2 * max_x + 1)] for _ in range(n + 1)]

dp[0][n * max_x] = 1
for i in range(1, n + 1):
    for j in range(1, n * 2 * max_x + 1):
        if 0 <= j + a - x[i - 1] <= 2 * n * max_x:
            dp[i][j] = dp[i - 1][j] + dp[i - 1][j + a - x[i - 1]]
        else:
            dp[i][j] = dp[i - 1][j]

print(dp[n][n * max_x] - 1)
### BUGGY CODE ###


def check_alloc(weights, cnt, cpct, st, stn):	
	num = 1
	cur = stn
	for i in range(st, len(weights)):
		w = weights[i]
		if cur + w > cpct:
			if num == 1:
				st = i
				stn = cur
			cur = w
			num += 1
			if num > cnt or cur > cpct:
				return False
		else:
			cur += w
	return True

n, k = map(int, input().split())
weights = [0] * n
cpct = 0
for i in range(n):
	weight = int(input())
	weights[i] = weight
	cpct += weight

cpct = int(cpct/k)
st = 0
stn = 0
while True:
	can_alloc = check_alloc(weights, k, cpct, st, stn)
	if can_alloc == False:
		cpct += 1
	else:
		break

print(cpct)



### FIXED CODE ###

import sys

def check_alloc(weights, k, cpct):
	num = 1
	cur = 0
	for i in range(len(weights)):
		w = weights[i]
		if cur + w > cpct:
			cur = w
			num += 1
			if num > k or cur > cpct:
				return False
		else:
			cur += w
	return True

n, k = map(int, input().split())
weights = [0] * n
sum = 0
maxi = 0
for i in range(n):
	w = int(input())
	weights[i] = w
	sum += w
	maxi = max(maxi, w)

if k == 1:
	print(sum)
	sys.exit()

start = maxi
end = sum
cpct = 0
while start <= end:
	cpct = int(start + (end - start) / 2)
	check = check_alloc(weights, k, cpct)
	if check == False:
		start = cpct + 1
	else:
		if start == end: break
		end = cpct
	
print(cpct)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    d = [[-1] * N for _ in range(N)]
    for _ in range(M):
        L, R, D = map(int, input().split())
        L -= 1
        R -= 1
        d[L][R] = D
        d[R][L] = D
        for i in range(N):
            if d[L][i] != -1 and d[i][R] != -1:
                if d[L][R] != d[L][i] + d[i][R]:
                    print('No')
                    exit()
    
    print('Yes')

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline

class WeightUnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        self.weight = [0] * n

    # xの根を求める
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            px = self.find(self.parents[x])
            self.weight[x] += self.weight[self.parents[x]]
            self.parents[x] = px
            return px
    
    # xの根から距離
    def dist(self, x):
        self.find(x)
        return self.weight[x]

    # w[y] = w[x] + wとなるようにxとyを併合
    def unite(self, x, y, w):
        w += self.weight[x] - self.weight[y]
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return False
        else:
            # sizeの大きいほうがx
            if self.parents[x] > self.parents[y]:
                x, y = y, x
                w = -w
            self.parents[x] += self.parents[y]
            self.parents[y] = x
            self.weight[y] = w
            return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.parents[self.find(x)]

    def diff(self, x, y):
        return self.dist(y) - self.dist(x)


    


def main():
    N, M = map(int, input().split())
    uni = WeightUnionFind(N)
    for _ in range(M):
        L, R, D = map(int, input().split())
        L -= 1
        R -= 1
        if uni.same(L, R):
            if D != uni.diff(L, R):
                print('No')
                exit()
        else:
            uni.unite(L,R,D)

    print('Yes')
    


if __name__ == "__main__":
    main()
### BUGGY CODE ###

# coding : utf-8

import numpy as np

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

for i in range(N):
    suml = 0
    start = 0
    for j in range(N):
        if i == j:
            continue
        suml += abs(start - D[j])
        start = D[j]
    print(suml+abs(start))


### FIXED CODE ###

# coding : utf-8

import numpy as np

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

alll = 0
start = 0
for i in range(N):
    alll += abs(D[i] - start)
    start = D[i]
alll += abs(start)

diff = abs(D[0]) + abs(D[1] - D[0])
net = abs(D[1])
print(alll - diff + net)
for i in range(1,N-1):
    diff = abs(D[i-1] - D[i]) + abs(D[i] - D[i+1])
    net = abs(D[i-1] - D[i+1])
    print(alll - diff + net)
diff = abs(D[N-2] - D[N-1]) + abs(D[N-1])
net = abs(D[N-2])
print(alll - diff + net)