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

A,B,K=map(int,input().split())
for i in range(A,B+1):
  if i<A+K or B-K<i:
    print(i)

### FIXED CODE ###

A,B,K=map(int,input().split())
for i in range(A,min(A+K,B+1)):
  print(i)
for j in range(max(A+K,B-K+1),B+1):
  print(j)
### BUGGY CODE ###

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

if A.count(0)>1:
  print(0)
  exit()
m=n
for i in set(A):
  if A.count(i)>3:
    print(0)
    exit()
  else:
    m-=1
print(2**m)

### FIXED CODE ###

n=int(input())
A=list(map(int,input().split()))
  
cnt=[abs(i-(n-i-1)) for i in range(n)]
if sorted(A)==sorted(cnt):
  print((2**(n//2))%(10**9+7))
else:
  print(0)
### BUGGY CODE ###

N,Q = map(int,input().split())
S = input()
for i in range(Q):
    l, r = map(int,input().split())
    print(S[l-1:r].count("AC"))


### FIXED CODE ###

N,Q = map(int,input().split())
S = input()

AC_list = [0]*(N+1)
for i in range(N):
    if S[i:i+2] == "AC":
        AC_list[i+1] = AC_list[i]+1
    else:
        AC_list[i+1] = AC_list[i]

for i in range(Q):
    l, r = map(int,input().split())
    print(AC_list[r-1]-AC_list[l-1])
### BUGGY CODE ###

import heapq

n = int(input())

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

func = lambda p: p * (-1)

b = list(map(func,a[:]))

#print(a)
#print(b)

l = [0] * (3*n)

first = a[0:n]
second = b[2*n:3*n]

x = [0] * (3*n)
y = [0] * (3*n)

x[n-1] = sum(first)
y[2*n-1] = sum(second)

heapq.heapify(first)
heapq.heapify(second)

for i in range(n,2*n):
    heapq.heappushpop(first, a[i])
    x[i] = sum(first)

for i in range(n,2*n):
    heapq.heappushpop(second, b[-i-1])
    y[-i-2] = sum(second)
    
for i in range(n-1,2*n):
    l[i] = x[i] + y[i]
    
#print(x)
#print(y)
#print(l)

print(max(l[n-1:2*n]))

### FIXED CODE ###

import heapq

n = int(input())

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

func = lambda p: p * (-1)

b = list(map(func,a[:]))

#print(a)
#print(b)

l = [0] * (3*n)

first = a[0:n]
second = b[2*n:3*n]

x = [0] * (3*n)
y = [0] * (3*n)

x[n-1] = sum(first)
y[2*n-1] = sum(second)

heapq.heapify(first)
heapq.heapify(second)

for i in range(n,2*n):
    heapq.heappush(first, a[i])
    s = first[0]
    heapq.heappop(first)
    x[i] = x[i-1] + a[i] - s

for i in range(n,2*n):
    heapq.heappush(second, b[-i-1])
    t = second[0]
    heapq.heappop(second)
    y[-i-2] = y[-i-1] + b[-i-1] - t
    
for i in range(n-1,2*n):
    l[i] = x[i] + y[i]
    
#print(x)
#print(y)
#print(l)

print(max(l[n-1:2*n]))
### BUGGY CODE ###

num = int(input())

power = 1
for n in range(1, num+1):
  power = power * n


power = power % (10 ** 9 + 7)
print(power)

### FIXED CODE ###

power = 1
x = int(input())
for a in range(1, x + 1):
  power = (power * a) % (10**9 + 7)

print(power)
### BUGGY CODE ###

from operator import mul
from functools import reduce

def combinations_count(n, r):
    #r = min(r, n - r)
    if r > n:
        return 0
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

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

d = dict()
for a in A:
    if a not in d.keys():
        d[a] = 1
    else:
        d[a] += 1

if len(d) == n:
    for i in range(n):
        print(0)
    exit()

d1 = dict()
for a in d.keys():
    d1[a] = combinations_count(d[a], 2)

d2 = dict()
for a in d.keys():
    d2[a] = combinations_count(d[a] - 1, 2)

ans = []
d3 = dict()
for a in A:
    if a not in d3.keys():
        ans.append(sum(d1.values()) - d1[a] + d2[a])
    else:
        ans.append(d3[a])

for a in ans:
    print(a)

### FIXED CODE ###

from operator import mul
from functools import reduce

def combinations_count(n, r):
    #r = min(r, n - r)
    if r > n:
        return 0
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

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

d = dict()
for a in A:
    if a not in d.keys():
        d[a] = 1
    else:
        d[a] += 1

if len(d) == n:
    for i in range(n):
        print(0)
    exit()

d1 = dict()
for a in d.keys():
    d1[a] = combinations_count(d[a], 2)

d2 = dict()
for a in d.keys():
    d2[a] = combinations_count(d[a] - 1, 2)

ans = []
d3 = dict()
s = sum(d1.values())
for a in A:
    if a not in d3.keys():
        ans.append(s - d1[a] + d2[a])
    else:
        ans.append(d3[a])

for a in ans:
    print(a)
### BUGGY CODE ###

class Heap:
    def __init__(self):
        self.sz = 0
        self.heap = []
    def push(self,x):
        cost = x[3]
        self.heap.append(x)
        i = self.sz
        self.sz += 1
        while i > 0 :
            p = int((i-1)/2)
            if p >= 0 and self.heap[p][3] <= cost:
                self.heap[i] = self.heap[p]
                i = p
            else :
                break
        self.heap[i] = x
    def pop2(self):
        ret = self.heap[0]
        cost = self.heap[-1]
        self.heap.pop(-1)
        self.sz -= 1
        i = 0
        while 2*i+1 < self.sz :
            a = 2 * i + 1
            b = 2 * i + 2
            if b < self.sz and self.heap[a][3] < self.heap[b][3] :
                a = b
            if self.heap[a][3] <= cost[3]:
                break
            self.heap[i] = self.heap[a]
            i = a
        self.heap[i] = cost
        return ret[3]



def main():
    X,Y,Z,K = map(int,input().split())
    size = max(X,Y,Z)
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]
    C = [int(i) for i in input().split()]
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)
    i = Heap()
    i.heap = [[0,0,0,A[0]+B[0]+C[0]],[0,0,0,0]]
    i.sz = 2
    count = [[[0 for i in range(Z+1)] for j in range(Y+1)] for k in range(X+1)]
    for p in range(K):
        x = i.heap[0]
        if x[0] + 1 < X  and count[x[0]+1][x[1]][x[2]] == 0 :
            i.push([x[0]+1, x[1] , x[2], A[x[0] + 1] + B[x[1]] + C[x[2]]])
            count[x[0] + 1][x[1]][x[2]] = 1
        if x[1] + 1 < Y  and count[x[0]][x[1]+1][x[2]] == 0:
            i.push([x[0], x[1] + 1, x[2], A[x[0]] + B[x[1] + 1 ] + C[x[2]]])
            count[x[0]][x[1] + 1][x[2]] = 1
        if x[2] + 1 < Z and count[x[0]][x[1]][x[2]+1] == 0:
            i.push([x[0] , x[1], x[2] + 1 , A[x[0]] + B[x[1]] + C[x[2] + 1 ]])
            count[x[0]][x[1]][x[2] + 1] = 1
        print(i.pop2())

if __name__ ==  "__main__":
    main()

### FIXED CODE ###

import heapq

def main():
    X, Y, Z, K = map(int,input().split())
    A = [int(o) for o in input().split()]
    B = [int(o) for o in input().split()]
    C = [int(o) for o in input().split()]
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)
    A_size = len(A)
    B_size = len(B)
    C_size = len(C)
    heap = []
    heapq.heappush(heap,(-(A[0]+B[0]+C[0]),0,0,0))
    for i in range(K):
        val,a,b,c = heapq.heappop(heap)
        if a < (A_size-1) and (-(A[a+1]+B[b]+C[c]),a+1,b,c) not in heap:
            heapq.heappush(heap,(-(A[a+1]+B[b]+C[c]),a+1,b,c))
        if b < (B_size-1) and (-(A[a]+B[b+1]+C[c]),a,b+1,c) not in heap:
            heapq.heappush(heap,(-(A[a]+B[b+1]+C[c]),a,b+1,c))
        if c < (C_size-1) and (-(A[a]+B[b]+C[c+1]),a,b,c+1) not in heap:
            heapq.heappush(heap,(-(A[a]+B[b]+C[c+1]),a,b,c+1))
        print(-val)
