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

import sys
sys.setrecursionlimit(10 ** 6)


def dfs(x, y):
    global N, Z, W
    X = Z if x == 0 else A[x - 1]
    Y = W if y == 0 else A[y - 1]

    if memo[x][y] >= 0:
        return memo[x][y]
    else:
        if x == N or y == N:
            rst = abs(X - Y)
        else:
            if x <= y:
                rst = 0
                for i in range(y + 1, N + 1):
                    rst = max(rst, dfs(i, y))
            else:
                rst = 10 ** 10
                for i in range(x + 1, N + 1):
                    rst = min(rst, dfs(x, i))
        memo[x][y] = rst
        return rst


N, Z, W = map(int, input().split())
A = list(map(int, input().split()))
memo = [[-1] * (N + 1) for _ in range(N + 1)]
ans = dfs(0, 0)
print(ans)


### FIXED CODE ###

N, Z, W = map(int, input().split())
A = list(map(int, input().split()))
dp = [[-1] * (N + 1) for _ in range(N + 1)]

for x in range(N, -1, -1):
    for y in range(N, -1, -1):
        if x == y:
            continue
        X = Z if x == 0 else A[x - 1]
        Y = W if y == 0 else A[y - 1]
        if x == N or y == N:
            rst = abs(X - Y)
        elif x - y == 1:
            rst = 10 ** 10
            for j in range(N, x, -1):
                rst = min(rst, dp[x][j])
        elif x - y > 1:
            rst = dp[x][y + 1]
        elif y - x == 1:
            rst = 0
            for i in range(N, y, -1):
                rst = max(rst, dp[i][y])
        elif y - x > 1:
            rst = dp[x + 1][y]
        else:
            raise Exception
        dp[x][y] = rst

ans = 0
for i in range(N):
    ans = max(ans, dp[i + 1][0])
print(ans)
### BUGGY CODE ###

