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

n,k = map(int,input().split())
MOD = 10**9 + 7


def combination(n, r,mod):# nCrを求める
    if r == -1 or n < r:
        return 0
    r = min(n-r, r)
    result = 1
    for i in range(n, n-r, -1):
        result *= i
    for i in range(1, r+1):
        result //= i
    return result%mod


for i in range(k):
    ans = 0
    if i == 0:
        print(n-k+1)
    else:
        p = combination(k-1,i,MOD)
        q = combination(n-k-1,i-1,MOD)+combination(n-k-1,i,MOD)*2 + combination(n-k-1,i+1,MOD)
        q %=MOD
        ans +=p*q
        ans %=MOD
        print(ans)

### FIXED CODE ###

n,k = map(int,input().split())
MOD = 10**9 + 7

memo = [-1 for i in range(k+1)]
memo[0] = 1
now = 1
for i in range(1,k+1):
    now = now*(n-k-i)//i
    memo[i] = now%MOD

memo2 = [-1 for i in range(k)]
memo2[0] = 1
now = 1
for i in range(1,k):
    now = now*(k-i)//i
    memo2[i] = now%MOD

for i in range(k):
    ans = 0
    if i == 0:
        print(n-k+1)
    else:
        p = memo2[i]
        r = memo[i-1] + memo[i]*2 + memo[i+1]
        r %=MOD
        ans +=p*r
        ans %=MOD
        print(ans)
### BUGGY CODE ###

X = int(input())
num = [1]
for i in range(1,X):
  temp = i
  while temp*i<=X:
    temp=temp*i
    num.append(temp)
    
print(num[-1])

### FIXED CODE ###

X = int(input())
num = [1]
for i in range(2,X):
  temp = i
  while temp*i<=X:
    temp=temp*i
    num.append(temp)
    
print(sorted(num)[-1])
### BUGGY CODE ###

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

for i in range(1,n+1):
    mod = 0
    while n > 0:
        mod += (i % 10)
        i //= 10
    if mod >= a and mod <= b:
        ans += mod

print(ans)


### FIXED CODE ###

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

for i in range(1,n+1):
    mod = 0
    div = i
    while div > 0:
        mod += (div % 10)
        div //= 10
    if mod >= a and mod <= b:
        ans += i

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

import numpy as np

n,m = [int(i) for i in input().split()]
a = np.array([0]*m)
b = np.array([0]*m)
ans = np.array([0]*m)
ans[m - 1] = n * (n - 1) / 2

for i in range(m):
	a[i],b[i] = [int(i) for i in input().split()]