if __name__ == "__main__" :
    main()
### BUGGY CODE ###

n,*a=map(int,open(0).read().split())
for i in range(n):print(a.count(i+1))

### FIXED CODE ###

n,*l=map(int,open(0).read().split());a=[0]*n
for i in l:a[i-1]+=1
print(*a)
### BUGGY CODE ###

s=input()
s1=""

for i in range(len(s)):
    if (i%2==0):
        s1="".join((s1,s[i]))
print(s1)

### FIXED CODE ###

s=input()
s1=""

for i in range(len(s)):
    if (i%2==0):
        s1="".join((s1,s[i]))
print(s1)
### BUGGY CODE ###

n, m = map(int, input().split())
ab = []
for i in range(m):
  ab.append(list(map(int, input().split())))
count = 0
while len(ab) > 0:
  c = float('inf')
  for i in range(len(ab)):
    if ab[i][1] < c:
      c = ab[i][1]
  count += 1
  tmp = []
  for i in range(len(ab)):
    if ab[i][0] >= c:
      tmp.append(ab[i])
  ab = tmp
print(count)

### FIXED CODE ###

n, m = map(int, input().split())
ab = []
for i in range(m):
  ab.append(list(map(int, input().split())))
count = 0
while len(ab) > 0:
  c = float('inf')
  for i in range(len(ab)):
    if ab[i][1] < c:
      c = ab[i][1]
  count += 1
  tmp = []
  for i in range(len(ab)):
    if ab[i][0] >= c:
      tmp.append(ab[i])
  ab = tmp
