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

import sys

sys.setrecursionlimit(100000)

N = int(input())
palette = [1]
colors = [None] * N
ends = [None] * N
edges = {}

for edge in range(1,N):
    ends[edge] = [int(n) for n in input().split()]

for edge in range(1,N):
    a, b = ends[edge]
    if a not in edges:
        edges[a] = [edge]
    else:
        edges[a].append(edge)
    if b not in edges:
        edges[b] = [edge]
    else:
        edges[b].append(edge)


def color_edges(parent, root):
    current_palette = palette[:]
    if parent > 0:
        del current_palette[current_palette.index(colors[parent])]
    for edge in edges[root]:
        if colors[edge]:
            continue
        if len(current_palette) > 0:
            colors[edge] = current_palette[0]
            del current_palette[0]
        else:
            color = len(palette) + 1
            palette.append(color)
            colors[edge] = color
    for edge in edges[root]:
        if edge == parent:
            continue
        a, b = ends[edge]
        if a == root:
            color_edges(edge, b)
        else:
            color_edges(edge, a)

color_edges(0, 1)

print(len(palette))
for edge in range(1,N):
    print(colors[edge])


### FIXED CODE ###

import sys

sys.setrecursionlimit(100000)

N = int(input())
palette = 1
colors = {}
ends = {}
edges = {}

for edge in range(1,N):
    ends[edge] = [int(n) for n in input().split()]

    a, b = ends[edge]
    if a not in edges:
        edges[a] = [edge]
    else:
        edges[a].append(edge)
    if b not in edges:
        edges[b] = [edge]
    else:
        edges[b].append(edge)


def color_edges(parent, root):
    ng = {}
    global palette
    if parent > 0:
        ng[colors[parent]] = True
    for edge in edges[root]:
        if edge in colors:
            color = colors[edge]
        elif palette - len(ng) > 0:
            color = 1
            while color in ng:
                color += 1
            colors[edge] = color
        else:
            palette += 1
            color = palette
            colors[edge] = color

        ng[color] = True
    for edge in edges[root]:
        if edge == parent:
            continue
        a, b = ends[edge]
        if a == root:
            color_edges(edge, b)
        else:
            color_edges(edge, a)

max_edges = 1
root = 1
for node in range(1,N+1):
    if len(edges[node]) > max_edges:
        max_edges = len(edges[node])
        root = node

color_edges(0, root)

print(palette)
for edge in range(1,N):
    print(colors[edge])
### BUGGY CODE ###

#!/user/bin/env python
#pythonプログラムであることを示している

# -*- coding: utf-8 -*-
"""
このプログラムはPythonを書く際のテンプレとなっています。これをコピペしてコーディングを行なってください。
なお字下げしないこと！！
"""

__author_ = 'Maruta Yuzuha'
__version_ = '1.0.0'
__date__ = '2019/12/25'

def main():
    """
    ここでプログラムの解説を行う
     >>main()
    Hello world.
    0
    """
    s = list(map(int, input().split()))
    t = list(map(int, input().split()))

    a = 0  #勝つまでの回数
    b = s[0]#何匹か
    d = s[1]#必殺技の回数
    # c = sum(t)
    # d = int(s[1])
    # for i in range(int(s[1])):
    #     if sum(t) != 0:
    #         if d != 0:
    #             c -= max(t)
    #             for j in range(int(s[0])):
    #                 if max(t) == t[j]:
    #                     t[j] = 0
    #             d -= 1
    #         else:
    #             break
    e = 0  #Max
    f = 0# Maxのいち
    for j in range(d):  #必殺技の回数
        c = sum(t)
        if c != 0:
            for i in range(b):
                if e < t[i]:
                    e = t[i]
                    f = i
            t[f] = 0
            e = 0
            f = 0
        else:
            break
    a += sum(t)
    print(a)
    return 0

if __name__ == '__main__':
    #上記のifの記述によってこのスクリプトファイルが起動された時だけ実行する部分になる。
    #ちなみにスクリプトが "モジュールとして"インポートされた時には実行されない、

    #単体テスト:モジュールのdocstring(ドキュメンテーション文字列)に記載された全ての対話実行例が書かれている通りに動作するかを確認
    #python ファイル名 -v
    import doctest
    doctest.testmod()

    #実際にmain()を呼び出して、結果を得て、その結果でPythonシステムを終える
    import sys
    sys.exit(main())

### FIXED CODE ###

#!/user/bin/env python
#pythonプログラムであることを示している

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

