Harryxun/stf_run huggingface dataset:
# -*- coding: utf-8 -*-
import math

# 解説見ながら記述
# 延長魔法は、合成前・合成後で実施しても等価。
# 合成魔法が使えないパターンにのみ延長魔法を使うようにして全探索するみたい

N, A, B, C = map(int, input().split())
ls = [int(input()) for i in range(N)]

def rec(cur, a, b, c):
    """
    cur: 現在のlsのindex
    a: 合成中の1本目の長さ
    b: 合成中の1本目の長さ
    c: 合成中の1本目の長さ
    """
    if cur == N:
        if min(a, b, c) > 0:
            # 合成1回目：1本目は選ぶだけで合成する必要ないので10*3を引いておく
            return abs(A-a) + abs(B-b) + abs(C-c) - 30
        else:
            # 1回も合成していない場合は無効
            return math.inf
    else:
        r0 = rec(cur+1, a, b, c)    # ls[cur]に対して何もしない
        r1 = rec(cur+1, a+ls[cur], b, c) + 10    # ls[cur]をaに合成
        r2 = rec(cur+1, a, b+ls[cur], c) + 10    # ls[cur]をbに合成
        r3 = rec(cur+1, a, b, c+ls[cur]) + 10    # ls[cur]をcに合成
        return min(r0, r1, r2, r3)

r = rec(0, 0, 0, 0)

print(r)


### FIXED CODE ###

# -*- coding: utf-8 -*-
# import math   # math.infが使えない？(3.5から。AtCoderは3.4)

# 解説見ながら記述
# 延長魔法は、合成前・合成後で実施しても等価。
# 合成魔法が使えないパターンにのみ延長魔法を使うようにして全探索するみたい

N, A, B, C = map(int, input().split())
ls = [int(input()) for i in range(N)]
INF = 10 ** 10  # int32.max = 2*10^9より大きくしている

def rec(cur, a, b, c):
    """
    cur: 現在のlsのindex
    a: 合成中の1本目の長さ
    b: 合成中の1本目の長さ
    c: 合成中の1本目の長さ
    """
    if cur == N:
        if min(a, b, c) > 0:
            # 合成1回目：1本目は選ぶだけで合成する必要ないので10*3を引いておく
            return abs(A-a) + abs(B-b) + abs(C-c) - 30
        else:
            # 1回も合成していない場合は無効
            # return math.inf
            return INF
    else:
        r0 = rec(cur+1, a, b, c)    # ls[cur]に対して何もしない
        r1 = rec(cur+1, a+ls[cur], b, c) + 10    # ls[cur]をaに合成
        r2 = rec(cur+1, a, b+ls[cur], c) + 10    # ls[cur]をbに合成
        r3 = rec(cur+1, a, b, c+ls[cur]) + 10    # ls[cur]をcに合成
        return min(r0, r1, r2, r3)

r = rec(0, 0, 0, 0)

print(r)
l,r = (int(i) for i in input().split())
mod = 2019
if l-r >=2019:
    print(0)
else:
    ans = float('inf')
    for i in range(l,r+1):
        for j in range(i,r+1):
            ans = (ans,i*j%mod)
        print(ans)


### FIXED CODE ###

l,r = (int(i) for i in input().split())
mod = 2019
if r-l >=2019:
    print(0)
else:
    ans = float('inf')
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            ans = min(ans,i*j%mod)
    print(ans)
import itertools
n,m = list(map(int,input().split()))

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

b = [[0 for i in range(n)] for j in range(n)]
for i in a:
    b[i[0]][i[1]] = 1
    b[i[1]][i[0]] = 1

c = [i+1 for i in range(m-1)]
ans = 0
for i in itertools.permutations(c,m-1):
    j = [0]
    j += i
    count = 0
    for i in range(m-1):
        if b[j[i]][j[i+1]] == 1:
            count += 1
            if count == m-1:
                ans += 1
                count = 0
        else:
            break
print(ans)

### FIXED CODE ###

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

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

b = [[0 for i in range(n)] for j in range(n)]
for i in a:
    b[i[0]][i[1]] = 1
    b[i[1]][i[0]] = 1