print(count)
### BUGGY CODE ###

#! python3
# maximum_profit.py

n = int(input())
R = [int(input()) for i in range(n)]

maximum_profit = R[-1]-R[-2]
min_i = R[0]
for i in range(n-2):
    if R[i] > min_i:
        continue
    else:
        min_i = R[i]
    max_profit_i = R[i+1]-R[i]
    for j in range(i+2, n):
        tmp = R[j]-R[i]
        if max_profit_i < tmp:
            max_profit_i = tmp
    if maximum_profit < max_profit_i:
        maximum_profit = max_profit_i
print(maximum_profit)



### FIXED CODE ###

#! python3
# maximum_profit.py

n = int(input())
R = [int(input()) for i in range(n)]

min_i = 0
max_val = R[1]-R[0]
max_j = -1
for i in range(n-1):
    if R[min_i] < R[i]:
        continue
    elif R[min_i] > R[i]:
        min_i = i

    if max_j <= i:
        max_j = i+1
        for j in range(i+1, n):
            if R[max_j] < R[j]:
                max_j = j

    if max_val < R[max_j] - R[min_i]:
        max_val = R[max_j] - R[min_i]

print(max_val)
### BUGGY CODE ###

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

maxN=0
for i in range(N-K+1):
  sumN=0
  for j in range(K):
    sumN=sumN+(P[i+j]+1)/2
  if sumN>=maxN:
    maxN=sumN
print(maxN)

### FIXED CODE ###

N,K = map(int, input().split())
P = list(map(int, input().split())) 
tmp=sum(P[:K])
maxN=tmp
for i in range(1,N-K+1):
  tmp=tmp-P[i-1]+P[i+K-1]
  if tmp>=maxN:
    maxN=tmp
print((maxN+K)/2)
### BUGGY CODE ###

n = int(input())
a_int = list(map(int, input().split()))
squ = 0
num = 10 ** 9 + 7
for i in range(0, n-1):
    for j in range(i+1, n):
        squ += (a_int[i] * a_int[j]) % num