def main():
    """
    ここでプログラムの解説を行う
     >>main()
    Hello world.
    0
    """
    s = list(map(int, input().split()))
    t = list(map(int, input().split()))
    t.sort(reverse=True)
    a = 0  #勝つまでの回数
    b = s[0]#何匹か
    d = s[1]#必殺技の回数
    f = 0# Maxのいち
    # for j in range(d):  #必殺技の回数
    #     c = sum(t)
    #     if c != 0:
    #         g = max(t)
    #         for i in range(b):
    #             if g == t[i]:
    #                 t[i] = 0
    #                 break
    #         t[f] = 0
    #         f = 0
    #     else:
    #         break
    c = sum(t)
    for i in range(d):
        if c != 0:
            c -= t[i]
            t[i] = 0
        else:
            break
    a += sum(t)
    print(a)
    return 0

if __name__ == '__main__':

    #実際にmain()を呼び出して、結果を得て、その結果でPythonシステムを終える
    import sys
    sys.exit(main())
### BUGGY CODE ###

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

s=list(set(l))

x=0
for i in s:
    y = l.count(i)
    if i <= y:
        x += y - i
    else:
        x += y

print(x)

### FIXED CODE ###

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

s=set(l)

import collections
c = collections.Counter(l)

x=0
for i in s:
    y = c[i]
    if i <= y:
        x += y - i
    else:
        x += y

print(x)
### BUGGY CODE ###

from sys import stdin
from bisect import insort


def main():
    N, M = [int(x) for x in stdin.readline().rstrip().split()]
    As = [int(x) for x in stdin.readline().rstrip().split()]
    As.sort()
    for _ in range(M):
        x = As[-1] / 2
        insort(As, x)
        del As[-1]
    print(sum([int(x) for x in As]))


if __name__ == "__main__":
    main()


### FIXED CODE ###

from sys import stdin
import heapq


def main():
    N, M = [int(x) for x in stdin.readline().rstrip().split()]
    As = []
    for i in [int(x) for x in stdin.readline().rstrip().split()]:
        heapq.heappush(As, -i)
    for _ in range(M):
        x = heapq.heappop(As)
        heapq.heappush(As, x / 2)
    print(sum([-1 * int(x) for x in As]))


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

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from heapq import heappush, heappop

N,M,S = map(int,readline().split())
ABC = [list(map(int,readline().split())) for _ in range(M)]
m = map(int,read().split())
CD = list(zip(m,m))

graph = [[] for _ in range(N)]
for u,v,a,b in ABC:
    graph[u-1].append((v-1,a,b))
    graph[v-1].append((u-1,a,b))

def f(p):
  INF = 10 ** 18
  qq = 2452
  dist = [[INF] * qq for _ in range(N)]
  dist[0][min(qq-1,S)] = 0
  q = [(0,min(qq-1,S),0)]
  while q:
      st,ss,v = heappop(q) # 総時間、銀貨、今いる頂点
      if dist[v][ss] < st:
        continue
      if v == p:
        break
      c,d = CD[v]
      # 銀貨の購入
      if ss < qq-1:
          ns = min(ss + c, qq-1)
          nt = st + d
          if dist[v][ns] > nt:
              dist[v][ns] = nt
              heappush(q,(nt,ns,v))
      # 移動
      for nex,g,tt in graph[v]:
          if ss-g < 0:
              continue
          dt = st + tt
          if dist[nex][ss-g] <= dt:
              continue
          dist[nex][ss-g] = dt
          heappush(q,(dt,ss-g,nex))
  return st
      
for i in range(1,N):
  answer = f(i)
  print(answer)


### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from heapq import heappush, heappop

N,M,S = map(int,readline().split())
ABC = [list(map(int,readline().split())) for _ in range(M)]
m = map(int,read().split())
CD = list(zip(m,m))

graph = [[] for _ in range(N)]
for u,v,a,b in ABC:
    graph[u-1].append((v-1,a,b))
    graph[v-1].append((u-1,a,b))

