Harryxun/stf_run huggingface dataset:
n,k=map(int,input().split())
h=list(map(int,input().split()))

dp=[0]*n
def calc(n,k,h)
for i in range(1,n):
    dp[i]=min([dp[j] + abs(h[i]-h[j]) for j in range(max(i-k,0),i)])

calc(n,k,h)
print(dp[-1])


### FIXED CODE ###

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

dp=[0]*n
def calc(n,k,h,dp):
    for i in range(1,n):
        dp[i]=min([dp[j] + abs(h[i]-h[j]) for j in range(max(i-k,0),i)])

calc(n,k,h,dp)
print(dp[-1])
n = int(input())
sn = str(n)
minx = 0
temp = 754
sav = 0
for i in range(len(str(n//100))):
    minx = abs(753-int(sn[i:i+3]))
    if temp > minx:
        temp = minx
        sav = n3

print(sav)


### FIXED CODE ###

n = int(input())
sn = str(n)
n3 = 0
minx = 0
temp = 754
for i in range(len(str(n // 100))):
    n3 = int(sn[i : i + 3])
    minx = abs(753 - n3)
    if temp > minx:
        temp = minx

print(temp)
if B//K - A//K >=1:
	print('OK')
elif B == A:
	print('OK')
else:
	print('NG')

### FIXED CODE ###

K = int(input())
AB = input()
ABB = AB.split()
A = int(ABB[0])
B = int(ABB[1])
C = 0

for i in range(A, B+1):
  if i % K ==0:
    print('OK')
    C = 1
    break
if C == 0:
  print('NG')
from collections import deque

n, m = list(map(int, input().split()))
AB = [[int(x) for x in input().split()] for _ in range(m)]

# representation matrix
repn = [[] for j in range(n)]
for a, b in AB:
    a -= 1
    b -= 1
    repn[a].append(b)
    repn[b].append(a)


# Minimum Spanning Tree
tree = [[] for i in range(n)]
visited = [True] + [False] * (n - 1)
q = deque([0])

while q:
    u = q.popleft()
    for v in repn[u]:
        if visited[v]:
            continue
        visited[v] = True
        tree[u].append(v)
        tree[v].append(u)
        q.append(v)


# define directions of the edges other than that of MST
degree = [0] * n
ans = []

for a, b in AB:
    a -= 1
    b -= 1
    if b in tree[a]:
        continue
    ans.append('{} {}'.format(a + 1, b + 1))
    degree[a] += 1


# defining orientations
def dfs(u = 0, parent = None):
    for v in tree[u]:
        if v == parent:
            continue
        dfs(v, u)
        if degree[v] % 2 == 0:
            ans.append('{} {}'.format(u + 1, v + 1))
            degree[u] += 1
        else:
            ans.append('{} {}'.format(v + 1, u + 1))
            degree[v] += 1

dfs()


# output answer
if degree[0] % 2 == 1:
    print(-1)
else:
    print('\n'.join(ans))


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
from collections import deque

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

if m % 2 == 1:
    print(-1)
    exit()



AB = [[int(x) for x in input().split()] for _ in range(m)]

# representation matrix
repn = [[] for j in range(n + 1)]
for a, b in AB:
    repn[a].append(b)
    repn[b].append(a)


# Minimum Spanning Tree
tree = [set() for i in range(n + 1)]
visited = [False] * (n + 1)
visited[1] = True
q = deque([1])

while q:
    u = q.popleft()
    for v in repn[u]:
        if visited[v]:
            continue
        visited[v] = True
        tree[u].add(v)
        tree[v].add(u)
        q.append(v)


# define directions of the edges other than that of MST
degree = [0] * (n + 1)
ans = []

for a, b in AB:
    if b in tree[a]:
        continue
    ans.append('{} {}'.format(a, b))
    degree[a] += 1


# defining orientations
def dfs(u = 1, parent = None):
    for v in tree[u]:
        if v == parent:
            continue
        dfs(v, u)
        if degree[v] % 2 == 0:
            ans.append('{} {}'.format(u, v))
            degree[u] += 1
        else:
            ans.append('{} {}'.format(v, u))
            degree[v] += 1

dfs()

print('\n'.join(ans))
a=int(input())
b=int(input())
print(a*b)

### FIXED CODE ###

a=list(map(int,input().split()))
print(a[0]*a[1])
import sys
import re
S = input()
if not ( 1 <= len(S) <= 10 ): sys.exit()
if not S.isupper: sys.exit()

max = max(re.findall('[A|T|G|C]+', S)) if re.findall('[A|T|G|C]+', S) else 0
if max > 0:max
print(max)

### FIXED CODE ###

import sys
import re
S = input()
if not ( 1 <= len(S) <= 10 ): sys.exit()
if not S.isupper: sys.exit()

result = 0
max = max(re.findall('[A|T|G|C]+', S),key=len) if re.findall('[A|T|G|C]+', S) else ''
if len(max) > 0:result = len(max)
print(result)
n = int(input())
A = [int(i) for i in input().split()]

dp = [-1 for i in range(n+1)]
import sys
sys.setrecursionlimit(10000)
def brute(i):
    if i>=n-1:
        return 0
    if dp[i]!=-1:
        return dp[i]
    ans = 10**10
    if i+1 < n:
        ans = min(ans, abs(A[i] - A[i+1]) + brute(i+1))
    if i+2 < n:
        ans = min(ans, abs(A[i] - A[i+2]) + brute(i+2))
    dp[i] = ans
    return ans

print(brute(0))


### FIXED CODE ###

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

dp = [-1 for i in range(n+50)]
import sys
sys.setrecursionlimit(1000000)
def brute(i):
    if i>=n-1:
        return 0
    if dp[i]!=-1:
        return dp[i]
    ans = 10**10
    if i+1 < n:
        ans = min(ans, abs(A[i] - A[i+1]) + brute(i+1))
    if i+2 < n:
        ans = min(ans, abs(A[i] - A[i+2]) + brute(i+2))
    dp[i] = ans
    return ans

print(brute(0))
a,s,b=map(input(),split())
print(a(1)+c(1)+b(1))


### FIXED CODE ###

a,b,c=input().split()
print(a[0]+b[0]+c[0])
def main():
    X, Y, A, B, C = [int(i) for i in input().split()]
    red = [int(i) for i in input().split()]
    blue = [int(i) for i in input().split()]
    noc = [int(i) for i in input().split()]
    red = sorted(red)[-X:]
    blue = sorted(blue)[-Y:]
    rb = sorted(red + blue)
    score = sum(rb)
    noc = sorted(noc)[::-1]

    s_noc = 0
    s_rb = 0
    for i in range(min(A+B, C)):
        if rb[i] > noc[i]:
            break
        s_noc += noc[i]
        s_rb += rb[i]

    print(score + s_noc - s_rb)


if __name__ == '__main__':
    main()



### FIXED CODE ###

def main():
    X, Y, A, B, C = [int(i) for i in input().split()]
    red = [int(i) for i in input().split()]
    blue = [int(i) for i in input().split()]
    noc = [int(i) for i in input().split()]
    red = sorted(red)[-X:]
    blue = sorted(blue)[-Y:]
    rb = sorted(red + blue)
    score = sum(rb)
    noc = sorted(noc)[::-1]

    s_noc = 0
    s_rb = 0
    for i in range(min(len(rb), len(noc))):
        if rb[i] > noc[i]:
            break
        s_noc += noc[i]
        s_rb += rb[i]

    print(score + s_noc - s_rb)


if __name__ == '__main__':
    main()
import sys
from collections import Counter

read = sys.stdin.read


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def sieve_of_eratosthenes(n):
    sieve = [True] * n
    for i in range(3, int(n ** 0.5) + 1, 2):
        if sieve[i]:
            sieve[i * i::2 * i] = [False] * ((n - i * i - 1) // (2 * i) + 1)
    return [2] + [i for i in range(3, n, 2) if sieve[i]]


def prime_factorize(n):
    a = []
    if n == 1:
        return [1]
    for i in primes:
        if n == 1:
            break
        while n % i == 0:
            a.append(i)
            n //= i
    return a


N, *A = map(int, read().split())
mod = 10 ** 9 + 7

primes = sieve_of_eratosthenes(10 ** 6)
dic = {i: 0 for i in primes}

n = len(primes)
p = [0] * n
for i in A:
    tmp = Counter(prime_factorize(i))
    for key, value in tmp.items():
        # print(key, value)
        if dic[key] < value:
            dic[key] = value

lcm = 1
for i, j in dic.items():
    if j == 0:
        continue
    lcm *= pow(i, j, mod)
    lcm %= mod

answer = 0
for i in A:
    answer += lcm * pow(i, mod - 2, mod)
    answer %= mod

print(answer)


### FIXED CODE ###

import sys
from collections import Counter

read = sys.stdin.read


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def sieve_of_eratosthenes(n):
    sieve = [True] * n
    for i in range(3, int(n ** 0.5) + 1, 2):
        if sieve[i]:
            sieve[i * i::2 * i] = [False] * ((n - i * i - 1) // (2 * i) + 1)
    return [2] + [i for i in range(3, n, 2) if sieve[i]]


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


N, *A = map(int, read().split())
mod = 10 ** 9 + 7

primes = sieve_of_eratosthenes(max(A) + 1)
dic = {i: 0 for i in primes}

n = len(primes)
p = [0] * n
for i in A:
    tmp = Counter(prime_factorize(i))
    for key, value in tmp.items():
        #print(key, value)
        if dic[key] < value:
            dic[key] = value

lcm = 1
for i, j in dic.items():
    if j == 0:
        continue
    lcm *= pow(i, j, mod)
    lcm %= mod

answer = 0
for i in A:
    answer += lcm * pow(i, mod - 2, mod)
    answer %= mod

print(answer)
n,k = map(int,input().split())
h = sorted([int(input()) for _ in range(n)])
print(min(h[j+k-1]-h[j] for j in range(n-k+1)))

### FIXED CODE ###

n = int(input())
print("Christmas" + " Eve" * (25-n))
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]
ans = 0
exist = False
if N == 1:
  x = 0
else:
  x = 10 ** (N - 1)
for i in range(x, 1000):
  s = str(i)
  f = True
  for j in range(len(s)):
    if int(s[sc[j][0] - 1]) != sc[j][1]:
      f = False
      break
  if f:
    ans = i
    exist = True
    break
print(ans if exist else -1)

### FIXED CODE ###

N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]
ans = 0
exist = False
if N == 1:
  x = 0
else:
  x = 10 ** (N - 1)
for i in range(x, 1000):
  s = str(i)
  f = True
  for j in range(M):
    if int(s[sc[j][0] - 1]) != sc[j][1]:
      f = False
      break
  if f:
    ans = i
    exist = True
    break
print(ans if exist else -1)
n, k = map(int, input().split())

mn = n - 2
mx = (n - 1) * (n - 2) // 2

if mn <= k <= mx:
    raise Exception

else:
    print(-1)


### FIXED CODE ###

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

if k <= (n - 1) * (n - 2) // 2:
    g = [0] * (n * n)
    for i in range(n * n):
        u = i // n
        v = i % n
        if u < v:
            g[i] = 1

    i = 0
    for _ in range(k):
        while g[i] == 0 or i % n == n - 1:
            i += 1
        g[i] = 0

    cnt = sum(g)
    print(cnt)
    for i, e in enumerate(g):
        if e:
            u = i // n + 1
            v = i % n + 1
            print(u, v)

else:
    print(-1)
N,K = map(int, input().split())
A = [(1+int(x))/2 for x in input().split()]
wa = []
w = 0
for i in range(0,K):
    w = w+A[i]
wa.append(w)
for j in range(N-k):
    w = w + wa[j+K] - wa[j]
    wa.append(w)
print(max(wa))

### FIXED CODE ###

N,K = map(int, input().split())
A = [(1+int(x))/2 for x in input().split()]
wa = []
w = 0
for i in range(0,K):
    w = w+A[i]
wa.append(w)
for j in range(N-K):
    w = w + A[j+K] - A[j]
    wa.append(w)
print(max(wa))
import numpy as np

n = list(map(int, input().split()))
d = np.array(list(map(int, input().split())))
a = len(str(n[0]))
x = np.zeros(a + 1)

for i in range(a + 1):
    x[i] = (n[0] % np.power(10, a - i + 1)) // np.power(10, a - i)

i = 0
while i != a + 1:
    i += 1
    while np.any(d == x[i]):
        x[i] += 1
        x[i + (i != a):] = 0
    if x[i] == 10:
        x[i - 1] += 1
        x[i:] = 0
    if np.any(d == x[0]) and x[0] != 0:
        i = 0
        
ans = 0
for i in range(a + 1):
    ans += x[i] * np.power(10, a - i)

print(int(ans))

### FIXED CODE ###

import numpy as np

n = list(map(int, input().split()))
d = np.array(list(map(int, input().split())))
a = len(str(n[0]))
x = np.zeros(a + 1)

for i in range(a + 1):
    x[i] = (n[0] % np.power(10, a - i + 1)) // np.power(10, a - i)

i = 0
while i != a:
    i += 1
    while np.any(d == x[i]):
        x[i] += 1
        if i != a:
            x[i + 1:] = 0
        if x[i] == 10:
            x[i - 1] += 1
            x[i:] = 0
            i -= 1

ans = 0
for i in range(a + 1):
    ans += x[i] * np.power(10, a - i)

print(int(ans))
N = int(input())
ans = 0
if N < 105:
  pass
else:
  for i in range(1, N+1):
    cnt = 0
    for j in range(1, N+1):
	    if j % i == 0:
          cnt += 1
    if cnt == 8:
      ans += 1
      
print(ans)  

### FIXED CODE ###

N = int(input())
ans = 0
if N < 105:
  pass
else:
  for i in range(105, N+1, 2):
    cnt = 0
    for j in range(1, N+1):
      if i % j == 0:
        cnt += 1
    if cnt == 8:
      ans += 1
      
print(ans)
def main():
  import sys
  input = sys.stdin.readline
  h, w = map(int, input().split())
  A = []
  B = []
  for i in range(h):
    row = list(map(int, input().split()))
    A.append(row)
  for i in range(h):
    row = list(map(int, input().split()))
    B.append(row)
 
  dp = [[[0 for k in range(12801)] for j in range(w+1)] for i in range(h+1)]
  dp[0][0].add(abs(A[0][0] - B[0][0]))
  for i in range(h):
    for j in range(w):
      for item, f in enumerate(dp[i][j]):
        if not f:
          continue
        if j < w - 1:
          dif = abs(A[i][j+1] - B[i][j+1])
          dp[i][j+1].add(item+dif)
          dp[i][j+1].add(abs(item-dif))
        if i < h - 1:
          dif = abs(A[i+1][j] - B[i+1][j])
          dp[i+1][j].add(item+dif)
          dp[i+1][j].add(abs(item-dif))
  print(min(dp[h-1][w-1]))
if __name__ == '__main__':
  main()


### FIXED CODE ###

import sys
def main():
  input = sys.stdin.readline
  h, w = map(int, input().split())
  A = []
  AB = []
  A_append = A.append
  AB_append = AB.append
  for i in range(h):
    row = list(map(int, input().split()))
    A_append(row)
  for i in range(h):
    row = [abs(A[i][j] - int(b)) for j, b in enumerate(input().split())]
    AB_append(row)
 
  dp_cur = [set([]) for _ in range(w)]
  dp_cur[0].add(AB[0][0])
  for i in range(h):
    dp_next = [set([]) for _ in range(w)]
    for j in range(w):
      if j < w - 1:
        add1 = dp_cur[j+1].add
        dif1 = AB[i][j+1]
      if i < h - 1:
        add2 = dp_next[j].add
        dif2 = AB[i+1][j]
      for item in dp_cur[j]:
        if j < w - 1:
          add1(item+dif1)
          add1(abs(item-dif1))
        if i < h - 1:
          add2(item+dif2)
          add2(abs(item-dif2))
    if i == h - 1:
      break
    dp_cur = dp_next
  print(min(dp_cur[w-1]))
if __name__ == '__main__':
  main()
import sys
sys.setrecursionlimit(10**6)

N, M = map(int, input().split())
link = [[] for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    link[a-1].append([b-1, c])
visited = [0] * N
ans = 0

def dfs(v, cnt):
    global ans
    if v == N-1:
        if visited[v] == 0:
            ans = cnt
        else:
            ans = max(ans, cnt)
        for p in link[v]:
            if visited[p[0]] and ans > 0:
                ans = 'inf'
                print(ans)
                exit()
            elif visited[p[0]] and ans <= 0:
                break
    visited[v] = 1
    for nv in link[v]:
        dfs(nv[0], cnt+nv[1])
    return

dfs(0, 0)
print(ans)


### FIXED CODE ###

N, M = map(int, input().split())
a = [0] * M
b = [0] * M
c = [0] * M
for i in range(M):
    a[i], b[i], c[i] = map(int, input().split())
    c[i] = -c[i]
    
INF = 10 ** 13
dist = [INF] * N

dist[0] = 0

for loop in range(N-1):
    for i in range(M):
        if dist[a[i]-1] == INF:
            continue
        if dist[b[i]-1] > dist[a[i]-1] + c[i]:
            dist[b[i]-1] = dist[a[i]-1] + c[i]

ans = dist[N-1]

nega = [0] * N

for loop in range(N):
    for i in range(M):
        if dist[a[i]-1] == INF:
            continue
        if dist[b[i]-1] > dist[a[i]-1] + c[i]:
            dist[b[i]-1] = dist[a[i]-1] + c[i]
            nega[b[i]-1] = 1
        if nega[a[i]-1] == 1:
            nega[b[i]-1] = 1

if nega[N-1]:
    print('inf')
else:
    print(-ans)
a, b, c = map(int, input().split())

if c - (a - b) < 0:
    print(0)
else:
    print(c - remain)


### FIXED CODE ###

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

if c - (a - b) < 0:
    print(0)
else:
    print(c - (a - b))
def matrixChainMultiplication(p):
    # p = [p_0, p_1, ..., p_n]
    n = len(p) - 1
    # n+1 x n+1 zero matrix?????????(0,...,n)
    # cost(i,j): (M_i...M_j)???????°??????????
    cost = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
    for numOfMatrices in range(2, n + 1):
        for i in range(1, n - numOfMatrices + 2):
            j = i + numOfMatrices - 1
            cost[i][j] = float('inf')
            for k in range(i, j):
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k + 1][j] + p[i - 1] * p[k] * p[j])
    print(m[1][n])

p = []
n = int(input())

for _ in range(n):
    listed_input = input().split()
    p.append(int(listed_input.[0]))
p.append(int(listed_input[1]))

matrixChainMultiplication(p)

### FIXED CODE ###

def matrixChainMultiplication(p):
    # p = [p_0, p_1, ..., p_n]
    n = len(p) - 1
    # n+1 x n+1 zero matrix?????????(0,...,n)
    # cost(i,j): (M_i...M_j)???????°??????????
    cost = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
    for numOfMatrices in range(2, n + 1):
        for i in range(1, n - numOfMatrices + 2):
            j = i + numOfMatrices - 1
            cost[i][j] = float('inf')
            for k in range(i, j):
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k + 1][j] + p[i - 1] * p[k] * p[j])
    print(cost[1][n])

p = []
n = int(input())

for _ in range(n):
    listed_input = input().split()
    p.append(int(listed_input[0]))
p.append(int(listed_input[1]))

matrixChainMultiplication(p)
s = input()
<_cnt = 0
>_cnt = 0
for i in range(len(s)):
  if s[i] == '<' and >_cnt == 0:
    <_cnt += 1
  elif s[i] == '<' and >_cnt > 0:
    k = max(<_cnt, >_cnt)
    l = min(<_cnt, >_cnt)
    total += (k+1)*k//2 + l*(l-1)//2
    <_cnt = 1
    >_cnt = 0
  elif s[i] == '>':
    >_cnt += 1
k = max(<_cnt, >_cnt)
l = min(<_cnt, >_cnt)
total += (k+1)*k//2 + l*(l-1)//2
print(total)
    

### FIXED CODE ###

s = input()
right_cnt = 0
left_cnt = 0
total = 0
for i in range(len(s)):
  if s[i] == '<' and left_cnt == 0:
    right_cnt += 1
  elif s[i] == '<' and left_cnt > 0:
    k = max(right_cnt, left_cnt)
    l = min(right_cnt, left_cnt)
    total += (((k+1)*k) + (l*(l-1)))//2
    right_cnt = 1
    left_cnt = 0
  elif s[i] == '>':
    left_cnt += 1
k = max(right_cnt, left_cnt)
l = min(right_cnt, left_cnt)
total += (((k+1)*k) + (l*(l-1)))//2
print(total)
K = int(input())

Ans = [1,2,3,4,5,6,7,8,9]
n,a = 10,9
while n <= 10**20:
    for i in range(1,10):
        Ans.append(n*i+a)
    a += n*9
    n *= 10

for i in range(K):
    print(Ans[i])

### FIXED CODE ###

K = int(input())

Ans = [1, 2, 3, 4, 5, 6, 7, 8, 9]
for x in range(1,15):
    B = [0]*100000
    n,d = 10**x,int("9"*x)
    for i in range(10000):
        num = i*n+d
        S = str(num)
        total = 0
        for s in S:
            total += int(s)
        B[i] = num/total
        if i > 0:
            if B[i] < B[i-1]:
                #最後の値を削除
                Ans.pop()
                break
            else:
                if num not in Ans:
                    Ans.append(num)

for i in range(K):
    print(Ans[i])
import sys
import heapq

N,M = [int(k) for k in sys.stdin.readline().split()]

job=[]
for i in range(N):
    A,B = [int(k) for k in sys.stdin.readline().split()]
    job.append((A,-B))

job.sort(key=lambda t: -t[0])

heap=[]
heapq.heapify(heap)

ans=0

for i in range(1,M+1):
    if len(job)!=0:
      while job[-1][0]==i:
         heapq.heappush(heap,job.pop()[1])
          if len(job)==0:
             break
    if len(heap) == 0:
        continue
    ans -= heapq.heappop(heap)
    
print(ans)


### FIXED CODE ###

import sys
import heapq

N,M = [int(k) for k in sys.stdin.readline().split()]

job=[]
for i in range(N):
    A,B = [int(k) for k in sys.stdin.readline().split()]
    job.append((A,-B))

job.sort(key=lambda t: -t[0])

heap=[]
heapq.heapify(heap)

ans=0

for i in range(1,M+1):
    if len(job)!=0:
      while job[-1][0]==i:
          heapq.heappush(heap,job.pop()[1])
          if len(job)==0:
             break
    if len(heap) == 0:
        continue
    ans -= heapq.heappop(heap)
    
print(ans)
# coding: utf-8
import time
import re
import math

def main():
    global n,H,memo,mn
    n=int(input())
    H=list(map(int,input().split()))
    mn=1e9
    memo=[]*n
    dp(0,0)
    print(mn)
def dp(index,cost):
    global n,H,memo,mn
    if index==n-1:
        #print("cost {}".format(cost))
        mn=min([mn,cost])
    else:
        if(index+1<n):dp(index+1,cost+abs(H[index]-H[index+1]))
        if(index+2<n): dp(index+2,cost+abs(H[index]-H[index+2]))

start=time.time()
main()
#print("処理速度 {}sec".format(time.time()-start))

### FIXED CODE ###

# coding: utf-8
import time
import re
import math

def main():
    n=int(input())
    H=list(map(int,input().split()))
    memo=[0]*n
    for a in range(n):
        if a==0:
            memo[a]=0
        elif a==1:
            memo[a]=memo[a-1]+abs(H[a-1]-H[a])
        else:
            memo[a]=min([memo[a-1]+abs(H[a-1]-H[a]),memo[a-2]+abs(H[a-2]-H[a])])
    print(memo[-1])


start=time.time()
main()
#print("処理速度 {}sec".format(time.time()-start))
k = int(input())
ans = 0
for i in range(1, k+1):
  for j in range(1, k+1):
    key = gcd(i, j)
    for n in range(1, k+1):
      ans += gcd(key, n)
print(ans)

### FIXED CODE ###

from math import gcd
k = int(input())
ans = 0
for i in range(1, k+1):
  for j in range(1, k+1):
    key = gcd(i, j)
    for n in range(1, k+1):
      ans += gcd(key, n)
print(ans)
A = set(int,input().split())

if len(A)==2:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

A = set(map(int,input().split()))

if len(A)==2:
    print("Yes")
else:
    print("No")
# from scipy.misc import comb
from scipy.special import comb


MOD = 10 ** 9 + 7

def main():
    N, K = map(int, input().split())

    note = [[-1 for i in range(N)] for j in range(N)]

    def calc_comb(n, r):
        if note[n][r] != -1:
            return note[n][r]
        a = comb(n, r, exact=True)
        note[n][r] = a
        return a

    def print_patterns(i, N, K):
        m = N - K
        if i - 1 > m:
            print(0)
            return
        if i == 1:
            p = 1 * (m+1) % MOD
            print(p)
            return
        p_red = 0
        for l in range(i-1, m+1):
            p_red += calc_comb(l-1, i-2) * (m-l+1)
            p_red %= MOD
        p = calc_comb(K-1, i-1) * p_red % MOD
        print(p)

    for i in range(1, K+1):
        print_patterns(i, N, K)


main()

### FIXED CODE ###

from scipy.misc import comb
# from scipy.special import comb


MOD = 10 ** 9 + 7

def main():
    N, K = map(int, input().split())

    note = [[-1 for i in range(N)] for j in range(N)]

    def calc_comb(n, r):
        if note[n][r] != -1:
            return note[n][r]
        a = comb(n, r, exact=True)
        note[n][r] = a
        return a

    def print_patterns(i, N, K):
        m = N - K
        if i - 1 > m:
            print(0)
            return
        if i == 1:
            p = 1 * (m+1) % MOD
            print(p)
            return
        p = calc_comb(K-1, i-1) * calc_comb(m+1, i) % MOD
        print(p)

    for i in range(1, K+1):
        print_patterns(i, N, K)


main()
import sys

sys.setrecursionlimit(100000)
n = int(input())
def train(n):
    if n == 1:
        return 1
    else:
        return n * train(n-1)

ans = train(n) % (10**9 + 7)

print(ans)


### FIXED CODE ###

import math

n = int(input())

ans = math.factorial(n) % (10**9 + 7)

print(ans)
n = int(input())
l = list(map(int,input().split()))
m = int(input())
p_x = []
for i in range(m):
  p_x.append(list(map(int,input()).split()))
for i in range(m):
  p = p_x[i][0]
  x = p_x[i][1]
  print(sum(l) - l[p-1] + x) 

### FIXED CODE ###

n = int(input())
l = list(map(int,input().split()))
m = int(input())
p_x = []
for i in range(m):
  p_x.append(list(map(int,input().split())))
for i in range(m):
  p = p_x[i][0]
  x = p_x[i][1]
  print(sum(l) - l[p-1] + x)
kx=list(map(int,input().split()))
k=kx[0]
x=kx[1]
a=x+1-k
b=x+k-1
print(a b)

### FIXED CODE ###

kx=list(map(int,input().split()))
k=kx[0]
x=kx[1]
a=x+1-k
b=x+k
for i in range(a,b):
  print(i,end=" ")
n, X = map(int, input().split())
import numpy as np

x = np.array(list(map(int, input().split())))
x -= X

x = np.abs(x)
D = 0
from math import gcd

for d in x:
  D = gcd(D,d)

print(D)

### FIXED CODE ###

n, X = map(int, input().split())
import numpy as np

x = np.array(list(map(int, input().split())))
x -= X

x = np.abs(x)
D = 0
from fractions import gcd

for d in x:
  D = gcd(D,d)

print(D)