ans = squ % num
print(ans)

### FIXED CODE ###

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

squ = 0
num = 10 ** 9 + 7

a_sum = 0
for i_sum in range(1, n):
    a_sum += a_int[i_sum]

for i in range(0, n-1):
    squ += a_int[i] * a_sum
    a_sum -= a_int[i+1]

ans = squ % num
print(ans)
### BUGGY CODE ###

N,K = map(int,input().split())
p = list(map(int,input().split()))
result = 0
for i in range(N-K+1):
    result = max(result,(sum(p[i:i+K])+K)/2)
print(result)

### FIXED CODE ###

N,K = map(int,input().split())
p = list(map(int,input().split()))
result = 0
p_t = [0]
for i in range(N):
    p_t.append(p[i]+p_t[i])
ans = p_t[K] - p_t[0]

for i in range(N-K):
    tmp = p_t[i+1+K] - p_t[i+1]
    if ans < tmp:
        ans = tmp
print((ans+K)/2)
### BUGGY CODE ###

from bisect import bisect_left, bisect_right
from itertools import combinations

n = int(input())
l = sorted(map(int, input().split()))
ans = 0

for (i1, a), (i2, b) in combinations(enumerate(l[:-1]), 2):
    i3s = bisect_right(l, b - a, i2 + 1)
    i3e = bisect_left(l, a + b, i3s)
    ans += i3e - i3s

print(ans)


### FIXED CODE ###

from bisect import bisect_left, bisect_right

n = int(input())
l = sorted(map(int, input().split()))
ans = 0
for i1 in range(n - 2):
    for i2 in range(i1 + 1, n - 1):
        a = l[i1]
        b = l[i2]
        i3s = max(bisect_right(l, b - a), i2 + 1)
        i3e = bisect_left(l, a + b)
        ans += i3e - i3s
print(ans)
### BUGGY CODE ###

N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
from numpy.linalg import solve
def nasu(a, b, c):
  A = a[0] ** 2 - b[0] ** 2 + a[1] ** 2 - b[1] ** 2
  B = b[0] ** 2 - c[0] ** 2 + b[1] ** 2 - c[1] ** 2
  x = [2 * (b[0] - a[0]), 2 * (c[0] - b[0])]
  y = [2 * (b[1] - a[1]), 2 * (c[1] - b[1])]
  if x[0] * y[1] == x[1] * y[0]:
    return 10 ** 10
  left = [[x[0], y[0]],
          [x[1], y[1]]]
  right = [-A, -B]
  Cx, Cy = solve(left, right)
  r = ((a[0] - Cx) ** 2 + (a[1] - Cy) ** 2) ** (1 / 2)
  for i in range(N):
    if honya(xy[i], Cx, Cy) > r:
      return 10 ** 10
  return r

def honya(a, Cx, Cy):
  return ((a[0] - Cx) ** 2 + (a[1] - Cy) ** 2) ** (1 / 2)
ans = 10 ** 10

def honyaraka(a, b):
  Cx = (a[0] + b[0]) / 2
  Cy = (a[1] + b[1]) / 2
  r = ((a[0] - Cx) ** 2 + (a[1] - Cy) ** 2) ** (1 / 2)
  for i in range(N):
    if honya(xy[i], Cx, Cy) > r:
      return 10 ** 10
  return r

for i in range(N - 2):
  for j in range(i + 1, N - 1):
    for k in range(j + 1, N):
      ans = min(ans, nasu(xy[i], xy[j], xy[k]))
for i in range(N - 1):
  for j in range(i + 1, N):
    ans = min(ans, honyaraka(xy[i], xy[j]))

print(ans)

### FIXED CODE ###

N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
def nasu(a, b, c):
  A = a[0] ** 2 - b[0] ** 2 + a[1] ** 2 - b[1] ** 2
  B = b[0] ** 2 - c[0] ** 2 + b[1] ** 2 - c[1] ** 2
  x = [2 * (b[0] - a[0]), 2 * (c[0] - b[0])]
  y = [2 * (b[1] - a[1]), 2 * (c[1] - b[1])]
  k = x[1] * y[0] - x[0] * y[1]
  if k == 0:
    return 10 ** 10
  Cx = -(y[0] * B - y[1] * A) / k
  Cy = (x[0] * B - x[1] * A) / k
  return honyamorake(Cx, Cy)