c = [i+1 for i in range(n-1)]
ans = 0
for i in itertools.permutations(c,n-1):
    j = [0]
    j += i
    count = 0
    for i in range(n-1):
        if b[j[i]][j[i+1]] == 1:
            count += 1
            if count == n-1:
                ans += 1
                count = 0
        else:
            break
print(ans)
import numpy as np
from numba import njit, i4, i8


@njit(i8(i8, i4), cache=True)
def div(n, d):
    cnt = 0
    while n % d == 0:
        n //= d
        cnt += 1
    return cnt


n = int(input())
arr = np.array([float(input()) for _ in range(n)], np.float64)
arr = np.rint(arr * 10**9).astype(np.int64)

f = np.vectorize(div)
arr2 = f(arr, 2) + np.zeros([arr.shape[0], arr.shape[0]], np.int64)
arr5 = f(arr, 5) + np.zeros([arr.shape[0], arr.shape[0]], np.int64)

arr2 = np.tril(arr2 + arr2.T)
arr2 -= arr2.T
arr5 = np.tril(arr5 + arr5.T)
arr5 -= arr5.T

result = (arr2 >= 18).astype(np.int32) + (arr5 >= 18).astype(np.int32)

print(np.sum(result >= 2))

### FIXED CODE ###

def div(n, d):
    cnt = 0
    while n % d == 0 and cnt < 18:
        n //= d
        cnt += 1
    return cnt


n = int(input())
dp = [[0]*19 for _ in range(19)]

ans = 0
for _ in range(n):
    x = round(float(input()) * pow(10, 9))
    two = div(x, 2)
    five = div(x, 5)
    ans += dp[18 - two][18 - five]
    for i in range(two + 1):
        for j in range(five + 1):
            dp[i][j] += 1

print(ans)
border = 101


def manhattan_distance(Cx, Cy, H, X, Y):
    return max(H - abs(X - Cx) - abs(Y - Cy), 0)


def judge_center(Cx, Cy, cords):
    for x, y, h in cords:
        if h > 0:
            H = abs(cords[0][0] - Cx) + abs(cords[0][1] - Cy) + cords[0][2]
            break
    for x, y, h in cords:
        tmp = manhattan_distance(Cx, Cy, H, x, y)
        if (h > 0 and H != tmp) or (h == 0 and H > tmp):
            return -1
    return H


def main():
    N = int(input())
    cords = [list(map(int, input().split(' '))) for _ in range(N)]

    for tmp_Cx in range(border):
        for tmp_Cy in range(border):
            h = judge_center(tmp_Cx, tmp_Cy, cords)
            if h != -1:
                print('{} {} {}'.format(tmp_Cx, tmp_Cy, h))
                return 0


if __name__ == '__main__':
    main()


### FIXED CODE ###

N = int(input())


if N == 1:
    print("Hello World")
else:
    A = int(input())
    B = int(input())
    print(A+B)
import random
val = input()
 
if len(val)<=3:
  val = input('Enter your name: ')
elif len(val)>=20:
  val = input('Enter your name: ')
else:
  t = random.randint(0,len(val)-3)
  print(val[t:t+3])

### FIXED CODE ###

val = input()
print(val[0:3])
ipt=input()
lst=ipt.split()
A=lst[0]
B=lst[1]
if A>=B and A-1>=B:
    print(A+A-1)
elif A>=B and A-1<B:
    print(A+B)
elif A<B and A<B-1:
    print(B+B-1)
else:
    print(A+B)


### FIXED CODE ###

ipt=input()
lst=ipt.split()
A=int(lst[0])
B=int(lst[1])
if A>=B and A-1>=B:
    print(A+A-1)
elif A>=B and A-1<B:
    print(A+B)
elif A<B and A<B-1:
    print(B+B-1)
else:
    print(A+B)
