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

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

sum_a = sum(arr_a)
mod = 10**9 + 7

ans = 0
for i in range(n):
    b = sum(arr_a[i+1:])
    ans += arr_a[i] * b
    ans = ans % mod

print(ans)


### FIXED CODE ###

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

mod = 10**9 + 7
memo = {}

for i in range(n):
    if i == 0:
        memo[n-i-1] = 0
    else:
        memo[n-i-1] = (memo[n-i] + arr_a[n-i]) % mod

ans = 0
for i in range(n):
    ans += arr_a[i] * memo[i]
    ans = ans % mod

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

N = int(input())
s = N
for i in range(1, N+1):
    for j in range(1, N+1):
        if N == i * j:
            flag = i + j - 2

            if flag <= s:
                s = flag

print(s)

### FIXED CODE ###


N = int(input())
s = N-1
a = N
b = 1
for i in range(int(N**0.5)+1, 1, -1):
        if N%i == 0:
            a = i
            b = N//i
            s = a + b -2
            break

print(s)
### BUGGY CODE ###

from collections import deque

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

links = [deque() for x in range(n + 1)]
sums = [0 for x in range(n + 1)]
adds = [0 for x in range(n + 1)]

links[0].append(1)
for _ in range(n - 1):
  a, b= map(int, input().split())
  links[a].append(b)
  links[b].append(a)

for _ in range(m):
  p, x = map(int, input().split())
  adds[p] += x

que = [0,[1]]
checked = [0 for x in range(n+1)]

que = [[-1, [0]]]

while que:
  link = que.pop()
  par = link[0]
  childs = link[1]

  for child in childs:
    if checked[child] != 1:
      sums[child] = sums[par] + adds[child]
      que.append([child, links[child]])
      checked[child] = 1

  
print(*sums[1:])

### FIXED CODE ###

from collections import defaultdict

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

links = [[] for x in range(n + 1)]
sums = [0 for x in range(n + 1)]
adds = [0 for x in range(n + 1)]

links[0].append(1)
for _ in range(n - 1):
  a, b= map(int, input().split())
  links[a].append(b)
  links[b].append(a)

for _ in range(m):
  p, x = map(int, input().split())
  adds[p] += x

# print(links)
que = [0,[1]]
checked = [0 for x in range(n+1)]

que = [[-1, [0]]]

while que:
  link = que.pop()
  # print(link)
  par = link[0]
  childs = link[1]

  for child in childs:
    if checked[child] != 1:
      sums[child] = sums[par] + adds[child]
      que.append([child, links[child]])
      checked[child] = 1

  
print(*sums[1:])
### BUGGY CODE ###

import math
h, n = map(int, input().split())
a, b = [], []
for i in range(n):
  x, y = map(int, input().split())
  a.append(x)
  b.append(y)

c = [min(b)] + [h*max(b)]*(h-1)

for i in range(1,h):
  for j in range(n):
    if a[j] >= i+1:
      c[i] = min(c[i], b[j])
    else:
      c[i] = min(c[i], c[i-a[j]]+b[j])
print(c[h-1])

### FIXED CODE ###

import math
h, n = map(int, input().split())
a, b = [], []
for i in range(n):
  x, y = map(int, input().split())
  a.append(x)
  b.append(y)

c = [min(b)] + [h*max(b)]*(h-1)

for i in range(1,h):
  for j in range(n):
    if a[j] >= i+1:
      c[i] = min(c[i], b[j])
    else:
      c[i] = min(c[i], c[i-a[j]]+b[j])
print(c[h-1])
### BUGGY CODE ###

from collections import Counter
n=int(input())
c=input()
d=Counter(c)
MIN=min(Counter(c)["W"],Counter(c)["R"])
ans=[]

for i in range(MIN):
  w=Counter(c[:i])["W"]
  r=Counter(c[i:])["R"]
  if w<=r:
    ans.append(r)
  else:
    ans.append(w)

if ans:
  print(min(ans))
else:
  print(0)

### FIXED CODE ###

from collections import Counter
n=int(input())
c=input()
d=Counter(c)
w,r=Counter(c)["W"], Counter(c)["R"]
ans=0
for i in range(r):
  if c[i]=="W":
    ans+=1

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

