Harryxun/stf_run huggingface dataset:
N = input()
height = list(map(int, input().split(" ")))
dp = [0]*N
 
for i in range(1,N):
  if i <= 2:
    dp[i] = abs(height[i]-height[0])
  if dp[i-1] < dp[i-2]:
    dp[i] = dp[i-1] + abs(height[i]-height[i-1])
  else:
    dp[i] = dp[i-2] + abs(height[i]-height[i-2])
 
print(dp[N-1])


### FIXED CODE ###

N = int(input())
height = list(map(int, input().split(" ")))
dp = [0]*N
 
for i in range(1,N):
  if i <= 2:
    dp[i] = abs(height[i]-height[0])
  else:
    dp[i] = min(dp[i-1] + abs(height[i]-height[i-1]), dp[i-2] + abs(height[i]-height[i-2]))

print(dp[N-1])
*A,=map(int,open(0));i=1;t=[0]*A[0]
while i-2and t[i]==0:t[i]=1;i=A[i]
print(-1if i-2else sum(t))

### FIXED CODE ###

*A,=map(int,open(0));i=1;t=[0]*A[0]+[0]
while i-2and t[i]==0:t[i]=1;i=A[i]
print(-1if i-2else sum(t))
from sys import stdin, exit

N = int(stdin.readline().rstrip())
s = [int(stdin.readline().rstrip()) for _ in range(N)]
dp = [0] * (100 * N)
dp[0] = 1
for n in range(N):
    for p in range(len(dp), 0, -1):
        if p - s[n] >= 0:
            if dp[p - s[n]] == 1:
                dp[p] = 1
for k in range(len(dp)):
    if dp[len(dp) - k - 1] == 1 and (len(dp) - k - 1) % 10 != 0:
        print(len(dp) - k - 1)
        exit()
print('0')


### FIXED CODE ###

from sys import stdin, exit

N = int(stdin.readline().rstrip())
s = [int(stdin.readline().rstrip()) for _ in range(N)]
dp = [0] * (100 * N)
dp[0] = 1
for n in range(N):
    for p in range(len(dp) - 1, 0, -1):
        if p - s[n] >= 0:
            if dp[p - s[n]] == 1 and 0 <= p:
                dp[p] = 1
for k in range(len(dp)):
    if dp[len(dp) - k - 1] == 1 and (len(dp) - k - 1) % 10 != 0:
        print(len(dp) - k - 1)
        exit()
print('0')
A, B = map(int, input().split())
p = input()
a, b = p[:A], p[A:B+1]
print('Yes' if b[0] == '-' and (a + b[1:]).isdecimal else 'No')


### FIXED CODE ###

a,b=map(int,input().split())
s=input()
if 1<=a<=5 and 1<=b<=5:
    if s[a]=="-":
        if s[0:a].isdecimal() and s[a+1:a+b+1].isdecimal():
            print("Yes")
            exit()
print("No")
N = int(input())
n = list(map(int,input().split()))
ans  = 0
for i in range(N):
    if n[n[i]] == i:
        ans += 1 
print(ans)

### FIXED CODE ###

N = int(input())
n = list(map(int,input().split()))
ans  = 0
for i in range(N):
    if n[n[i]-1] == i+1:
        ans += 1 
