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

n=int(input())
data=[]
for _ in range(n):
    data.append(list(map(int,input().split())))
ans=0
for i in range(0,n-1):
    for j in range(i+1,n):
        d=abs(data[i][0]-data[j][0])+abs(data[i][1]-data[j][1])
        ans=max(ans,d)
print(ans)

### FIXED CODE ###

n=int(input())
data=[]
for _ in range(n):
    data.append(list(map(int,input().split())))

data_sum=[]
for i in range(n):
    data_sum.append(data[i][0]+data[i][1])


data_sum_1=[]
for i in range(n):
    data_sum_1.append(data[i][1]-data[i][0])

d_1=max(data_sum)-min(data_sum)
d_2=max(data_sum_1)-min(data_sum_1)

print(max(d_1,d_2))
### BUGGY CODE ###

import math

n, h = map(int, input().split())
a, b = [0] * n, [0] * n
for i in range(n):
    x, y = map(int, input().split())
    a[i], b[i] = x, y
b.sort(reverse = True)
ans = 0
for i in range(n):
    if b[i] < max(a):
        break
    h -= b[i]
    ans += 1
    if h <= 0:
        break
if not h <= 0:
    ans += math.ceil(h / max(a))
print(ans)

### FIXED CODE ###

import math

n, h = map(int, input().split())
b = [0] * n
maxa = 0
for i in range(n):
    x, y = map(int, input().split())
    maxa = max(x, maxa)
    b[i] = y
b.sort(reverse = True)
ans = 0
for i in range(n):
    if b[i] < maxa:
        break
    h -= b[i]
    ans += 1
    if h <= 0:
        break
if not h <= 0:
    ans += math.ceil(h / maxa)
print(ans)
### BUGGY CODE ###