K,S = map(int, input().split())

count = 0
for i in range(K+1):
  for j in range(K+1):
    for k in range(K+1):
      if i + j + k == S:
        count += 1

print(count)

### FIXED CODE ###

K,S = map(int, input().split())

count = 0
for i in range(K+1):
  for j in range(K+1):
    if  0 <= S - i - j <= K:
      count += 1
print(count)
### BUGGY CODE ###

import sys

S = input()
T = input()

limit = len(S) * pow(10, 100)

count = 0

t_indexs = []

is_contain = True
for t in T:
    current_index = [i + 1 for i, x in enumerate(S) if x == t]
    if len(current_index) == 0:
        is_contain = False
        break

    t_indexs.append(current_index)

if not is_contain:
    print(-1)
    sys.exit()

is_limit = False


ans = 0
previous_count = 0
for t_index in t_indexs:
    # preよりうえで最小
    is_in_current = False
    add_index = -1
    for t in t_index:
        if previous_count < t:
            add_index = t
            is_in_current = True
            break
    if is_in_current:
        ans += (add_index - previous_count) 
        previous_count = add_index
    else:
        ans += t_index[0] + len(S) - previous_count
        previous_count = t_index[0]

    if ans > limit:
        is_limit = True
        break

if is_limit:
    print(-1)
    sys.exit()

print(ans)


### FIXED CODE ###

import bisect
import sys
S = input()
T = input()


# sが何番目に出てくるかの辞書をついくる
s_index = {}
for i in range(len(S)):
    if S[i] in s_index:
        s_index[S[i]].append(i + 1)
    else:
        s_index[S[i]] = [i+1]


current_s_index = 0
loop_count = 0
ans = 0
for t in T:
    if not t in s_index:
        print(-1)
        sys.exit()

    if current_s_index >= s_index[t][-1]:
        current_s_index = s_index[t][0]
        loop_count += 1
    else:
        index = bisect.bisect(s_index[t], current_s_index)
        current_s_index = s_index[t][index]

print(current_s_index + loop_count * len(S))
### BUGGY CODE ###

def main():
    a, b, m = map(int, input().split())
    priceOfMicrowaves = list(map(int, input().split()))
    priceOfRefrigerators = list(map(int, input().split()))
    priceTable = [list(map(int,input().split())) for i in range(m)]
    cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
    for p in priceOfMicrowaves:
        for q in priceOfRefrigerators:
            if p + q < cheepest:
                cheepest = p + q
    for price in priceTable:
        if priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
            cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
    print(cheepest)
    
main()

### FIXED CODE ###

a, b, m = map(int, input().split())
priceOfMicrowaves = list(map(int, input().split()))
priceOfRefrigerators = list(map(int, input().split()))
priceTable = [list(map(int,input().split())) for i in range(m)]
cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
for price in priceTable:
    if priceOfMicrowaves[price[0]-1]-price[2] >= cheepest:
        continue
    elif priceOfRefrigerators[price[1]-1]-price[2] >= cheepest:
        continue
    elif priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
        cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
if cheepest > min(priceOfMicrowaves) + min(priceOfRefrigerators):
    cheepest = min(priceOfMicrowaves) + min(priceOfRefrigerators)
print(cheepest)
### BUGGY CODE ###


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

HSum=[0 for _ in range(H)]
WSum=[0 for _ in range(W)]


bombs = set()
for _ in range(M):
	hi,wi = map(lambda x:int(x)-1,input().split())
	HSum[hi] += 1
	WSum[wi] += 1
	bombs.add( (hi,wi) )
# print(HSum)
# print(WSum)



curMax = 0

## 計算量多すぎ。。
# for h in range(H):
# 	for w in range(W):
# 		tmp = HSum[h] + WSum[w]
# 		if curMax <= tmp:
# 			if (h,w) in bombs:
# 				tmp -= 1
# 			curMax = max( curMax, tmp )

hMax = max(HSum)
wMax = max(WSum)
tmpMax = hMax + wMax

ans = 0

# hSumMaxOnly = [h for h, x in enumerate(HSum) if x == hMax]
# wSumMaxOnly = [w for w, y in enumerate(WSum) if y == wMax]

