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


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

dp = [0]*n
dp[0] = 0
dp[1] = dp[0] + abs(h[1]-h[0])

for i in range(2, n): 
    dp[i] = min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1, min(k, i)+1)])

print(dp[n-1])

### FIXED CODE ###

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

dp = [10**9+1]*n
dp[0] = 0
dp[1] = dp[0] + abs(h[1]-h[0])

for i in range(2, n): 
    dp[i] = min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1, min(k, i)+1)])

print(dp[n-1])
### BUGGY CODE ###

# coding:utf-8
def main():
    import math

    a, b, n = map(int, input().split())
    ans = 0

    for x in range(n, 0, -1):
        tmp = math.floor((a * x) / b) - a * (math.floor(x / b))
        ans = max(tmp, ans)

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

# coding:utf-8

import math

a, b, n = map(int, input().split())
x = min(b - 1, n)

ans = math.floor((a * x) / b) - a * (math.floor(x / b))

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

from functools import reduce
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))
A = list(set(a))
ans = [reduce(gcd, a)]

if len(A) == 1:
    print(A[0])
    exit()
for i in a:
    b = sorted(A)
    b.remove(i)
    if a.count(i) == 1:
        ans.append(reduce(gcd, b))

print(max(ans))


### FIXED CODE ###

from functools import reduce
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))
A = list(set(a))
ans = [reduce(gcd, A)]

if len(A) == 1:
    print(A[0])
    exit()
for i in A:
    b = sorted(A)
    b.remove(i)
    if a.count(i) == 1:
        ans.append(reduce(gcd, b))

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

from heapq import heapify, heapreplace
N,M=[int(a) for a in input().split()]
A=[int(a) for a in input().split()]
BC=[[int(a) for a in input().split()] for _ in range(M)]
heapify(A)
for B,C in BC:
    for _ in range(B):
        if C<=A[0]:
            break
        heapreplace(A, C)
print(sum(A))

### FIXED CODE ###

from heapq import heapify, heapreplace
N,M=[int(a) for a in input().split()]
A=sorted([int(a) for a in input().split()])
BC=[[int(a) for a in input().split()] for _ in range(M)]
B,C=zip(*sorted(BC, key=lambda row: row[1], reverse=True))
i,j=0,0
for k in range(N):
    if j>=B[i]:
        i+=1
        j=0
    if i>=M or A[k]>= C[i]:
        break
    A[k] = C[i];
    j+=1
print(sum(A))
### BUGGY CODE ###

a = 'a'*2000
b = 'b'*2000
c = 'c'*2000

len_a = len(a)
len_b = len(b)
len_c = len(c)

def match(a, b):
    return a=='?' or b=='?' or a==b

dp_len=50000
ab = [True] * dp_len
ac = [True] * dp_len
bc = [True] * dp_len

