Harryxun/stf_run huggingface dataset:
import math

p = 1000000007

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

b = k
r = n - k

def P(n, r):
    return math.factorial(n)//math.factorial(n-r)

def C(n, r):
    return P(n, r)//math.factorial(r)

for i in range(k):
    t = i + 1
    x = C(b - 1, t - 1)
    y = C(r + 1, t)
    print((x * y) % p)


### FIXED CODE ###

import math

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

p = 1000000007

b = k
r = n - k


def P(n, r):
    return (math.factorial(n) // math.factorial(n - r))


def C(n, r):
    return (P(n, r) // math.factorial(r))


for i in range(k):
    t = i + 1
    if (b - 1) < (t - 1):
        print("0")
    elif (r + 1) < t:
        print("0")
    else:
        x = C(b - 1, t - 1)
        y = C(r + 1, t)
        print((x * y) % p)
N = int(input())
s = set()
for i in range(N):
    a = input()
    s.add(a)
print(len(s))

### FIXED CODE ###

N = int(input())
a = list(input().split())

if("Y" in a):
  print("Four")
else:
  print("Three")
N,M=map(int,input().split())
cakes=[]
for i in range(N):
  x,y,z=map(int,input().split())
  cakes.append([x,y,z])
score=[0]*8
c=sorted(map(lambda c: [ c[0]+c[1]+c[2],*c], cakes),key=lambda c: c[0])[-M:]
score[0]=sum(list(map(abs,map(sum,zip(*c))))[1:])
c=sorted(map(lambda c: [ c[0]+c[1]-c[2],*c], cakes),key=lambda c: c[0])[-M:]
score[1]=sum(list(map(abs,map(sum,zip(*c))))[1:])
c=sorted(map(lambda c: [ c[0]-c[1]+c[2],*c], cakes),key=lambda c: c[0])[-M:]
score[2]=sum(list(map(abs,map(sum,zip(*c))))[1:])
c=sorted(map(lambda c: [ c[0]-c[1]-c[2],*c], cakes),key=lambda c: c[0])[-M:]
score[3]=sum(list(map(abs,map(sum,zip(*c))))[1:])
c=sorted(map(lambda c: [-c[0]+c[1]+c[2],*c], cakes),key=lambda c: c[0])[-M:]
score[4]=sum(list(map(abs,map(sum,zip(*c))))[1:])
c=sorted(map(lambda c: [-c[0]+c[1]-c[2],*c], cakes),key=lambda c: c[0])[-M:]
score[5]=sum(list(map(abs,map(sum,zip(*c))))[1:])
c=sorted(map(lambda c: [-c[0]-c[1]+c[2],*c], cakes),key=lambda c: c[0])[-M:]
score[6]=sum(list(map(abs,map(sum,zip(*c))))[1:])
c=sorted(map(lambda c: [-c[0]-c[1]-c[2],*c], cakes),key=lambda c: c[0])[-M:]
score[7]=sum(list(map(abs,map(sum,zip(*c))))[1:])
print(max(score))


### FIXED CODE ###

N,M=map(int,input().split())
cakes=[]
for i in range(N):
  x,y,z=map(int,input().split())
  cakes.append([x,y,z])
if M==0:
  print(0)
  quit()
score=[0]*8
score[0]=sum(sorted(map(lambda c: c[0]+c[1]+c[2], cakes))[-M:])
score[1]=sum(sorted(map(lambda c: c[0]+c[1]-c[2], cakes))[-M:])
score[2]=sum(sorted(map(lambda c: c[0]-c[1]+c[2], cakes))[-M:])
score[3]=sum(sorted(map(lambda c: c[0]-c[1]-c[2], cakes))[-M:])
score[4]=sum(sorted(map(lambda c:-c[0]+c[1]+c[2], cakes))[-M:])
score[5]=sum(sorted(map(lambda c:-c[0]+c[1]-c[2], cakes))[-M:])
score[6]=sum(sorted(map(lambda c:-c[0]-c[1]+c[2], cakes))[-M:])
score[7]=sum(sorted(map(lambda c:-c[0]-c[1]-c[2], cakes))[-M:])
print(max(score))
div = ["dream", "dreamer", "erase", "eraser"]
rev = []
t = ""
s_rev = s[::-1]
for d in div:
    rev.append(d[::-1])

result = True
i = 0
while i < len(s):
    can_divide = False
    for d in rev:
        if len(s_rev) - i >= len(d):
        	if s_rev[i:i + len(d)] == d:
	            can_divide = True
    	        i += len(d)
        	    break
    if not can_divide:
        result = False
        break

print("YES" if result else "NO")


### FIXED CODE ###

s = input()
t = ""
while len(t) < len(s):
    target_len = len(s) - len(t)

    if s[len(t)] == 'd':
        if target_len == 5:
            t += "dream"
        elif target_len == 7:
            t += "dreamer"
        elif target_len > 7:
            if s[len(t) + 5] != 'd' and s[len(t) + 5:len(t) + 7 + 1] != "era":
                t += "dreamer"
            else:
                t += "dream"
        else:
            break
    else:
        if target_len == 5:
            t += "erase"
        elif target_len == 6:
            t += "eraser"
        elif target_len > 6:
            if s[len(t) + 5] != 'd' and s[len(t) + 5:len(t) + 6 + 2] != "era":
                t += "eraser"
            else:
                t += "erase"
        else:
            break

    if s[0:len(t)] != t:
        break

print("YES" if s == t else "NO")
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    x=int(readline())
    to=6000
    memo=[0]*to
    #memo={}
    for i in range(to):
        memo[i]=i**5

    for i in range(to):
        z1=x-memo[i]
        z2=memo[i]-x
        if z1 in memo:
            a=i
            for j in range(to):
                if memo[j]==z1:
                    b=j*-1
            break
        if z2 in memo:
            a=i
            for j in range(to):
                if memo[j]==z1:
                    b=j
            break

    print(a,b)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

### FIXED CODE ###

### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    x=int(readline())
    to=1001
    memo=[0]*to
    #memo={}
    for i in range(to):
        memo[i]=i**5

    a=0
    b=0
    if x==0:
        print(a,b)
        return

    for i in range(to):
        z1=x-memo[i]
        z2=memo[i]-x
        if z1 in memo:
            a=i
            for j in range(to):
                if memo[j]==z1:
                    b=j*-1
            break
        if z2 in memo:
            a=i
            for j in range(to):
                if memo[j]==z2:
                    b=j
            break
    #if a!=0 or b!=0:
    #    print(a,b)
    #    return
    print(a,b)
    return
    
    b=1000**5
    for i in range(1001,100000000):
        a=b
        b=i**5
        if (b-a)==x:
            print(i,(i-1))
            return

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------
n, k = map(int, input().split())
h = [int(i) for i in input().split()]

def chmin(a, b):
    if a > b:
        return b
    else:
        return a
f_inf = pow(10,9)+99

dp = [f_inf] * (N+1)
dp[0] = 0
for i in range(1, n):
    for j in range(1, k+1):
        if i - j >= 0:
            dp[i] = chmin(dp[i], dp[i-j]+ abs(h[i] - h[i - j]))
print(dp[n-1])


### FIXED CODE ###

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

def chmin(a, b):
    if a > b:
        return b
    else:
        return a
f_inf = pow(10,9)+99

dp = [f_inf] * (10**5+10)
dp[0] = 0
for i in range(1, n):
    for j in range(1, k+1):
        if i - j >= 0:
            dp[i] = chmin(dp[i], dp[i-j]+ abs(h[i] - h[i - j]))
print(dp[n-1])
s = list(input())
t = list(input())
dic = {}
flg = 'Yes'
for i in range(len(s)):
    if s[i] in dic.keys():
        if t[i] !=  dic.values(s[i]):
            flg = 'No'
    else:
        dic[s[i]] = t[i]
print(flg)

### FIXED CODE ###

s = list(input())
t = list(input())
dic = {}
flg = 'Yes'
for i in range(len(s)):
    if s[i] in dic.keys():
        if dic[s[i]] != t[i]:
            flg = 'No'
    else:
        dic[s[i]] = t[i]
dic2 = {}
for i in range(len(s)):
    if t[i] in dic2.keys():
        if dic2[t[i]] != s[i]:
            flg = 'No'
    else:
        dic2[t[i]] = s[i]
#print(dic)
print(flg)
実装無理
import math
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
ind = A.index(1)
if (ind%(K-1) + (N-ind-1)%(K-1)) <= K-1:
    print(math.floor(ind/(K-1)) + math.floor((N-ind-1)/(K-1))+1)
else:
    print(math.ceil(ind/(K-1)) + math.ceil((N-ind-1)/(K-1)))

### FIXED CODE ###

import math
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
ind = A.index(1)
print(math.ceil((ind + (N-ind-1))/(K-1)))
#落ち着くのんな
import sys
input = sys.stdin.readline

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


used = [True]*n
res = [0]*n
for i in range(1,n+1):
    
    for j in range(n-1,-1,-1):
        if b[j] == i:
            res[tank] = i
            tank = cnt + 1
            cnt = 0
        else:
            cnt += 1



### FIXED CODE ###

import sys
input = sys.stdin.readline

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

res = [-1]*n
#今考えている数列のindex、ないなら-1
ind = [i for i in range(1,n+1)]
#決定した数
cnt = 0
while cnt != n:
    #judge:変化があるか
    judge = False
    for i in range(n-1,-1,-1):
        if ind[i] == b[i]:
            ind[i] = -1
            res[n-1-cnt] = b[i]
            cnt += 1
            judge = True
            break
        else:
            ind[i] -= 1
    if not judge:
        print(-1)
        exit()
for e in res:
    print(e)
#c

S = input()

def clean(seq):
#     print("seq: ", seq)
    if len(seq) == 1:
        return seq
    
    def get_removee_left(cand_seq):
        if len(cand_seq) == 1:
            return -1
        for idx, s in enumerate(cand_seq[:-1]):
            if int(s) + int(cand_seq[idx+1]) == 1:
                return idx
        return -1
        
    ans = seq
    
    left = get_removee_left(seq)
#     print("left: ",left)
    if left > 0:
#         print("give:",seq[:left]+seq[left+2:])
        give = seq[:left]+seq[left+2:]
        ans = clean(give)
    elif left == 0:
#         print("give:", seq[left+2:])
        ans = clean(seq[left+2:])
    else:
        pass
        
    return ans
    
    
#     cleaned_seq = []
#     remove_flag = False
#     for idx, s in enumerate(seq):
#         if remove_flag:
#             ans = clean(clean_seq)
            
#         if idx == len(seq)-1:
#             cleaned_seq.append(s)
#             break

#         this_ = int(s)
#         next_ = int(seq[idx+1])
#         if this_ + next_ == 1:
#             remove_flag = True
#         else:
#             cleaned_seq.append(s)
            
#     return cleaned_seq

# former_cleaned = []
# cleaned = S
# while(not len(cleaned) == len(former_cleaned)):
#     former_cleaned = cleaned
#     cleaned = clean(former_cleaned)
    
# print(len(S) - len(cleaned))
print(len(S) - len(clean(S)))


### FIXED CODE ###

S = input()

save = []
flag = False
modori_flag = False
count = 0
for idx, s in enumerate(S):
    if modori_flag:
        modori_flag = False
    elif flag:
        flag = False
        continue
            
    this_ = int(s)
    if len(save) > 0 and this_ + save[-1] == 1:
        modori_flag = True
        del save[-1]
        count += 2
        continue
    if idx == len(S) -1:
        break
    next_ = int(S[idx+1])
    if this_ + next_ == 1:
        flag = True
        count += 2
        continue
        
    save.append(this_)
    
print(count)
a = int(input())
b = int(input())

print(a*b)

### FIXED CODE ###

[a,b] = [int(x) for x in input().split()]

print(a*b)
n,t = map(int,input().split())
ct = [list(map(int,input().split())) for i in range(n)]

for j in range(n):
  if ct[j][1] <= t:
    c = ct[j][0]
    k = j
    break

for i in range(k+1,n):
  if ct[i][1] < t:
    c = min(c,ct[i][0])
    
print(c)

### FIXED CODE ###

n,t = map(int,input().split())
ct = [list(map(int,input().split())) for i in range(n)]
T = []

for h in range(n):
  T.append(ct[h][1])
  
if min(T) > t:
  print("TLE")
  exit()
else:
  for j in range(n):
    if ct[j][1] <= t:
      c = ct[j][0]
      k = j
      break
 

for i in range(k+1,n):
  if ct[i][1] <= t:
    c = min(c,ct[i][0])
    
print(c)
n, m = map(int, input().split())
a = [int(i) for i in input().split()];a.insert(0,0)
p = [int(i) for i in range(n+1)]
def f(x):return p[x] if p[x]==x else f(p[x])
def u(x,y):p[f(x)]=f(y)
xy = [u(*[int(i) for i in input().split()]) for _ in range(m)]
out = [f(i+1)==f(a[i+1]) for i in range(n)]
print(sum(out))

### FIXED CODE ###

N, M = map(int, input().split())
# p = [int(i) for i in input().split()]
p = map(int,input().split())
# graph = [[]]*(N+1)
graph = [[] for _ in range(N+1)]
group = [0]*(N+1)
ans = 0
for _ in range(M):
    x, y = map(int, input().split())
    graph[x].append(y)
    graph[y].append(x)
for i, num in enumerate(p, 1):
    space = [i]
    for point in space:
        if group[point]:
            continue
        group[point] = i
        space.extend(graph[point])
    ans += (group[num] == group[i])
print(ans)
from functools import lru_cache

def main():
    n=int(input())
    a=list(map(int,input().split()))
    x=set()
    y=a[0]
    pair=True
    for i in a:
        if pair:
            p=set(prime_factorize(i))
            if len(x&p)>0:
                pair=False
            x|=p
        y=math.gcd(y, i)
    if pair:
        print("pairwise coprime")
    elif y==1:
        print("setwise coprime")
    else:
        print("not coprime")

# 素数リスト（エラトステネスの篩）
@lru_cache(maxsize=None)
def primes(n:int) -> list:
    '''n以下の全素数をlistで返す'''
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

# 素数判定（単純な素数判定なら十分早い。大量にやる場合はX in primesがよさそう）
@lru_cache(maxsize=None)
def is_prime(n: int) -> bool:
    '''引数nが素数であればTrue、そうでなければFalseを返す'''
    if n == 1:
        return False
    elif n == 2:
        return True
    elif n % 2 == 0:
        return False
    
    for i in range(3, int(n**0.5)+1, 2):
        if n % i == 0:
            return False
    return True

# 素因数分解
def prime_factorize(n: int) -> list:
    '''引数nの素因数分解結果のlistを返す。'''
    arr = []
    # 2で割り続け奇数まで還元する
    while n % 2 == 0:
        arr.append(2)
        n //= 2
    # sqrt(n)までの素数で試し割
    for f in primes(int(n**0.5)):
        while n % f == 0:
            arr.append(f)
            n //= f
    if n != 1:
        arr.append(n)
    return arr

if __name__ == "__main__":
    main()

### FIXED CODE ###

from functools import lru_cache
import math
def main():
    n=int(input())
    a=list(map(int,input().split()))
    pair,setwise=True,True
    x,y=set(),a[0]
    for i in a:
        if pair:
            ap=set(prime_factorize(i))
            if len(x & ap) > 0:
                pair=False
            x |= ap
        y=math.gcd(y, i)
    if pair:
        print("pairwise coprime")
    elif y == 1:
        print("setwise coprime")
    else:
        print("not coprime")

def prime_factorize(n: int) -> list:
    '''引数nの素因数分解結果のlistを返す。'''
    arr = []
    # 2で割り続け奇数まで還元する
    while n % 2 == 0:
        arr.append(2)
        n //= 2
    # sqrt(n)までの素数で試し割
    for f in primes(int(n**0.5)):
        while n % f == 0:
            arr.append(f)
            n //= f
    if n != 1:
        arr.append(n)
    return arr

@lru_cache(maxsize=None)
def primes(n:int) -> list:
    '''n以下の全素数をlistで返す'''
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

@lru_cache(maxsize=None)
def is_prime(n: int) -> bool:
    '''引数nが素数であればTrue、そうでなければFalseを返す'''
    if n == 1:
        return False
    elif n == 2:
        return True
    elif n % 2 == 0:
        return False
    
    for i in range(3, int(n**0.5)+1, 2):
        if n % i == 0:
            return False
    return True

if __name__ == "__main__":
    main()
import matplotlib.pyplot as plt
import networkx as nx
import numpy as np

def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

def main():
    s = input().strip()
    # tmp = 0
    # mx = 0
    # for ch in s:
    #     if ch == ">"
    #         tmp -= 1
    #     else:
    #         tmp += 1
    #
    #     if abs(tmp) > mx:
    #         mx = abs(tmp)
    #
    fwd = [0]
    rev = [0]
    tmp = 0
    mn = 0
    for ch in s:
        # print(ch)
        if ch == "<":
            tmp += 1
        else:
            tmp = 0
        fwd.append(tmp)

    for ch in s[::-1]:
        # print(ch)
        if ch == ">":
            tmp += 1
        else:
            tmp = 0
        rev.append(tmp)
    rev.reverse()
    # print(fwd, rev)
    print(sum([max(i, j) for i, j in zip(fwd, rev)]))

    #     if mn > tmp:
    #         mn = tmp
    #     print(tmp)
    #
    # ans = 0
    # print(mn)
    # ttmp = max(0, -mn)
    # for ch in s:
    #     ans += ttmp
    #     if ch == ">":
    #         ttmp -= 1
    #     else:
    #         ttmp += 1
    #
    # print(ans)
    return

if __name__ == "__main__":
    main()

### FIXED CODE ###

def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
 
def main():
    s = input().strip()
    # tmp = 0
    # mx = 0
    # for ch in s:
    #     if ch == ">"
    #         tmp -= 1
    #     else:
    #         tmp += 1
    #
    #     if abs(tmp) > mx:
    #         mx = abs(tmp)
    #
    fwd = [0]
    rev = [0]
    tmp = 0
    mn = 0
    for ch in s:
        # print(ch)
        if ch == "<":
            tmp += 1
        else:
            tmp = 0
        fwd.append(tmp)
 
    for ch in s[::-1]:
        # print(ch)
        if ch == ">":
            tmp += 1
        else:
            tmp = 0
        rev.append(tmp)
    rev.reverse()
    # print(fwd, rev)
    print(sum([max(i, j) for i, j in zip(fwd, rev)]))
 
    #     if mn > tmp:
    #         mn = tmp
    #     print(tmp)
    #
    # ans = 0
    # print(mn)
    # ttmp = max(0, -mn)
    # for ch in s:
    #     ans += ttmp
    #     if ch == ">":
    #         ttmp -= 1
    #     else:
    #         ttmp += 1
    #
    # print(ans)
    return
 
if __name__ == "__main__":
    main()
import math
a,b,c=map(int,input().split())
if 4*a*b < (c-a-b)**2):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

import math
a,b,c=map(int,input().split())
if a >= c or b >= c:
    print("No")
else:
    left= 4*a*b 
    right = (c-a-b)**2
    if left < right:
        print("Yes")
    else:
        print("No")
N,X = map(int,input().split())
L = list(map(int,input().split()))

curCoord = 0
n = 1

while (curCoord<=X):
    n=n+1
    curCoord = curCoord+L[n-2]
    
print(str(n-1))

### FIXED CODE ###

N,X = map(int,input().split())
L = list(map(int,input().split()))

curCoord = 0
n = 1

while (curCoord<=X):
    n = n+1
    
    if (n>N+1):
        break
    else:
        curCoord = curCoord+L[n-2]

print(n-1)
N = int(input())

d = []
for _ in range(N):
  d.append(int(input()))

sm = 0
for i in range(N):
  sm += 1/d

print(1/sm)

### FIXED CODE ###

_ = int(input())
print(1/sum([1/int(x) for x in input().split()]))
a , b = map(int , input().split)
c=str(a)+str(b)
c=int(c)
for i in range (20):
    if c== int(i*i):
        print("Yes")  
        break      
    elif i==20-1:
        print("No")
        break

        

### FIXED CODE ###

a , b = map(int , input().split())
c=str(a)+str(b)
c=int(c)
for i in range (1000):
    if c== int(i*i):
        print("Yes")  
        break      
    elif i==1000-1:
        print("No")
        break
n=int(intput())
if n < 1000:
	print("ABC")
else:
	print("ABD")


### FIXED CODE ###

n = int(input())
if n < 1000:
	print('ABC')
else:
	print('ABD')
import numpy as np
H,W = map(int,input().split())
table = [["."]*(W+2),]
for _ in range(H):
    table.append([".",]+list(input())+[".",])
table.append(["."]*(W+2))
table = np.array(table)
ans = []
#print(table)
for h in range(H):
    for w in range(W):
        mawari = table[h:h+3,w:w+3]
        if mawari.shape != (3,3):
            continue
        #print(mawari)
        if mawari[1,1] == ".":
            ans.append(np.count_nonzero(mawari=="#"))
        else:
            ans.append("#")
ans = np.array(ans).reshape(H,W)
#print(ans)
for i in ans:
    print("".join(i))


### FIXED CODE ###

import numpy as np
H,W = map(int,input().split())
table = [["."]*(W+2),]
for _ in range(H):
    table.append([".",]+list(input())+[".",])
table.append(["."]*(W+2))
table = np.array(table)
ans = []
#print(table)
for h in range(H):
    for w in range(W):
        mawari = table[h:h+3,w:w+3]
        #print(mawari)
        if mawari[1,1] == ".":
            ans.append(np.count_nonzero(mawari=="#"))
        else:
            ans.append("#")
ans = np.array(ans).reshape(H,W).astype(np.unicode)
for i in ans:
    print("".join(i))
x,y = map(str,input().split())

x = int(x,16)
y = int(y,16)

if x<y:
    print("<")
elif x == y:
    print("=")
eldr:
    ptiny(">")

### FIXED CODE ###

x,y = map(str,input().split())

x = int(x,16)
y = int(y,16)

if x<y:
    print("<")
elif x == y:
    print("=")
else:
    print(">")
import sys
n=int(input())
nl=list(map(int, input().split(" ")))

for i in range(n):
 if nl[i]%2==0 :
　　if  nl[i]%6!=0 or nl[i]%10!=0:
          print("DENIED")
           sys.exit()
 

print("APPROVED")


### FIXED CODE ###

import sys
n=int(input())
nl=list(map(int, input().split(" ")))

for i in range(n):
 if nl[i]%2==0:
  #print(nl[i]%6,nl[i]%10)
  if nl[i]%6 !=0 and nl[i]%10!=0:
   print("DENIED")
   sys.exit()
print("APPROVED")
n=int(input())
l=list(map(int,input().split()))
dp=[-1 for i in range(10000001)]
def solve(ind):
    if(ind==n-1):
        return 0
    if(dp[ind]!=-1):
        return dp[ind]
    ans=solve(ind+1)+abs(l[ind+1]-l[ind])
    if(ind+2<n):
        ans=min(ans,solve(ind+2)+abs(l[ind+2]-l[ind]))
    dp[ind]=ans
    return dp[ind]
print(solve(0))

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
dp=[10**55 for i in range(n)]
dp[0]=0
dp[1]=abs(l[1]-l[0])
for i in range(2,n):
    dp[i] = min(dp[i], dp[i-1] + abs(l[i] - l[i - 1]))
    dp[i] = min(dp[i], dp[i-2] + abs(l[i] - l[i - 2]))
print(dp[n-1])
N,K=map(int,input().split())

num=[0]*(max(N+1,K)
for i in range(1,N+1):
    num[i%K]+=1
#print(num)
ans=0
for a in range(K):
    b=(K-a)%K#a=0なら0 a!=0ならk-aになる賢い手
    c=(K-a)%K
    if (b+c)%K!=0:
        continue
    else:
      	#print(a)
        ans+=num[a]*num[b]*num[c]
        #print(a,b,c)
print(ans)

### FIXED CODE ###

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

num=[0]*(max(N+1,K))
for i in range(1,N+1):
    num[i%K]+=1
#print(num)
ans=0
for a in range(K):
    b=(K-a)%K#a=0なら0 a!=0ならk-aになる賢い手
    c=(K-a)%K
    if (b+c)%K!=0:
        continue
    else:
      	#print(a)
        ans+=num[a]*num[b]*num[c]
        #print(a,b,c)
print(ans)