N = int(input())
D = list(map(int, input().split()))
ans = 0
for i in range(max(D)) :
  cnt = len(list(filter(lambda x : x <= i, D)))
  if(cnt == N // 2) :
    ans += 1
  elif(cnt > N // 2) :
    break
  else :
    pass
print(ans)

### FIXED CODE ###

N = int(input())
D = list(map(int, input().split()))
D.sort()
ans = 0
for i in range(N // 2) :
  cnt = len(list(filter(lambda x : x <= D[N // 2 - 1 + i], D)))
  if(cnt == N // 2) :
    ans += D[N // 2] - D[N // 2 - 1]
  elif(cnt > N // 2) :
    break
  else :
    pass
print(ans)
### BUGGY CODE ###

S = input()
S = list(S)
count_p = 0
count = 0

mark = 1
if len(S) <= 1:
    print(0)
    mark = 0
while mark:
    i = 0
    while i < len(S)-1:
        if int(S[i])+int(S[i+1]) == 1:
            S[i] = '2'
            S[i+1] = '2'
            count += 2
            i += 2
        else:
            i += 1
    if count == count_p:
        print(count)
        break
    else:
        count_p = count
        S = [e for e in S if e!='2']


### FIXED CODE ###

S = list(input())
a = 0
b = 0
for i in range(len(S)):
  if int(S[i]):
    a += 1
  else:
    b += 1
if a < b:
  print(a*2)
else:
  print(b*2)
### BUGGY CODE ###

N, M = map(int, input().split())

l, r = map(int, input().split())
a = set([i for i in range(l, r+1)])
for i in range(M-1):
    l, r = map(int, input().split())
    a = set(a) & set([i for i in range(l, r+1)])

ans = 0
for i in range(N+1):
    if i in a:
        ans += 1

print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
L, R = [], []

for i in range(M):
    l, r = map(int, input().split())
    L.append(l), R.append(r)

if max(L) <= min(R):
    print(min(R) - max(L) + 1)
else:
    print(0)
### BUGGY CODE ###

n=int(input())
A=[int(input()) for i in range(n)]
L = [1]
crt=1
for i in range(n):
  crt = A[crt-1]
  if crt in L:
    print(-1)
    break
  if crt == 2:
    print(len(L))
    break
  L.append(crt)

    

### FIXED CODE ###

def main():
  n=int(input())
  A=[int(input()) for i in range(n)]
  crt=1
  cnt=0
  for i in range(n):
    cnt += 1
    crt = A[crt-1]
    if crt == 2:
      print(cnt)
      break
  else:
    print(-1)
main()
### BUGGY CODE ###

from builtins import enumerate, len

import numpy as np
import copy

N = int(input())
nums = []

for i in range(N):
    nums.append(int(input()))

a = np.array(nums)
maxIndex = [i for i, x in enumerate(a) if x == np.max(a)]

max1 = 0
max2 = 0

if(len(maxIndex)==1):
    nums2 = copy.copy(nums)
    nums2.pop(maxIndex[0])
    b = np.array(nums2)
    maxIndex2 = [i for i, x in enumerate(b) if x == np.max(b)]
    max1 = nums[maxIndex[0]]
    max2 = nums2[maxIndex2[0]]
else:
    max1 = nums[maxIndex[0]]
    max2 = nums[maxIndex[0]]

for num in nums:
    if(num!=max1):
        print(max1)
    else:
        print(max2)

### FIXED CODE ###

N = int(input())
nums = []

for i in range(N):
    nums.append(int(input()))

nums_sorted = sorted(nums,reverse=True)
max1 = nums_sorted[0]
max2 = nums_sorted[1]

for num in nums:
    if(num!=max1):
        print(max1)
    else:
        print(max2)
### BUGGY CODE ###

N = int(input())
S = input()
ok, ng = 0, N + 1
while abs(ok - ng) > 1:
    x = (ok + ng) // 2
    for i in range(N - x + 1):
        target = S[i: i + x]
        if S.find(target, i + x) > 0:
            ok = x
            break
    else:
        ng = x

print(ok)


### FIXED CODE ###

def main():
    N = int(input())
    S = input()
    ok, ng = 0, N + 1
    while abs(ok - ng) > 1:
        x = (ok + ng) // 2
        check = set()
        for i in range(N - x + 1):
            check.add(S[i: i + x])
            if S[i + x: i + 2 * x] in check:
                ok = x
                break
        else:
            ng = x

    print(ok)


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

a,b = map(int, input().split())
ans = 1
while True:
    if (ans%a + ans%b) == 0:
        print(ans)
        break
    ans += 1

### FIXED CODE ###

ab = list(map(int, input().split()))
a = max(ab)
b = min(ab)
r = a%b
while r!=0:
    a = b
    b = r
    r = a%b
print(int(max(ab) * min(ab)/b))
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
sum = 0
b = [i % (10**9+7) for i in a if i % (10**9+7) != 0]
# print(b)
for j in range(0,len(b)-1):
    for k in range(j+1,len(b)):
        c = b[j]*b[k]
        sum = sum + c
print(sum%(10**9+7))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
A = sum(a)
s = 0
for i in range(n-1):
    A = A - a[i]
    b = (a[i]*A)%(10**9+7)
    s = s + b
print(s%(10**9+7))
### BUGGY CODE ###

n = int(input())
lst = [int(i) for i in range(n)]
print(sum(lst))

### FIXED CODE ###

n = int(input())
tmp = (n * (n - 1))//2
print(tmp)
### BUGGY CODE ###

import itertools
import math

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

mod = 10**9+7

# print(list(itertools.combinations(range(6), 3)))
# A = range(6)
# N = 6
# K = 3

def comb(n, k):
    if n >= k:
        ans = 1
        for i in range(k):
            ans *= n-i
        for i in range(k):
            ans //= i+1
        return ans
        # return math.factorial(n) // (math.factorial(n-k) * math.factorial(k))
    else:
        return 0

ans = 0
for i in range(N):
    # print(comb(i, K-1) - comb(N-i-1, K-1))
    ans += (comb(i, K-1) - comb(N-i-1, K-1)) * A[i] % mod

print(ans%mod)

### FIXED CODE ###

# import itertools
# import math

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

mod = 10**9+7

# print(list(itertools.combinations(range(6), 3)))
# A = range(6)
# N = 6
# K = 3

# 二項係数を素数で割った余り
def combMod(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
    # fact = [-1 for _ in range(n+1)]
    # fact[0] = 1
    # fact[1] = 1
    # inv = [-1 for _ in range(n+1)]
    # inv[0] = 0
    # inv[1] = 1
    # factinv = [-1 for _ in range(n+1)]
    # factinv[0] = 1
    # factinv[1] = 1
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
p = mod
    
for i in range(2, N + 1):
    # fact[i] = ((fact[i-1] * i) % p)
    # inv[i] = ((-inv[p % i] * (p // i)) % p)
    # factinv[i] = ((factinv[i-1] * inv[i]) % p)
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)




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

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

N = int(input())
S = list(input())
Q = int(input())

for _ in range(Q):
    type, x, y = input().split()
    if type == "1":
        x = int(x)
        S[x-1] = y
    else:
        x = int(x)
        y = int(y)
        print(len(set(S[x-1:y])))


### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline
    from bisect import bisect_left, insort_left
    N = int(input())
    S = list(input())
    Q = int(input())
    dic = {chr(i): [] for i in range(ord('a'), ord('z')+1)}
    for i in range(N):
        dic[S[i]].append(i)
    for _ in range(Q):
        query, a, c = input().split()
        if query == "1":
            i = int(a)-1
            if S[i] == c:
                continue
            ind = bisect_left(dic[S[i]], i)
            dic[S[i]].pop(ind)
            insort_left(dic[c], i)
            S[i] = c
        else:
            l, r = int(a)-1, int(c)-1
            ans = 0
            for inds in dic.values():
                if inds and l <= inds[-1] and inds[bisect_left(inds, l)] <= r:
                    ans += 1
            print(ans)

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

import math
 
d,g = [int(i) for i in input().split()]
P = []
C = []
for i in range(d):
    p,c = [int(i) for i in input().split()]
    P.append(p)
    C.append(c)

# cnt = 0
# def count():
#     global cnt
#     cnt+=1
#     print(cnt)

m = 10**9
def score(point = 0, n = 0, now=-1, done=[]):
    global m
    if m <= n: return
    elif point >= g:
        if m > n: m = n
    elif point+100*(now+1)*P[now] >= g:
        n += math.ceil((g-point)/(100*(now+1)))
        if m > n: m = n
    else:
        done.append(now)
        if now == -1:
            for i in range(d):
                score(point, n, i, done[:])
        elif m <= n+P[now]: return
        else:
            for i in range(d):
                if not i in done:
                    score(point+P[now]*100*(now+1) + C[now], n + P[now], i, done[:])

score()
print(m)

### FIXED CODE ###

import math
 
d,g = [int(i) for i in input().split()]
P = []
C = []
for i in range(d):
    p,c = [int(i) for i in input().split()]
    P.append(p)
    C.append(c)

# cnt = 0
# def count():
#     global cnt
#     cnt+=1
#     print(cnt)

def flag(point,P,now):
    if point+100*(now+1)*(P-1) >= g: return 1
    elif point+100*(now+1)*P + C[now] >= g: return 2
    else: return 0

m = 10**9
def score(point = 0, n = 0, now=-1, remain = list(range(d))):
    global m
    if m <= n: return
    elif now == -1:
        for i in remain:
            score(point, n, i, remain)
    elif point >= g: m = n
    elif flag(point,P[now],now) == 1:
        n += math.ceil((g-point)/(100*(now+1)))
        if m > n: m = n
    elif flag(point,P[now],now) == 2:
        n += P[now]
        if m > n: m = n
    else:
        if m <= n+P[now]: return
        else:
            remain = remain[:]
            remain.remove(now)
            nxtp = point + P[now]*100*(now+1) + C[now]
            for i in remain:
                score(nxtp, n + P[now], i, remain)

score()
print(m)
### BUGGY CODE ###

N = int(input())

cnt = 0
for i in range(1,N+1,2):
    tmp = set(str(i))
    if len(tmp)==3 and '7' in tmp and '5' in tmp and '3' in tmp:
        cnt += 1
print(cnt)

### FIXED CODE ###

N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    ret = 1 if '7' in s and '5' in s and '3' in s else 0
    for c in '753':
        ret += dfs(s + c)
    return ret

print(dfs('0'))
### BUGGY CODE ###

import math

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

ans = 0
sm = 1
for i in range(k):
    sm *= aL[i]

prev = sm

for i in range(1, n - k + 1):
    j = i + k - 1
    sm = sm // aL[i - 1]
    sm = sm * aL[j]
    if prev < sm:
        print("Yes")
    else:
        print("No")
    prev = sm

### FIXED CODE ###

import math

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

ans = 0

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

n,m = map(int,input().split())
a = [input() for i in range(n)]
b = list(zip(*a))
for i in range(m):
  b[i] = "".join(b[i])
ans = 0
for i in range(m-1):
  b1 = b[i]
  b2 = b[i+1]
  ct1 = [[0 for k in range(n-j+1)] for j in range(n+1)]
  for j in range(n+1):
    b2c = b2[:n-j]
    for k in range(n-j):
      if b1[k+j] == b2c[k]:
        ct1[j][k+1] += ct1[j][k]+1
      else:
        ct1[j][k+1] += ct1[j][k]
  ct2 = [[0 for k in range(n-j+1)] for j in range(n+1)]
  for j in range(n+1):
    b1c = b1[:n-j]
    for k in range(n-j):
      if b2[k+j] == b1c[k]:
        ct2[j][k+1] += ct2[j][k]+1
      else:
        ct2[j][k+1] += ct2[j][k]
  dp = [[10**6 for i in range(n+1)] for j in range(n+1)]
  dp[0][0] = 0
  for i in range(n+1):
    for j in range(n+1):
      if i <= j:
        cost = ct2[j-i][n-j]
      else:
        cost = ct1[i-j][n-i]
      if i < n:
        dp[i+1][j] = min(dp[i+1][j],dp[i][j]+cost)
      if j < n:
        dp[i][j+1] = min(dp[i][j+1],dp[i][j]+cost)
  ans += dp[-1][-1]
print(ans)

### FIXED CODE ###

n,m = map(int,input().split())
a = [input().rstrip() for i in range(n)]
b = list(zip(*a))
for i in range(m):
  b[i] = "".join(b[i])
ans = 0
ct1 = [[0 for k in range(n-j+1)] for j in range(n+1)]
ct2 = [[0 for k in range(n-j+1)] for j in range(n+1)]
dp = [[10**5 for i in range(n+1)] for j in range(n+1)]
for i in range(m-1):
  b1 = b[i]
  b2 = b[i+1]
  for j in range(n+1):
    ct1[j][0] = 0
    ct2[j][0] = 0
    for k in range(n-j):
      ct1[j][k+1] = ct1[j][k]
      ct2[j][k+1] = ct2[j][k]
      if b1[k+j] == b2[k]:
        ct1[j][k+1] += 1
      if b2[k+j] == b1[k]:
        ct2[j][k+1] += 1
  dp[0][0] = 0
  for i in range(n+1):
    if i < n:
      dp[i+1][0] = 10**6
    for j in range(n+1):
      if i == 0 and j < n:
        dp[i][j+1] = 10**6
      if i <= j:
        cost = ct2[j-i][n-j]
      else:
        cost = ct1[i-j][n-i]
      if j < n:
        dp[i][j+1] = min(dp[i][j+1],dp[i][j]+cost)
      if i < n:
        dp[i+1][j] = dp[i][j]+cost
  ans += dp[-1][-1]
print(ans)
### BUGGY CODE ###

def main():
  n = int(input())
  ls = []
  ls_count = []
  for i in range(n):
    item = input()
    if item not in ls:
      ls.append(item)
      ls_count.append(1)
    else:
      ls_count[ls.index(item)] += 1
  max_count = max(ls_count)
  max_index = [i for i, n in enumerate(ls_count) if n == max_count]
  ans = []
  for idx in max_index:
    ans.append(ls[idx])
  ans = sorted(ans)
  for itm in ans:
    print(itm)
  

if __name__ == '__main__':
  main()

### FIXED CODE ###

def main():
  n = int(input())
  dict = {}
  for i in range(n):
    s = input()
    dict.setdefault(s, 0)
    dict[s] += 1
  max_val = 0
  ans_ls = []
  for kv in dict.items():
    if kv[1] > max_val:
      max_val = kv[1]
      ans_ls = [kv[0]]    
    elif kv[1] == max_val:
      ans_ls.append(kv[0])
  ans_ls = sorted(ans_ls)
  for name in ans_ls:
    print(name)
 
 
if __name__ == '__main__':
  main()
### BUGGY CODE ###

from itertools import count

X = int(input())

pn = []
for L in count(2):
    chk = True
    for L2 in pn:
        if L % L2 == 0:
            break
    else:
        pn.append(L)
        if L >= X:
            print(L)
            break

### FIXED CODE ###

from itertools import count

X = int(input())

pn = []
for L in count(2):
    chk = True
    for L2 in pn:
        if L % L2 == 0:
            break
    else:
        pn.append(L)
        if L >= X:
            print(L)
            break
### BUGGY CODE ###

N = int(input())
S = [0]*N
ans = 0

for i in range(N) :
    s = input()
    S[i] =''.join(sorted(s))

for i in range(N-1) :
    for j in range(i+1,N) :
        if S[i] == S[j] :
            ans += 1

print(ans)




### FIXED CODE ###

N = int(input())
dic = {}
ans = 0

for i in range(N) :
    s = tuple(sorted(input()))
    if s in dic :
        ans += dic[s]
        dic[s] += 1
    else : 
        dic[s] = 1

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

import numpy as np

h,w,k = map(int,input().split())
S = [list(input()) for _ in range(h)]

res = 10**5
for div in range(2**(h-1)):
    cut = []
    for i in range(h-1):
        if ((div >> i) & 1):
            cut.append(i+1)
    fr = 0
    part = []
    for i in range(len(cut)):
        to = cut[i]
        part.append(S[fr:to])
        fr = to
    else:
        part.append(S[fr:])
    comp_arr = []
    for p in part:
        p_ = np.array(p).astype(np.int)
        comp_arr.append(p_.sum(axis=0))
    comp_arr_T = np.array(comp_arr).T
    
    cnt = len(cut)

    tank = [0]*len(comp_arr)
    
    for m in range(w):
        for n in range(len(comp_arr)):
            tank[n] += comp_arr[n][m]

        if any([c>k for c in tank]):
            cnt += 1
            for n in range(len(comp_arr)):
                tank[n] = comp_arr[n][m]

    res = min(res, cnt)
print(res)

### FIXED CODE ###

h,w,k = map(int,input().split())
S = [list(map(int,list(input()))) for _ in range(h)]
ans = 10**9+7
for i in range(1 << (h-1)):
    group = [[0]*w]
    g_id = 0
    group[g_id] = [s+b for s, b in zip(S[0], group[0])]
    for j in range(1, h):
        if (i>>(j-1))&1:
            group.append([0]*w)
            g_id += 1
        group[g_id] = [s+b for s, b in zip(S[j], group[g_id])]
    if not all([all([i <= k for i in b]) for b in group]):
        continue
    cnt = len(group) - 1
    g_cnt = [0] * len(group)
    
    for jj in range(w):
        for g_id in range(len(group)):
            g_cnt[g_id] += group[g_id][jj]
        if any([c > k for c in g_cnt]):
            cnt  += 1
            for g_id in range(len(group)):
                g_cnt[g_id] = group[g_id][jj]
    ans = min(ans, cnt)
print(ans)
### BUGGY CODE ###

x, y, z, k = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
c = list(map(int, input().split(' ')))
ab = []
for i in range(len(a)):
    for j in range(len(b)):
        ab.append(a[i]+b[j])
ab.sort(reverse = True)
abc = []
k_1 = min([len(ab), k])
for i in ab:
    for j in c:
        abc.append(i+j)
abc.sort(reverse = True)
for i in range(k):
    print(abc[i])

### FIXED CODE ###

import heapq
import sys
x, y, z, k = map(int, input().split())

a, b, c = (sorted(map(int, sys.stdin.readline().split()), reverse=True) for _ in range(3))

abc = {(0,0,0)}

stu = [[-a[0]-b[0]-c[0], 0,0,0]]
heapq.heapify(stu)
result = []
while k > 0:
    out_p, n, m, l = heapq.heappop(stu)
    if n+1<x and not((n+1,m,l) in abc):
        abc.add((n+1,m,l))
        heapq.heappush(stu, [-a[n+1]-b[m]-c[l], n+1, m, l])
    if m+1<y and not((n,m+1,l) in abc):
        abc.add((n,m+1,l))
        heapq.heappush(stu, [-a[n]-b[m+1]-c[l], n, m+1, l])
    if l+1<z and not((n,m,l+1) in abc):
        abc.add((n,m,l+1))
        heapq.heappush(stu, [-a[n]-b[m]-c[l+1], n, m, l+1])
    result.append(-out_p)
    k -= 1
result.sort(reverse=True)
for i in result:
    print(i)
### BUGGY CODE ###

from math import gcd

if __name__ == '__main__':

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

    gcd_ = gcd(A[0], A[1])
    for i in range(2, len(A)):
        gcd_ = gcd(gcd_, A[i])

    set_wise = False
    if gcd_ == 1:
        set_wise = True
    if not(set_wise):
        print("not coprime")
    else:
        pairwise = True
        for i in range(n):
            for j in range(i+1, n):
                gcd_ = gcd(A[i], A[j])
                if gcd_ != 1:
                    pairwise = False
        if pairwise:
            print("pairwise coprime")
        else:
            print("setwise coprime")






### FIXED CODE ###

import math


def divisorGenerator(n):

    large_divisors = []
    for i in range(1, int(math.sqrt(n) + 1)):
        if n % i == 0:
            yield i
            if i*i != n:
                large_divisors.append(n // i)
    for divisor in reversed(large_divisors):
        yield divisor

if __name__ == '__main__':

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

    gcd_ = math.gcd(A[0], A[1])
    for i in range(2, len(A)):
        gcd_ = math.gcd(gcd_, A[i])

    set_wise = False
    if gcd_ == 1:
        set_wise = True
    if not(set_wise):
        print("not coprime")
    else:
        pairwise = True
        divs = dict()
        for i in A:
            res = list(divisorGenerator(i))
            for el in res:
                if el != 1:
                    if not(el in divs):
                        divs[el] = 0
                    divs[el] += 1
                    if divs[el] > 1:
                        print("setwise coprime")
                        exit()
        print("pairwise coprime")
        # for value in divs.values():
        #     if value > 1:
        #         pairwise = False
        #         break
        # if pairwise:
        #     print("pairwise coprime")
        # else:
        #
        #
### BUGGY CODE ###

N = [int(i) for i in input().split()]

answerList = []

for i in range(N[0]):
    answerList.append(0)

for i in range(N[0]):
    if i > 0:
        for j in range(N[0]):
            if j + 1 > i > 0:
                a = abs(j + 1 - i)
                if a == 1:
                    answerList[1] = answerList[1] + 1
                    continue
                calculateList = [a,
                                 abs(N[1] - i) + 1 + abs(j + 1 - N[2]),
                                 abs(N[2] - i) + 1 + abs(j + 1 - N[1])]
                answer = min(calculateList)
                answerList[answer] = answerList[answer] + 1

for i in range(N[0] - 1):
    print(answerList[i + 1])

### FIXED CODE ###

N = [int(i) for i in input().split()]

answerList = []

for i in range(N[0]):
    answerList.append(0)

for i in range(N[0]):
    if i > 0:
        for j in range(N[0]):
            if j + 1 > i > 0:
                calculateList = [abs(j + 1 - i),
                                 abs(N[1] - i) + 1 + abs(j + 1 - N[2]),
                                 abs(N[2] - i) + 1 + abs(j + 1 - N[1])]
                answer = min(calculateList)
                answerList[answer] = answerList[answer] + 1

for i in range(N[0] - 1):
    print(answerList[i + 1])
### BUGGY CODE ###

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

a = sorted(a)
ans = 0
while len(a) > 1:
    m = a[len(a) - 1]
    del a[len(a) - 1]
    temp = 2
    for i in range(n):
        if temp > m:
            break
        else:
            temp *= 2
    if temp > m * 2:
        continue
    if (temp - m) in a:
        ans += 1
        a.remove(temp - m)

print(ans)



### FIXED CODE ###

from collections import Counter

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

a.sort(reverse=True)
c = Counter(a)

ans = 0
for x in a:
    if c[x] == 0:
        continue
    temp = (1 << x.bit_length()) - x
    c[x] -= 1
    if temp in c.keys():
        if c[temp] > 0:
            c[temp] -= 1
            ans += 1

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

def factorial(n) : 
    a = 1
    for i in range(1 , n+1):
        a *= i
    return a

def solve():
    (n,m) = map(int,input().split())
    if(abs(n-m)>1):
        return 0
    if(n==m):
        return (factorial(n)**2 * 2) % 1000000007
    if(n > m):
        return (factorial(m)**2 * n) % 1000000007
    else:
        return (factorial(n)**2 * m) % 1000000007

if(__name__ == "__main__"):
    print(solve())

### FIXED CODE ###

import math

mod = 1000000007

def solve():
    (n,m) = map(int,input().split())
    if(abs(n-m)>1):
        return 0
    if(n==m):
        return (math.factorial(n)**2 * 2) % mod
    if(n > m):
        return (math.factorial(m)**2 * n) % mod
    else:
        return (math.factorial(n)**2 * m) % mod

if(__name__ == "__main__"):
    print(solve())
### BUGGY CODE ###

# key not available ""
import sys
n, k = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]
dp = [sys.maxsize]*n
dp[0] = 0
for i in range(n):
    for j in range(i+1, i+k+1):
        if j < n:
            dp[j] = min(dp[j], dp[i]+abs(arr[i]-arr[j]))
print(dp[-1])


### FIXED CODE ###

# key not available ""
import sys
n, k = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]
dp = [sys.maxsize]*n
dp[0] = 0
for i in range(n):
    for j in range(i+1, i+k+1):
        if j < n:
            dp[j] = min(dp[j], dp[i]+abs(arr[i]-arr[j]))
print(dp[-1])