for h in [h for h, x in enumerate(HSum) if x == hMax]:
	if ans == tmpMax:
		break
	for w in [w for w, y in enumerate(WSum) if y == wMax]:
		if (h,w) in bombs:
			ans = tmpMax - 1
		else:
			ans = tmpMax
			break



print(ans)


### FIXED CODE ###


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

HSum=[0 for _ in range(H)]
WSum=[0 for _ in range(W)]


bombs = set()
for _ in range(M):
	hi,wi = map(lambda x:int(x)-1,input().split())
	HSum[hi] += 1
	WSum[wi] += 1
	bombs.add( (hi,wi) )
# print(HSum)
# print(WSum)



curMax = 0

## 計算量多すぎ。。
# for h in range(H):
# 	for w in range(W):
# 		tmp = HSum[h] + WSum[w]
# 		if curMax <= tmp:
# 			if (h,w) in bombs:
# 				tmp -= 1
# 			curMax = max( curMax, tmp )

hMax = max(HSum)
wMax = max(WSum)
tmpMax = hMax + wMax

ans = 0

hSumMaxOnly = [h for h, x in enumerate(HSum) if x == hMax]
wSumMaxOnly = [w for w, y in enumerate(WSum) if y == wMax]

for h in hSumMaxOnly:
	if ans == tmpMax:
		break
	for w in wSumMaxOnly:
		if (h,w) in bombs:
			ans = tmpMax - 1
		else:
			ans = tmpMax
			break



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

n = int(input())
a = [int(input()) 
     for nesya in range(n)]
s = set(a)
ans = 0
for i in range(len(s)):
  c = a.count(s.pop())
  if c%2 == 1:
    ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
a = [int(input()) 
     for nesya in range(n)]
s = set()
for b in a:
  if b in s:
    s.discard(b)
  else:
    s.add(b)
print(len(s))
### BUGGY CODE ###

n, m = map(int, input().split())
d = {i+1 : [] for i  in range(n)}
for _ in range(m):
    u, v = map(int, input().split())
    d[u].append(v)
s, t = map(int, input().split())
q = set([s])
visited = set([s])
c = 1
def solve():
    global visited, c, q
    while True:
        q2 = list(q)
        q = set([])
        for v in q2:
            es = set([e3 for e1 in d[v] for e2 in d[e1] for e3 in d[e2]]) - visited
            if t in es:
                return c
            else:
                visited |= es
                q |= es
        if not len(q):
            return -1
        c += 1
print(solve())


### FIXED CODE ###

n, m = map(int, input().split())
d = {i+1 : [] for i  in range(n)}
for _ in range(m):
    u, v = map(int, input().split())
    d[u].append(v)

visited1 = [False for i in range(n+1)]
visited2 = [False for i in range(n+1)]
visited3 = [False for i in range(n+1)]

s, t = map(int, input().split())
q = set([s])
c = 1
def solve():
    global visited1, visited2,visited3,  c, q
    while True:
        q2 = list(q)
        q = set([])
        for v in q2:
            for e1 in d[v]:
                if visited1[e1]:
                    continue
                visited1[e1] = True
                for e2 in d[e1]:
                    if visited2[e2]:
                        continue
                    visited2[e2] = True
                    for e3 in d[e2]:
                        if visited3[e3]:
                            continue
                        visited3[e3] = True
                        if e3 == t:
                            return c
                        else:
                            q.add(e3)
        if not len(q):
            return -1
        c += 1
print(solve())
### BUGGY CODE ###

import bisect,collections,copy,heapq,itertools,math,string
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
d = LIST()
m = INT()
t = LIST()
for x in t:
    if(x in d):
        d.remove(x)
    else:
        print("NO")
        exit()
print("YES")

### FIXED CODE ###

import bisect,collections,copy,heapq,itertools,math,string
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
d = LIST()
m = INT()
t = LIST()
d.sort()
t.sort()
j = 0
for i in range(n):
    if(d[i]==t[j]):
        j += 1
    if(j == m):
        break
if(j == m):
    print("YES")
else:
    print("NO")
### BUGGY CODE ###

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

L.sort()