def honya(x, y, Cx, Cy):
  return ((x - Cx) ** 2 + (y - Cy) ** 2) ** (1 / 2)

def honyaraka(a, b):
  Cx = (a[0] + b[0]) / 2
  Cy = (a[1] + b[1]) / 2
  return honyamorake(Cx, Cy)

def honyamorake(Cx, Cy):
  r = honya(xy[0][0], xy[0][1], Cx, Cy)
  for i in range(1, N):
    r = max(r, honya(xy[i][0], xy[i][1], Cx, Cy))
  return r

ans = 10 ** 10
for i in range(N - 2):
  for j in range(i + 1, N - 1):
    for k in range(j + 1, N):
      ans = min(ans, nasu(xy[i], xy[j], xy[k]))
for i in range(N - 1):
  for j in range(i + 1, N):
    ans = min(ans, honyaraka(xy[i], xy[j]))

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

from collections import Counter
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


N, M = map(int, input().split())
mat = [list(map(lambda x:int(x)-1, input().split())) for _ in range(N)]

ans = N
Q = [set([v for v in range(M)])]
while Q:
    sports_cand = Q.pop(0)
    n_sports = [0]*M
    for n in range(N):
        for m in range(M):
            if mat[n][m] in sports_cand:
                n_sports[mat[n][m]] += 1
                break
    max_val = max(n_sports)
    for i, v in enumerate(n_sports):
        if v == max_val:
            ans = min(ans, v)
            if len(sports_cand) > 2:
                Q.append(sports_cand-{i})
print(ans)


### FIXED CODE ###

from collections import Counter
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


N, M = map(int, input().split())
mat = [list(map(lambda x:int(x)-1, input().split())) for _ in range(N)]

ans = N
Q = [set([v for v in range(M)])]
while Q:
    C = Counter()
    sports_cand = Q.pop(0)
    for n in range(N):
        for m in range(M):
            if mat[n][m] in sports_cand:
                C[mat[n][m]] += 1
                break
    tmp = 0
    for key, val in C.most_common():
        if val > tmp:
            tmp = val
            ans = min(ans, val)
            if len(sports_cand) > 2:
                Q.append(sports_cand-{key})
        else:
            break
print(ans)
### BUGGY CODE ###

s = input()
q = int(input())
inversion_flag = 0
for _ in range(q):
    inp =  list(input().split())
    if inp[0] == '1':
        inversion_flag = not inversion_flag
    else:
        if inp[1] == '1':
            if not inversion_flag:
                s = inp[2] + s
            else:
                s = s + inp[2]
        else:
            if not inversion_flag:
                s = s + inp[2]
            else:
                s = inp[2] + s
if inversion_flag:
    print(s[::-1])
else:
    print(s)

### FIXED CODE ###

from collections import deque

s = input()
q = int(input())
isInversed = False
front = deque()
back = deque()
for _ in range(q):
    inp =  list(input().split())
    if inp[0] == '1':
        isInversed = not isInversed
    else:
        if inp[1] == '1':
            if not isInversed:
                front.appendleft(inp[2])
            else:
                back.append(inp[2])
        else:
            if not isInversed:
                back.append(inp[2])
            else:
                front.appendleft(inp[2])

front_str = ''.join(front)
back_str = ''.join(back)
ans = front_str + s + back_str

if not isInversed:
    print(ans)
else:
    print(ans[::-1])
### BUGGY CODE ###

import numpy as np

def count_num_light(a):
  ret = np.array([0 for _ in range(len(a))])
  for i in range(len(a)):
    start = max(0, i-a[i])
    ret[start:i+a[i]+1] += 1
  
  return ret
                  
n, k = map(int, input().split())
a = np.array(list(map(int, input().split())))
num_light = count_num_light(a)