a,b=map(int,input().split())
print((b-a)*(1+b-a)//2-b)…

### FIXED CODE ###

a,b=map(int,input().split())
print((b-a)*(1+b-a)//2-b)
N, M = map(int, input().split())
# A = [int(input()) for _ in range(M)]
A = range(M)
B = range(M)
for i in range(M):
  diff = 0
  if i == 0:
    diff = A[i] - 1
    # B[0] = fib_memo(diff + 1)
  else if i == (M - 1):
    diff = N - A[M - 1] -1
    # B[M-1] = fib_memo(diff + 1)
  else:
    diff = A[i] - A[i-1]
    # B[i] = fib_memo(diff + 1)
# Ans = reduce(lambda a, b: a*b, B)
Ans = 10
print(Ans % 1000000007)
    


### FIXED CODE ###

N, M = map(int, input().split())
A = [True] * (N+1)
for _ in range(M):
  idx = int(input())
  A[idx] = False

step = [0] * (N+1)
step[0] = 1
for i in range(1, N+1):
  if A[i]:
    step[i] = step[i-1] + step[i-2]
  else:
    step[i] = 0
print(step[N]%(10**9+7))
t=int(input())

res='No'

if t>3 and (t%4==0 or t%7==0 or t%4==3 or t%7==4):
	res='Yes'

print(res)

### FIXED CODE ###

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

res=1

if n%k==0:
	res=0

print(res)
N,A,B = map(float,input().split())

r = ''
while True:
    r += "b"* int(A)
    if len(r) >= int(N):
        break
    r += "r"* int(B)
    if len(r) >= int(N):
        break
print(r[:int(N)].count('b'))

### FIXED CODE ###

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

s = 0
s = int(N / (A+B))*A
if N % (A+B) > A:
    s += A
else:
    s += N % (A+B)
print(s)
from math import sqrt
 
while True:
    e = int(raw_input())
  
    if e == 0: break
 
    x, y, z, ans = 0, 0, 0, e
 
    for z in range(e+1):
        if z**3 > e: break
        y = int(sqrt(e - z**3))
        x = e - y**2 - z**3
        ans = min(ans, x+y+z)
 
    print ans


### FIXED CODE ###

#!/usr/bin/env python3

from math import sqrt

while True:
    e = int(input())

    if e == 0: break
    z, ans = 0, e

    while z ** 3 <= e:
        y = int(sqrt(e - z**3))
        x = e - y**2 - z**3
        ans = min(ans, x + y + z)
        z += 1

    print(ans)
a, b, c, d = map(int, input().split())
l = a + b
r = c + d
if l == r:
    print(Balanced)
elif l < r:
    print(Right)
else:
    print(Left)


### FIXED CODE ###

a, b, c, d = map(int, input().split())
l = a + b
r = c + d
if l == r:
    print("Balanced")
elif l < r:
    print("Right")
else:
    print("Left")
from collections import deque


def operation(command, arrey):
    if command[0] == 'insert':
        arrey.insert(0,command[1])
        return arrey
    elif command[0] == 'delete':
        if command[1] in arrey:
            arrey.remove(command[1])
    elif command[0] == 'deleteFirst':
        arrey.popleft()
    elif command[0] == 'deleteLast':
        arrey.pop()


n = int(input())
list = deque()

for i in range(n):
    command = input().split()
    operation(command,list)

print(' '.join(list))

### FIXED CODE ###

from collections import deque
import sys
 
n = int(sys.stdin.readline())
q = deque()
 
for i in range(n):
    command = sys.stdin.readline()[:-1]
    if command[0] == 'i':
        q.appendleft(command[7:])
    elif command[6] == ' ':
        try:
            q.remove(command[7:])
        except Exception as e:
            pass
    elif command[6] == 'F':
        q.popleft()
    else:
        q.pop()
 
print(' '.join(q))
import numpy as np
N, C, *L = map(int, open('0').read().split())
program = np.zeros((10**5+2,31),np.int32)
for s,t,c in zip(*[iter(L)]*3):
  program[s][c] += 1
  program[t+1][c] += -1
program = np.cumsum(program, axis=0)
ans = np.apply_along_axis(np.count_nonzero, 1, program).max()
print(ans)

### FIXED CODE ###

N, C = map(int, input().split())
dic = []
for i in range(N):
  s, t, c = map(int, input().split())
  dic += [(c-1,s,t)]

L = 2*100000+1
sm = [0]*L
for c in range(C):
  tt = [0]*(L)
  for i in range(N):
    if dic[i][0]==c:
      tt[dic[i][1]*2-1] += 1
      tt[dic[i][2]*2] -= 1
  for i in range(1,L):
    tt[i] += tt[i-1]
  for i in range(L):
    if tt[i]>0:
      sm[i] += 1
print(max(sm))
a, b, c, d = map(int, input().split())

t_hp = a
a_hp = c
while a_hp >= 0 or t_hp >= 0:
a_hp -= b
t_hp -= d

if a_hp <= t_hp:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

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

t_hp = a
a_hp = c
while a_hp > 0 or t_hp > 0:
    a_hp -= b
    t_hp -= d
    if a_hp <= 0:
         print("Yes")
         exit()
    elif t_hp <= 0:
         print("No")
         exit()
s = str(input())

days = [SUN,MON,TUE,WED,THU,FRI,SAT]

k=1
while k<=7:
  if s==days[k]:
    print(k)
  else:
    k+=1
    

### FIXED CODE ###

s = str(input())

days = ['SUN','MON','TUE','WED','THU','FRI','SAT']

print(7-days.index(s))
#coding:utf-8
#dp[i]:i段目に登るまでの組み合わせ総数
#dp[i] = dp[i-1] + dp[i-2] if dp[i] != B[i] else 0
N,M = list(map(int,input().split()))
B = [True] * N
for _ in range(M):
    B[int(input())-1] = False
dp = [0] * N
dp[0] = 1 if B[0] else 0
dp[1] = dp[0] + 1 if B[1] else 0
mod = 10**9 + 7
for i in range(2,N):
    if B[i] :
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod
print(dp[-1])



### FIXED CODE ###

#coding:utf-8
#dp[i]:i段目に登るまでの組み合わせ総数
#dp[i] = dp[i-1] + dp[i-2] if dp[i] != B[i] else 0
N,M = list(map(int,input().split()))
B = [True] * N

for _ in range(M):
    B[int(input())-1] = False
dp = [0] * N
if B[0]:
    dp[0] = 1
if N >= 2 and B[1]:
    dp[1] = dp[0] + 1 
mod = 10**9 + 7
for i in range(2,N):
    if B[i] :
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod
print(dp[-1])
i = input().split(" ")

r = int(i[0])
d = int(i[1])
a = int(i[2])

for i in range(10):
	a = a * r - d
	print(a)


### FIXED CODE ###

i = input().split(' ')

a = int(i[0])
b = int(i[1])

if a >= 13:
	print(b)
elif a >= 6:
	print(b // 2)
else:
	print(0)
R,G,B,N=map(int,input().split())

ans=[]

for r in range(int(N/R)+1):
    for g in range(int((N-r*R)/G)+1):
    	aaa=(N-r*R-g*G)/B)
        if aaa.is_integer():
            ans.append([r,g,aaa])

print(len(ans))

### FIXED CODE ###

R,G,B,N=map(int,input().split())

ans=[]

count=0
for r in range(int(N/R)+1):
    for g in range(int((N-r*R)/G)+1):
        
        if (N-r*R-g*G)%B==0:
            count+=1
            #ans.append([r,g,(N-r*R-g*G)/B])

#print(ans)
print(count)
import sys
N, M = map(int, input().split())

#とりまぶっこむ 
SClis = [] 
for _ in range(M):
    a, b = map(int, input().split())
    SClis.append([a,b])

ans = [-1]*N

for i in range(M):
    singlelis = SClis[i]
    S =  (singlelis[0] - 1)
    C =  (singlelis[1])
    
    if ans[S] != -1 and ans[S] != C:
        print(-1)
        sys.exit()
    else:
        ans[S] = C


    
if N == 1:
    if ans[0] == -1:
        ans[0] = 0
        print(''.join(map(str, ans)))
        sys.exit()

if N != 1:
    if ans[0] == 0:
        print(-1)
        sys.exit()
    
    if ans[0] == -1:
        ans[0] = 1
    
    for i in range(1,N):
        if ans[i] == -1:
            ans[i] = 0

print(''.join(map(str, ans)))


### FIXED CODE ###

N = int(input())
if N % 2 == 0:
    print(int(N/2))
else:
    print(int(N//2)+1)
n = input()
a = map(int,raw_input.split())
print sum(i == a[a[i-1]]-1 for i in range(n)) / 2

### FIXED CODE ###

n = input()
a = map(int,raw_input().split())
print sum(i == a[a[i]-1]-1 for i in range(n)) / 2
# coding: utf-8
# Your code here!
import itertools
import pandas as pd

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

lst = [i for i in range(k+1)]




ans = 0
ans = s_bool.sum()

print(ans)











### FIXED CODE ###

# coding: utf-8
# Your code here!

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

cnt = 0

for i in range(k+1):
    for j in range(k+1):
        if s-i-j <= k and s-i-j>=0:
            cnt += 1

print(cnt)
# -*- coding:utf-8 -*-

sA = raw_input()
sB = raw_input()

A = int(sA)
B = int(sB)

if (A > B):
  print 'GREATER'
elif (A < B):
  print 'LESS'
else:
  print 'EQUAL'

### FIXED CODE ###

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

fullstr = raw_input()

sf = ['','','']

sf[0] = fullstr[0]
num = 1

for i in range(len(fullstr)):
  if (fullstr[i] == ' '):
    sf[num] = fullstr[i+1]
    num += 1

print '%s%s%s' % (sf[0].upper(), sf[1].upper(), sf[2].upper())
import collecions

N = int(input())
W = [input() for i in range(N)]
c = collecions.Counter(W)

for i in range(N-1):
    if W[i][-1] != W[i+1][1]:
        print("No")
        exit()
if len(c) != N:
    print("No")
    exit()
print("Yes")

### FIXED CODE ###

import collections

N = int(input())
W = [input() for i in range(N)]
c = collections.Counter(W)

for i in range(N-1):
    if W[i][-1] != W[i+1][0]:
        print("No")
        exit()
if len(c) != N:
    print("No")
    exit()
print("Yes")
a=input()
b=input()
dp=[[0 for i in range(len(a+1))] for j in range(len(b+1))]
for i in range(1,en(a+1)):
  for j in range(1,len(b+1)):
    if a[j-1]==b[i-1]:
      dp[i][j]=dp[i-1][j-1]
    else:
      dp[i][j]=max(dp[i-1][j],dp[i][j-1])+1
print(dp[-1][-1])
        
      


### FIXED CODE ###

a=input()
b=input()
dp=[[0 for i in range(len(a)+1)] for j in range(len(b)+1)]
for i in range(1,len(b)+1):
  for j in range(1,len(a)+1):
    if a[j-1]==b[i-1]:
      dp[i][j]=dp[i-1][j-1]+1
    else:
      dp[i][j]=max(dp[i-1][j],dp[i][j-1])

res=''

j=len(a)
i=len(b)
while j>0 and i>0:
 
    if dp[i][j]==dp[i-1][j]:
        i-=1
  
    elif dp[i][j]==dp[i][j-1]:
        j-=1
    elif dp[i][j]==dp[i-1][j-1]+1:

        res+=a[j-1]
        i-=1
        j-=1
    
print(res[::-1])
n = int(input())
if n%2=0:
  print(n//2)
else:
  print(n//2+1)

### FIXED CODE ###

n = int(input())
if n%2==0:
  print(n//2)
else:
  print(n//2+1)
s = raw_input()
orig = 'CODEFESTIVAL2016'

result = 0
for i in len(s):
  if orig[i] != s:
    result += 1

print result

### FIXED CODE ###

s = raw_input()
orig = 'CODEFESTIVAL2016'

result = 0
for i in range(len(s)):
  if orig[i] != s[i]:
    result += 1

print result
n,k=map(int,input().split())
p=10**9+7
def fact(n,p):
    a=[[] for _ in range(n+1)]
    a[0]=1
    for i in range(n):
        a[i+1]=(a[i]*(i+1))%p
    return a
f=fact(n-k+1,p)
invf=[]
for i in f:
    invf.append(pow(i,-1,p))
ans=[]
for i in range(1,k+1):
    if i>n-k+1:
        ans.append(0)
        continue
    ans.append(((f[n-k+1]*invf[n-k+1-i])%p)*((invf[i]*f[k-1])%p)*((invf[i-1]*invf[k-i]))%p)
for i in ans:
    print(i%p)

### FIXED CODE ###

n,k=map(int,input().split())
p=10**9+7
def fact(n,p):
    a=[[] for _ in range(n+1)]
    a[0]=1
    for i in range(n):
        a[i+1]=(a[i]*(i+1))%p
    return a
f=fact(n,p)
invf=[]
for i in f:
    invf.append(pow(i,-1,p))
ans=[]
for i in range(1,k+1):
    if i>n-k+1:
        ans.append(0)
        continue
    ans.append(((f[n-k+1]*invf[n-k+1-i])%p)*((invf[i]*f[k-1])%p)*((invf[i-1]*invf[k-i]))%p)
for i in ans:
    print(i%p)
n=int(input())
l=map(int,input().spliut())
max=l[0]
c=0
for x in l:
    if max <x:
        max=x
    else:
        c+=(max-x)
print(c)

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
max=l[0]
c=0
for x in l:
    if max <x:
        max=x
    else:
        c+=(max-x)
print(c)
n, t = map(int, input().split())
a = []
for i in range(n):
  c, s = map(int, input().split())
  if s <= t:
    a.append(c)
print(min(a))

### FIXED CODE ###

n, t = map(int, input().split())
a = []
for i in range(n):
  c, s = map(int, input().split())
  if s <= t:
    a.append(c)
print("TLE" if len(a) == 0 else min(a))
N = int(input())
A = input().split()
for i in A:
    A = [j for j in A if j != i]
    if len(A) == N - 1:
        N -= 1
        continue
    else:
        print("NO")
        break
if N == 0:
    print("YES")


### FIXED CODE ###

S, T = input().split()
A, B = map(int,input().split())
U = input()
if U == S:
    A -= 1
else:
    B -= 1
print(str(A)+' '+str(B))
S = input()

import math
N = len(S)
for i in range(math.ceil(N/2), N):
    if S[N-i:i] == '0'*(i-(N-i)) or S[N-i:i] == '1'*(i-(N-i)):
        K = i
print(K)


### FIXED CODE ###

S = input()

N = len(S)
K = N
for i in range(1, N):
    if S[i-1] != S[i]:
        K = min(K, max(i, N-i))
print(K)
n = int(input())
data = [input().split() for i in range(n)]
light = [0]*n
light[0] = 1
count = 0
bool = False
for i in range(n):
    temp = light.index(1)
    light[int(data[temp][0])  - 1] = 1
    light[temp] = 0
    if temp == 1:
        bool = True
        print(count)
        exit()
    count += 1
if bool == False:
    print(-1)

### FIXED CODE ###

n = int(input())
data = [int(input()) for i in range(n)]
count = 0
temp = 1
for i in range(n):
    temp = data[temp-1]
    count += 1
    if temp == 2:
        print(count)
        break
else:
    print(-1)
while True:
    n,x=map(int,input().split())
    if n=0 and x=0:break
    ans =0
    for a in range(1,n+1):
        for b in range(1,n+1):
            if b<=a:continue
            c=x-(a+b)
            if c>b and c<=n:ans+=1
    print("%d"%(ans))



### FIXED CODE ###

while True:
    n,x=map(int,input().split())
    a=0
    if n==0 and x==0:break
    for i in range(1,n+1):
        for j in range(1,i):
            for k in range(1,j):
                if i+j+k==x:a+=1
    print(a)
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]
dpx = 10**4+1
for i in range(1,K+1):
  for j in range(1,i):
      dpx = min(dpx, abs(h[i]-h[i-j])+dp[i-j])
  dp.append(dpx)
for k in range(K+1,N+1):
  for l in range(1,K+1):
    dpx = min(dpx, abs(h[i]-h[i-j])+dp[i-j])
  dp.append(dpx)
print(dp[-1])

### FIXED CODE ###

def main():
    N,K = map(int,input().split())
    h = list(map(int,input().split()))
    dp = [0]*N
    for i in range(1,N):
        dp[i]= min(abs(h[i]-h[j])+dp[j] for j in range(max(0,i-K),i))
    print(dp[-1])
main()
import math

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

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

print(lcm(A, B))


### FIXED CODE ###

import fractions

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

A,B = map(int, input().split())
print(lcm(A,B))
import sys

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

A = []
for i in range(W):
    A.append(list(input()))

# print(A)
for r in range(H):
    for line in range(W):
        # print(r, line)
        if(A[r][line] != "#"):
            continue

        # print(r, line, A[r][line])

        if(line == 0):
            L = False
        else:
            L = A[r][line - 1] == "#"

        if(r == 0):
            U = False
        else:
            U = A[r - 1][line] == "#"

        if(line == W - 1):
            R = False
        else:
            R = A[r][line + 1] == "#"

        if(r == H - 1):
            D = False
        else:
            D = A[r + 1][line] == "#"

        # print(L, U, R, D)
        # print(L or U or R or D)
        if((L or U or R or D) is False):
            print("No")
            sys.exit()

print("Yes")

### FIXED CODE ###

import sys

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

A = []
for i in range(H):
    A.append(list(input()))

# print(A)
for r in range(H):
    for line in range(W):
        # print(r, line)
        if(A[r][line] != "#"):
            continue

        # print(r, line, A[r][line])

        if(line == 0 or W == 1):
            L = False
        else:
            L = A[r][line - 1] == "#"

        if(r == 0 or H == 1):
            U = False
        else:
            U = A[r - 1][line] == "#"

        if(line == W - 1 or W == 1):
            R = False
        else:
            R = A[r][line + 1] == "#"

        if(r == H - 1 or H == 1):
            D = False
        else:
            D = A[r + 1][line] == "#"

        # print(L, U, R, D)
        # print(L or U or R or D)
        if((L or U or R or D) is False):
            print("No")
            sys.exit()

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

print("Left" if (A+B)>(C+D) else "Balanced" if (A+B)=(C+D) else "Right

### FIXED CODE ###

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

print("Left" if (A+B)>(C+D) else "Balanced" if (A+B)==(C+D) else "Right")
INF = float('inf')
dp = [INF] * (10**5 + 10)
dp[0] = 0
h = [0] * (10 ** 4)
N, K = map(int, input().split())
h = list(map(int, input().split())) + h
for i in range(N+1):
    for k in range(1, K+1):
        dp[i+k] = min(dp[i+k], dp[i] + abs(h[i] - h[i+k]))
print(dp[N-1])


### FIXED CODE ###

n, k = map(int, input().split())
h = list(map(int, input().split()))
INF = float('inf')
dp = [INF] * (1 + 10 ** 5)
dp[0] = 0
for i in range(n):
    for j in range(1, k + 1):
        if i - j < 0:
            continue
        dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]))
print(dp[n-1])
while True:
  h,w=map(int,input().split())
  if h==0 & w==0:
    break
  for i in range(h):
    for i in range(w):
      if (i+j)%2==0:
        print("#")
      else:
        print(".")
  print()


### FIXED CODE ###

while True:
  h,w=map(int,input().split())
  if h==0 & w==0:
    break
  for i in range(h):
    print(("#."* w)[i%2:][:w])
  print()
imports sys

def sub(field, x, y):
  if y < 0 or x < 0 or y >= len(field) or x >= len(field[y]):
    return True
  if field[y][x] != '#':
    return False
  return True

def isok(field, x, y):
  units = [(0, 1), (1, 0), (0, -1), (-1, 0)]
  for unit in units:
    _x = x + unit[0]
    _y = y + unit[1]
    if not sub(field, _x, _y):
      return False
  return True
    
l = sys.stdin.readline()
xy = [int(x) for x in l.rstrip('¥n').split(' ')]
height = xy[0]
width = xy[1]

field = []
for _ in xrange(height):
  field.append(sys.stdin.readline())
 
for y in len(field):
  for x in len(field[y]):
    if not isok(field, x, y):
      print 'No'
print 'Yes'


### FIXED CODE ###

import sys

def sub(field, x, y):
  if y < 0 or x < 0 or y >= len(field) or x >= len(field[y]):
    return True
  if field[y][x] == '#':
    return True
  return False

def isok(field, x, y):
  units = [(0, 1), (1, 0), (0, -1), (-1, 0)]
  for unit in units:
    _x = x + unit[0]
    _y = y + unit[1]
    if sub(field, _x, _y):
      return True
  return False


l = sys.stdin.readline()
xy = [int(x) for x in l.rstrip('\n').split(' ')]
height = xy[0]
width = xy[1]

field = []
for _ in xrange(height):
  field.append(sys.stdin.readline().rstrip('\n'))

for y in xrange(len(field)):
  for x in xrange(len(field[y])):
    if field[y][x] == '#' and not isok(field, x, y):
      print 'No'
      exit()
print 'Yes'
print(24 - int(input())

### FIXED CODE ###

print(48 - int(input()))