value = 0
for i in range(len(L)-2):
    for j in range(i+1, len(L)-1):
        for k in range(j+1, len(L)):
            a = L[i]
            b = L[j]
            c = L[k]
            if c < a+b:
                if a < c+b:
                    if b < c+a:
                        value+=1
            else:
                break
                

print(value)

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
l.sort()
 
from bisect import bisect_left
ans = 0
for i in range(n):
  for j in range(i+1, n):
    t = l[i]+l[j]
    idx = bisect_left(l, t)
    ans += max(0, idx-j-1)
print(ans)
### BUGGY CODE ###

N, M, Q = map(int, input().split())
abcd = []
for i in range(Q): abcd.append(list(map(int, input().split())))
ans = 0
per_lst = []
def make_per(lst, n, m):
    n_lst = lst.copy()
    n_lst.append(0)
    if n == 1:
        for i in range(1, m+1):
            n_lst = n_lst.copy()
            n_lst[-1] = i
            if len(n_lst) > 1:
                if i >= n_lst[-2]:
                    per_lst.append(n_lst)
            else:
                per_lst.append(n_lst)
    else:
        for i in range(1, m+1):
            n_lst[-1] = i
            if len(n_lst) > 1:
                if i >= n_lst[-2]:
                    make_per(n_lst, n-1, m)
            else:
                make_per(n_lst, n-1, m)

make_per([], N, M)
# for i in per_lst:
#     print(i)
maxi = 0
for per in per_lst:
    score = 0
    for i in range(Q):
        a, b, c, d = abcd[i][0], abcd[i][1], abcd[i][2], abcd[i][3]
        a -= 1
        b -= 1
        if (per[b] - per[a]) == c: score += d
    if score > maxi: maxi = score
print(maxi)

### FIXED CODE ###

N, M, Q = map(int, input().split())
abcd = []
for i in range(Q): abcd.append(list(map(int, input().split())))
ans = 0
per_lst = []
def make_per(lst, n, m):
    n_lst = lst.copy()
    n_lst.append(0)
    if n == 1:
        for i in range(1, m+1):
            n_lst = n_lst.copy()
            n_lst[-1] = i
            if len(n_lst) > 1:
                if i >= n_lst[-2]:
                    per_lst.append(n_lst)
            else:
                per_lst.append(n_lst)
    else:
        for i in range(1, m+1):
            n_lst[-1] = i
            if len(n_lst) > 1:
                if i >= n_lst[-2]:
                    make_per(n_lst, n-1, m)
            else:
                make_per(n_lst, n-1, m)

make_per([], N, M)
# for i in per_lst:
#     print(i)
maxi = 0
for per in per_lst:
    score = 0
    for i in range(Q):
        a, b, c, d = abcd[i][0], abcd[i][1], abcd[i][2], abcd[i][3]
        a -= 1
        b -= 1
        if (per[b] - per[a]) == c: score += d
    if score > maxi: maxi = score
print(maxi)
### BUGGY CODE ###

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

for i in range(1,N+1):
    print(sum(x == i for x in A))


### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
m = [0]*N #0~N-1

for i in A:
    m[i-1] += 1
# print(m)
for i in range(N):
    print(m[i])
### BUGGY CODE ###

S = input()
p = 10 ** 9 + 7
DP = [0, 0, 0, 1]
for i in range(len(S) - 1, -1, -1):
  dp = [0] * 4
  for j in range(3, -1, -1):
    if j == 3:
      dp[j] = DP[3] * (3 if S[i] == '?' else 1)
    else:
      dp[j] += DP[j + 1] * (1 if S[i] == chr(65 + j) or S[i] == '?' else 0)
      dp[j] += DP[j] * (3 if S[i] == '?' else 1)
      dp[j] % p
  DP = [x for x in dp]
print(DP[0] % p)

### FIXED CODE ###

S = input()
p = 10 ** 9 + 7
DP = [0, 0, 0, 1]
dp = [0] * 4
for i in range(len(S) - 1, -1, -1):
  for j in range(3, -1, -1):
    if j == 3:
      dp[j] = DP[3] * (3 if S[i] == '?' else 1) % p
    elif S[i] == '?':
      dp[j] = (3 * DP[j] + DP[j + 1]) % p
    elif S[i] == chr(65 + j):
      dp[j] = (DP[j] + DP[j + 1]) % p
    else:
      dp[j] = DP[j]
  DP = [x for x in dp]