print(ans // 2)
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce
import statistics


# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

def treesearch(root, cost, data, ans):
    for i in range(len(data)):
        if data[i][0] == root:
            ans[data[i][1]-1] += cost
            treesearch(data[i][1], cost, data, ans)

data1 = getInputListInt()
n = data1[0]
q = data1[1]

data2 = getSomeInputListInt(n-1)

data3 = getSomeInputListInt(q)

ans = np.zeros(n)

for i in range(len(data3)):
    ans[data3[i][0]-1] += data3[i][1]
    treesearch(data3[i][0], data3[i][1], data2, ans)

for s in ans:
    print(int(s), end =" ")



### FIXED CODE ###

import sys
input = sys.stdin.readline #for input speed
sys.setrecursionlimit(10**6) #for deep recursion
n, q = map(int, input().split())

tree_index = [[] for _ in range(n)]
for i in range(n-1):
  a,b = map(int, input().split())
  a -= 1
  b -= 1
  tree_index[a].append(b) # a<bとは限らないため、双方向にする
  tree_index[b].append(a)
ans = [0] * n
for i in range(q):
  p, x = map(int, input().split())
  ans[p-1] += x
def dfs(cur, par):
    for chl in tree_index[cur]:
      if chl == par: #parentとchildが等しい時はスキップ
        continue
      ans[chl] += ans[cur] 
      dfs(chl, cur)
dfs(0, -1)
print(*ans)
# スペース区切りの整数の入力
n, y = map(int, input().split())

i = 0
j = 0
k = 0

l = [-1,-1,-1]
#print(l)

for i in reversed(range(0,n+1)):
    #print('i= %d' % i)
    if  y >= i*10000:
        for j in reversed(range(0,n-i+1)):
            #print('j= %d' % j)
            k = n - i - j
            #print('k= %d' % k)
            if  y == i*10000 + j*5000 + k*1000:
                l = [i, j, k]

#----ここは一つ見つかったら抜けるための命令
                break
        else:
            continue
        break
#------------------------------------

                #print(l)

print(l[0], l[1], l[2])


### FIXED CODE ###


s = input()

#print(s)

#文字を置き換える
print(s.replace('2017', '2018'))
N, M = [int(x) for x in input().split()]
V = [tuple(map(int, innput().split())) for i in range(N)]
V.sort()

money = 0
count = 0

for a, b in V:
  if count + b < M:
    count += b
    money += a * b
  else:
    money += (M - b) * a
    break
print(money)

### FIXED CODE ###

N, M = [int(x) for x in input().split()]
V = [tuple(map(int, input().split())) for i in range(N)]
V.sort()

money = 0
count = 0

for a, b in V:
  if count + b < M:
    count += b
    money += a * b
  else:
    money += (M - count) * a
    break
print(money)
from　fractions import gcd
n = int(input())
a = list(map(int, input().split()))
gcd_l = a[0]
gcd_r = a[-1]
gcd_l_li = []
gcd_r_li = []
for i in range(n):
    gcd_l = gcd(gcd_l, a[i])
    gcd_l_li.append(gcd_l)
for i in range(n)[::-1]:
    gcd_r = gcd(gcd_r, a[i])
    gcd_r_li.append(gcd_r)
#print(gcd_l_li)
#print(gcd_r_li)

ans = max(gcd_r_li[n-2], gcd_l_li[n-2])  # かきかえる整数が右端のときと左端のとき
for target in range(1, n-1):
    ans = max(ans, gcd(gcd_l_li[target-1], gcd_r_li[target-1]))
print(ans)




### FIXED CODE ###

from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
gcd_l = a[0]
gcd_r = a[-1]
gcd_l_li = []
gcd_r_li = []
for i in range(n):
    gcd_l = gcd(gcd_l, a[i])
    gcd_l_li.append(gcd_l)
for i in range(n)[::-1]:
    gcd_r = gcd(gcd_r, a[i])
    gcd_r_li.append(gcd_r)
#print(gcd_l_li)
#print(gcd_r_li)

ans = max(gcd_r_li[n-2], gcd_l_li[n-2])  # かきかえる整数が右端のときと左端のとき
for target in range(1, n-1):
    ans = max(ans, gcd(gcd_l_li[target-1], gcd_r_li[n-2-target]))
print(ans)
W,H,x,y,r=map(int,input().split())
if !(x+r>W or r>x or r>y or y+r>H):
 print("Yes")
else :
 print("No")

### FIXED CODE ###

W,H,x,y,r=map(int,input().split())
if not (x+r>W or r>x or r>y or y+r>H):print("Yes")
else:print("No")
import math

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

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

print(lcm(a, b))


### FIXED CODE ###

from fractions import gcd

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

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

print(lcm(a, b))
def fact(n):
    if n == 0: return 1
    return n * fact(n-1)

import sys
sys.setrecursionlimit(1000)
N, M=map(int,input().split())
if(abs(N%1000000007-M%1000000007)>1):
    i=0
else:
    i=fact(M%1000000007)*fact(N%1000000007)
if(N==M):
    i=i*2
ans=i%1000000007
print(ans)

### FIXED CODE ###

import sys
import math

N, M=map(int,input().split())
if(abs(N%1000000007-M%1000000007)>1):
    i=0
else:
    i=math.factorial(M%1000000007)*math.factorial(N%1000000007)
if(N==M):
    i=i*2
ans=i%1000000007
print(ans)
N = int(input())
D = []
for i in range(N):
    a = list(map(int,input().split()))
    if(a[0] == a[1]):
        D.append(1)
    else:
        D.append(0)
for i in range(N-2):
    if D[i] == D[i+1] == D[i+2] == 1:
        tf = 1
if tf == 1:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

N = int(input())
D = []
for i in range(N):
    a = list(map(int,input().split()))
    if(a[0] == a[1]):
        D.append(1)
    else:
        D.append(0)
tf = 0
for i in range(N-2):
    if D[i] == D[i+1] == D[i+2] == 1:
        tf = 1
if tf == 1:
    print("Yes")
else:
    print("No")
N = int(input())
a = list(int,map(input().split())
i = 0
for z in range(N)         
	for x,y in enumerate a:
         b=x+1
		 if b%2!=0 and y%2!=0:
    		i+=1
print(i)


### FIXED CODE ###

L,R,d = map(int,input().split())
i=0
for x in range (L,R+1):
    if x%d==0:
        i+=1
print(i)
# @author 

import sys

class SDigitSum:
    def solve(self):
        MOD = 10 ** 9 + 7

        k = input()
        d = int(input())

        s = len(k)
        dp = [[0] * d for _ in range(s + 1)]
        dp[0][0] = 1
        for i in range(10):
            dp[1][i % d] += 1

        # pre = [[0] * (d + 1) for _ in range(s + 1)]
        # for i in range(d):
        #     pre[1][i] = pre[1][i - 1] + dp[1][i]
        # for l in range(2, s):
            # cur is sum(dp[l - 1][(-lm + r) % d] for lm in range(1, 10)
            # cur = sum(dp[l - 1][(-lm + 0) % d] for lm in range(1, 10))
            # for r in range(d):
            #     dp[l][r] = (dp[l - 1][r] + sum(dp[l - 1][(-lm + r) % d] for lm in range(1, 10))) % MOD
                # dp[l][r] = (dp[l - 1][r] + cur) % MOD
                # cur -= dp[l - 1][(r - 9) % d]
                # cur += dp[l - 1][(r + 1 - 1) % d]


        ans = dp[s - 1][0]
        done = 0
        for i in range(s):
            lm = int(k[i])
            ans = (ans + sum(dp[s - 1 - i][(-done - (lm - v)) % d] for v in range(1, lm + 1 * (i != 0)))) % MOD
            done += lm

        if (sum(int(x) for x in k)) % d == 0:
            ans = (ans + 1) % MOD

        print((ans - 1) % MOD)

solver = SDigitSum()
input = sys.stdin.readline

solver.solve()


### FIXED CODE ###

# @author 

import sys

class SDigitSum:
    def solve(self):
        MOD = 10 ** 9 + 7

        k = input().strip()
        d = int(input())

        s = len(k)
        dp = [[0] * d for _ in range(s + 1)]
        dp[0][0] = 1
        for i in range(10):
            dp[1][i % d] += 1

        pre = [[0] * (d + 1) for _ in range(s + 1)]
        for i in range(d):
            pre[1][i] = pre[1][i - 1] + dp[1][i]
        for l in range(2, s):
            # cur is sum(dp[l - 1][(-lm + r) % d] for lm in range(1, 10)
            cur = sum(dp[l - 1][(-lm + 0) % d] for lm in range(1, 10))
            for r in range(d):
                # dp[l][r] = (dp[l - 1][r] + sum(dp[l - 1][(-lm + r) % d] for lm in range(1, 10))) % MOD
                dp[l][r] = (dp[l - 1][r] + cur) % MOD
                cur -= dp[l - 1][(r - 9) % d]
                cur += dp[l - 1][(r + 1 - 1) % d]


        ans = dp[s - 1][0]
        done = 0
        for i in range(s):
            lm = int(k[i])
            ans = (ans + sum(dp[s - 1 - i][(-done - (lm - v)) % d] for v in range(1, lm + 1 * (i != 0)))) % MOD
            done += lm

        if (sum(int(x) for x in k)) % d == 0:
            ans = (ans + 1) % MOD

        print((ans - 1) % MOD)

solver = SDigitSum()
input = sys.stdin.readline

solver.solve()
s_inv = str(input())[::-1]
dp = [1]+[0]*2018
MOD = 0
k = 1
ans = 0

for i in range(len(s_inv)):
  MOD += s_inv[i]*k%2019
  dp[MOD] += 1
  k*10

for i in dp:
  ans += i(i-1)/2

print(ans)

### FIXED CODE ###

s_inv = str(input())[::-1]
dp = [1]+[0]*2018
MOD = 0
ans = 0
num = 0
k = 1

for i in range(len(s_inv)):
  num+=int(s_inv[i])*k
  MOD = num % 2019
  dp[MOD] += 1
  k = k*10
  k %= 2019
for i in dp:
  ans += i*(i-1)/2

print(int(ans))
#d-even relation
#ふかさ優先探索の実装
#再起関数の実装を行う
n=int(input())
visitedlist=[-1 for  i in range(n)]
lists=[tuple(map(int,input().split())) for i in range(n-1)]
kilist=[[] for i in range(n)]
for i in lists:
    kilist[i[0]-1].append(i[1:])
    kilist[i[1]-1].append(i[0:3:2])
visitedlist[0]=1
anslist=[0 for i in range(n)]
#開始地点1のところは0を基準としている
#1には初めに訪れる
def search(i):
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                
                if j[1]%2==0:
                    anslist[j[0]-1]=anslist[i-1]
                elif j[1]%2!=0:
                    anslist[j[0]-1]=1-anslist[i-1]      
        if flag>0:    
            for j in kilist[i-1]:
                return search(j[0])
        else:
            pass
            
search(1)
for k in anslist:
    print(k)


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

n=int(input())
visitedlist=[-1 for  i in range(n)]
kilist=[[] for i in range(n)]
anslist=[0 for i in range(n)]
searchedlist=[-1 for i in range(n)]
for i in range(n-1):
        a,b,c=map(int,input().split())
        kilist[a-1].append((b,c))
        kilist[b-1].append((a,c))
def search(i):
        searchedlist[i-1]=1
        visitedlist[i-1]=1
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=anslist[i-1]+j[1]
        else:
            pass

        if flag>0:    
            for k in kilist[i-1]:
                if searchedlist[k[0]-1]==-1:
                    search(k[0])
search(2)
for i in anslist:
    print(i%2)
n, k = map(int, input().split())
a = [int(i) for i in input().split()]


lst = []
visit_now = 1
visit_list = [0] * n

while True:
    if visit_list[visit_now - 1] == 1:
        break
    visit_list[visit_now - 1] = 1
    lst.append(visit_now)
    visit_now = a[visit_now - 1]


start = lst.index(visit_now)
loop_num = n - start - 1
lst = lst[start:]

k -= start
k %= loop_num

print(lst[k])
# print(lst, loop_num, loop_list, k)


### FIXED CODE ###

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


lst = []
visit_now = 1
visit_list = [-1] * (n + 1)
cnt = 0

while visit_list[visit_now - 1] == -1:
    visit_list[visit_now - 1] = cnt
    lst.append(visit_now)
    visit_now = a[visit_now - 1]
    cnt += 1

start = visit_list[visit_now - 1]
loop_num = cnt - start

if k <= start:
    ans = lst[k]
else:
    k -= start
    k %= loop_num
    ans = lst[start + k]

print(ans)
L = list(map(int,input().split()))

print(L[0]+l[1]//2)

### FIXED CODE ###

L = list(map(int,input().split()))

print(L[0]+L[1]//2)
s = input ()

function radius (r) {
  return r ** 2
  
console.log(radius(s))

### FIXED CODE ###

s = input ()

def radius(r):
  to_number = int(r)
  return to_number ** 2

print (radius(s))
n = set(list(input()))
if n == set("N","S") or n == set("W","E") or n == set("N","S","W","E")
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n = set(list(input()))
if n == set(["N","S"]) or n == set(["W","E"]) or n == set(["N","S","W","E"]):
  print("Yes")
else:
  print("No")
if __name__ == '__main__':
    from math import pi
    radius = int(input())

    area = radius**2 * pi
    perimeter = 2 * radius * pi

    print('{0:.6f} {1:.6f}'.format(area, perimeter))

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_4_B&lang=jp

"""
import sys
from sys import stdin
from math import pi
input = stdin.readline


def main(args):
    r = float(input())
    print('{:.6f} {:.6f}'.format(r**2*pi, 2*pi*r))


if __name__ == '__main__':
    main(sys.argv[1:])
n,m=map(int,input().split())
ab=[]
for i in range(m):
  a,b=map(int,input().split())
  ab.append((a,b))
#print(ab)
     
mid=[]
for (i,j) in ab:
  if i==1:
    mid.append(j)

for (i,j) in ab:
  if i in mi and j==n:
    print("POSSIBLE");exit()
    
print("IMPOSSIBLE")

    

### FIXED CODE ###

n,m=map(int,input().split())
c=[]
d=[]
for i in range(m):
  a,b=map(int,input().split())
  if a==1:
    c.append(b)
  if b==n:
    d.append(a)
#O(m)
if len(set(c)&set(d))!=0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")
S = int(input())

A = [0,0,1]
for i in range(3,S):
  A += [A[i-1] + A[i-3]]
print(A[i] % (10 ** 9 + 7))

### FIXED CODE ###

S = int(input())
 
A = [0,0,1]
if S == 1 or S == 2:
  print(0)
elif S == 3:
  print(1)
else:
  for i in range(3,S):
    A += [A[i-1] + A[i-3]]
  print(A[i] % (10 ** 9 + 7))
if a >=3200
    print(s)
else 
    print("red")

### FIXED CODE ###

a  = int(input())
s = str(input())
if a >= 3200 :
    print(s)
else :
    print("red")
import heapq

def isCLKWISE(ph):
    a = [ph[-1][0]-ph[-3][0],ph[-1][1]-ph[-3][1]]
    b = [ph[-2][0]-ph[-3][0],ph[-2][1]-ph[-3][1]]
    crs = a[0]*b[1] - a[1]*b[0]
    if crs < 0 :
        return False
    else :
        return True
    
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            if isCLKWISE(phU) :
                break
            else :
                del phU[-2]
                if len(phU) == 2 :
                    break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            if isCLKWISE(phL) :
                break
            else :
                del phL[-2]
                if len(phL) == 2 :
                    break
    ph = phU + phL[1:-1]
    return ph

n = int(input())
P = []
for i in range(n):
    heappush(P,[int(x) for x in input().split()])
    
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
for q in Q:
    idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
    R = Q[idx:] + Q[:idx]
for r in R:
    print(r[0],r[1])

### FIXED CODE ###

def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            try :
                if isCLKWISE(phU) : break
                else : del phU[-2]
            except IndexError : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            try :
                if isCLKWISE(phL) : break
                else : del phL[-2]
            except IndexError : break
    ph = phU + phL[1:-1]
    return ph
  
P = [[int(x) for x in input().split()] for _ in range(int(input()))]
P = ConvexHullScan(P)
P.reverse()
print(len(P))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(P)])[2]
for p in P[idx:] + P[:idx] : print(p[0],p[1])
def check(x, y, S):

K, S = list(map(int, input('').split()))
count = 0
for x in range(K+1):
  for y in range(K+1):
    if x + y <= S:
      count += 1
print(count)

### FIXED CODE ###

K, S = list(map(int, input('').split()))
count = 0
for x in range(K+1):
  for y in range(K+1):
    if x + y <= S and x + y + K >= S:
      count += 1
print(count)
a=input()
b=input()
print(max([a-b,a+b,a*b]))

### FIXED CODE ###

a,b=map(int,input().split())
print(max([a-b,a+b,a*b]))
import numpy as np
print("hello")

### FIXED CODE ###

[n, m] = [int(x) for x in raw_input().split()]
A = []

counter = 0
while counter < n:
    A.append([int(x) for x in raw_input().split()])
    counter += 1

B = [int(raw_input()) for j in range(m)]

counter = 0
while counter < n:
    result = 0
    for j in range(m):
        result += A[counter][j] * B[j]
    print(result)
    counter += 1
A, B, K = [int(i) for i in input().split()]
if K <= A:
    a = A-K
    b = B
elif A < K and K <= A+B:
    a = 0
    b = B-(K-A)
else:
    a = 0
    b = 0
print(a, b)


### FIXED CODE ###

S, T = [str(s) for s in input().split()]

print(T+S)
s = input().split()
if s[2] == s[3] and s[4] == s[5]:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

s = input()
if s[2] == s[3] and s[4] == s[5]:
    print("Yes")
else:
    print("No")
import numpy as np
from scipy.sparse.csgraph import shortest_path
from scipy.sparse import csr_matrix
N, X, Y = map(int, input().split())
G = np.zeros((N, N))
for i in range(N-1):
    G[i,i+1] = 1
    G[i+1,i] = 1
G[X-1, Y-1] = 1
G[Y-1, X-1] = 1
#print(G)
spG = shortest_path(csr_matrix(G))
for i in range(1,N):
    print(int(np.count_nonzero(spG==i)/2))

### FIXED CODE ###

N, X, Y = map(int, input().split())
X -= 1
Y -= 1
#print(N)
dlist = [0]*N
for k in range(1, N):
    for i in range(N-k):
        j = i + k
        usek = abs(X -i)+1+abs(j-Y)
        curk = min(k, usek)
        dlist[curk] += 1

for i in dlist[1:]:
    print(i)
N, M = map(int, input().split())
A = []
for _ in range(M):
    A.append(int(input()))

case = [0] * (N + 1)
case[0] = 1
if not 1 in A:
    case[1] = 1
for x in range(2, N + 1):
    if x in A:
        case[x] = 0
    elif x - 1 in A:
        case[x] = case[x - 2]
    else:
        case[x] = case[x - 1] + case[x - 2]

print(case[N] % 1000000007)

### FIXED CODE ###

P,Q,R=map(int, input().split())
print(min(P+Q,P+R,Q+R))
n = int(input())
v = [{}, {}]
for i, vi in enumerate(map(int, input().split())):
    j = i % 2
    if vi in v[j]:
        v[j][vi] += 1
    elif not (vi in v[j]):
        v[j][vi] = 1
f1 = lambda v, i: max(v[i], key=v[i].get) if len(v[i]) > 0 else 0
f2 = lambda v, i, k: v[i].pop(k) if len(v[i]) > 0 else 0
kMax = [[f1(v, 0), f1(v, 1)]]
vMax = [[f2(v, 0, kMax[0][0]), f2(v, 1, kMax[0][1])]]
if kMax[0][0] != kMax[0][1]:
    print(n - sum(vMax[0]))
else:
    kMax.append([f1(v, 0), f1(v, 1)])
    vMax.append([f2(v, 0, kMax[0][0]), f2(v, 1, kMax[0][1])])
    print(n - max([vMax[0][0] + vMax[1][1], vMax[0][1] + vMax[1][0]]))

### FIXED CODE ###

n = int(input())
v = [{}, {}]
for i, vi in enumerate(map(int, input().split())):
    j = i % 2
    v[j].update([(vi, v[j][vi] + 1)]) if vi in v[j] else v[j].update([(vi, 1)])
f1 = lambda v, i: max(v[i], key=v[i].get) if len(v[i]) > 0 else 0
f2 = lambda v, i, k: v[i].pop(k) if len(v[i]) > 0 else 0
kMax, vMax = [], []
for i in [0, 1]:
    kMax.append([f1(v, 0), f1(v, 1)])
    vMax.append([f2(v, 0, kMax[i][0]), f2(v, 1, kMax[i][1])])
if kMax[0][0] != kMax[0][1]:
    print(n - sum(vMax[0]))
else:
    print(n - max([vMax[0][0] + vMax[1][1], vMax[0][1] + vMax[1][0]]))
import copy

N = int(input())
A = list(map(int, input().split()))
A.sort()

plus = [i for i in A if i >= 0]
minus = [i for i in A if i < 0]

M = len(minus)


if M % 2 == 0:
  ans = sum(A) + abs(sum(minus))*2
else:
  minus2 = copy.copy(minus)
  minus2.pop(-1)
  tmp = sum(A) + abs(sum(minus2))*2
  tmp2 = sum(A) + abs(sum(minus))*2 - min(plus) * 2
  ans = max(tmp, tmp2)
print(ans)
  
  
  

### FIXED CODE ###

import bisect
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
idx = bisect.bisect_left(A,0)
ans = 0
if idx%2 == 0:
  ans += abs(sum(A[0:idx]))
  if N > idx:
    ans += sum(A[idx:])
else:
  ans += abs(sum(A[0:idx-1]))
  if idx < N:
    ans += abs(A[idx-1]+A[idx])
  elif idx == N:
    ans += A[idx-1]
  if idx + 1 < N:
    ans += sum(A[idx+1:])
print(ans)
import math
a,b,k=map(int,input().split(" "))
g=math.gcd(a,b)
if k==1:
    print(g)
else:
    cnt = 1
    for n in range(2,g+1):
        if g%n==0:
            cnt+=1
            if cnt==k:
                print(int(g/n))
                break

### FIXED CODE ###

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

a,b,k=map(int,input().split(" "))
g=gcd(a,b)
if k==1:
    print(g)
else:
    cnt = 1
    for n in range(2,g+1):
        if g%n==0:
            cnt+=1
            if cnt==k:
                print(int(g/n))
                break