def f():
  INF = 10 ** 18
  arrive = [False]*N
  ans = []
  qq = 2500
  dist = [[INF] * qq for _ in range(N)]
  dist[0][min(qq-1,S)] = 0
  q = [(0,min(qq-1,S),0)]
  while q:
      st,ss,v = heappop(q) # 総時間、銀貨、今いる頂点
      if dist[v][ss] < st:
        continue
      if not arrive[v]:
        arrive[v] = True
        ans.append((v,st))
        if all(arrive):
          break
      c,d = CD[v]
      # 銀貨の購入
      if ss < qq-1:
          ns = min(ss + c, qq-1)
          nt = st + d
          if dist[v][ns] > nt:
              dist[v][ns] = nt
              heappush(q,(nt,ns,v))
      # 移動
      for nex,g,tt in graph[v]:
          if ss-g < 0:
              continue
          dt = st + tt
          if dist[nex][ss-g] <= dt:
              continue
          dist[nex][ss-g] = dt
          heappush(q,(dt,ss-g,nex))
  return ans

ab = f()
from operator import itemgetter
ab = sorted(ab,key=itemgetter(0))
for i in range(1,N):
  print(ab[i][1])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10000000)
s=input()
n=len(s)
def mod10(x):
    p=x//100
    q=x%100
    if p==0:
        return (10**q)%2019
    return (mod10(q)+mod10(p))%2019


def T(i):
    if i==n-1:
        return int(s[n-1])
    return T(i+1)+10**(n-1-i)*int(s[i])
dict={}
def modi(i,dict):
    if i in dict.keys():
        return dict[i]
    else:
        if i==n-1:
            dict[i]=int(s[i])
            return int(s[i])
        else:
            c=modi(i+1,dict)+(10**(n-1-i)*int(s[i]))
          #  c=modi(i+1,dict)+(mod10(n-1-i)*int(s[i]))
            c=c%2019
            dict[i]=c
            return c

modnum={}
for i in range(n):
    #print(T(i))
    if int(s[i])==0:
        continue
    x=modi(i,dict)
 #   print(T(i),x)
    if x not in modnum.keys():
        modnum[x]=1
    else:
        modnum[x]+=1
sum=0
for md in modnum.keys():
    a=modnum[md]
    if md==0:
        sum+=a
        sum+=-(a*(a-1)//2)
   # print(a*(a-1)//2)
    sum+=a*(a-1)//2
#print(modnum)
print(sum)


### FIXED CODE ###

import sys
import collections as coun
sys.setrecursionlimit(10000000)
s=input()
n=len(s)
def mod10(x):
    return (10**(x%224))%2019
dp=[-1]*n
tmp=0
for i in reversed(range(n)):
    if i==n-1:
        dp[i]=int(s[i])
    else:
        dp[i]=(dp[i+1]+int(s[i])*pow(10,n-1-i,2019))%2019

#print(dp)
p=-1
for i in range(len(dp)-1):
    if dp[i]==dp[i+1]:
        dp[i]=p
        p=p-1

#print(dp)

c=coun.Counter(dp)
sum=0
for v in c.values():
    sum+=v*(v-1)//2
#print(sum)
for i in dp:
    if i==0:
        sum+=1
#print(sum)
if dp[-1]==0:
    sum=sum-1
print(sum)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)

def rgb(n,s):    
    a=s[0]
    if len(s)==3:
        SUM=0

    else:
        SUM=rgb(n-1,s[1:])

        for i in range(1,n-1):
            l=["R","G","B"]
            l.remove(a)
            if s[i] != a:
                b=s[i]
                l.remove(b)
                if l!=[]:
                    c=l[0]
                    p=s.count(c,i+1,2*i)
                    q=s.count(c,2*i+1,n+1)
                    SUM+=p+q
                
    return SUM

n=int(input())
s=input()
print(rgb(n,s))

### FIXED CODE ###

n=int(input())
s=input()
r=[0]*n
g=[0]*n
b=[0]*n
R=0; G=0; B=0
for i in range(n):
    if s[i]=="R":
        r[i]=1
        R+=1
    elif s[i]=="G":
        g[i]=1
        G+=1
    else:
        b[i]=1
        B+=1
