Harryxun/stf_run huggingface dataset:
N=int(input())
inputs=[]
dp=[]
for _ in range(N):
    inputs.append([int(x) for x in input().split()])
    dp.append([0]*3)

for j in range(3):
    dp[0][j]=inputs[0][j]

for i in range(1,N):

    for j in range(3):
        
        for k in range(3):
            if(j!=k):
                dp[i][j]=max(dp[i-1][k],dp[i][j])
        
        dp[i][j]+=inputs[i][j]


print(dp[N-1][N-1])


### FIXED CODE ###

N=int(input())
inputs=[]
dp=[]
for _ in range(N):
    inputs.append([int(x) for x in input().split()])
    dp.append([0]*3)

for j in range(3):
    dp[0][j]=inputs[0][j]

for i in range(1,N):

    for j in range(3):
        
        for k in range(3):
            if(j!=k):
                dp[i][j]=max(dp[i-1][k],dp[i][j])
        
        dp[i][j]+=inputs[i][j]



print(max(dp[N-1]))
N = int(input())
X = list(map(int, input().split())
Y = list(map(int, input().split())
ans = 0
         
for i in range(N):
         ans += max(X[i] - Y[i]), 0)

print(ans)
         

### FIXED CODE ###

N = int(input())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
ans = 0
         
for i in range(N):
         ans += max(X[i] - Y[i], 0)

print(ans)
N, M = list(map(int,input().split()))
a = [int(input()) for i in range(M)]

b = [0]*N

if 1 not in a:
    b[0] = 1

if 2 not in a:
    if b[0] == 1:
        b[1] = 2
    else:
        b[1] = 1

for i in range(2,N):
    if i+1 not in a:
        if b[i-2] != 0:
            b[i]+= b[i-2]
        if b[i-1] != 0:
            b[i]+= b[i-1]

print(b[N-1]%1000000007)

### FIXED CODE ###

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

b = [0]*(N+2)
b[0] = 1

for i in range(M):
    b[int(input())] = -1

for i in range(N):
    if b[i] != -1:
        if b[i+1] != -1:
            b[i+1] += b[i]
        if b[i+2] != -1:
            b[i+2] += b[i]

print(b[N]%1000000007)
s = input()
K = int(input())
L = len(s)
cand = []
for i in range(L):
    for j in range(i+1,min(i+K+1,L+1)):
        cand.append(s[i:j])
cand.sort()

i = 0
if len(cand) == 1:
    print(cand[0])
    exit()
while True:
    if cand[i] == cand[i+1]:
        i+=1
        continue
    K-=1
    i+=1
    if K == 0:
        print(cand[i-1])
        break


### FIXED CODE ###

s = input()
K = int(input())
L = len(s)
cand = []

if L > 5:
    c = []
    order = sorted(list(s))
    for i in range(L):
        if order[i] in c:
            pass
        else:
            c.append(order[i])
            if len(c) == 5:
                break
else:
    c = list(s)

for i in range(L):
    if s[i] in c:
        for j in range(i+1,min(i+K+1,L+1)):
            cand.append(s[i:j])
cand.sort()

i = 0
if len(cand) == 1:
    print(cand[0])
    exit()

i = 0
while True:
    K -= 1
    if K == 0:
        print(cand[i])
        break
    i += 1
    while(cand[i] == cand[i-1]):
        cand.pop(i)
n,k=map(int,input().split())
s=input()
s_list=[]
first=s[0]
last=s[n-1]
state=first
length=1
for i in range(1,n):
    if (state=='0' and s[i]=='0') or (state=='1' and s[i]=='1'):
        state=s[i]
        length=length+1
    else:
        state=s[i]
        s_list.append(length)
        length=1
s_list.append(length)
if first=='0':
    if last=='0':
        number0=(len(s_list)+1)/2
    else:
        number0=len(s_list)/2
else:
    if last=='0':
        number0=len(s_list)/2
    else:
        number0=(len(s_list)-1)/2
if first=='0' and last=='0':
    if number0<=k:
        Max=n
    else:
        p_list=s_list[0:2*k]
        Max=sum(p_list)
        i=1
        while i+2*k+1<n-1:
            p_list=s_list[i:i+2*k+1]
            if sum(p_list)>Max:
                Max=sum(p_list)
            i=i+2
        p_list=s_list[n-2*k:]
        if sum(p_list)>Max:
            Max=sum(p_list)
elif first=='0' and last=='1':
    if number0<=k:
        Max=n
    else:
        p_list=s_list[0:2*k]
        Max=sum(p_list)
        i=1
        while i+2*k+1<=n-1:
            p_list=s_list[i:i+2*k+1]
            if sum(p_list)>Max:
                Max=sum(p_list)
            i=i+2
elif first=='1' and last=='0':
    if number0<=k:
        Max=n
    else:
        p_list=s_list[0:2*k+1]
        Max=sum(p_list)
        i=2
        while i+2*k+1<n-1:
            p_list=s_list[i:i+2*k+1]
            if sum(p_list)>Max:
                Max=sum(p_list)
            i=i+2
        p_list=s_list[n-2*k:]
        if sum(p_list)>Max:
            Max=sum(p_list)
elif first=='1' and last=='1':
    if number0<=k:
        Max=n
    else:
        p_list=s_list[0:2*k+1]
        Max=sum(p_list)
        i=2
        while i+2*k+1<=n-1:
            p_list=s_list[i:i+2*k+1]
            if sum(p_list)>Max:
                Max=sum(p_list)
            i=i+2
print(Max)


### FIXED CODE ###

a,b=map(int,input().split())
print(max(a+b,2*a-1,2*b-1))
num = [0,0,0]
num[0] = int(input())
num[1] = int(input())
num[2] = int(input())

num.sort()

print(int(str(num[0]) + str(num[1])) + num[2])

### FIXED CODE ###

s = input()

num = list(s)

num.sort()
num.reverse()

print(int(num[0] + num[1]) + int(num[2]))
a,b,c=map(int,raw_input.split())
if a+b+c==17:
  print "YES"
else:
  print "NO"

### FIXED CODE ###

a,b,c=map(int,raw_input().split())
if a+b+c==17:
  print "YES"
else:
  print "NO"
N,A,B=map(int,input().split())

if A*N<B:
    ans=a*N
else:
    ans=B

print(ans)


### FIXED CODE ###

N,A,B=map(int,input().split())

if A*N<B:
    ans=A*N
else:
    ans=B

print(ans)
N = int(input())
arr = list(map(int, input().split()))
memo = [0]*((10**9)*2)
ans = 0
for i in range(N):
    if (i+1)-arr[i] >= 0:
        ans += memo[(i+1)-arr[i]]
    if (i+1)+arr[i] > 0:
        memo[(i+1)+arr[i]] += 1
print(ans)

### FIXED CODE ###

from collections import defaultdict
d = defaultdict(int)
N = int(input())
arr = list(map(int, input().split()))
ans = 0
for i in range(N):
    ans += d[(i+1)-arr[i]]
    d[(i+1)+arr[i]] += 1
print(ans)
n,k = map(int,input().split())
xyl = []
for _ in range(n):
    x,y = map(int,input().split())
    xyl.append((x,y))

ans = float("inf")
for i in range(n):
    for j in range(i+1, n):
        for h in range(j+1, n):
            for g in range(h+1, n):
                x1 = min(xyl[i][0], xyl[j][0], xyl[h][0], xyl[g][0])
                x2 = max(xyl[i][0], xyl[j][0], xyl[h][0], xyl[g][0])
                y1 = min(xyl[i][1], xyl[j][1], xyl[h][1], xyl[g][1])
                y2 = max(xyl[i][1], xyl[j][1], xyl[h][1], xyl[g][1])
                cnt = 0
                for p in range(n):
                    if x1 <= xyl[p][0] <= x2 and  y1 <= xyl[p][1] <= y2:
                        cnt += 1
                if k <= cnt:
                    ans = min(ans, (x2-x1)*(y2-y1))

for i in range(n):
    for j in range(i+1, n):
        for h in range(j+1, n):
            x1 = min(xyl[i][0], xyl[j][0], xyl[h][0])
            x2 = max(xyl[i][0], xyl[j][0], xyl[h][0])
            y1 = min(xyl[i][1], xyl[j][1], xyl[h][1])
            y2 = max(xyl[i][1], xyl[j][1], xyl[h][1])
                cnt = 0
                for p in range(n):
                    if x1 <= xyl[p][0] <= x2 and  y1 <= xyl[p][1] <= y2:
                        cnt += 1
                if k <= cnt:
                    ans = min(ans, (x2-x1)*(y2-y1))

for i in range(n):
    for j in range(i+1, n):
        x1 = min(xyl[i][0], xyl[j][0])
        x2 = max(xyl[i][0], xyl[j][0])
        y1 = min(xyl[i][1], xyl[j][1])
        y2 = max(xyl[i][1], xyl[j][1])
            cnt = 0
            for p in range(n):
                if x1 <= xyl[p][0] <= x2 and  y1 <= xyl[p][1] <= y2:
                    cnt += 1
            if k <= cnt:
                ans = min(ans, (x2-x1)*(y2-y1))



print(ans)

### FIXED CODE ###

N, K = list(map(int, input().split()))
P = sorted([tuple(map(int, input().split())) for _ in range(N)])

ans = 1e30
for lx in range(N):
    for rx in range(lx+K, N+1):
        Q = sorted(P[lx:rx], key=lambda x:x[1])
        for ly in range(len(Q)):
            R = Q[ly:ly+K]
            if len(R)>=K: ans = min(ans, (P[rx-1][0]-P[lx][0])*(R[-1][1]-R[0][1]))
print(ans)
N, M = map(int, input().split())
A = []
B = []

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

A.append(a)
B.append(b)

if N != 1:
    for n in range(N-1):
        a, b = map(int, input().split())
        swi = 0
        BSum = 0
        for j in range(len(A)):
            if BSum > M:
                swi = 1
                break
            else:
                if A[j] > a:
                    A.insert(j, a)
                    B.insert(j, b)
                    swi = 1
                    break
                elif A[j] == a:
                    B[j] += b
                    swi = 1
                    break
            BSum += b
        if swi == 0:
            A.append(a)
            B.append(b)

cntSum = 0
moneySum = 0

print(A, B)

for n in range(N):
    if cntSum + B[n] > M:
        moneySum += A[n] * (M - cntSum)
        cntSum += M - cntSum
        break
    else:
        cntSum += B[n]
        moneySum += A[n] * B[n]

print(moneySum)


### FIXED CODE ###

n, m = map(int, input().split())
abList = sorted([list(map(int, input().split())) for _ in range(n)])
abSum = 0
abNum = m
for i in range(n):
    ab = abList[i]
    a, b = ab[0], ab[1]
    if b >= abNum:
        abSum += abNum * a
        break
    else:
        abSum += b * a
        abNum -= b
print(abSum)
N,K = map(int,input().split())
P = [0]*(N+1)
for i in range(3,N+1):
    P[i] = (i-1)*(i-2)//2
ans =[]
l = 0
for i in range(N,2,-1):
    while P[i] <= K:
        ans.append(i-1)
        K -= P[i]
        N -= i-2
        l += 1
if N < 2:
    print(-1)
else:
    M = sum(ans)-len(ans)+1
    print(M)
    S = [[0,0]for i in range(M)]
    l,n = 0,2
    hoge = 1
    for i in range(ans[0]):
        u,v = hoge,n
        n += 1
        S[l] = [u,v]
        l += 1
    for i in ans[1:]:
        hoge = n-1
        for j in range(i-1):
            u,v = hoge,n
            n += 1
            S[l] = [u,v]
            l += 1
    for u,v in S:
        print(u,v)


### FIXED CODE ###

N,K = map(int,input().split())
Ni = (N-1)*(N-2)//2
if Ni < K:
    print(-1)
    exit()
M = N-1+Ni-K
print(M)
for i in range(2,N+1):
    print(1,i)
for i in range(2,N):
    for j in range(i+1,N+1):
        if Ni-K <= 0:
            exit()
        print(i,j)
        Ni -= 1
n = int(input())
cnt  = [0 for i in range(10001)]

for x in range(1,105):
    for y in range(1, 105):
        for z in range(1, 105):
                ans = x**2 + y**2 + z**2 + x*y + y*z + z*x 
                if ans <= 10000:    
                    cnt[ans] +=1
for i in range(1, N+1):  
    print(cnt[i])


### FIXED CODE ###

n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
    for j in range(1,105):
        for k in range(1,105):
            v = i*i+j*j+k*k+i*j+j*k+k*i;
            if v<10050:
                ans[v]+=1
for i in range(n):
    print(ans[i+1])
import math
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

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

l = lcm(*[a // 2 for a in A])
ans = math.floor((m + l) / (2*l))
if any([(2*l / a - 1) % 2 != 0 for a in A]):
    print(0)
else:
    print(ans)

### FIXED CODE ###

import math
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def f(x):
    res = 0
    while x % 2 == 0:
        res += 1
        x /= 2
    return res

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

l = lcm(*[a // 2 for a in A])
ans = math.floor((m + l) / (2*l))
if len(set([f(a) for a in A])) != 1:
    print(0)
else:
    print(ans)
N = int(input())
memo = {}

def mcd(a, b) :
    if (a, b) in memo.keys() :
        return memo[(a, b)]
    else :
        if max(a, b) % min(a, b) == 0 :
            return min(a, b)
        else :
            memo[(a, b)] = mcd(min(a, b), max(a, b) % min(a, b))
            return memo[(a, b)]

def lcm(a, b) :
    return int((a * b) / mcd(a, b))

cur_lcm = 1

for i in range(N) :
    n = int(input())
    
    cur_lcm = lcm(cur_lcm, n)
    
print(cur_lcm)
    

### FIXED CODE ###

N = int(input())

'''
def mcd(a, b) :
    if (a, b) in memo.keys() :
        return memo[(a, b)]
    else :
        if max(a, b) % min(a, b) == 0 :
            return min(a, b)
        else :
            memo[(a, b)] = mcd(min(a, b), max(a, b) % min(a, b))
            return memo[(a, b)]

def lcm(a, b) :
    return int((a * b) / mcd(a, b))
'''

def gcd(x, y) :
    if y == 0 : return x
    else : return gcd(y, x % y)

h = 1

for i in range(N) :
    n = int(input())
    
    h = n * h // gcd(n, h)
    
print(h)
N,M=map(int,input().split())
x=[]
an=0
for i in range(M+1):
    x.insert(i,[])
for i in range(N):
    a,b=map(int,input().split())
    if a<=M:
        x[a].append(b)
y=[]
while n in <=M+1:
    y+=x[n]
    try:
        n=y.count(max(y))
        an+=n*max(y)
        for z in range(n)
            y.remove(max(y))
        n+=1
    except:
        continue
print(an)

### FIXED CODE ###

import heapq
N,M=map(int,input().split())
x={}
for i in range(M+1):
    x[i]=[]
for i in range(N):
    a,b=map(int,input().split())
    if a>M:
        continue
    x[a].append(-b)
y=[]
an=0
for i in range(M+1):
    for n in x[i]:
        heapq.heappush(y,n)
    try:
        an-=heapq.heappop(y)
    except:
        pass
print(an)
i = list(map(int, input().split()))

A = i[0]
B = i[1]

k = (A + B) / 2

if k.is_integer() == False:
	print(IMPOSSIBLE)
else:
	print(int(k))


### FIXED CODE ###

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

A = i[0]
B = i[1]

k = (A + B) / 2

if k.is_integer() == False:
	print("IMPOSSIBLE")
else:
	print(int(k))
N,X=map(int,input().split())
*M,=map(int,open(0))
print(N+(X-sum(M))//min(M))

### FIXED CODE ###

N,X,*M,=map(int,open(0).read().split())
print(N+(X-sum(M))//min(M))
n, m = map(int, input().split())
road = [tuple(map(int, input().split())) for _ in range(m)]

table = [list() for _ in range(n+1)]
ans = [0 for _ in range(n+1)]
hush = {}

for i in range(1, n+1):
    hush[i] = False

for a, b in road:
    table[a].append(b)
    table[b].append(a)

def bfs(i):
    hush[i] = True
    rec = []
    for j in table[i]:
        if hush[j] == False:
            ans[j] = i
            hush[j] = True
            rec.append(j)
    for j in rec:
        bfs(j)

bfs(1)

print('Yes')
for i in range(2, n+1):
    print(ans[i])

### FIXED CODE ###

from collections import deque

n, m = map(int, input().split())
ways = [tuple(map(int, input().split())) for _ in range(m)]
ans = [None] * (n+1)

hush = {}
hush[1] = True
for i in range(2, n+1):
    hush[i] = False
table = [list() for _ in range(n+1)]
for a, b in ways:
    table[a].append(b)
    table[b].append(a)

que = deque([1])
while len(que) > 0:
    room = que.popleft()
    for next in table[room]:
        if hush[next] == False:
            ans[next] = room
            que.append(next)
            hush[next] = True

print('Yes')
for i in range(2, n+1):
    print(ans[i])
# AGC 015: A – A+...+B Problem
from itertools import combinations_with_replacement

n, a, b = [int(s) for s in input().split()]

if a > b or n == 1:
    print(0)
elif a == b:
    print(1)
else:
    candidates = list(combinations_with_replacement(range(a, b + 1), n - 2))
    sum_variations = []

    for candidate in candidates:
        if sum(candidate) not in sum_variations:
            sum_variations.append(sum(candidate))
    
    print(len(sum_variations))

### FIXED CODE ###

# AGC 015: A – A+...+B Problem
from itertools import combinations_with_replacement

n, a, b = [int(s) for s in input().split()]


if a == b:
    print(1)
elif a > b or n <= 2:
    print(0)
else:
    print((b - a) * (n - 2) + 1)
def f(i,s,t):
    if i==3:
        if s==7:
            print(t + '=7')
            exit()
    
    else:
        f(i+1,t+'-'+a[i+1],s-int(a[i+1]))
        f(i+1,t+'+'+a[i+1],s+int(a[i+1]))

a=input()
f(0,a[0],int(a[0]))

### FIXED CODE ###

def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            # 答えは1つ出力すれば良いので =7 になれば終了
            print(f + "=7")
            exit()

    else:
        # 式 f の末尾に符号と次の数字を追加し、その分 sum に加減する
        dfs(i + 1, f + "-" + s[i + 1], sum - int(s[i + 1]))
        dfs(i + 1, f + "+" + s[i + 1], sum + int(s[i + 1]))


s = input()

dfs(0, s[0], int(s[0]))
x, y = input().split()
x = int(x)
y = int(y)
xy_sum = x + y
point_num = 0
kimari = 10 ** 9 + 7
if (xy_sum % 3 == 0):
    point_num += ((xy_sum - 1) / 3) ** 2
    point_num += (xy_sum - 1) // 6
    count = 2 ** point_num
    print(count % kimari)
else:
    print(0)


### FIXED CODE ###

r = int(input())
print(r ** 2)
n = int(input())
for i in range(1, n+1):
    num = 2
    while i != 1:
        if i % num==0:
            i //= num
            l.append(num)
        else:
            num += 1
ans = 1
for i in set(l):
    ans *= (l.count(i) + 1) % (10**9+7)
print(ans)

### FIXED CODE ###

n = int(input())
s, ans, num = 1, 1, 2
for i in range(2, n+1):
  s *= i
l = []
while s != 1:
  if not s % num:
    l.append(num)
    s //= num
  else:
    num += 1
for i in set(l):
  ans *= l.count(i)+1
print(ans%(10**9+7))
x = int(input())
for i in range(100):
  for j in range(-100,100):
    if i ^ 5 - j * 5 == x:
      a = i
      b = j
    break
  break
print(str(a)+" "+str(b))

### FIXED CODE ###

x = int(input())
a = 0
b = 0
if not x == 0:
  for i in range(1000):
    for j in range(-100,1000):
      if i**5 - j**5 == x:
        a = i
        b = j
      if a != 0 or b != 0:
        break
    if a != 0 or b != 0:
        break
    
print(str(a)+" "+str(b))
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def resolve():
    N, K = map(int, input().split())
    const = 1e9 + 7
    n_iter = int(min(K, N - K + 1))
    for i in range(1, K + 1):
        ans = combinations_count(N - K + 1, i) * combinations_count(
            K - 1, i - 1)
        print(int(ans % const))

resolve()

### FIXED CODE ###

import math


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


def resolve():
    N, K = map(int, input().split())
    const = 1e9 + 7
    for i in range(1, K + 1):
        if (N - K + 1 >= i):
            print(
                combinations_count(N - K + 1, i) *
                combinations_count(K - 1, i - 1) % 1000000007)
        else:
            print(0)
            
resolve()
a,b=map(int,input().split())
c=list(map(int,input().split()))
d=-1
if len(c)<=b:
    print(0)
else:
    c.sort()
    for i in range(b):
        c.pop(d)
        d-=1
    print(sum(c))


### FIXED CODE ###

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

if N - K < 0:
  print(0)
else:
  print(sum(H[:N-K]))
from sys import stdin
from functools import lru_cache


# 最小化問題
def chmin(a,b):
    if a > b: return b
    else: return a


class Rec_memo:
    def __init__(self, N, h_arr):
        self.dp = [float('inf')] * (N+2)
        self.h_arr = h_arr

    def rec(self, i):
        if self.dp[i] < float('inf'):
            return self.dp[i]
        elif i == 0:
            return 0
        else:
            if i>0:
                self.dp[i] = chmin(self.dp[i],self.rec(i-1)+abs(self.h_arr[i]-self.h_arr[i-1]))
            if i>1:
                self.dp[i] = chmin(self.dp[i],self.rec(i-2)+abs(self.h_arr[i]-self.h_arr[i-2]))
            return self.dp[i]


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    h_arr = [0] * (N+2)
    h_arr[0:N] = list(map(int,_in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    # dp[i]:=カエルが足場iへと移動するのに必要な最小コスト
    dp = [float('inf')] * (N+2)  # 最小化問題
    dp[0] = 0                    # 初期条件
    
    # 貰うDP
    #for i in range(0,N):
    #    dp[i] = chmin(dp[i],dp[i-1]+abs(h_arr[i]-h_arr[i-1]))
    #    if i > 1:
    #        dp[i] = chmin(dp[i],dp[i-2]+abs(h_arr[i]-h_arr[i-2]))
    #cnt = dp[N-1]

    # 配るDP
    #for i in range(0,N):
    #    dp[i+1] = chmin(dp[i+1],dp[i]+abs(h_arr[i]-h_arr[i+1]))
    #    dp[i+2] = chmin(dp[i+2],dp[i]+abs(h_arr[i]-h_arr[i+2]))
    #cnt = dp[N-1]

    # メモ化再帰
    memo = Rec_memo(N,h_arr)
    cnt = memo.rec(N-1)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


### FIXED CODE ###

from sys import stdin


# 最小化問題
def chmin(a,b):
    if a > b: return b
    else: return a


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    h_arr = list(map(int,_in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    dp = [float('inf')] * N  # 最小化問題
    dp[0] = 0                # 初期条件
    
    for i in range(0,N):
        dp[i] = chmin(dp[i],dp[i-1]+abs(h_arr[i]-h_arr[i-1]))
        if i > 1:
            dp[i] = chmin(dp[i],dp[i-2]+abs(h_arr[i]-h_arr[i-2]))
    cnt = dp[N-1]
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)
s=input()
x='keyence'
if s==x:
  print('YES')
  exit()
if s.count(x)>0:
  p=s.split('keyence')
  if p[0]=='' or p[1]=='':
    print('YES')
    exit()
  elif p[0]+p[1]=='keyence':
    print('YES')
    exit()
for i in range(1,len(x)):
  a=x[:i]
  b=x[i:]
  if s.index(a)==0 and s[len(s)-len(b):]==b:
    print('YES')
    exit()
  else:
    continue
print('NO')


### FIXED CODE ###

s=input()
x='keyence'
if s==x:
  print('YES')
  exit()
if s.count(x)>0:
  p=s.split('keyence')
  if p[0]=='' or p[1]=='':
    print('YES')
    exit()
  elif p[0]+p[1]=='keyence':
    print('YES')
    exit()
for i in range(1,len(x)):
  a=x[:i]
  b=x[i:]
  if s.count(a)>0 and (s.index(a)==0 and s[len(s)-len(b):]==b):
    print('YES')
    exit()
  else:
    continue
print('NO')
S = input()
if(s=='ARC'):
  print('ABC')
else:
  print('ARC')

### FIXED CODE ###

s = input()
if(s=='ARC'):
  print('ABC')
else:
  print('ARC')
X, Y, X = map(str, input().split())
print(Z, X, Y)

### FIXED CODE ###

X, Y, Z = map(str, input().split())
print(Z, X, Y)
n=int(input())
a,b,c=input().split()
ab=0;bc=0;ca=0
for i in range(n):
  if a[i]!=b[i]:
    ab+=1
  if b[i]!=c[i]:
    bc+=1
  if c[i]!=a[i]:
    ca+=1
print(min(ab,bc,ca))

### FIXED CODE ###

n=int(input())
a=input();b=input();c=input()
x=0
for i in range(n):
  x+=len(list(set([a[i],b[i],c[i]])))-1
print(x)
import math
from functools import reduce
import sys

def gcd(number_list):
    return reduce(math.gcd, number_list)

N = int(input())
Numbers = list(map(int, input().split()))


gcd_list = []
for i in range(N):
    tmp_list = Numbers[:i] + Numbers[i + 1:]
    gcd_list.append(gcd(tmp_list))
print(int(max(gcd_list)))


### FIXED CODE ###

from functools import reduce
from itertools import combinations
from fractions import gcd

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


Left = [0] * (N + 1)
Right = [0] * (N + 1)

for i in range(N):
    Left[i + 1] = gcd(Left[i], A[i])
    Right[N - i - 1] = gcd(Right[N - i], A[N - i - 1])
ans = 0
for i in range(N):
    ans = max(ans, gcd(Left[i], Right[i + 1]))
    
print(ans)
a,b,c,d=map(int,input().split())
print(max(a,b)+max(c,d))

### FIXED CODE ###

a,b,c,d=(int(input()) for i in range(4))
print(min(a,b)+min(c,d))
a,b=map(int,input().split())
count=0
while b>=1:
    b-=a
    connt+=1
     
print(count)

### FIXED CODE ###

a,b=map(int,input().split())
c=0
d=1
while d<b:
  d=d+a-1
  c=c+1
  
print(c)
x1,y1,x2,y2=map(int,input().split())
fx=1
fy=1
if x1>x2:
	x1,x2=x2,x1
	fx=-1
if y1>y2:
	y1,y2=y2,y1
	fy=-1

n=int(input())
p=[]
for i in range(n):
	x,y=map(int,input().split())
	if x1<=x<=x2 and y1<=y<=y2:
		p.append((fx*x,fy*y))
p=[y for x,y in sorted(p)]

from bisect import bisect_left as bl

b=[]

for y in p:
	pos=bl(b,y)
	if len(b)<=pos:
		b.append(y)
	else:
		b[pos]=y
	
from math import pi

l=len(b)

if l==min(x2-x1,y2-y1)+1:
	print(100*(x2-x1+y2-y1)+(5*pi-20)*(l-1)+(10*pi-20))
else:
	print(100*(x2-x1+y2-y1)+(5*pi-20)*l);


### FIXED CODE ###

q,h,s,d=map(int,input().split())

h=min(h,q+q)
s=min(s,h+h)
d=min(d,s+s)

n=int(input())

print(n//2*d+n%2*s)