def check(a, b, ab):
    for i in range(len(a)):
        for j in range(len(b)):
            if not match(a[i], b[j]):
                ab[i-j+dp_len//2] = False

check(a, b, ab)
check(a, c, ac)
check(b, c, bc)

len_max = len(a)+len(b)+len(c)

ans = len_max
for i in range(-2*len_max, 2*len_max+1):
    for j in range(-2*len_max, 2*len_max+1):
        if ab[i+dp_len//2] and ac[j+dp_len//2] and bc[j-i+dp_len//2]:
            ans = min(ans, max(len_a, len_b+i, len_c+j) - min(0, i, j))
print(ans)



### FIXED CODE ###

"""
a = 'a'*2000
b = 'b'*2000
c = 'c'*2000
"""
a = input()
b = input()
c = input()


len_a = len(a)
len_b = len(b)
len_c = len(c)

def match(a, b):
    return a=='?' or b=='?' or a==b

dp_len=50000
ab = [True] * dp_len
ac = [True] * dp_len
bc = [True] * dp_len

def check(a, b, ab):
    for i in range(len(a)):
        for j in range(len(b)):
            if not match(a[i], b[j]):
                ab[i-j+dp_len//2] = False

check(a, b, ab)
check(a, c, ac)
check(b, c, bc)

len_max = 2000

ans = len_a+len_b+len_c
for i in range(-2*len_max, 2*len_max+1):
    for j in range(-2*len_max, 2*len_max+1):
        if ab[i+dp_len//2] and ac[j+dp_len//2] and bc[j-i+dp_len//2]:
            ans = min(ans, max(len_a, len_b+i, len_c+j) - min(0, i, j))
print(ans)
### BUGGY CODE ###

from itertools import combinations

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

for i in range(1,N+1):
	for cmb in combinations(l,i):
		if sum(cmb) / i == A:
			cnt += 1

print(cnt)

### FIXED CODE ###

N, A = map(int, input().split())
X = list(map(lambda x: int(x) - A, input().split()))
dp = [[0 for j in range(100 * N + 1)] for i in range(N+1)]
dp[0][50 * N] = 1
for i in range(N):
	for j in range(50, 100*N + 1-50):
		dp[i+1][j] = dp[i][j] + dp[i][j - X[i]]
print(dp[N][50 * N] -1)
### BUGGY CODE ###

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

for i in range(q):
  b,c = map(int, input().split())
  for j in range((len(a))):
    if a[j] == b:
      a[j] = c
  
  sums = sum(a)
  print(sums)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
q = int(input())
sums = sum(a)
d = {}

for i in a:
  if i in d:
    d[i] += 1
  else:
    d[i] = 1

for i in range(q):
    b,c = map(int, input().split())
    if b in d:
        sums += d[b]*(c-b)
        if c in d:
          d[c] += d[b]
        else:
          d[c] = d[b]
        d[b] = 0
    print(sums)
### BUGGY CODE ###

n = int(input())
p = list(map(int,input().split()))
ans = 1
 
for i in range(1,n):
  if min(sorted(p[:i+1])) == p[:i+1][-1]:
    ans += 1
    
print(ans)

### FIXED CODE ###

n = int(input())
p = list(map(int,input().split()))
ans = 0
m= 10**10

for i in range(n):
  tmp = m
  m = min(m,p[i])
  if tmp != m:
    ans += 1
    
print(ans)
### BUGGY CODE ###

n,*a=map(int,open(0).read().split())
t,v=sum(a),[1]
print(-1 if [-1 for q in a if(v:=v+[min(2*(v[-1]-q),t:=t-q)])[-1]<0] else sum(v))

### FIXED CODE ###

from itertools import accumulate
n=int(input())
a=list(map(int,input().split()))
c=list(accumulate(a))
b=[0]*(n+1)
#大きくしすぎてしまう場合がある
#いや上限を考えろや
def f():
    global n,a,b
    for i in range(n+1):
        if i==0:
            b[0]=min(c[n]-c[0],1)
        else:
            b[i]=min(2*(b[i-1]-a[i-1]),c[n]-c[i-1])

    if n==0:
        if a[0]!=1:
            print(-1)
        else:
            print(1)
    elif b[n]!=a[n]:
        print(-1)
    else:
        print(sum(b))
        #print(b)
f()
### BUGGY CODE ###

import sys
inputs = sys.stdin.readline
N, Q= map(int,inputs().split())
V = [list(map(int,inputs().split())) for p in [0]*N]
M = [int(inputs()) for p in [0]*Q]
V.sort(key = lambda x:(x[2]))

for m in M:
	for n in range(N):
		if V[n][0] - V[n][2] <=m and m <= V[n][1] - V[n][2] -1:
			print(V[n][2])
			break
	else:
		print(-1)

### FIXED CODE ###

import sys
from operator import itemgetter
def main():
	inputs = sys.stdin.readline
	N, Q= map(int,inputs().split())
	E = [None]*2*N
	for n in range(N):
		a,b,c = map(int,inputs().split())
		E[2*n] = (a - c, 1, c)
		E[2*n + 1] = (b - c, -1, c)
	E.sort(key=itemgetter(0))
	tuple(tuple(E))
	mini = 1000000001
	kouho = {1000000001}
	my_add = kouho.add
	my_discard = kouho.discard
	q = 0
	d = int(inputs())
	flag = False
	cont = False
	for e in E:
		while e[0] > d:
			if cont == True:
				print(mini-(mini//1000000001)*1000000002)
			else:
				mini = min(kouho)
				print(mini-(mini//1000000001)*1000000002)
			cont = True
			q = q + 1
			if q > Q-1:
				flag = True
				break
			d = int(inputs())
		if flag == True:
			break
		if e[1] == 1:
			my_add(e[2])
			if mini > e[2]:
				mini = e[2]
		elif e[1] == -1:
			my_discard(e[2])
			if mini == e[2]:
				cont = False
	for t in [None]*(Q-q):
		print(-1)
main()
### BUGGY CODE ###

def resolve():
    '''
    code here
    '''

    N, K = [int(item) for item in input().split()]
    queries = [[int(item) for item in input().split()] for _ in range(N)]

    queries.sort(key=lambda x:x[0])

    que = []
    for num, val in queries:
        que += [num]*val

    print(que[K-1])

if __name__ == "__main__":
    resolve()


### FIXED CODE ###

def resolve():
    '''
    code here
    '''

    N, K = [int(item) for item in input().split()]
    queries = [[int(item) for item in input().split()] for _ in range(N)]

    queries.sort(key=lambda x:x[0])

    temp_que = []
    for num, val in queries:
        temp_que = num
        K -= val
        if K <= 0:
            break

    print(temp_que)

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

from heapq import heappush, heappop
import itertools
sx,sy,gx,gy=map(int,input().split())
n=int(input())
g = [[] for i in range(n+2)]
data=[(sx,sy,0)]
data+=[tuple(map(int,input().split())) for i in range(n)]
data.append((gx,gy,0))

for i,j in itertools.product(range(n+2), range(n+2)):
    if i>=j:
        continue
    tmp=((data[i][0]-data[j][0])**2+(data[i][1]-data[j][1])**2)**0.5-data[i][2]-data[j][2]
    g[i].append((tmp,j))
    g[j].append((tmp,i))

dist=[2828427127 for i in range(n+2)]
dist[0]=0
que=[]
heappush(que,(0,0))
while que:
    c,v=heappop(que)
    if dist[v]<c:
        continue
    for x in g[v]:
        tmp=x[0]+c if not x[0]<0 else c
        if tmp<dist[x[1]]:
            dist[x[1]]=tmp
            heappush(que,(tmp,x[1]))
print(dist[n+1])


### FIXED CODE ###

from heapq import heappush, heappop
sx,sy,gx,gy=map(int,input().split())
n=int(input())
g = [[] for i in range(n+2)]
data=[(sx+sy*1j,0)]
for i in range(n):
    a,b,c=map(int,input().split())
    data.append((a+b*1j,c))
data.append((gx+gy*1j,0))

for i in range(n+2):
    for j in range(i+1,n+2):
        tmp=abs(data[i][0]-data[j][0])-data[i][1]-data[j][1]
        g[i].append((tmp,j))
        g[j].append((tmp,i))

dist=[2828427127 for i in range(n+2)]
visited=[False for i in range(n+2)]
dist[0]=0
que=[]
heappush(que,(0,0))

while que:
    c,v=heappop(que)
    if visited[v]:
        continue
    visited[v]=True
    for x in g[v]:
        if visited[x[1]]:
            continue
        tmp=x[0]+c if not x[0]<0 else c
        if tmp<dist[x[1]]:
            dist[x[1]]=tmp
            heappush(que,(tmp,x[1]))
print(dist[n+1])
### BUGGY CODE ###

n = int(input())
dic = {}
for _ in range(n):
  k = input()
  dic[k] = 1 if k not in dic else dic[k] + 1
result = []
for i,j in dic.items():
  result.append((j,i))
  result.sort()
  maxi = result[-1][0]
  reresult=[]
  for i in result:
    if maxi == i[0]:
      reresult.append(i[1])
for i in sorted(reresult):
  print(i)

### FIXED CODE ###

n = int(input())
dic = {}
maxi = 0
for _ in range(n):
  k = input()
  dic[k] = 1 if k not in dic else dic[k] + 1
  if dic[k] > maxi: maxi = dic[k]
result = []
for i,j in dic.items():
  if j == maxi:
    result.append(i)
result.sort()
for r in result:
  print(r)
### BUGGY CODE ###

import sys
input = sys.stdin.buffer.readline

def main():
    N,M = map(int,input().split())
    INF = 10**7
    k = []
    for _ in range(M):
        a,b = map(int,input().split())
        c = list(map(int,input().split()))
        bit = 0
        for i in c:
            bit += 2**(i-1)
        k.append((a,bit))
    dp = [[INF for _ in range(1<<N)] for _ in range(M+1)]
    dp[0][0] = 0
    for i in range(M):
        a,bit = k[i]
        for j in range(1<<N):
            dp[i+1][j] = min(dp[i][j],dp[i+1][j])
            dp[i+1][j|bit] = min(dp[i+1][j|bit],dp[i][j|bit],dp[i][j]+a)
    
    print(dp[-1][-1] if dp[-1][-1] != INF else -1)
if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

def main():
    N,M = map(int,input().split())
    INF = 10**7
    k = []
    for _ in range(M):
        a,b = map(int,input().split())
        c = list(map(int,input().split()))
        bit = 0
        for i in c:
            bit += 2**(i-1)
        k.append((a,bit))
    dp = [INF for _ in range(1<<N)]
    dp[0] = 0
    for i in range(M):
        a,bit = k[i]
        for j in range(1<<N):
            af = bit|j
            dp[af] = min(dp[af],dp[j]+a)
            
    print(dp[-1] if dp[-1] != INF else -1)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

def getNumNeg(L):
    return sum([i<0 for i in L])

def findmax(L):
    numNeg = getNumNeg(L)
    if numNeg % 2 == 0: # end-point: all positive
        while getNumNeg(L) != 0:
            i = L.index(min(L[:-1]))
            j = i + 1
            L[i] = L[i] * (-1)
            L[j] = L[j] * (-1)
        print(sum(L))
    else: # end-point: smallest abs(number) is negative
        absL = list(map(abs, L))
        stop = min(absL)*(-1)
        while (getNumNeg(L) != 1) or (min(L) != stop):
            i = L.index(min(L[:-1]))
            j = i + 1
            L[i] = L[i] * (-1)
            L[j] = L[j] * (-1)
        print(sum(L))

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


### FIXED CODE ###

def getNumNeg(L):
  return sum([i<0 for i in L])
  
def findmax2(L):
  numNeg = getNumNeg(L)
  absL = list(map(abs, L))
  if numNeg % 2 == 0:
    print(sum(absL))
  else:
    print(sum(absL)-2*min(absL))
        
n = int(input())
a = list(map(int, input().split()))
findmax2(a)
### BUGGY CODE ###

n=int(input());sa=[0]*n
h=list(map(int,input().split()))
for i in range(n):
    for j in range(n):
        try:
            if h[j]>h[j+1] and sa[j]!=1:
                h[j]=h[j]-1
                sa[j]=1
        except IndexError:
            pass
for i in range(n):
    try:
        if h[i]>h[i+1]:
                print("No")
                exit()
    except IndexError:
        pass
print("Yes")

### FIXED CODE ###

n=int(input())
h=list(map(int,input().split()))
h[0]=h[0]-1
for i in range(1,n):
    try:
        if h[i-1]<=h[i]-1:
            h[i]=h[i]-1
    except IndexError:
        pass
for i in range(n):
    try:
        if h[i]>h[i+1]:
                print("No")
                exit()
    except IndexError:
        pass
print("Yes")
### BUGGY CODE ###

k,s=map(int,input().split())
x=0
for a in range(k+1):
  if a>s:
    break
  for b in range(k+1):
    if a+b>s:
      break
    for c in range(k+1):
      if a+b+c==s:
        x+=1
print(x)

### FIXED CODE ###

k,s=map(int,input().split())
x=0
m=min(s+1,k+1)
for a in range(m):
  for b in range(m):
    if a+b>s or a+b<s-k:
      continue
    x+=1
print(x)
### BUGGY CODE ###

#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, exit
from collections import Counter


def main(readline=stdin.readline):
    n, q = (int(s) for s in readline().split())
    count = Counter()
    count[1] = 0
    for i in range(q):
        a, v = (int(s) for s in readline().split())
        count[a] += v
        it = iter(count.most_common())
        index, value = next(it)
        for i, v in it:
            if value != v:
                break
            if index > i:
                index = i
        print(index, value)
    exit()


if __name__ == '__main__':
    main()

### FIXED CODE ###

#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, exit


def main(readline=stdin.readline):
    n, q = (int(s) for s in readline().split())

    base = [0] * n
    midway = [0] * (n//100 + 1)
    last = [0] * (n//10000 + 1)

    for _ in range(q):
        a, v = (int(s) for s in readline().split())

        a -= 1
        base[a] += v

        b = a - a % 100

        index = b
        value = base[b]
        end = b + 100 if b + 100 < n else n
        for i in range(b, end):
            if value < base[i]:
                value = base[i]
                index = i
        midway[b//100] = index

        c = a - a % 10000
        cc = c // 100

        index = c
        value = base[c]
        for i in midway[cc:cc+100]:
            if value < base[i]:
                value = base[i]
                index = i
        last[c//10000] = index

        index = last[0]
        value = base[index]
        for i in last:
            if value < base[i]:
                value = base[i]
                index = i

        print(index+1, value)
    exit()


if __name__ == '__main__':
    main()
### BUGGY CODE ###

N , M = map(int, input().split())
list1 = list(map(int, input().split()))
dp =[float('inf') for i in range(N)]
dp[0] = 0
for i in range(N):
    for j in range(1,M+1):
        if j > i:
            break
        dp[i] = min(dp[i],dp[i-j]+abs(list1[i]-list1[i-j]) )
        #print(dp)
print(dp[N-1])

### FIXED CODE ###

N , M = map(int, input().split())
import numpy as np
list1=np.array(list(map(int, input().split())))
dp = np.array([float('inf') for i in range(N)])
dp[0] = 0
#print(np.abs(list1[1]-list1[1:1+1]))
for i in range(N):
    if i - M < 0:
        dp[i] = np.min(dp[:i+1]+np.abs(list1[i]-list1[:i+1]) )
    else:
        dp[i] = np.min(dp[i-M:i+1]+np.abs(list1[i]-list1[i-M:i+1]) )
    #print(dp)
print(int(dp[N-1]))
### BUGGY CODE ###

S=input()
T=input()


ans = 0
l=len(S)


for a in range(l): 
      if S[a] != T[a]:
          S.replace(S[a], T[a])
          ans += 1
          
print(ans)

### FIXED CODE ###

S=input()
T=input()

ans = 0
l=len(S)

if S ==T:
    print(0)
else:
    for a in range(l): 
          if S[a] != T[a]:
              ans += 1
          
    print(ans)
### BUGGY CODE ###

H,W,D = map(int,input().split())
A = []
for i in range(H):
    tmp = list(map(int,input().split()))
    A.append(tmp)
dist = []
for k in range(1,H*W+1):
    for i in range(H):
        for j in range(W):
            if A[i][j] == k:
                dist.append([i+1,j+1])
                break
def exam(L,R,D):
    ans = 0
    while R != L:
        ##print("L",L,"R",R)
        ans += abs(dist[L+D-1][0]-dist[L-1][0])+abs(dist[L+D-1][1]-dist[L-1][1])
        L += D
    return ans    

LR = []
Q = int(input())
for i in range(Q):
    L,R = map(int,input().split())
    LR.append([L,R])

for i in range(Q):
    print(exam(LR[i][0],LR[i][1],D))

### FIXED CODE ###

##解答を見た 手前でO(H^2W^2) ~O(10^9)くらいのことをしていた
H,W,D = map(int,input().split())
A = []
for i in range(H):
    A.append(list(map(int,input().split())))

pos = [[0 for i in range(2)] for j in range(H*W+1)]

for i in range(H):
    for j in range(W):
        pos[A[i][j]][0] = i+1
        pos[A[i][j]][1] = j+1

dist = []
for i in range(1,H*W+1):##O(HW)
    if i<=D:
        dist.append(0)
    else:
        dist.append(dist[i-D-1]+abs(pos[i][0]-pos[i-D][0])+abs(pos[i][1]-pos[i-D][1]))

LR = []
Q = int(input())
for i in range(Q):
    L,R = map(int,input().split())
    LR.append([L,R])

for i in range(Q):
    print(dist[LR[i][1]-1]-dist[LR[i][0]-1])
### BUGGY CODE ###

N = int(input())
A = [int(i) for i in input().split()]
res = 1
for i in range(N):
    if A[i] >= 0:
        res *= A[i];

if res > 1e+18: print("-1")
else          : print(res)

### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]
res = 1
for i in range(N):
    if A[i] == 0:
        res = 0
    if res < 0:
        continue
    res *= A[i];
    if res > 1e+18:
        res = -1

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

N, A, B, C, D, E = [int(input()) for _ in range(6)]

towns = [N, 0, 0, 0, 0, 0]
moves = [A, B, C, D, E]
count = 0


def step():
    stack = [0, 0, 0, 0, 0]
    for i in range(5):
        stack[i] = min(towns[i], moves[i])
        towns[i] = max(0, towns[i] - moves[i])
    for i in range(5):
        towns[i+1] = towns[i+1] + stack[i]
    return towns


while True:
    count += 1
    if step()[-1] == N:
        break
print(count)

### FIXED CODE ###

import math

N, A, B, C, D, E = [int(input()) for _ in range(6)]
moves = [A, B, C, D, E]

ans = math.ceil(N/min(moves)) + 4
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
ans = 1
if 0 in a:
    print(0)
    exit()
for i in a:
    ans *= i
print("-1" if ans > 10**18 else ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
ans = 1
if 0 in a:
    print(0)
    exit()
for i in a:
    ans *= i
    if ans > 10**18:
        print("-1")
        exit()
print(ans)
### BUGGY CODE ###

X, Y = map(int, input().split())
num = X
l = 10**18
while num <= l:
    if num % Y != 0:
        print(num)
    num += X
else:
    print(-1)

### FIXED CODE ###

X, Y = map(int, input().split())
if X % Y != 0:
    print(X)
elif X*2%Y != 0:
    print(X*2)
else:
    print(-1)
### BUGGY CODE ###

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

mod=10**9+7
sum=0
for i in range(N-1):
    for j in range(i+1,N):
       sum+=((A[i])*(A[j]))%mod
else:
    sum=sum%mod

print(sum)

### FIXED CODE ###

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

mod=10**9+7

B=[0]
for i in range(1,N+1):
    B.append(A[i-1]+B[i-1])

ans=0
for i in range(N-1):
    ans+=A[i]*(B[N]-B[i+1])
    ans%=mod

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

N = int(input())
A = list(map(int,input().split()))
MOD = 10 ** 9 + 7
ans = 0

for i in range(61):
    cnt = 0
    for j in range(N):
        cnt += A[j] % 2
        A[j] >>= 1
    ans += (2 ** i) * cnt * (N - cnt)

print(ans % MOD)

### FIXED CODE ###

import numpy as np
N = int(input())
A = np.array(list(map(int,input().split())))
MOD = 10 ** 9 + 7
ans = 0

for i in range(61):
    cnt = np.count_nonzero(A & 1)
    ans += (2 ** i) * cnt * (N - cnt)
    A >>= 1

print(ans % MOD)
### BUGGY CODE ###

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

for i in range(1, N+1):
    print(A.count(i))

### FIXED CODE ###

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

l = [0]*N

for i in A:
    l[i-1] += 1

print(*l, sep="\n")
### BUGGY CODE ###

N,K = map(int, input().split())
H = list(map(int, input().split()))
dp = [10 ** 9] * N
dp[0] = 0

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

print(dp[-1])


### FIXED CODE ###

n, k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]

def frog(n, k, h):
    d = [float('inf')] * n
    d[0] = 0

    for i in range(1, n):
        d[i] = min(
            d[j] + abs(h[i] - h[j]) for j in range(max(i - k, 0), i)
        )
    return d[n - 1]


print(frog(n, k, h))
### BUGGY CODE ###

h, w, a, b = map(int, input().split(' '))
MOD = 10**9 + 7
MAX = 2*10**5


def modpow(a, b):
    res = 1
    while b:
        if (b & 1):
            res = (res * a) % MOD
        a = (a * a) % MOD
        b >>= 1
    return res


def nCr(n, r):
    if r == 0 or n == r:
        return 1
    return (((f[n] * ivf[n-r]) % MOD) * ivf[r]) % MOD


f = [1] * MAX
ivf = [0] * MAX
for i in range(1, MAX):
    f[i] = (f[i-1] * i) % MOD
    ivf[i] = modpow(f[i], MOD-2)
r = 0
for i in range(b, w):
    y1 = h - a - 1
    x1 = i
    y2 = a - 1
    x2 = w - i - 1
    p = (nCr(x1 + y1, x1) * nCr(x2 + y2, x2)) % MOD
    r = (r + p) % MOD
print(int(r))


### FIXED CODE ###

from array import *
import time
h, w, a, b = map(int, input().split(' '))
MOD = 10**9 + 7
MAX = max(h+w-a-1, a+w)


def modpow(a, b):
    res = 1
    while b:
        if (b & 1):
            res = (res * a) % MOD
        a = (a * a) % MOD
        b >>= 1
    return res


def nCr(n, r):
    if r == 0 or n == r:
        return 1
    return (((f[n] * ivf[n-r]) % MOD) * ivf[r]) % MOD


f = [1] * MAX
f = array('q', f)
ivf = [0] * MAX
ivf = array('q', ivf)
for i in range(1, MAX):
    f[i] = (f[i-1] * i) % MOD
    ivf[i] = modpow(f[i], MOD-2)
r = 0
for i in range(b, w):
    y1 = h - a - 1
    x1 = i
    y2 = a - 1
    x2 = w - i - 1
    p = (nCr(x1 + y1, x1) * nCr(x2 + y2, x2)) % MOD
    r = (r + p) % MOD
print(int(r))
### BUGGY CODE ###

ks = input().split()

k = int(ks[0])
s = int(ks[1])

ans = 0

for x in range(k+1):
	for y in range(k+1):
		for z in range(k+1):	
			if x + y + z == s:
				ans += 1
		
print(ans)

### FIXED CODE ###

ks = input().split()

k = int(ks[0])
s = int(ks[1])

ans = 0

for x in range(k+1):
	for y in range(k+1):
			tmp = s - (x + y)
			if tmp  <= k and tmp >= 0:
				ans += 1
		
print(ans)