s=0
for j in range(n):
    for k in range(n):
        if r[j]==1 and g[k]==1:
            if j!=k:
                j1,k1=(max(j,k),min(j,k))
                if (j1-k1)+j1<n:
                    if b[(j1-k1)+j1]==1:
                        s+=1
                if k1-(j1-k1)>=0:
                    if b[k1-(j1-k1)]==1:
                        s+=1
                if (j1-k1)>1 and (j1-k1)%2==0:
                    if b[k1+(j1-k1)//2]==1:
                        s+=1
print(R*G*B-s)
### BUGGY CODE ###

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

res = 1
for i in a:
    res *= i

if res > 10**18:
    print(-1)
else:
    print(res)

### FIXED CODE ###

input()
a = [int(i) for i in input().split()]
 
res = 1
if 0 in a:
    res = 0
else:
    for i in a:
        res *= i
        if res > 10**18:
            res = -1
            break

print(res)
### BUGGY CODE ###

N = int(input())
ans = 1
max_count = 0
n = 2
while (n <= N):
  k = n
  count = 0
  while k%2 == 0:
    k /= 2
    count += 1
  if count > max_count:
    ans = n
    max_count = count
print(ans)

### FIXED CODE ###

n = int(input())
ans = 1
while ans*2 <= n:
  ans *= 2
print(ans)
### BUGGY CODE ###

N,M=map(int,input().split())
now=0
MOD=10**9+7
p=[1,0]#0 humu  1 humazu
A=[int(input()) for i in range(M)]+[-1]
while now<N:
  if now==A[0]-1:
    p=[0,p[0]]
    A=A[1:]
  else:
    p=[(p[0]+p[1])%MOD, p[0]%MOD]
  now+=1
print(p[0]%MOD)

### FIXED CODE ###

N,M=map(int,input().split())
now=0
a=0
MOD=10**9+7
p=[1,0]#0 humu  1 humazu
A=[int(input()) for i in range(M)]+[-1]
while now<N:
  if now==A[a]-1:
    p=[0,p[0]]
    a+=1
  else:
    p=[(p[0]+p[1])%MOD, p[0]%MOD]
  now+=1
print(p[0]%MOD)
### BUGGY CODE ###

n = int(input())
a = [int(i) for i in input().split()]

div = 10 ** 9 + 7

ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        ai = bin(a[i])
        aj = bin(a[j])
        ai = ai[2:]
        aj = aj[2:]
        dif = len(ai) - len(aj)
        if dif > 0:
            add = ''
            for _ in range(dif):
                add += '0'
            aj = add + aj
        elif dif < 0:
            add = ''
            for _ in range(-dif):
                add += '0'
            ai = add + ai
        xor = ['0' for _ in range(len(ai))]
        for k in range(len(ai)):
            if ai[k] != aj[k]:
                xor[k] = '1'
        plus = '0b'
        for k in range(len(ai)):
            plus += xor[k]
        plus = int(plus, 2)
        ans += plus
        ans %= div

print(ans)


### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return list(map(int, input().split()))
mod = 10 ** 9 + 7

n = INT()
a = LIST()
arr = [0 for _ in range(61)]
for i in range(n):
    ai = a[i]
    for j in reversed(range(61)):
        arr[j] += ai % 2
        ai //= 2
ans = 0
for i in range(61):
    ans *= 2
    arri = arr[i]
    ans += arri * (n - arri if arri != 0 else 0)
    ans %= mod
print(ans)
### BUGGY CODE ###

n = int(input())
numList = []
for i in range(n):
  numList.append(int(input()))

workList = numList[:]
for j in range(n):
  workList.remove(numList[j])
  workSet = set(workList)
  print(max(workSet))
  workList = numList[:]

### FIXED CODE ###

n = int(input())
numList  = [int(input()) for i in range(n)]
maxVal = max(numList)
workList = numList[:]
workList.remove(maxVal)
secondVal = max(workList)
for num in numList:
  if num != maxVal:
    print(maxVal)
  else:
    print(secondVal)
### BUGGY CODE ###

import sys
def input():
	return sys.stdin.readline()[:-1]

class BIT():#1-indexed
	def __init__(self, size):
		self.table = [0 for _ in range(size+2)]
		self.size = size

	def Sum(self, i):#1からiまでの和
		s = 0
		while i > 0:
			s += self.table[i]
			i -= (i & -i)
		return s

	def PointAdd(self, i, x):#
		while i <= self.size:
			self.table[i] += x
			i += (i & -i)
		return

	def SegAdd(self, l, r, x):#lからrにxを足す
		self.PointAdd(l, x)
		self.PointAdd(r+1, -x)
		return

n, m = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(n)]
s.sort(key=lambda x: x[1]-x[0])
b = BIT(m)

too_long = n #r-l+1よりも大きい区間（必ず訪れる）
cur = 0
for i in range(1, m+1):
	while cur < n and s[cur][1]-s[cur][0]+1 < i:
		too_long -= 1
		b.SegAdd(s[cur][0], s[cur][1], 1)
		cur += 1
	ans = too_long
	for j in range(i, m+1, i):
		ans += b.Sum(j)
	print(ans)

