Harryxun/stf_run huggingface dataset:
n = int(input())

ans = 10**12
for i in range(1, int(ns**0.5)+1):
    if n%i==0:
        ans = min(ans, i+n//i)
print(ans-2)

### FIXED CODE ###

n = int(input())

ans = 10**12
for i in range(1, int(n**0.5)+1):
    if n%i==0:
        ans = min(ans, i+n//i)
print(ans-2)
from math import factorial
def conb(n):
    if n == 1:
        return 0
    else:
        return factorial(n) / factorial(2) / factorial(n - 2)


n = int(input())
l = [input() for _ in range(n)]
mst = set((list("".join(l))))
l = ["".join(map(str, [x.count(a) for a in mst])) for x in l]
l_s = set(l)
result = 0
for s in l_s:
    result += int(conb(l.count(s)))
print(result)

### FIXED CODE ###

from math import factorial
from collections import Counter
 
def conb(n):
    if n <= 1:
        return 0
    else:
        return factorial(n) // factorial(n-2) // factorial(2) 

n = int(input())
S = [''.join(sorted(list(input()))) for i in range(n)]

print(int(sum([conb(i) for i in Counter(S).values()])))
i = input().split(" ")
m,n = i[0]*i[1]
if m <= 9 and m>=9 and n<=9 and n>=1:
  print(m*n)
else:
  print(-1)


### FIXED CODE ###

a,b=map(int,input().split())
if a>9 or b>9:print(-1)
else:print(a*b)
N, a, b = map(int, input().split())

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
X = 2 * (10**5)
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, X + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ax = cmb(N, a, mod)
bx = cmb(N, b, mod)

print(pow(2, N)%mod - ax - bx - 1)

### FIXED CODE ###

N, a, b = map(int, input().split())

MOD = 10**9+7

def modcmb(n, r, m):
    x = 1
    y = n
    for i in range(2,r+1):
        x *= i
        x %= MOD
        y *= n-i+1
        y %= MOD
    return y * pow(x, m-2, m) % m

ans = pow(2, N, MOD) - modcmb(N, a, MOD) - modcmb(N, b, MOD) - 1
print(ans % MOD)
n = int(input())
t,a = map(int,input().split())
height = [int(input()) for i in range(N)]
subduction = [float(abs(t-height[i]*0.006-a)) for i in range(N)]
print(min(subduction)) 

### FIXED CODE ###

N = int(input())
t,a = map(int,input().split())
height = list(map(int,input().split()))
subduction = [float(abs(t-height[i]*0.006-a)) for i in range(N)]
ans = float(10**7)
lst = []
for i in range(N):
  if ans > subduction[i]:
    ans = subduction[i]
    lst.append(i)
print(lst[-1]+1)
import math

s = input()
n = len(s)

l = math.floor(n/2)
if n % 2 == 0:
  k = l
else:
  k = l+1
  

s_f = s[:l]
s_r = s[k:]
j = 0

for i in [0,l-1]:
  if s_f[i] != s_r[(l-1)-i]:
    j+=1
    
print(j)

### FIXED CODE ###

import math

s = input()
n = len(s)

l = math.floor(n/2)
if n % 2 == 0:
  k = l
else:
  k = l+1
  

s_f = s[:l]
s_r = s[k:]
j = 0

#print(s_f)
#print(s_r)

for i in range(0,l):
  if s_f[i] != s_r[(l-1)-i]:
    #print(s_f[i] + " " + s_r[(l-1)-i])
    j+=1
    
print(j)
import math
A, B, C, D = map(int, input().split())

ans_c = (B - A) // C
ans_d = (B - A) // D
i = (B - A) // (C * D // math.gcd(C, D))

print(B - A - ans_c - ans_d + i)

### FIXED CODE ###

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

def gcd(a, b):
    if (b==0):
        return a
    else:
        return gcd(b, a % b)

G = C * D // gcd(C, D)

ans_b = B - B//C - B//D + B//G
ans_a = A - 1 - (A-1)//C - (A-1)//D + (A-1)//G

print(ans_b - ans_a)
import numpy as np
a,b = map(int, input().split())
grid1 = np.full((50,100), '.')
grid2 = np.full((50,100), '#')
a = a-1
b = b-1
x = y = 1
for i in range(a):
    grid2[x, y] = '.'
    x += 2
    if x != x % 100:
        y += 2
    x = x % 100
    
x = y = 1
for i in range(b):
    grid1[x, y] = '#'
    x += 2
    if x != x % 100:
        y += 2
    x = x % 100

print(100, 100)
grid = np.concatenate((grid1, grid2), axis=0)
for row in grid:
    print(''.join(row))

### FIXED CODE ###

import numpy as np
a,b = map(int, input().split())
grid1 = [['.' for j in range(100)] for i in range(50)]
grid2 = [['#' for j in range(100)] for i in range(50)]
a -= 1
b -= 1
x = y = 1

for i in range(a):
    grid2[x][y] = '.'
    y += 2
    if y != y % 100:
        x += 2
    y = y % 100
    if x >= 50 or y >= 100:break

x = y = 1
for i in range(b):
    grid1[x][y] = '#'
    y += 2
    if y != y % 100:
        x += 2
    y = y % 100
    if x >= 50 or y >= 100:break

print(100, 100)
grid = np.concatenate((grid1, grid2), axis=0)
for row in grid:
    print(''.join(row))
n = input()

hon = [2,4,5,7,9]
pon = [0,1,6,8]
bon = 3

if n in hon:
    print(hon)
elif n in pon:
    print(pon)
elif n == bon:


### FIXED CODE ###

n = input()

hon = ['2','4','5','7','9']
pon = ['0','1','6','8']
bon = ['3']

if n[-1] in bon:
    print('bon')
elif n[-1] in hon:
    print('hon')
elif n[-1] in pon:
    print('pon')
N,M = map(int,input().split())
A = [0 for _ in range(N+1)]
B = [0 for _ in range(N+1)]
for _ in range(M):
    p,S = input().split()
    p = int(p)
    if S=="AC":
        if A[p]==0:
            A[p]=1
    else:
        if A[p]==0:
            B[p] += 1
for i in range(N+1):
    if A[p]==0:
        B[p]=0
print(sum(A),sum(B))

### FIXED CODE ###

N,M = map(int,input().split())
C = {str(i):[0,0] for i in range(1,N+1)}
for _ in range(M):
    p,s = input().split()
    if s == "AC":
        if C[p][0]==0:
            C[p][0] = 1
    else:
        if C[p][0]==0:
            C[p][1] += 1
A = [0,0]
for i in range(1,N+1):
    if C[str(i)][0]==1:
        A[0] += 1
        A[1] += C[str(i)][1]
print(*A)
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import combinations
def main():
    x = int(input())
    n5 = [i**5 for i in range(-100,1000)]
    c = combinations(n5, 2)
    for ce in c:
        if ce[0] + ce[1] == x:
            r = (int(ce[0]**0.2), int(ce[1]**0.2)* -1)
            break
        elif ce[0] - ce[1] == x:
            r = (int(ce[0] ** 0.2), int(ce[1] ** 0.2))
            break
    print(*r, sep=' ')
if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from math import pow
def main():
    x = int(input())
    for a in range(-1000,1001):
        for b in range(-1000,1001):
            if pow(a, 5) - pow(b, 5) == x:
                print(a, b)
                sys.exit()

if __name__ == '__main__':
    main()
n=int(input())
A=list(map(int,input().split()))
from collections import deque
ans=deque([])
d=deque(A)
for i in range(0,n):
    if i%2==0:
        ans.append(d[i])
    if i%2==1:
        ans.insert(0,d[i])
if n%2==1:
    ans=list(ans)[::-1]
print(" ".join(map(str, ans)))

### FIXED CODE ###

n=int(input())
A=list(map(int,input().split()))
from collections import deque
ans=deque([])
d=deque(A)
for i in range(0,n):
    if i%2==0:
        ans.append(d[i])
    if i%2==1:
        ans.appendleft(d[i])
a=list(ans)
if n%2==1:
    c=a[::-1]
else:
    c=a
print(" ".join(map(str, c)))
n = int(input())
print(sum(list(range(n))))

### FIXED CODE ###

n = int(input())-1
print(int(n*(n+1)//2))
len=input().split
sorted(len, reverse=True)
print(len[0]*len[1]/2)

### FIXED CODE ###

l = list(map(int, input().split()))
len=sorted(l)
print(int(len[1]*len[0]/2))
a=int(input())
b=int(input())
if a > b:
print("a > b")
elif a < b:
print("a < b")
else:
print("a == b"


### FIXED CODE ###

n=input().split()
a=int(n[0])
b=int(n[1])
if a > b:
    print("a > b")
elif a < b:
    print("a < b")
else:
    print("a == b")
a, b = [int(i) in input().split(" ")]
c = "{0:.f8}".format(a/b)
print(int(a/b), a%b, c, sep = " ")

### FIXED CODE ###

a, b = [int(i) for i in input().split(" ")]
num1 = a // b
num2 = a % b
num3 = "{:.8f}".format(a / b)

print(num1, num2, num3)
N, M = map(int, input().split())
if N == M:
  print(Yes)
elif N != M:
  print(No)

### FIXED CODE ###

N, M = map(int, input().split())
if N == M:
  print("Yes")
elif N != M:
  print("No")
import sys

input=sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()


def II(): return int(input())


def MI(): return map(int,input().split())


def MF(): return map(float,input().split())


def LI(): return list(map(int,input().split()))


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))


# rstrip().decode('utf-8')
import numpy as np

def main():
	n=II()
	A=np.array([0]+LI()+[10**6])
	B=np.array([0]+LI()+[10**6])
	Ar=(A[:-1]<A[1:])[1:]
	Al=(A[:-1]<A[1:])[:-1]
	Br=(B[:-1]<B[1:])[1:]
	Bl=(B[:-1]<B[1:])[:-1]
	
	A=A[1:-1]
	B=B[1:-1]
	
	#print(Ar*A)
	
	AAl=np.array([10**7]*(n+1))
	AAr=np.array([10**7]*(n+1))
	BBl=np.array([-10**7]*(n+1))
	BBr=np.array([-10**7]*(n+1))
	
	for i in range(n):
		if Al[i]==1:
			AAl[A[i]]=i
		if Ar[i]==1:
			AAr[A[i]]=i
		if Bl[i]==1:
			BBl[B[i]]=i
		if Br[i]==1:
			BBr[B[i]]=i
	
	L=AAl-BBr
	R=AAr-BBl
	R=R[R<10**6]
	#print(L)
	LL=L.min()
	RR=max(R)
	#print(LL)
	#print(RR)
	
	if RR-LL+2>n:
		print("No")
	else:
		print("Yes")
		C=np.concatenate([B[RR+1:],B[:RR+1]])
		print(*C)
	
	


	









if __name__=="__main__":
	main()


### FIXED CODE ###

import sys

input=sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()


def II(): return int(input())


def MI(): return map(int,input().split())


def MF(): return map(float,input().split())


def LI(): return list(map(int,input().split()))


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))


# rstrip().decode('utf-8')
import numpy as np

def main():
	n=II()
	A=np.array([0]+LI()+[10**6])
	B=np.array([0]+LI()+[10**6])
	Ar=(A[:-1]<A[1:])[1:]
	Al=(A[:-1]<A[1:])[:-1]
	Br=(B[:-1]<B[1:])[1:]
	Bl=(B[:-1]<B[1:])[:-1]
	
	A=A[1:-1]
	B=B[1:-1]
	
	#print(Al,Ar,Bl,Br)
	
	AAl=np.array([10**7]*(n+1))
	AAr=np.array([10**7]*(n+1))
	BBl=np.array([-10**7]*(n+1))
	BBr=np.array([-10**7]*(n+1))
	
	for i in range(n):
		if Al[i]==1:
			AAl[A[i]]=i
		if Ar[i]==1:
			AAr[A[i]]=i
		if Bl[i]==1:
			BBl[B[i]]=i
		if Br[i]==1:
			BBr[B[i]]=i
	
	L=AAl-BBr
	R=AAr-BBl
	R=R[R<10**6]
	#print(L)
	LL=L.min()
	
	try:
		RR=max(R)
	except:
		RR=0
	#print(LL)
	#print(RR)
	
	if RR-LL+2>n:
		print("No")
	else:
		print("Yes")
		C=np.concatenate([B[-LL+1:],B[:-LL+1]])
		print(*C)
	
	


	









if __name__=="__main__":
	main()
n, m = list(map(int, input().split()))

ac = [0] * n
wa = [0] * n
pena = 0

for i in range(m):
    question, answer = input().split()
    question = int(question)
    if (answer == "AC") and (ac[question] == 0):
        ac[question] = 1
        pena += wa[question]
    elif (answer == "WA") and (ac[question] == 0):
        wa[question] += 1

print(sum(ac), pena)

### FIXED CODE ###

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

ac = [0] * (n+1)
wa = [0] * (n+1)
pena = 0

for i in range(m):
    question, answer = input().split()
    question = int(question)
    if (answer == "AC") and (ac[question] == 0):
        ac[question] = 1
        pena += wa[question]
    elif (answer == "WA") and (ac[question] == 0):
        wa[question] += 1

print(sum(ac), pena)
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
a = []
for i in range(m-1):
  a.append(x[i+1]-x[i])
if n >= m:
  print(0)
  else:
    for i in range(n-1):
      a.remove(max(a))
    print(sum(a))

### FIXED CODE ###

n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
a = []
ans = 0
for i in range(m-1):
  a.append(x[i+1]-x[i])
a.sort()
if n >= m:
  print(0)
else:
  for i in range(m-n):
    ans += a[i]
  print(ans)
n=int(input())
l=[None for i in range(n)]
for i in range(n):
  l[i]=sorted(input())
print(len(set(l)))

### FIXED CODE ###

n=int(input())
l=[None for i in range(n)]
for i in range(n):
  l[i]=sorted(input())
l.sort()
l+="l"
cnt=1
ans=0
for i in range(n):
  if l[i]!=l[i+1]:
    ans+=(cnt-1)*cnt//2
    cnt=1
    continue
  cnt+=1
print(ans)
a,v=(int(x) for x in input().split())
b,w=(int(x) for x in input().split())
t = int(input())

distance = abs(a-b)
sa = v - w

if distance % sa != 0:
  print('NO')
elif distance < t*sa:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

a,v=(int(x) for x in input().split())
b,w=(int(x) for x in input().split())
t = int(input())
 
distance = abs(a-b)
sa = v - w
 
if distance <= t*sa:
  print('YES')
else:
  print('NO')
N = int(input())

for i in range(100000):
    if 2**i <= N and N<2**(i+1):
        print(2**(i+1)-1)
        break


### FIXED CODE ###

H, A = map(int, input().split())

import math
print(math.ceil(H/A))
while True:
????????(m, f, r) = [int(i) for i in input().split()]
????????if m == f == r == -1:
????????????????break
????????total = m + f
????????if m == -1 or f == -1 or total < 30:
????????????????print('F')
????????elif total < 50 and r < 50:
????????????????print('D')
????????elif total < 65:
????????????????print('C')
????????elif total < 80:
????????????????print('B')
????????else:
????????????????print('A')

### FIXED CODE ###

while True:
    (m, f, r) = [int(i) for i in input().split()]
    if m == f == r == -1:
        break
    total = m + f
    if m == -1 or f == -1 or total < 30:
        print('F')
    elif total < 50 and r < 50:
        print('D')
    elif total < 65:
        print('C')
    elif total < 80:
        print('B')
    else:
        print('A')
def gcd(a, b):
    md = a % b
    if md == 0:
        return b
    return gcd(b, md)

def lcm(a, b):
    _gcd = gcd(a, b)
    return int((a * b) / _gcd)

n = int(input())

ans = 1
for i in range(n):
    t = int(input())
    a = max(ans, t)
    b = min(ans, t)
    ans = lcm(a, b)
print(ans)

### FIXED CODE ###

from fractions import gcd
def lcm(a,b): return a*b//gcd(a,b)

n = int(input())

ans = 1
for i in range(n):
    t = int(input())
    ans = lcm(t, ans)
print(ans)
n = int(input())
x = list(map(int,input().split()))
y = sorted(x)
x1, x2 = y[n//2-1], y[n//2]
for i, yy in enumerate(y):
    if yy<=x1:
        print(x2)
    else:
        print(x1)


### FIXED CODE ###

a, b, x = map(int, input().split())
if a + b >= x and a <= x:
    print('YES')
else:
    print('NO')
from collections import Counter
import sys
input = sys.stdin.readline

N = int(input())
AB = [[int(i) for i in input().split()] for _ in range(N)]

mod = 10 ** 9 + 7

def gcd(a, b) :
  if b > a : 
    a, b = b, a
  
  while b != 0 :
    a, b = b, a % b
  return a

p = []
for i, (a, b) in enumerate(AB) :
  g = gcd(a, b)
  a //= g
  b //= g
  if a < 0 :
    a *= -1
    b *= -1
  p.append((a, b))

ret = 1
visited = set()
cnt = Counter(p)
for k, v in cnt.items() :
  a, b = k
  c, d = b, -a
  if c < 0 :
    c *= -1
    d *= -1
  if cnt[(c, d)] == 0 :
    ret *= pow(2, v, mod)
  else :
    if not (c, d) in visited :
      u = cnt[(c, d)]
      ret *= (pow(2, u, mod) +  pow(2, v, mod) - 1)
      visited.add((a, b))
      visited.add((c, d))
  ret %= mod

print(ret - 1)

### FIXED CODE ###

from collections import Counter
import sys
input = sys.stdin.readline

N = int(input())
AB = [[int(i) for i in input().split()] for _ in range(N)]

mod = 10 ** 9 + 7

def gcd(a, b) :
  if b > a : 
    a, b = b, a
  
  while b != 0 :
    a, b = b, a % b
  return a

p = []
both = 0
zeroa = 0
zerob = 0
for a, b in AB :
  if a == 0 and b == 0 :
    both += 1
    continue
  elif a == 0 :
    zeroa += 1
    continue
  elif b == 0 :
    zerob += 1
    continue
    
  g = gcd(abs(a), abs(b))
  a //= g
  b //= g
  if a < 0 :
    a *= -1
    b *= -1
  p.append((a, b))

ret = 1
visited = set()
cnt = Counter(p)
for k, v in cnt.items() :
  a, b = k
  c, d = b, -a
  if c < 0 :
    c *= -1
    d *= -1
  if cnt[(c, d)] == 0 :
    ret *= pow(2, v, mod)
  else :
    if not (c, d) in visited :
      u = cnt[(c, d)]
      ret *= (pow(2, u, mod) + pow(2, v, mod) - 1)
      visited.add((a, b))
      visited.add((c, d))
  ret %= mod

ret *= pow(2, zeroa, mod) + pow(2, zerob, mod) - 1
ret %= mod

print((ret - 1 + both) % mod)
N = input()
A = input().split()
if n in A:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

N = input()
A = input().split()
if int(N) == len(set(A)):
  print("YES")
else:
  print("NO")
import math
from numba import njit,i8
import numpy as np

@njit((i8, i8, i8, i8[:]), cache=True)
def solve():
    
    r,c,k = map(int,input().split())

    value = np.zeros((r,c), dtype=np.int64)
    for i in range(k):
        r_t,c_t,v_t = map(int,input().split())
        value[r_t-1][c_t-1] = v_t

    dp = np.zeros((r,c,4), dtype=np.int64)
    dp[0][0][0] = 0

    for i in range(r):
        for j in range(c):
            for m in range(4):
                if i + 1 < r:
                    dp[i+1][j][0] = max(dp[i+1][j][0],dp[i][j][m])
                if j + 1 < c:
                    dp[i][j+1][m] = max(dp[i][j+1][m],dp[i][j][m])
                if value[i][j] != 0 and m < 3:
                    if i + 1 < r:
                        dp[i+1][j][0] = max(dp[i+1][j][0],dp[i][j][m]+value[i][j])
                    if j + 1 < c:
                        dp[i][j+1][m+1] = max(dp[i][j+1][m+1],dp[i][j][m]+value[i][j])

    for m in range(2,-1,-1):
        dp[r-1][c-1][m+1] = max(dp[r-1][c-1][m+1],dp[r-1][c-1][m]+value[r-1][c-1])
    return max(dp[r-1][c-1])

print(solve())

### FIXED CODE ###

import math
from numba import jit
import numpy as np

@jit
def solve():
    
    r,c,k = map(int,input().split())

    value = np.zeros((r,c), dtype=np.int64)
    for i in range(k):
        r_t,c_t,v_t = map(int,input().split())
        value[r_t-1][c_t-1] = v_t

    dp = np.zeros((r,c,4), dtype=np.int64)
    dp[0][0][0] = 0

    for i in range(r):
        for j in range(c):
            for m in range(4):
                if i + 1 < r:
                    dp[i+1][j][0] = max(dp[i+1][j][0],dp[i][j][m])
                if j + 1 < c:
                    dp[i][j+1][m] = max(dp[i][j+1][m],dp[i][j][m])
                if value[i][j] != 0 and m < 3:
                    if i + 1 < r:
                        dp[i+1][j][0] = max(dp[i+1][j][0],dp[i][j][m]+value[i][j])
                    if j + 1 < c:
                        dp[i][j+1][m+1] = max(dp[i][j+1][m+1],dp[i][j][m]+value[i][j])

    for m in range(2,-1,-1):
        dp[r-1][c-1][m+1] = max(dp[r-1][c-1][m+1],dp[r-1][c-1][m]+value[r-1][c-1])
    return max(dp[r-1][c-1])

print(solve())
n, m=map(int, input().split())
a=[0 for i in range(m)]
b=[0 for i in range(m)]
g=[list() for i in range(1+n)]
#print(g)

root=[i for i in range(m)]
cnt_con=[1 for i in range(m)]

def parent(x):
    return root[x]
def connect(x,y):
    if root[x]==root[y]:
        0
    else:
        root[x]=root[y]
        cnt_con[root[y]]+=cnt_con[root[x]]
    return

for i in range(m):
    a[i], b[i]=map(int, input().split())
    a[i], b[i]=a[i]-1, b[i]-1

tmp=int(n*(n-1)/2)
ans=[0]*m
ans[-1]=tmp
ans[0]=0
#print('a,b=',a,b)
for i in range(m-1,-1,-1):
    ans[i]=tmp
    if root[a[i]]==root[b[i]]:
        0
    else:
        tmp-=cnt_con[a[i]]*cnt_con[b[i]]
    connect(a[i],b[i])
    #print('i,tmp',i,tmp,root,cnt_con)
        
    
for i in range(m):
    print(ans[i])

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

n, m=map(int, input().split())
a=[0 for i in range(m)]
b=[0 for i in range(m)]
g=[list() for i in range(1+n)]
#print(g)

par=[i for i in range(n)]
cnt_con=[1 for i in range(n)]

def root(x):
    if x==par[x]:
        return x
    else:
        par[x]=root(par[x])
        return par[x]
def connect(x,y):
    #par[x]=root(x)
    #par[y]=root(y)
    if root(x)==root(y):
        0
    else:
        cnt_con[root(y)]+=cnt_con[root(x)]
        par[root(x)]=root(y)      
    return

for i in range(m):
    a[i], b[i]=map(int, input().split())
    a[i], b[i]=a[i]-1, b[i]-1


tmp=int(n*(n-1)/2)
ans=[0]*m
ans[-1]=tmp
#ans[0]=0
#print('a,b=',a,b)
for i in range(m-1,-1,-1):
    ans[i]=tmp
    if root(a[i])==root(b[i]):
        0
    else:
        tmp-=cnt_con[root(a[i])]*cnt_con[root(b[i])]
    connect(a[i],b[i])
    #print('i,tmp',i,(a[i],b[i]),ans[i],tmp,par,cnt_con)
    

    
for i in range(m):
    print(ans[i])
import fractions
A, B = map(int, input().split())
print (int(A * B // (fractions.gcd(A,B))))

### FIXED CODE ###

#a,b,c = map(int,input().split())
a = int(input())
b = int(input())
print(6-a-b)
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

if N < sum(A):
    print(-1)
else:
    print(N-sum(A))

### FIXED CODE ###

import math
R = int(input())

print(2*math.pi*R)
from itertools import accumulate
from collections import deque
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))

def dfs(G, v, p):
    seen[v] = True
    his.append(v)
    sc.append(c[v])

    for nv in G[v]:
        if nv == p:
            continue
        if seen[nv]:
            pos[0] = nv
            return

        dfs(G, nv, v)
        if pos[0] != -1:
            return


G = [[] for _ in range(n)]
for i in range(n):
    G[i].append(p[i]-1)

seen = [False]*n
ans = -float('inf')
for i in range(n):
    if seen[i] == False:
        his = []
        pos = [-1]
        sc = []
        dfs(G, i, -1)

        sumsc = sum(sc)
        lenc = len(sc)
        for j in range(lenc):
            if j != 0:
                sc = sc[1:] + [sc[0]]
            ac = list(accumulate(sc))
            
            if sumsc <= 0:
                ans = max(ans, max(ac[:min(k, lenc)]))
            else:
                ans = max(ans, ac[-1] * (k//lenc) + max(ac[:k%lenc]))
print(ans)

### FIXED CODE ###

from itertools import accumulate
import sys
sys.setrecursionlimit(10**6)
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))

def dfs(G, v, p):
    seen[v] = True
    sc.append(c[v])

    for nv in G[v]:
        if nv == p:
            continue
        if seen[nv]:
            pos[0] = nv
            return

        dfs(G, nv, v)
        if pos[0] != -1:
            return


G = [[] for _ in range(n)]
for i in range(n):
    G[i].append(p[i]-1)

seen = [False]*n
ans = -float('inf')
for i in range(n):
    if seen[i] == False:
        pos = [-1]
        sc = []
        dfs(G, i, -1)

        if sc:
            sumsc = sum(sc)
            lenc = len(sc)
            for j in range(lenc):
                if j != 0:
                    sc = sc[1:] + [sc[0]]
                ac = list(accumulate(sc))
                
                if sumsc <= 0:
                    ans = max(ans, max(ac[:min(k, lenc)]))
                else:
                    if k%lenc == 0:
                        ans = max(ans, ac[-1]*(k//lenc - 1) + max(ac))
                    else:
                        ans = max(ans, ac[-1]*(k//lenc) + max(ac[:k%lenc]))
print(ans)
INP = input().split()
N = int(INP[0])
M = int(INP[N + 1])
ans = [0] * N

for i in range(N):
    for k in range(N):
        if INP[i + 1] == INP[k + 1]:
            ans[i] += 1
for i in range(N):
    for j in range(M):

        if INP[i+1] == INP[N + j + 1]:
            ans[i] -= 1
mx = max(ans)
print(mx)

### FIXED CODE ###

N = int(input())
INPn = [input() for i in range(N)]
M = int(input())
INPm = [input() for i in range(M)]

ans = [0] * N

for i in range(N):
    for k in range(N):
        if INPn[i] == INPn[k]:
            ans[i] += 1
for i in range(N):
    for j in range(M):

        if INPn[i] == INPm[j]:
            ans[i] -= 1

for i in range(N):
    if ans[i] < 0:
        ans[i] = 0
        
mx = max(ans)
print(mx)
S=input()
if S="Sunny":
  	print("Cloudy")
elif S="Cloudy":
  	print("Rainy")
elif S="Rainy":
	print("Sunny")

### FIXED CODE ###

S=input()
if S=="Sunny":
  	print("Cloudy")
elif S=="Cloudy":
  	print("Rainy")
elif S=="Rainy":
	print("Sunny")
n=int(input())
    h=list(map(int,input().split()))
    dp=[0]*(len(h))
    dp[1]+=abs(h[1]-h[0])
    for i in range(2,len(h)):
        dp[i] = min( 
                abs(h[i]-h[i-1])+dp[i-1],
                abs(h[i]-h[i-2])+dp[i-2]
                )
    print(dp[-1])


### FIXED CODE ###

n=int(input())
h=list(map(int,input().split()))
dp=[0]*(len(h))
dp[1]+=abs(h[1]-h[0])
for i in range(2,len(h)):
    dp[i] = min( 
            abs(h[i]-h[i-1])+dp[i-1],
            abs(h[i]-h[i-2])+dp[i-2]
            )
print(dp[-1])