for i in range(k-1):
  num_light = count_num_light(num_light)
  if np.sum(num_light) == n**2:
    break

print(*num_light)

### FIXED CODE ###

def count_num_light(a):
  ret = [0 for _ in range(len(a))]
  n = len(a)
  for i in range(n):
    start = max(0, i-a[i])
    end = min(n-1, i+a[i])
    ret[start] += 1
    if end+1 < n:
      ret[end+1] -= 1
  for i in range(1,n):
    ret[i] += ret[i-1]
  
  return ret
                  
n, k = map(int, input().split())
a = list(map(int, input().split()))
num_light = count_num_light(a)
 
for i in range(k-1):
  num_light = count_num_light(num_light)
  if sum(num_light) == n**2:
    break
    
print(*num_light)
### BUGGY CODE ###

import fileinput


def frog(stones, jump_range):
    stone_cost = [0]
    for i in range(1, len(stones)):
        stone_cost.append(min(
            stone_cost[i - curr_jmp] + abs(stones[i] - stones[i - curr_jmp])
            for curr_jmp in range(1, min(i, jump_range) + 1)
        ))
    return stone_cost[-1]


inp = fileinput.input()
jump_range = [int(v) for v in inp.readline().split(" ")][1]
stones = [int(v) for v in inp.readline().split(" ")]
print(frog(stones, jump_range))

### FIXED CODE ###

import fileinput


def frog(stones, jump_range):
    stone_cost = [0]
    for i in range(1, len(stones)):
        stone_cost.append(min(
            stone_cost[i - curr_jmp] + abs(stones[i] - stones[i - curr_jmp])
            for curr_jmp in range(1, min(i, jump_range) + 1)
        ))
    return stone_cost[-1]


inp = fileinput.input()
jump_range = [int(v) for v in inp.readline().split(" ")][1]
stones = [int(v) for v in inp.readline().split(" ")]
print(frog(stones, jump_range))
### BUGGY CODE ###

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

hyouten = [0]*n
hyouten[k-1] = 1
for i in range(k):
    hyouten[k-1] *= a[i]
#print(hyouten[k-1])
for i in range(k+1, n+1):
    hyouten[i-1] = hyouten[i-2]//a[i-k-1]
    hyouten[i-1] = hyouten[i-1]*a[i-1]
    if hyouten[i-1] > hyouten[i-2]:
        print("Yes")
    else:
        print("No")
#print(hyouten)

### FIXED CODE ###

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

for i in range(k+1, n+1):
    if a[i-1] > a[i-k-1]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

from collections import Counter
import collections

N = int(input())
a = [input() for i in range(N)]



c = collections.Counter(a)

list = []
if(len(c.most_common()) == 1):
	list.append(c.most_common()[0][0])



for i in range(0,len(c.most_common())-1):
    if(c.most_common()[i][1] == c.most_common()[0][1]):
        list.append(c.most_common()[i][0])

if(len(c.most_common()) == N):
  list.append(c.most_common()[N-1][0])

list.sort()

print(' \n'.join(map(str, list)))

    



### FIXED CODE ###

from collections import Counter
import collections

N = int(input())
a = [input() for i in range(N)]

c = collections.Counter(a)
hoge = c.most_common()
i = 0

list = []
if(len(hoge) == 1):
	list.append(hoge[0][0])
elif(len(hoge) == N):
  list = a
else:
  ##for i in range(0,len(c.most_common())-1):
    while(hoge[i][1] == hoge[0][1]):
        list.append(hoge[i][0])
        i += 1



list.sort()

print(' \n'.join(map(str, list)))
### BUGGY CODE ###

import bisect
# N = input()   # 単純な入力
# input = list(input()) # ひとかたまりの文字列をリスト化
# N = int(input())  # 整数一つ
# input = input().split()   # スペース区切りを文字としてリスト化
# X,Y = map(int,input().split())  # ２個や３個の整数をそれぞれ取得
# input = list(map(int,input().split()))
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

sa = [A[i] - B[i] for i in range(len(A))]
sa.sort()
# print(sa)
insert_index = bisect.bisect_left(sa,0)
# print(insert_index)
Sum = sum(sa[0:insert_index])