### FIXED CODE ###

import sys
def input():
	return sys.stdin.readline()[:-1]

class BIT():#1-indexed
	def __init__(self, size):
		self.table = [0 for _ in range(size+2)]
		self.size = size

	def Sum(self, i):#1からiまでの和
		s = 0
		while i > 0:
			s += self.table[i]
			i -= (i & -i)
		return s

	def PointAdd(self, i, x):#
		while i <= self.size:
			self.table[i] += x
			i += (i & -i)
		return

	def SegAdd(self, l, r, x):#lからrにxを足す
		self.PointAdd(l, x)
		self.PointAdd(r+1, -x)
		return

n, m = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(n)]
s.sort(key=lambda x: x[1]-x[0])
b = BIT(m)

too_long = n #r-l+1よりも大きい区間（必ず訪れる）
cur = 0
for i in range(1, m+1):
	while cur < n and s[cur][1]-s[cur][0]+1 < i:
		too_long -= 1
		b.SegAdd(s[cur][0], s[cur][1], 1)
		cur += 1
	ans = too_long
	for j in range(i, m+1, i):
		ans += b.Sum(j)
	print(ans)
### BUGGY CODE ###

import math
ans=0
k=int(input())
for i in range(k):
    for j in range(k):
        for z in range(k):
            ans+=math.gcd(z+1,math.gcd(i+1,j+1))
print(ans)

### FIXED CODE ###

import math
ans=0
k=int(input())
gcdlist=[[math.inf]*(k+1) for i in range(k+1)]
for i in range(1,k+1):
    for j in range(1,k+1):
        gcdlist[i][j]=math.gcd(i,j)
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            ans+=gcdlist[gcdlist[a][b]][c]
print(ans)
### BUGGY CODE ###

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

minimum_cost = [float('inf') for i in range(N)]
for i in range(min(K+1, N)):
    minimum_cost[i] = abs(H[i] - H[0])
for i in range(1, N):
    for j in range(i, i+K+1):
        if j >= N:
            break
        temp = minimum_cost[i] + abs(H[j]-H[i])
        minimum_cost[j] = min(temp, minimum_cost[j])

print(minimum_cost[N-1])


### FIXED CODE ###

import numpy as np

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

minimum_cost = np.zeros(N, dtype=int)
H = np.array(H)

for i in range(1, N):
    start = max(0, i-K)
    minimum_cost[i] = min(minimum_cost[start:i]
                          + np.abs(H[i] - H[start:i]))

print(minimum_cost[-1])
### BUGGY CODE ###

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

for i in range(n):
    if a[i] == 0:
        continue
    m = a[i]
    for j in range(i + 1, n):
        if a[j] == m:
            a[i] = 0
        if a[j] % m == 0:
            a[j] = 0

ans = sum(x > 0 for x in a)
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a.sort()
m = a[-1]
c = [0] * (m + 1)

for ai in a:
    for i in range(ai, m + 1, ai):
        c[i] += 1

ans = 0
for ai in a:
    if c[ai] == 1:
        ans += c[ai]

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

N = int(input())
v = 1
for i in range(1, N + 1):
    v *= i
print(v % (pow(10,9) + 7))

### FIXED CODE ###

N = int(input())
v = 1
for i in range(1, N + 1):
    v *= i
    v = v % (pow(10,9) + 7)
print(v)
### BUGGY CODE ###

N = int(input())
numbers = [int(n) for n in input().split(' ')]
distances = []
for i in range(0, len(numbers)):
    counter = 0
    for j in range(i, len(numbers)):
        if j == i:
            continue
        if numbers[j - 1] >= numbers[j]:
            counter += 1
        else:
            break
    distances.append(counter)
print(max(distances))

### FIXED CODE ###

N = int(input())
numbers = [int(n) for n in input().split(' ')]
distances = []
if N == 1:
    print(0)
else:
    counter = 0
    for i in range(0, len(numbers)):
        if i == len(numbers) - 1:
            distances.append(counter)
            break
        if numbers[i] >= numbers[i + 1]:
            counter += 1
        else:
            distances.append(counter)
            counter = 0

    print(max(distances))
### BUGGY CODE ###

import math
K=int(input())
s=0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            s=s+math.gcd(math.gcd(a,b),c)
print(s)

### FIXED CODE ###

import math
k=int(input())
s=[]
ans=0
for a in range(1,k):
  for b in range(a+1,k+1):
    s.append(math.gcd(a,b))