print(DP[0] % p)
### BUGGY CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
#from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, M, Q = na()
dp = [[0] * (N + 3) for _ in range(N + 3)]
for i in range(M):
    l, r = na()
    for x in range(1, l+1):
        for y in range(r, N+1):
            dp[x][y] += 1

for i in range(Q):
    p, q = na()
    print(dp[p][q])


### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, M, Q = na()
dp = [[0] * (N + 3) for _ in range(N + 3)]
for i in range(M):
    l, r = na()
    dp[1][r] += 1
    dp[l+1][r] -= 1
    dp[l][N+1] -= 1

for i in range(N+1):
    for j in range(N+1):
        dp[i][j+1] += dp[i][j]

for j in range(N+1):
    for i in range(N+1):
        dp[i+1][j] += dp[i][j]

for i in range(Q):
    p, q = na()
    print(dp[p][q])
### BUGGY CODE ###

N, M = map(int, raw_input().split())
S = [True]*(N+1)
for _ in range(M):
  a = input()
  S[a] = False
T = [0]*(N+1)
T[0] = 1
T[1] = 1 if S[1] else 0
for i in range(2, N+1):
  if S[i]:
    T[i] = (T[i-1]+T[i-2])%1000000007
print T[N]

### FIXED CODE ###

N, M = map(int, raw_input().split())
S = [True]*(N+1)
for _ in range(M):
  a = input()
  S[a] = False
T = [0]*(N+1)
T[0] = 1
T[1] = 1 if S[1] else 0
for i in range(2, N+1):
  if S[i]:
    T[i] = (T[i-1]+T[i-2])%1000000007
print T[N]
### BUGGY CODE ###

import sys
input = sys.stdin.buffer.readline

r, c, k = map(int, input().split())
v = [[0]*(c+1) for i in range(r+1)]
for i in range(k):
    cr, cc, cv = map(int, input().split())
    v[cr][cc] = cv

dp = [[0]*4 for _ in range(c+1)]
last = [[0]*4 for _ in range(c+1)]
for cr in range(1, r+1):
    for cc in range(1, c+1):
        upper = max(last[cc][0], last[cc][1], last[cc][2], last[cc][3])
        dp[cc][0] = max(upper, dp[cc-1][0], dp[cc][0])
        dp[cc][1] = max(dp[cc-1][1], dp[cc-1][0]+v[cr][cc], upper+v[cr][cc])
        dp[cc][2] = max(dp[cc-1][2], dp[cc-1][1]+v[cr][cc])
        dp[cc][3] = max(dp[cc-1][3], dp[cc-1][2]+v[cr][cc])
        last = dp
print(max(dp[c]))

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

r, c, k = map(int, input().split())
v = [[0]*(c+1) for i in range(r+1)]
for i in range(k):
    cr, cc, cv = map(int, input().split())
    v[cr][cc] = cv

dp = [[0]*4 for _ in range(c+1)]
last = [[0]*4 for _ in range(c+1)]
for cr in range(1, r+1):
    for cc in range(1, c+1):
        upper = max(last[cc][0], last[cc][1], last[cc][2], last[cc][3])
        dp[cc][0] = max(upper, dp[cc-1][0], dp[cc][0])
        dp[cc][1] = max(dp[cc-1][1], dp[cc-1][0]+v[cr][cc], upper+v[cr][cc])
        dp[cc][2] = max(dp[cc-1][2], dp[cc-1][1]+v[cr][cc])
        dp[cc][3] = max(dp[cc-1][3], dp[cc-1][2]+v[cr][cc])
        last = dp
print(max(dp[c]))
### BUGGY CODE ###

N, M = map(int,input().split())
a = list(map(int,input().split()))
check = []
for i in range(M):
    check.append(list(map(int,input().split())))
check.sort(key=lambda x : x[1],reverse = True)
a.sort()
ans = []
for b, c in check:
    ans += [c for i in range(b)]
if len(ans) <= N:
    ans+=[0 for i in range(N-len(ans))]
A=0
for i in range(N):
    A+=max(ans[i],a[i])
print(A)

### FIXED CODE ###