class UnionFind:
    def __init__(self, n):
        #親の番号を格納する。親だった場合は-(その集合のサイズ)
        #作るときはself.parの値をすべて-1にする
        self.par = [-1 for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
        
    def size(self, x):
        return -self.par[self.find(x)]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return 
        if self.size(x) < self.size(y):
            x , y = y , x
        self.par[x] += self.par[y]
        self.par[y] = x

uni = UnionFind(n)

for i in range(m-1,0,-1):
    ans[i-1] = ans[i]
    if uni.find(a[i]-1) != uni.find(b[i]-1):
        ans[i-1] -= uni.size(a[i]-1)*uni.size(b[i]-1)
    
        uni.union(a[i]-1,b[i]-1)

for i in ans:
    print(i)

### FIXED CODE ###

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.size = [1 for _ in range(n+1)]

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
    
    
def main():
    N, M = [int(_) for _ in input().split()]
    bridge = [tuple(map(int, input().split())) for _ in range(M)]

    last = []
    last.append(int(N * (N-1) * 0.5))

    ins = UnionFind(N)
    last_temp = 0

    for i in range(M-1):
        #print(ins.par)
        if ins.same_check(bridge[M-1-i][0],bridge[M-1-i][1]):
            last.append(last[-1])
            #ins.union(bridge[M-1-i][0],bridge[M-1-i][1])
        else:
            last_temp = last[-1] - (ins.size[ins.find(bridge[M-1-i][0])]) * (ins.size[ins.find(bridge[M-1-i][1])])
            #print(ins.size,i)
            last.append(last_temp)
            ins.union(bridge[M-1-i][0],bridge[M-1-i][1])
    
    [print(last[M-i-1]) for i in range(M)]
    exit()
    
main()
### BUGGY CODE ###

n = int(input())
d = [[] for i in range(n)]
for i in range(n - 1):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    d[u].append(v)
    d[v].append(u)
ans = 0
for l in range(n):
    cur = 0
    ans += (l + 1) * (l + 2) // 2
    for r in range(l, n):
        for t in d[r]:
            if l <= t < r:
                cur -= 1
        ans += cur
print(ans)


### FIXED CODE ###

n = int(input())
d = [0] * n
present = [[] for i in range(n)]
for i in range(n - 1):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    if u > v:
        u, v = v, u
    d[v] += 1
    present[u].append(v)
ans = 0
cur = 0
for v in range(n):
    cur += (n - v) * d[v]
for l in range(n):
    ans += (l + 1) * (l + 2) // 2
    ans -= cur
    for v in present[l]:
        cur -= (n - v)
print(ans)
### BUGGY CODE ###

def TLE(N, Y):
    # 2000**3 => 2 * 10 * 9:TLE
    for m in range(N, -1, -1):
        for g in range(N - m, -1, -1):
            for s in range(N - m - g, -1, -1):
                if m + g + s == N and \
                        m * 10000 + g * 5000 + s * 1000 == Y:
                    print(m, g, s)
                    return

    print(-1, -1, -1)

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

TLE(N, Y)


### FIXED CODE ###

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

    exhaustive_search(N, Y)

def exhaustive_search(N, Y):
    # 2000**2 => 4 * 10 * 6:Not TLE
    for m in range(N + 1):
        for g in range(N + 1):
            s = N - m - g
            #print(m, g, s)
            if 0 <= s <= N and \
                    m + g + s == N and \
                    m * 10000 + g * 5000 + s * 1000 == Y:
                print(m, g, s)
                return

    print(-1, -1, -1)

main()
### BUGGY CODE ###

import re

N, M = map(int, input().split())
S = str(input())
T = str(input())
#print(S)

# 最大公約数
def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a

# 最小公倍数
def lcm(a, b):
  return a*b/gcd(a, b)

L = int(lcm(N, M))

#文字列の作成
#SをもとにX
X1 = r''
n = 0
m = 0
ans = 0


for i in range(0,int(L)):
  if i == n * (L//N):
    X1 += S[n]
    n += 1
  else:
    X1 += r'*'
#print(X1)  
#X1とTを比べる

  if i == m * (L//M) :
    #print(i,m,X1[i],T[m])
    if X1[i] == T[m] or X1[i] == "*":
      ans = 1
      m += 1
    else:
      ans = -1
      break

if ans != -1:
  print(int(L))
else:
  print(-1)

### FIXED CODE ###

from fractions import gcd
from bisect import bisect_left
 
N, M = map(int, input().split())
S = input()
T = input()
 
if N > M:
    N, M = M, N
    S, T = T, S

G = N*M // gcd(N, M)
 
a = G//N
b = G//M
 
X = [a*i for i in range(N)]
Y = [b*j for j in range(M)]
 
for i, x in enumerate(X):
    j = bisect_left(Y, x)
    if j < M and Y[j] == x:
        if S[i] != T[j]:
            print(-1)
            break
else:
    print(G)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

N = int(input().strip())
s_list = [input().strip() for _ in range(N)]
#-----

for i,s in enumerate(s_list):
    s_list[i] = "".join(sorted(s))

cnt=0
for i in range(len(s_list)):
    for j in range( (i+1),len(s_list)):
        if s_list[i] == s_list[j]:
            cnt += 1

print(cnt)


### FIXED CODE ###

# -*- coding: utf-8 -*-

N = int(input().strip())
s_list = [input().strip() for _ in range(N)]
#-----

check_dic={}
cnt=0
for i,s in enumerate(s_list):
    key = "".join(sorted(s))
    
    if key not in check_dic:
        check_dic[key] = 1
    else:
        cnt += check_dic[key]
        check_dic[key] += 1

print(cnt)
### BUGGY CODE ###

# ABC042D - いろはちゃんとマス目 / Iroha and a Grid (ARC058D)
def main():
    H, W, A, B = tuple(map(int, input().split()))
    a = H - A + 1
    MOD = 10 ** 9 + 7
    prev, cur = [0] * (W + 1), [0] * (W + 1)
    cur[0] = 1
    for i in range(1, H + 1):
        for j in range(1, W + 1):
            if i >= a and j <= B:
                continue
            cur[j] = (prev[j] + cur[j - 1]) % MOD
        if i != H:
            prev, cur = cur, [0] * (W + 1)
    print(cur[-1])


if __name__ == "__main__":
    main()

### FIXED CODE ###

# ABC042D - いろはちゃんとマス目 / Iroha and a Grid (ARC058D)
def comb(n: int, r: int) -> int:
    return fact[n] * inv[n - r] * inv[r]


def main():
    global fact, inv
    H, W, A, B = tuple(map(int, input().split()))
    MOD = 10 ** 9 + 7
    # table of factorials
    fact, x = [1] * (H + W + 1), 1
    for i in range(1, H + W + 1):
        x = (x * i) % MOD
        fact[i] = x
    # table of inverse factorials
    inv = [1] * (H + W + 1)
    inv[-1] = pow(fact[-1], MOD - 2, MOD)
    x = inv[-1]
    for i in range(H + W - 1, 0, -1):
        x = (x * (i + 1)) % MOD
        inv[i] = x

    ans = 0
    for i in range(B, W):
        ans += comb(i + H - A - 1, i) * comb(W - i - 1 + A - 1, A - 1)
    print(ans % MOD)


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

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

for i in range(n):
    l.append(a.index(i + 1) + 1)

print(*l)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
l = [0] * n

for i, j in enumerate(a, 1):
    l[j - 1] = i

print(* l)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n = int(input())
degree = [ 0 for i in range(n) ]
connect_list = [ [] for i in range(n) ]
node_color = [0 for i in range(n)]
for i in range(n-1):
    a, b = [ int(v)-1 for v in input().split() ]
    connect_list[a].append([b,i])
    degree[a] += 1
    degree[b] += 1


maxcolor = max(degree)
search_list = [0]
node_color[0] = 0

while search_list:
    new_search_list = []
    for i in search_list:
        if node_color[i] == 0:
            color_list = [ k for k in range(1,maxcolor+1) ]
        else:
            color_list = [ k for k in range(1,maxcolor+1) if k != node_color[i] ]
        p = 0
        for j, v in enumerate(connect_list[i]):
            a, b = v
            new_search_list.append(a)
            node_color[a] = color_list[p]
            connect_list[i][j] = [b,color_list[p]]
            p += 1
    search_list = new_search_list

ans_list = []
for i in connect_list:
    for j in i:
        ans_list.append(j)

ans_list.sort()
print(maxcolor)
for i in ans_list:
    print(i[1])

### FIXED CODE ###

import sys
input = sys.stdin.readline
n = int(input())
degree = [ 0 for i in range(n) ]
connect_list = [ [] for i in range(n) ]
node_color = [0 for i in range(n)]
for i in range(n-1):
    a, b = [ int(v)-1 for v in input().split() ]
    connect_list[a].append([b,i])
    degree[a] += 1
    degree[b] += 1


maxcolor = max(degree)
search_list = [0]
node_color[0] = 0
color_list = [ k for k in range(1,maxcolor+1) ]

while search_list:
    new_search_list = []
    for i in search_list:
        p = 0
        for j, v in enumerate(connect_list[i]):
            a, b = v
            new_search_list.append(a)
            if node_color[i] == color_list[p]:
                p += 1
            node_color[a] = color_list[p]
            connect_list[i][j] = [b,color_list[p]]
            p += 1
    search_list = new_search_list

ans_list = []
for i in connect_list:
    for j in i:
        ans_list.append(j)

ans_list.sort()
print(maxcolor)
for i in ans_list:
    print(i[1])
### BUGGY CODE ###

import fractions

mod=10**9+7

n=int(input())

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

def lcm(a,b):
    return a//fractions.gcd(a,b)*b

lcma=1

for i in range(n):
    lcma=lcm(lcma,a[i])

ans=0

for i in range(n):
    ans=(ans+lcma//a[i])%mod

print(ans)


### FIXED CODE ###

mod=10**9+7

n=int(input())

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

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

def lcm(a,b):
    return a//gcd(a,b)*b

lcma=1

for i in range(n):
    lcma=lcm(lcma,a[i])

ans=0

for i in range(n):
    ans=(ans+lcma//a[i])

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

s = list(input())

minLength = 4
maxLength = len(s)
cnt = 0

for length in range(minLength,maxLength+1):
    for position in range(maxLength - length + 1):
        num = int(''.join(s[position:position+length]))
        if num % 3 == 0:
            if num % 673 == 0:
                cnt += 1
                position += 4

print(cnt)

### FIXED CODE ###

s = list(input())
mods = [0]*(len(s))
countRemainder = [0] * 2019
cnt = 0


m = 1
mod = 0
for i in range(len(s)):
    mod += int(s[len(s) - i - 1]) * m

    mod %= 2019
    m *= 10
    m %= 2019

    countRemainder[mod] += 1

countRemainder[0] += 1

for i in range(2019):
    cnt += int(countRemainder[i] * (countRemainder[i] - 1) / 2)

print(cnt)
### BUGGY CODE ###

import sys 

N,M  = map(int,input().split())
     
a = [[0 for i in range(2)] for j in range(M)]
b = []     
for l in range(M):
  a[l][0] , a[l][1] = map(int,input().split())
  if a[l][0] == 1:
    b.append(l)

res = 'IMPOSSIBLE'

for i in b:
  for k in range(M):
    if a[k][0] == a[i][1]:
      if a[k][1] == N:
         res = 'POSSIBLE'
         break

print (res)


### FIXED CODE ###

import sys 

N,M  = map(int,input().split())
     
a = [[0 for i in range(2)] for j in range(M)]
b = [] 
c = []

for i in range(M):
  a[i][0] , a[i][1] = map(int,input().split())
  first, second = a[i][0],a[i][1]
  if first == 1:
    b.append(second)
  if second == N:
    c.append(first)

b_set = set(b)
c_set = set(c)

if list(b_set & c_set) is None or len(list(b_set & c_set)):
  res = ('POSSIBLE')
else:
  res = ('IMPOSSIBLE')

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

n,k,q=map(int,input().split())
a=[int(input()) for _ in range(q)]
if k>100000:
  for _ in range(n):
    print("Yes")
else:
  for i in range(1,n+1):
    m=a.count(i)
    b=k-q+m
    if b<=0:
      print("No")
    else:
      print("Yes")

### FIXED CODE ###

n,k,q=map(int,input().split())
a=[int(input()) for _ in range(q)]
b=[0]*n
for i in range(q):
  b[a[i]-1]+=1
if k-q>0:
  for _ in range(n):
    print("Yes")
else:
  for i in range(n):
    if k-q+b[i]>0:
      print("Yes")
    else:
      print("No")
### BUGGY CODE ###

from collections import deque

h,w = map(int,input().split())
sy,sx = map(int,input().split())
gy,gx = map(int,input().split())
a = [list(input())for _ in range(h)]

sx -= 1
sy -= 1
gx -= 1
gy -= 1

dx=[1,0,-1,0,  2,1,0,-1,-2,  2,1,-1,-2,  2,-2,  2,1,-1,-2,  2,1,0,-1,-2]
dy=[0,1,0,-1,  2,2,2,2,2,  1,1,1,1,  0,0,  -1,-1,-1,-1,  -2,-2,-2,-2,-2]
m = len(dx)

def bfs():
    d = [[float("inf")]*w for _ in range(h)]
    q = deque([])
    q.append((sx,sy))
    d[sy][sx] = 0 #warp回数
    goal = False

    while q:
        p = q.popleft()
        #print((p[0],p[1]),d[p[1]][p[0]])
        if p[0] == gx and p[1] == gy:
            goal = True

        for i in range(m):
            nx = p[0]+dx[i]
            ny = p[1]+dy[i]
            if i < 4:
                if 0<=nx<w and 0<=ny<h and a[ny][nx] != "#" and d[p[1]][p[0]] < d[ny][nx]:
                    q.append((nx,ny))
                    d[ny][nx] = d[p[1]][p[0]]
            else:
                if 0<=nx<w and 0<=ny<h and a[ny][nx] != "#" and d[p[1]][p[0]] < d[ny][nx]:
                    q.append((nx,ny))
                    d[ny][nx] = d[p[1]][p[0]] + 1

    if goal == False:
        return -1
    else:
        return d[gy][gx]
        
print(bfs())

### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline

h,w = map(int,input().rstrip().split())
sy,sx = map(int,input().rstrip().split())
gy,gx = map(int,input().rstrip().split())
a = [list(input().rstrip())for _ in range(h)]

sx -= 1
sy -= 1
gx -= 1
gy -= 1

dx=[1,0,-1,0]
dy=[0,1,0,-1]

def bfs():
    d = [[float("inf")]*w for _ in range(h)]
    q = deque([])
    q.append((sx,sy))
    d[sy][sx] = 0 #warp回数
    goal = False
    local_area = deque([])

    while q:
        p = q.popleft()
        local_area.append((p[0],p[1]))
        if p[0] == gx and p[1] == gy:
            goal = True
            break

        for i in range(4):
            nx = p[0]+dx[i]
            ny = p[1]+dy[i]
            if 0<=nx<w and 0<=ny<h and a[ny][nx] != "#" and d[ny][nx] == float("inf"):
                q.append((nx,ny))
                d[ny][nx] = d[p[1]][p[0]]
        if len(q) == 0 and goal == False:
            while local_area:
                p = local_area.popleft()
                for i in range(-2,3):
                    for j in range(-2,3):
                        nx = p[0]+i 
                        ny = p[1]+j
                        if 0<=nx<w and 0<=ny<h and a[ny][nx] != "#" and d[ny][nx] == float("inf"):
                            q.append((nx,ny))
                            d[ny][nx] = d[p[1]][p[0]] + 1                        

    if goal == False:
        return -1
    else:
        return d[gy][gx]
        
print(bfs())
### BUGGY CODE ###

n, c = input().split()
n = int(n)
c = int(c)
x = [0]
v = [0]
sv = [0]
ssv = 0
for i in range(n):
    xx, vv = input().split()
    xx = int(xx)
    vv = int(vv)
    x.append(xx)
    v.append(vv)
    ssv += vv
    sv.append(ssv)
ans = -10**15
for i in range(0, n + 1, 1):
    e1 = sv[i] - x[i]
    for j in range(-1, -n +  i  - 1, -1):
        e2 = sv[-1] - sv[j - 1] - (c - x[j])
        e3 = e1 + e2 - x[i]
        e4 = e1 + e2 - (c - x[j])
        ans = max([ans, e2, e3, e4])
    ans = max([ans, e1])
for j in range(0, -n - 1, -1):
    e2 = sv[-1] - sv[j - 1] - (c - x[j])
    for i in range(1, n - i + 1, 1):
        e1 = sv[i] - x[i]        
        e3 = e1 + e2 - x[i]
        e4 = e1 + e2 - (c - x[j])
        ans = max([ans, e1, e3, e4])
    ans = max([ans, e1])
print(ans)

### FIXED CODE ###

n, c = input().split()
n = int(n)
c = int(c)
x = [0]
v = [0]
gs1 = [0]
gs2 = [0]
gs3 = [0]
gs4 = [0]
s = 0
for i in range(n):
    xx, vv = input().split()
    xx = int(xx)
    vv = int(vv)
    x.append(xx)
    v.append(vv)
    s += vv
    f = s - xx
    gs1.append(max(gs1[-1], f))
    f = s - 2 * xx
    gs2.append(max(gs2[-1], f))
s = 0
for i in range(-1, -n - 1, -1):
    s += v[i]
    f = s - (c - x[i])
    gs3.append(max(gs3[-1], f))
    f = s - 2 * (c - x[i])
    gs4.append(max(gs4[-1], f))
ans = 0
for i in range(n + 1):
    ans = max(ans, gs1[i] + gs4[n - i], gs2[i] + gs3[n - i])
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)

n,x,y = map(int,input().split())

import queue
# FIFOキューの作成
q = queue.Queue()

dst = [[0 for i in range(n+1)] for j in range(n+1)]

kyori = [0] * (n+1)

#num = 1

for i in range(1,n):
    num = 1
    q.put([i,0])
    while not q.empty():
        
        kari = q.get()
        tmp = kari[0]
        tmp_dst = kari[1]
        #print(tmp[0])
        #exit()
        if tmp >= n+1:
            continue
        if tmp < 1:
            continue
        if tmp == x:
            if dst[i][y] == 0:
                #kyori[tmp_dst+1] += 1
                dst[i][y] = tmp_dst+1
                q.put([y,tmp_dst+1])
                
        if tmp == y:
            if dst[i][x] == 0:
                #kyori[tmp_dst+1] += 1
                dst[i][x] = tmp_dst+1
                q.put([x,tmp_dst+1])
        if tmp+1 <= n:
            if dst[i][tmp+1] == 0:
                q.put([tmp+1,tmp_dst+1])
                #kyori[tmp_dst+1] += 1
                dst[i][tmp+1] = tmp_dst+1
        if tmp-1 >= 1:
            if dst[i][tmp-1] == 0:
                q.put([tmp-1,tmp_dst+1])
                #kyori[tmp_dst+1] += 1
                dst[i][tmp-1] = tmp_dst+1
        
        num += 1
        #print(dst[i])
    #exit()
    #print(dst[i])

#print(kyori)
#print(dst)

kyori = [0] * (n+1)

for i in range(1,n):
    #print(dst[i],i)
    for j in range(i+1,n+1):
        #print(i,j,dst[i][j])
        kyori[dst[i][j]] += 1

#print(kyori)
#exit()

for i in range(1,n):
    print(kyori[i])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

n,x,y = map(int,input().split())

dst = [0] * n

#print(dst)

for i in range(1,n+1):
    for j in range(i+1,n+1):
        kyori = min(j-i,abs(x-i)+abs(y-j)+1)
        dst[kyori] += 1
        #print(i,j,kyori)
        
for i in range(n-1):
    print(dst[i+1])
#print(dst)
### BUGGY CODE ###

import fractions
K = int(input())
ans = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        ab = fractions.gcd(i,j)
        if ab == 0:
            continue
        for k in range(1,K+1):
            ans += fractions.gcd(ab,k)

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):
        ab = gcd(i,j)
        if ab == 0:
            continue
        for k in range(1,K+1):
            ans += gcd(ab,k)

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

k,s=[int(i) for i in input().split()]
count=0
#print(k,s)
for y in range(k+1):
 for x in range(k+1):
   if x + y <= s + k and s-x-y>=0 and s-x-y<=k:
#      print(x,y,s-x-y)
      count=count+1
print(count)


### FIXED CODE ###

k,s=[int(i) for i in input().split()]
count=0
for y in range(k+1):
 for x in range(k+1):
   if x + y <= s + k and s>=x+y and s<=k+x+y:
      count=count+1
print(count)
### BUGGY CODE ###

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

while True:
	updated = False
	for i in range(N-1):
		for j in range(i+1, N):
			if (A[i] + A[j] < 0):
				updated = True
				A[i] *= -1
				A[j] *= -1
				updated = True
	if not updated:
		break

print(sum(A))


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split(" ")))
abs_list = list(map(abs, A))
abs_list.sort()
pos = list(filter(lambda x: x > 0, A))
neg = list(filter(lambda x: x < 0, A))
pos.sort()
neg.sort()

# A has 0
if abs_list[0] == 0:
	print(sum(abs_list))
elif len(neg) % 2 == 0:
	print(sum(abs_list))
elif len(pos) > 0 and abs(pos[0]) < abs(neg[-1]):
	print(sum(abs_list) - 2*pos[0])
else:
	print(sum(abs_list[1:])-abs_list[0])
### BUGGY CODE ###

L, R = map(int, input().split())
ij = [_ for _ in range(L, R+1)]
list_ = []
for i in ij:
    for j in ij:
        if i < j:
            list_.append((i*j) % 2019)
print(min(list_))


### FIXED CODE ###

l, r = map(int, input().split())
if r // 3 > (l - 1) // 3 and r // 673 > (l - 1) // 673:
    print(0)
else:
    print(min(i * j % 2019 for i in range(l, r + 1) for j in range(l, i)))
### BUGGY CODE ###

from collections import deque
n = int(input())
Ps = list(map(lambda x: int(x)-1, input().split()))
cost = [min(i, n-1-i, j, n-1-j) for i in range(n) for j in range(n)]
exist = [1]*(n**2)


def to_idx(p):
    return divmod(p, n)


def generate_dv(i, j):
    if 0 < i:
        yield -n
    if i < n-1:
        yield n
    if 0 < j:
        yield -1
    if j < n-1:
        yield 1


def bfs(init_v):
    next_v = deque([init_v])
    exist[init_v] = 0
    while next_v:
        v = next_v.popleft()
        i, j = to_idx(v)
        for dv in generate_dv(i, j):
            if cost[v+dv] <= cost[v]+exist[v]:
                continue
            cost[v+dv] = cost[v]+exist[v]
            next_v.append(v+dv)


ans = 0
for p in Ps:
    ans += cost[p]
    bfs(p)
print(ans)

### FIXED CODE ###

from collections import deque
n = int(input())
Ps = list(map(lambda x: int(x)-1, input().split()))
cost = [min(i, n-1-i, j, n-1-j) for i in range(n) for j in range(n)]
exist = [1]*(n**2)


def to_idx(p):
    return divmod(p, n)


def to_v(i, j):
    return i*n+j


def bfs(init_v):
    next_v = deque([init_v])
    exist[init_v] = 0
    while next_v:
        v = next_v.popleft()
        i, j = to_idx(v)
        if 0 < i:
            v2 = v-n
            if cost[v2] > cost[v]+exist[v]:
                cost[v2] = cost[v]+exist[v]
                next_v.append(v2)

        if i < n-1:
            v2 = v+n
            if cost[v2] > cost[v]+exist[v]:
                cost[v2] = cost[v]+exist[v]
                next_v.append(v2)

        if 0 < j:
            v2 = v-1
            if cost[v2] > cost[v]+exist[v]:
                cost[v2] = cost[v]+exist[v]
                next_v.append(v2)

        if j < n-1:
            v2 = v+1
            if cost[v2] > cost[v]+exist[v]:
                cost[v2] = cost[v]+exist[v]
                next_v.append(v2)

ans = 0
for p in Ps:
    ans += cost[p]
    bfs(p)
print(ans)