for c in range(1,k+1):
  for i in range(len(s)):
    ans+=math.gcd(s[i],c)*2
  for j in range(1,k+1):
    ans+=math.gcd(c,j)
print(ans)
### BUGGY CODE ###

### https://atcoder.jp/contests/dp/tasks/dp_d
N,W = map(int,input().split())
Goods_List=[]

dp={0:0}
for i in range(N):
    Current_Weight,Current_Value = map(int,input().split())
    if (i == 0) & (Current_Weight <= W) :
        dp[Current_Weight] = Current_Value
    elif i > 0:
        Last_Search_List = list(dp.keys())
        Current_Search_List = list(map(lambda x:x+Current_Weight,Last_Search_List))
        for j in range(len(Current_Search_List)):
            Last_Search_Weight = Last_Search_List[j]
            Current_Search_Weight = Current_Search_List[j]
            if Current_Search_Weight in dp:
                dp[Current_Search_Weight] = max(dp[Current_Search_Weight],
                                                dp[Last_Search_Weight] + Current_Value)
            elif Current_Search_Weight <= W :
                dp[Current_Search_Weight] = dp[Last_Search_Weight] + Current_Value

print(max(dp.values()))

### FIXED CODE ###

#https://atcoder.jp/contests/dp/tasks/dp_e
import copy
N,W = map(int,input().split())
Goods_List=[]
for i in range(N):
    Goods_List.append(list(map(int,input().split())))
 
Sum_Value = sum(map(lambda x:x[1],Goods_List))
dp = [[0] * (Sum_Value + 1) for i in range(N)]

for i in range(N):
    if i == 0:
        dp[i][Goods_List[i][1]] = Goods_List[i][0]
    else:
        dp[i] = copy.copy(dp[i-1])
        Valid_List = [k for k, x in enumerate(dp[i]) if x != 0]
        Valid_List.append(0)
        for j in Valid_List:
            if dp[i][j + Goods_List[i][1]] == 0:
                dp[i][j + Goods_List[i][1]] = dp[i-1][j] + Goods_List[i][0]
            else:
                dp[i][j + Goods_List[i][1]] = min(dp[i-1][j] + Goods_List[i][0],dp[i][j + Goods_List[i][1]])
        

for k in range(len(dp[-1])-1,0,-1):
    if (dp[-1][k] != 0) & (dp[-1][k] <= W):
        print(k)
        break
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
now = 0
ans = []

A.append(0)
A.insert(0,0)
for i in range(len(A)-1):
    ans.append(abs(A[i+1]-A[i]))

for j in range(1,len(A)-1):
    print(sum(ans)-ans[j]-ans[j-1]+abs(A[j+1]-A[j-1]))

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
now = 0
ans = []

A.append(0)
A.insert(0,0)
for i in range(len(A)-1):
    ans.append(abs(A[i+1]-A[i]))

sm = sum(ans)

for j in range(1,len(A)-1):
    print(sm-ans[j]-ans[j-1]+abs(A[j+1]-A[j-1]))
### BUGGY CODE ###

from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix


n,m = map(int,input().split())
g = [[0]*n for i in range(n)]
for i in range(m):
    ai,bi = map(int,input().split())
    g[ai-1][bi-1] = 1
    g[bi-1][ai-1] = 1
g = csr_matrix(g)
r = connected_components(g,return_labels=False)
print(r-1)

### FIXED CODE ###

class UnionFind:
    def __init__(self, n: int) -> None:
        self.forest = [-1] * n

    def union(self, x: int, y: int) -> None:
        x = self.findRoot(x)
        y = self.findRoot(y)
        if x == y:
            return
        if self.forest[x] > self.forest[y]:
            x,y = y,x
        self.forest[x] += self.forest[y]
        self.forest[y] = x
        return

    def findRoot(self, x: int) -> int:
        if self.forest[x] < 0:
            return x
        else:
            self.forest[x] = self.findRoot(self.forest[x])
            return self.forest[x]

    def issame(self, x: int, y: int) -> bool:
        return self.findRoot(x) == self.findRoot(y)

    def size(self,x: int) -> int:
        return -self.forest[self.findRoot(x)]


n,m = map(int,input().split())
uf = UnionFind(n)
s = set()
for i in range(m):
    ai,bi = map(int,input().split())
    uf.union(ai-1,bi-1)

for i in range(n):
    s.add(uf.findRoot(i))
print(len(s)-1)