L, R = map(int, input().split())
l = []
frag = False
for i in range(L, R):
    for j in range(i+1, R+1):
        l.append((i*j) % 2019)
        n = len(l)
        if n % 2 == 0:
            if l[:n//2] == l[n//2:]:
                frag = True
                break
    if frag: break

print(min(l))

### FIXED CODE ###

L, R = map(int, input().split())
if R - L >= 2018:
	print(0)
else:
	ans = 2019
	for i in range(L, R):
		for j in range(i + 1, R + 1):
			ans = min(ans, i * j % 2019)
	print(ans)
### BUGGY CODE ###

N,K = map(int,input().split())
a = list(map(int,input().split()))
c = []
c_re = [0]
tmp = 0
for e in a:
    tmp += e
    c.append(tmp)
tmp = 0
for e in reversed(a):
    tmp += e
    c_re.append(tmp)
c_re = list(reversed(c_re))
# sum(a) < K ならば0通り
# dp[i][j]:i番目までの子供,残っている飴の個数j ans = dp[N][0]
# 0 <= k <= min(c[i] ,K) - j
# dp[i][j] += dp[i-1][j+k]
dp = [[0]*(K+1) for i in range(N+1)]
dp[0][K] = 1
for i in range(1,N+1):
    inf = K - c[i-1] if K - c[i-1] > 0 else 0
    for j in range(inf,min(c_re[i],K) + 1):
        for k in range(min(a[i-1],K-j) + 1): 
            dp[i][j] += dp[i-1][j+k]
ans = dp[N][0] % (10**9 + 7)
print(ans)

### FIXED CODE ###

mod = 10**9 + 7

def accmulate(array):
    cs = [0]*(len(array)+1)
    for i in range(len(array)):
        cs[i+1] = cs[i] + array[i]
    return cs

def query(l,r):
    return cs[r+1] - cs[l]

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

dp = [[0]*(K+1) for _ in range(N+1)]

dp[0][0] = 1

for i in range(1,N+1):
    cs = accmulate(dp[i-1])
    for j in range(K+1):
        dp[i][j] += query(max(j-A[i-1], 0), j)
        dp[i][j] %= mod

ans = dp[N][K]
print(ans)
### BUGGY CODE ###

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

tmpA = max(a, b)
tmpB = min(a, b)

while tmpB != 0:
    newB = tmpA % tmpB
    tmpA = tmpB
    tmpB = newB

already = [1]
tmp = tmpA

while True:
    if tmp == 1:
        break
    
    for i in range(2, tmp):
        if tmp % i == 0:
            already.append(i)
            tmp = tmp // i
            break
    else:
        already.append(tmp)
        break

print(len(set(already)))


### FIXED CODE ###

import math

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

tmpA = max(a, b)
tmpB = min(a, b)

while tmpB != 0:
    newB = tmpA % tmpB
    tmpA = tmpB
    tmpB = newB

tmp = tmpA
res = 1

for i in range(2, int(math.sqrt(tmp)) + 1):
    if tmp % i == 0:
        res += 1
        tmp //= i
    else:
        continue

    while tmp % i == 0:
        tmp = tmp//i


if tmp != 1:
    res += 1

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

from itertools import combinations
n=int(input())
s=input()
ans=0
set_s=len(set([i for i in s]))
for i in range(1,set_s+1):
    koho=tuple(combinations([j for j in s],i))
    for j in koho:
        if len(j)==len(tuple(set(j))):
            ans+=1
print(ans%(10**9+7))

### FIXED CODE ###

from collections import Counter
n=int(input())
s=input()
cnt=Counter(s)
ans=1
for i in cnt.values():
    ans*=i+1
print((ans-1)%(10**9+7))
### BUGGY CODE ###

n = int(input())
line = input().split(' ')
total_list =[]
for i in range(0,n):
   total = i + int(line[i])
   total_list.append(total)
answer = 0
for i in range(n *2 -1):
    if total_list.count(i) == 2:
        answer += 1
    else:
        answer += 0
print(answer)

### FIXED CODE ###

n = int(input())
a = input().split(' ')
t = 0
for o in range(n):
    i = o + 1
    b = int(a[o]) - i
    if i == int(a[o + b]):
      t += 1
print(int(t / 2))
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n,k=MI()
    aa=LI()
    cs=[0]*(n+1)

    s=0
    for i,a in enumerate(aa,1):
        s+=a%k
        cs[i]=s-i
    #print(cs)
    ans=0
    for r in range(n+1):
        for l in range(max(0,r-k+1),r):
            if (cs[r]-cs[l])%k==0:
                #print(l,r)
                ans+=1
    print(ans)

main()

### FIXED CODE ###

from collections import defaultdict
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n,k=MI()
    aa=LI()
    cs=[0]*(n+1)
    s=0
    for i,a in enumerate(aa,1):
        cs[i]=(cs[i-1]+a-1)%k
    #print(cs)
    cnt=defaultdict(int)
    ans=0
    for i,c in enumerate(cs):
        if i-k>=0:cnt[cs[i-k]]-=1
        ans+=cnt[c]
        cnt[c]+=1
    print(ans)

main()
### BUGGY CODE ###

def main():
    import numpy as np
    s = list(reversed(input()))
    mod = 10**9+7
    memo = np.zeros(13, dtype=np.int64)
    m13 = [(10**i) % 13 for i in range(12)]
    npa13 = np.array([i * np.arange(10) % 13 for i in range(13)])
    memo[0] = 1
    for j, i in enumerate(s):
        memo2 = np.zeros(13, dtype=np.int64)
        a = m13[j % 12]
        if i == "?":
            for l in npa13[a]:
                memo2[l:] += memo[:13-l]
                memo2[:l] += memo[13-l:]
            memo = memo2 % mod
        else:
            l = a*int(i) % 13
            memo = np.append(memo[13-l:], memo[:13-l]) % mod
    print(int(memo[5]))


main()

### FIXED CODE ###

s=list(reversed(input()))
mod=10**9+7
memo=[0 for _ in [0]*13]
m13=[(10**i)%13 for i in range(12)]
memo[0]=1
for i in range(len(s)):
    memo2=[0 for _ in [0]*13]
    a=m13[i%12]
    if s[i]=="?":
        list_=[0,1,2,3,4,5,6,7,8,9]
    else:
        list_=[int(s[i])]
    list_=[(a*j)%13 for j in list_]
    for l in list_:
        for j in range(13):
            memo2[(l+j)%13]+=memo[j]
    memo=[j%mod for j in memo2]
print(memo[5])
### BUGGY CODE ###

maps = input()
people = [{'pos': i, 'prev': -1, 'loop': -1} for i in range(len(maps))]
max_count = 10**100


def update(people, index):
    for p in people:
        if maps[p['pos']] == 'R':
            if p['prev'] == p['pos'] + 1:
                p['loop'] = index
            p['prev'] = p['pos']
            p['pos'] += 1
        else:
            if p['prev'] == p['pos'] - 1:
                p['loop'] = index
            p['prev'] = p['pos']
            p['pos'] -= 1


def get_output(people):
    output = [0] * len(people)

    for p in people:
        output[p['pos']] += 1

    return ' '.join(str(i) for i in output)


for index in range(max_count):
    # print(index, 'before', get_output(people))
    update(people, index)
    # print(index, 'after', get_output(people))

    if len([p for p in people if p['loop'] < 0]) == 0:
        # print(get_output(people))
        for p in people:
            mod = (max_count - p['loop'] + 1) % 2
            # print(mod)
            for i in range(mod):
                if maps[p['pos']] == 'R':
                    p['prev'] = p['pos']
                    p['pos'] += 1
                else:
                    p['prev'] = p['pos']
                    p['pos'] -= 1
        # print(get_output(people))
        break

print(get_output(people))


### FIXED CODE ###

maps = input()
people = [0] * len(maps)

counter = 0
for i in range(len(maps)):
    if maps[i] == 'R':
        counter += 1
        if maps[i+1] == 'L':
            people[i] += (counter+1) // 2
            people[i+1] += counter // 2
    else:
        counter = 0

counter = 0
for i in range(len(maps) - 1, 0, -1):
    if maps[i] == 'L':
        counter += 1
        if maps[i-1] == 'R':
            people[i] += (counter+1) // 2
            people[i-1] += counter // 2
    else:
        counter = 0

print(*people)
### BUGGY CODE ###

numq = int(input())
lis = [1]*100001
lis[0] = 0
lis[1] = 0
i = 2
while(i < 318):
  if lis[i] == 1:
    k = 2
    while(i*k < 100001):
      lis[i*k] = 0
      k += 1
  i += 1
lis2 = [0]*100001

for i in range(1,100001):
  if i % 2 == 1 and lis[i] == lis[(i+1)//2] == 1:
    lis2[i] = 1

for _ in range(numq):
  a,b = map(int,input().split())
  print(sum(lis2[a:b+1]))


### FIXED CODE ###

numq = int(input())
lis = [1]*100001
lis[0] = 0
lis[1] = 0
i = 2
while(i < 318):
  if lis[i] == 1:
    k = 2
    while(i*k < 100001):
      lis[i*k] = 0
      k += 1
  i += 1
lis2 = [0]*100001

for i in range(1,100001):
  if i % 2 == 1 and lis[i] == lis[(i+1)//2] == 1:
    lis2[i] = lis2[i-1] + 1
  else:
    lis2[i] = lis2[i-1]

for _ in range(numq):
  a,b = map(int,input().split())
  print(lis2[b] - lis2[a-1])
### BUGGY CODE ###

x, y, z, k = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse = True)
b = sorted(list(map(int, input().split())), reverse = True)
c = sorted(list(map(int, input().split())), reverse = True)

list = []
for i in range(x):
    for j in range(y):
        list.append(a[i]+b[j])
list.sort(reverse = True)
list = list[:k]

list1 = []
for i in range(len(list)):
    for j in range(z):
        list1.append(list[i]+c[j])
list1.sort(reverse = True)
list1 = list1[:k]

for i in range(k):
    print(list1[i])

### FIXED CODE ###

x, y, z, k = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse = True)
b = sorted(list(map(int, input().split())), reverse = True)
c = sorted(list(map(int, input().split())), reverse = True)

list = []
for aa in a:
    for bb in b:
        list.append(aa+bb)
list.sort(reverse = True)
list = list[:k]

list1 = []
for ab in list:
    for cc in c:
        list1.append(ab+cc)
list1.sort(reverse = True)
list1 = list1[:k]

for i in range(k):
    print(list1[i])
### BUGGY CODE ###


def resolve():
    n, t = map(int, input().split())
    foods = []
    limit = 0
    tt = []
    for i in range(n):
        a, b = map(int, input().split())
        foods.append((a,b))
        limit += a
        tt.append(a)
    c = max(tt) * 2
    foods.sort(key=lambda x:(x[0], -x[1]))
    limit = min(limit * 2, t * 2)
    time = [0 for _ in range(limit+c)]
    used = [0] * (limit + c)
    used[0] = 1

    for a,b in foods:
        for i in range(limit+c)[::-1]:
            if used[i] and i+a*2 < limit + c and time[i+a*2] < time[i] + b:
                time[i+a*2] = time[i] + b
                if i+a*2 < limit:
                    used[i+a*2] = 1

    print(max(time))

if __name__ == "__main__":
    resolve()


### FIXED CODE ###


def resolve():
    n, t = map(int, input().split())
    foods = []
    limit = 0
    tt = []
    for i in range(n):
        a, b = map(int, input().split())
        foods.append((a,b))
        limit += a
        tt.append(a)
    c = max(tt) * 2
    foods.sort(key=lambda x:(x[0], -x[1]))
    limit = min(limit * 2, t * 2)
    time = [0 for _ in range(limit+c)]
    used = [0] * (limit + c)
    used[0] = 1

    for a,b in foods:
        for i in range(limit+c)[::-1]:
            if used[i] and i+a*2 < limit + c and time[i+a*2] < time[i] + b:
                time[i+a*2] = time[i] + b
                if i+a*2 < limit:
                    used[i+a*2] = 1

    print(max(time))

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

n=int(input())
b=list(map(int,input().split()))
count=1
temp=[b[0]]
for i in range(1,n):
  temp.append(b[i])
  if b[i]==min(temp):
    count=count+1  
print(count)

### FIXED CODE ###

n=int(input())
b=list(map(int,input().split()))
count=1
temp=b[0]
for i in range(1,n):  
  if b[i]==min(b[i],temp):
    count=count+1
    temp=b[i]
print(count)
### BUGGY CODE ###

def solve():
    N,M,S = map(int,input().split())
    UVAB = [tuple(map(int,input().split())) for i in range(M)]
    CD = [tuple(map(int,input().split())) for i in range(N)]

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

    INF = float('inf')
    times = [INF] * (2501 * N)
    start = min(2500,S)*N
    times[start] = 0
    hq = [(0,start)]
    ans = [-1] * N
    reached = set()
    import heapq
    heapq.heapify(hq)
    while hq:
        t,v = heapq.heappop(hq)
        s,i = divmod(v,N)
        if ans[i] < 0:
            ans[i] = t
            reached.add(i)
            if len(reached) == N: break
        for to,a,b in es[i]:
            if a > s: continue
            nv = (s-a)*N + to
            if times[nv] <= t + b: continue
            times[nv] = t + b
            heapq.heappush(hq, (t+b, nv))
        ns = s
        nt = times[v]
        while ns <= 2500:
            ns += CD[i][0]
            nt += CD[i][1]
            nv = min(2500,ns)*N + i
            if times[nv] <= nt: continue
            times[nv] = nt
            heapq.heappush(hq, (nt, nv))
    print(*ans[1:], sep='\n')
solve()

### FIXED CODE ###

def solve():
    import sys
    input = sys.stdin.readline
    N,M,S = map(int,input().split())
    UVAB = [tuple(map(int,input().split())) for i in range(M)]
    CD = [tuple(map(int,input().split())) for i in range(N)]

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

    INF = float('inf')
    times = [INF] * (2501 * N)
    start = min(2500,S)*N
    times[start] = 0
    hq = [start]
    ans = [-1] * N
    ans[0] = 0
    reached = 0
    import heapq
    heapq.heapify(hq)
    while hq:
        x = heapq.heappop(hq)
        t,v = divmod(x,N*2501)
        s,i = divmod(v,N)
        if ans[i] < 0:
            ans[i] = t
            reached += 1
            if reached == N-1: break
        for to,a,b in es[i]:
            if a > s: continue
            nv = (s-a)*N + to
            if times[nv] <= t + b: continue
            times[nv] = t + b
            heapq.heappush(hq, (t+b)*N*2501 + nv)
        ns = s
        nt = times[v]
        while ns <= 2500:
            ns += CD[i][0]
            nt += CD[i][1]
            nv = min(2500,ns)*N + i
            if times[nv] <= nt: break
            times[nv] = nt
            heapq.heappush(hq, nt*N*2501 + nv)
    print(*ans[1:], sep='\n')
solve()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
h, n = map(int, input().split())
l = []
for i in range(n):
  a, b = map(int, input().split())
  l.append([a, b])

dp = [10 ** 9 for i in range(h+1)]

for i in range(h+1):
  for j in range(n):
    if l[j][0] >= i:
      if dp[i] > l[j][1]:
        dp[i] = l[j][1]
    else:
      if dp[i] > l[j][1] + dp[i-l[j][0]]:
        dp[i] = l[j][1] + dp[i-l[j][0]]


print(dp[h])


### FIXED CODE ###

def main():
    from sys import stdin
    readline = stdin.readline
    H, N = map(int, readline().split())
    AB = [list(map(int, readline().split())) for _ in range(N)]

    dp = [100000000] * (H + 10 ** 4 + 1)
    dp[0] = 0
    for i in range(H):
        if dp[i] == 100000000:
            continue
        for a, b in AB:
            t = dp[i] + b
            if t < dp[i + a]:
                dp[i + a] = t
    print(min(dp[H:]))


main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

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

FRIEND = [[0]*n for _ in range(n)]
BLOCK = [[0]*n for _ in range(n)]

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

for _ in range(k):
    a, b = map(lambda x: int(x)-1, input().split())
    BLOCK[a][b] = BLOCK[b][a] = 1


def make_dfs():
    visited = [0] * n

    def inner(v):
        visited[v] = 1
        for v2 in range(n):
            if not FRIEND[v][v2]:
                continue
            if visited[v2]:
                continue
            inner(v2)
        return visited
    return inner


ans = [-1]*n

for i in range(n):
    friends = FRIEND[i]
    dfs = make_dfs()
    possibly_friends = dfs(i)
    blocks = BLOCK[i]

    for f, pf, b in zip(friends, possibly_friends, blocks):
        if pf and (not f) and (not b):
            ans[i] += 1

print(*ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

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

class UnionFind:
    def __init__(self, n):
        self.p = [-1]*n
        self.c = None

    def find(self, x):
        if self.p[x] < 0:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def union(self, x, y):
        rx, ry = self.find(x), self.find(y)
        if rx != ry:
            self.p[ry] += self.p[rx]
            self.p[rx] = ry

    def count_member(self, x):
        return -self.p[self.find(x)]


uf = UnionFind(n)

ab = []
for i in range(m):
    a, b = map(lambda x: int(x)-1, input().split())
    ab.append((a, b))
    uf.union(a, b)

cd = [list(map(lambda x: int(x)-1, input().split())) for _ in range(k)]
ans = [uf.count_member(i)-1 for i in range(n)]

for a, b in ab:
    if uf.find(a) == uf.find(b):
        ans[a] -= 1
        ans[b] -= 1

for c, d in cd:
    if uf.find(c) == uf.find(d):
        ans[c] -= 1
        ans[d] -= 1

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

import math
A ,B ,N = map(int,input().split())
l = []
for x in range(1,N+1):
    l.append(math.floor(A*x/B)-A*math.floor(x/B))
print(max(l))

### FIXED CODE ###

A , B , N = map(int,input().split())
x = min(B-1,N)
print((A*x)//B)
### BUGGY CODE ###

# %%time
# N = 20000
# A_list = list(range(N))
N = int(input())
A_list = list(map(int, input().split()))
total = 0
A_counts = []
for i in range(1, N+1):
    i_count = A_list.count(i)
    A_counts.append(i_count)
    total += i_count*(i_count-1)//2
for k in range(N):
    A_k_count = A_counts[A_list[k]-1]
    print(total-(A_k_count-1))

### FIXED CODE ###

import collections
N = int(input())
A_list = list(map(int, input().split()))
A_collection=collections.Counter(A_list)
total=0
for i in A_collection.values():
    total+=i*(i-1)//2
for k in A_list:
    print(total-(A_collection[k]-1))
### BUGGY CODE ###

k,s = map(int,input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        z = s - x - y
        
        if z + x + y == s and 0 <= z <= k:
            ans += 1
print(ans)

### FIXED CODE ###

k, s = map(int, input().split())
x = 0
for i in range(k+1):
    for j in range(k+1):
        z = s - i - j
        if 0 <= z and  z <= k:
            x += 1
print(x)
### BUGGY CODE ###

a=0
S=input()
N=len(S)
for i in range(N-3):
  for j in range(i+3,N):
    if int(S[i:j+1])%2019==0:
      a=a+1
print(a)

### FIXED CODE ###

ans=0
S=input()
a=len(S)
k=0
c=dict()
mod=2019
s=1
c[0]=1
for i in range(a):
  k+=(s*int(S[a-i-1]))
  k%=mod
  s*=10
  s%=mod
  if k in c:
    c[k]+=1
  else:
    c[k]=1
for i in c:
  ans+=c[i]*(c[i]-1)//2
print(ans)
### BUGGY CODE ###

n,m = map(int, input().split())
a = list(map(int, input().split()))
lis = [2,5,5,4,5,6,3,7,6]
mat=[]
for num in a:
    mat.append([num,lis[num-1]])

def new_val(num1,num2): # 123 , 4 -> 4123
    if num1<0:
        return -(10**10)
    if num1==0:
        return num2
    return max(int(str(num2)+str(num1)),int(str(num1)+str(num2)))

dp = [[-(10**10) for i in range(1+n)] for j in range(1+m)]
for i in range(m):
    dp[i][0]=0

for i in range(m):
    num=mat[i][0]
    honsu=mat[i][1]
    for j in range(1+n):
        if j<honsu:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(new_val(dp[i+1][j-honsu] , num),dp[i][j])
print(dp[-1][-1])

### FIXED CODE ###

n,m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
lis = [2,5,5,4,5,6,3,7,6]
def new_val(num1,num2): # 123 , 4 -> 1234
    if num1<0:
        return -(10**10)
    if num1==0:
        return num2
    ret = (10**len(str(num2)))*num1 + num2
    return ret

dp = [[-(10**10) for i in range(1+n)] for j in range(1+m)]
for i in range(m):
    dp[i][0]=0

for i in range(m):
    num=a[i]
    honsu=lis[a[i]-1]
    for j in range(1+n):
        if j<honsu:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(new_val(dp[i+1][j-honsu] , num),dp[i][j])
print(dp[-1][-1])
### BUGGY CODE ###

l,r = map(int,input().split())
ans = []
for i in range(l,r):
    for j in range(l+1,r+1):
        ans.append((i*j)%2019)
print(min(ans))

### FIXED CODE ###

import sys
l,r = map(int,input().split())
ans = int(2018)
if(r-l > 2020):
    print(0)
    sys.exit()
else:
    for i in range(l,r):
        for j in range(l+1,r+1):
            if((i*j)%2019 < ans):
                ans = (i*j)%2019
print(ans)
### BUGGY CODE ###

n, k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
d=sorted([a.count(i) for i in range(n)])[::-1]
print(n-sum(d[:k]))


### FIXED CODE ###

n, k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
d={i:0 for i in set(a)}
for i in a: d[i]+=1
print(n-sum([t[1] for t in sorted(d.items(), key=lambda x:-x[1])][:k]))
### BUGGY CODE ###

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

ans = 0
s = [(K, V[:], [])]
while s:
    cnt, v, bag = s.pop()
    ans = max(ans, sum(bag))
    if cnt > 0 and v:
        s.append((cnt-1, v[1:], bag + [v[0]]))
        s.append((cnt-1, v[:-1], bag + [v[-1]]))
    if cnt > 0 and bag:
        bag.sort()
        s.append((cnt-1, [bag[0]] + v, bag[1:]))
        s.append((cnt-1, v + [bag[0]], bag[1:]))

print(ans)

### FIXED CODE ###

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

ans = 0
for l in range(K+1):
    for r in range(K-l+1):
        if l + r < N:
            bag = V[:l] + V[N-r:] + [0]
            rest_ope = K-l-r
        else:
            bag = V[:]
            rest_ope = K - N
        for _ in range(rest_ope):
            min_bag = min(bag)
            if min_bag < 0 and rest_ope > 0:
                bag.remove(min_bag)
                rest_ope -= 1
        else:
            ans = max(ans, sum(bag))

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

from itertools import accumulate

N, *A = map(int, open(0).read().split())

S = [0] + list(accumulate(A))

memo = {}
def dp(L, R):
    if L == R:
        return 0
    if (L, R) in memo:
        return memo[(L, R)]

    memo[(L, R)] = min(dp(L, c) + dp(c + 1, R) + S[R + 1] - S[L] for c in range(L, R))
    return memo[(L, R)]

print(dp(0, N - 1))

### FIXED CODE ###

from itertools import accumulate

N, *A = map(int, open(0).read().split())

S = [0] + list(accumulate(A))

memo = [[-1] * N for _ in range(N)]
def dp(L, R):
    if L == R:
        return 0
    if memo[L][R] >= 0:
        return memo[L][R]

    memo[L][R] = min(dp(L, c) + dp(c + 1, R) + S[R + 1] - S[L] for c in range(L, R))
    return memo[L][R]

print(dp(0, N - 1))