for i in range(len(sa),insert_index-1,-1):
    # print(i)
    # print(sa[len(sa)-1:i-1:-1])
    if abs(Sum) <= sum(sa[N:i-1:-1]):
        print(insert_index - 1 + N - i + 1)
        exit()
print(-1)

### FIXED CODE ###

import bisect
# N = input()   # 単純な入力
# input = list(input()) # ひとかたまりの文字列をリスト化
# N = int(input())  # 整数一つ
# input = input().split()   # スペース区切りを文字としてリスト化
# X,Y = map(int,input().split())  # ２個や３個の整数をそれぞれ取得
# input = list(map(int,input().split()))
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

sa = [A[i] - B[i] for i in range(len(A))]
sa.sort()
# print(sa)
insert_index = bisect.bisect_left(sa,0)
# print(insert_index)
Sum = sum(sa[0:insert_index])
Sumlist = [0 for i in range(N)]
isum = 0

if Sum == 0:
    print(0)
    exit()

for i in range(len(sa),insert_index-1,-1):
    isum = isum + sa[i-1]
    if abs(Sum) <= isum:
        print(insert_index + N - i + 1)
        exit()
    elif sa[i-2] <= 0:
        print(-1)
        exit()
### BUGGY CODE ###

n, k = map(int, input().split())
hhh = list(map(int, input().split()))
dp = [float('inf')] * n
dp[0] = 0
for i in range(1, n):
    min_tmp = float('inf')
    if i - k >= 0:
        for j in range(i - k, i):
            tmp = dp[j] + abs(hhh[i] - hhh[j])
            min_tmp = min(tmp, min_tmp)
        dp[i] = min_tmp
    else:
        for j in range(i):
            tmp = dp[j] + abs(hhh[i] - hhh[j])
            min_tmp = min(tmp, min_tmp)
        dp[i] = min_tmp
print(dp[-1])

### FIXED CODE ###

n, k = map(int, input().split())
hhh = list(map(int, input().split()))
dp = [float('inf')] * n
dp[0] = 0
for i in range(1, n):
    min_tmp = float('inf')
    if i - k >= 0:
        for j in range(i - k, i):
            tmp = dp[j] + abs(hhh[i] - hhh[j])
            min_tmp = min(tmp, min_tmp)
        dp[i] = min_tmp
    else:
        for j in range(i):
            tmp = dp[j] + abs(hhh[i] - hhh[j])
            min_tmp = min(tmp, min_tmp)
        dp[i] = min_tmp
print(dp[-1])
### BUGGY CODE ###

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

cnt = 1
ans=[]
for _ in range(n):
    for i in range(n):
        if a[i] == cnt:
            ans.append(i+1)
            cnt += 1
            break

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

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
num = list(range(1, n+1))

cin = dict(zip(a, num))
ans =[]

for i in range(n):
    ans.append(cin[i+1])

print(' '.join(map(str, ans)))
### BUGGY CODE ###

from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq

n,p = list(map(int, input().split()))
s = input()

ans = 0

if p == 2 or p == 5:
    for i in range(n):
        a = int(s[n-1-i])
        if a % p == 0: ans += n-i

else:
    d = {0: 1}
    for i in range(n):
        if int(s[n-1-i:]) % p not in d:
            d[int(s[n-1-i:]) % p] = 1
        else:
            d[int(s[n - 1 - i:]) % p] += 1

    for dd in d.values():
        ans += dd*(dd-1)//2

print(ans)











### FIXED CODE ###

from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq

n,p = list(map(int, input().split()))
s = input()

ans = 0

if p == 2 or p == 5:
    for i in range(n):
        a = int(s[n-1-i])
        if a % p == 0: ans += n-i

else:
    d = {0: 1}
    c = 0
    for i in range(n):
        c += (pow(10, i, p)*int(s[n-1-i])) % p
        c %= p
        if c not in d:
            d[c] = 1
        else:
            d[c] += 1

    for dd in d.values():
        ans += dd*(dd-1)//2

print(ans)