N, M = map(int,input().split())
a = list(map(int,input().split()))
check = []
for i in range(M):
    check.append(list(map(int,input().split())))
check.sort(key=lambda x : x[1],reverse = True)
a.sort()
ans = []
for b, c in check:
    ans += [c for i in range(b)]
    if len(ans) > N:
        break
else:
    ans+=[0 for i in range(N-len(ans))]
A=0
for i in range(N):
    A+=max(ans[i],a[i])
print(A)
### BUGGY CODE ###

import numpy as np
n, m = list(map(int, input().split()))
rl = [list(map(int, input().split())) for i in range(m)]

ranges = np.array([0] * (n))
for r, l in rl:
  ranges[r-1:l] += 1
  
print((ranges == m).sum())

### FIXED CODE ###

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

R, L = [], []
for i in range(m):
  l, r = list(map(int, input().split()))
  R.append(r)
  L.append(l)
  
print(max(min(R) - max(L) + 1, 0))
### BUGGY CODE ###

A,B,K = [int(i) for i in input().rstrip().split()]

nums=[i for i in range(A,B+1)]

if K <= len(nums)/2:
  print(*(nums[:K] + nums[-K:]),sep="\n")
else:
  print(*nums,sep="\n")

### FIXED CODE ###

A,B,K = [int(i) for i in input().rstrip().split()]

if K <= (B-A+1)/2:
  print(*( list(range(A,A+K)) + list(range(B-K+1,B+1)) ),sep="\n")
else:
  print(*list(range(A,B+1)),sep="\n")
### BUGGY CODE ###

while 1:
 n=int(input())
 if n:
  a=[int(input())for _ in[0]*n]
  print(max(sum(a[i:j+1])for i in range(n)for j in range(i,n)))


### FIXED CODE ###

while 1:
 n=int(input())
 if n==0:break
 a=[int(input())for _ in[0]*n]
 for i in range(1,n):a[i]=max(a[i],a[i]+a[i-1])
 print(max(a))
### BUGGY CODE ###

N = int(input())
L = [n for n in map(int,input().split())]
res = 1 #一つ目はどれよりも”大きい”
k = 0
i = 1
while i<N:
    if L[i] > max(L[0:i+1]):
        i+=1
    elif L[i] == min(L[0:i+1]):
        res += 1
        i+=1
    else:
        i+=1
print(res)   

### FIXED CODE ###

N = int(input())
L = [_ for _ in map(int,input().split())]
res = 0
for x in L:
  if x <= N:
    res += 1
    N = x #最小上書き。次にresが増えるのは後々の要素で最小より小さいのが出てきたとき。
print(res)
#みんなもtabulationミスってREには気をつけようね
### BUGGY CODE ###

arr = [0 for i in range(2019)]
arr[0] = 1

s = input()
n = len(s)

for i in range(1,n+1):
    num = int(s[-i:])
    arr[num%2019] += 1

ans = 0
for i,m in enumerate(arr):
    if m==0: continue
    ans += m*(m-1)//2

print(ans)



### FIXED CODE ###

arr = [0 for i in range(2019)]
arr[0] = 1

s = input()
n = len(s)

num = 0
for i,ele in enumerate(s[::-1]):
    num += int(ele) * pow(10, i, 2019)
    arr[num%2019] += 1


ans = 0
for m in arr:
    if m==0: continue
    ans += m*(m-1)//2

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

import numpy as np


def main():
    N, K = map(int, input().split())
    H = list(map(int, input().split()))
    for i in range(K):
        H.append(10**10)

    dp = np.full(N+K, 10**10, np.int64)
    dp[0] = 0

    for i in range(N):
        for k in range(1, K+1):
            dp[i+k] = min(dp[i+k], dp[i] + abs(H[i+k] - H[i]))


    print(dp[N-1])


main()


### FIXED CODE ###

import sys

readline = sys.stdin.buffer.readline


def main():
    N, K = map(int, readline().split())
    H = list(map(int, readline().split()))
    for i in range(K):
        H.append(10**10)

    dp = [10**10] * (N+K)
    dp[0] = 0

    for i in range(N):
        for k in range(1, K+1):
            dp[i+k] = min(dp[i+k], dp[i] + abs(H[i+k]-H[i]))

    print(dp[N-1])


main()