Harryxun/stf_run huggingface dataset:
# -*- coding: utf-8 -*-
"""
Created on Sun Oct  7 22:06:12 2018
ABC073D
@author: maezawa
"""
import itertools as itr
import sys
#input = sys.stdin.readline

n, m, r = list(map(int, input().split()))
rarray = list(map(int, input().split()))
adjmatrix = [[10**10]*(n+1) for _ in range(n+1)]
for i in range(1,n+1):
    adjmatrix[i][i] = 0
    
for i in range(m):
    a, b, c = list(map(int, input().split()))
    if adjmatrix[a][b] > c:
        adjmatrix[a][b] = c
        adjmatrix[b][a] = c

#print(abc)

# Warshall-Floyd Algorithm
for k in range(1,n+1):
    for i in range(1,n+1):
        for j in range(j+1,n+1):
            adjmatrix[i][j] = min([adjmatrix[i][j],
                      adjmatrix[i][k] + adjmatrix[k][j]])
            adjmatrix[j][i] = adjmatrix[i][j]
        
#print(*adjmatrix, sep='\n')
    
# search for ri to rj
mincnt = 10*10
for route in itr.product(rarray,len(rarray)):
    cnt = 0
    for i in range(len(rarray)-1):
        cnt += adjmatrix[route[i]][route[i+1]]
    if cnt < mincnt:
        mincnt = cnt

print(mincnt)
        
        

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Mon Oct  8 10:17:39 2018

@author: maezawa
"""

import math
from itertools import permutations

#フロイド・ワーシャル
def warshall_floyd(glath):
	
	for k in range(len(glath)):
		for i in range(len(glath)):
			for j in range(len(glath[i])):
				if glath[i][j] > glath[i][k] + glath[k][j]:
                                   glath[i][j] = glath[i][k] + glath[k][j]
                                   glath[j][i] = glath[i][k] + glath[k][j]				
	return glath

N, M ,R= [int(x) for x in str(input()).split()]  #グラフの大きさ 
r=[int(x) for x in str(input()).split()]
graph=[[float("inf")]*N for i in range(N)]


for i in range(M):
	a,b,c=[int(x) for x in str(input()).split()]
	#if a in r and b in r:
	graph[a-1][b-1]=c
	graph[b-1][a-1]=c

#all_cost=warshall_floyd(select_graph)
all_cost=warshall_floyd(graph)


max_count=float("inf")
for i in permutations(r):
        cost=0
        for j in range(len(i)-1):                
                cost+= all_cost[i[j]-1][i[j+1]-1]       
        max_count=min(max_count,cost)

print(max_count)
s = input()
s1 = set(input())
if len(s1)==2:
  if s.count(list(s1)[0])==2 and s.count(list(s1)[1])==2: print('YES')
  else: print('NO')
else: print('NO')

### FIXED CODE ###

s = input()
s1 = set(s)
if len(s1)==2:
  if s.count(list(s1)[0])==2 and s.count(list(s1)[1])==2: print('Yes')
  else: print('No')
else: print('No')
N, M = map(int, input().split())
s = [list(map(int, input().spllit())) for i in range(M)]
p = list(map(int, input().split()))
total = 0
flag = 1
for i in range(2 ** N):
  now = format(i, "0{}b".format(N))
  for k in range(M):
    tmp = 0
    for l in range(s[k][0]):
      if now[s[k][l+1]-1] == '1':
        tmp += 1
    if tmp % 2 == p[k]:
      continue
    else:
      flag = 0
      break
  if flag == 1:
    total += 1
  flag = 1
print(total)


### FIXED CODE ###

n, m = map(int, input().split())
switch = []
for i in range(m):
    switch.append(list(map(int, input().split())))
p = list(map(int, input().split()))

ans = 0
for i in range(2**n):
    i = format(i, "0{}b".format(n))
    flag = 1
    for j in range(m):
        count = 0
        for k in range(switch[j][0]):
            if i[switch[j][k+1]-1] == "1":
                count += 1
        if count % 2 == p[j]:
            continue
        else:
            flag = 0
            break
    if flag == 1:
        ans += 1
print(ans)
s = input()
s.reverse()
MOD = 2019
a =[0]*MOD
a[0] = 1
c_ = 0
ans = 0
t = 1
for i in s:
  c = (c_+int(i)*t)%MOD
  a[c] += 1
  t *= 10
  t %= MOD
  c_ = c
for i in a:
  ans += i*(i-1)//2
print(ans)


### FIXED CODE ###

s = input()
MOD = 2019
a =[0]*MOD
a[0] = 1
c_ = 0
ans = 0
t = 1
for i in reversed(s):
  c = (c_+int(i)*t)%MOD
  a[c] += 1
  t *= 10
  t %= MOD
  c_ = c
for i in a:
  ans += i*(i-1)//2
print(ans)
import numpy as np
n,m,x=map(int,input().split())
c=[None for i in range(n)]
a=[None for i in range(n)]
for i in range(n):
    l=[int(i) for i in input().split()]
    c[i]=l[0]
    a[i]=np.array(l[1:])
mincos=1000000000000
for mask in range(2**n):
    rikai=np.zeros(m,dtype="int32")
    cos=0
    mm=mask
    for i in range(n):
        if mm%2:
            rikai+=a[i]
            cos+=c[i]
        mm//=2
    if np.all(rikai>=x):
        mincos=min(cos,mincos)

if mincos==1000000000000:
    print(-1)
else:
    print(mincos)


### FIXED CODE ###

import numpy as np
n,m,x=map(int,input().split())
c=[None for i in range(n)]
a=[None for i in range(n)]
for i in range(n):
    l=[int(i) for i in input().split()]
    c[i]=l[0]
    a[i]=np.array(l[1:])
mincos=1000000000000
for mask in range(2**n):
    rikai=np.zeros(m,dtype="int32")
    cos=0
    mm=mask
    for i in range(n):
        if mm%2:
            rikai+=a[i]
            cos+=c[i]
        mm//=2
    if np.all(rikai>=x):
        mincos=min(cos,mincos)

if mincos==1000000000000:
    print(-1)
else:
    print(mincos)
s = print(int(input()))
n = 0
for i in range(0, s):
  n = n + 1
return(n)


### FIXED CODE ###

s=int(input())
n=0
while(s>0):
  n=n+s
  s=s-1
print(n)
w,h,x,y = map(int, input().split())

# 横
men1 = w * y
men2 = w * (h-y)

# 縦
men3 = x * h
men4 = (w-x) * h


#print("{0} {1} {2} {3}".format(str(men1), str(men2), str(men3), str(men4)))
out1 = max(min(men1, men2), min(men3, men4))
if min(men1, men2) == min(men3, men4):
    out2 = 1
elif (h / w) == (y / x):
    out2 = 1
else:
    out2 = 0

print("{0} {1}".format(out1, out2))

### FIXED CODE ###

w,h,x,y = map(int, input().split())
out1 = w * h / 2
out2 = 1 if x == w/2 and y == h/2 else 0
print("{0} {1}".format(str(out1), str(out2)))
n = int(input())
X = list(map(int, input().split()))

for i in X:
  x = sorted(X)
  x.pop(i)
  print(x[n//2- 1])

### FIXED CODE ###

n = int(input())
X = list(map(int, input().split()))
x = sorted(X)

res1 = x[n//2]
res2 = x[n//2 -1]

for i in range(n):
  if X[i] >= res1:
    print(res2)
  elif X[i] <= res2:
    print(res1)
from collections import defaultdict
import sys
sys.setrecursionlimit(10**10)
N,M = map(int,input().split())

d = defaultdict(lambda:[])

for _ in range(M):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    d[x].append(y)

dp = [-1]*N

def dist(s):
    if dp[s] >= 0:
        return dp[s]
    if d[s] == []:
        dp[s] = 0
        return 0
    res = 0
    for t in d[s]:
        res = max(res,1+dist(t))
    dp[s] = res
    return res

ans = 0
for i in range(N):
    ans = max(ans,dist(i))

print(ans)

### FIXED CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(10**9)
N,M = map(int,input().split())

d = defaultdict(lambda:[])

for _ in range(M):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    d[x].append(y)

dp = [-1]*N

def dist(s):
    if dp[s] >= 0:
        return dp[s]
    if d[s] == []:
        dp[s] = 0
        return 0
    res = 0
    for t in d[s]:
        res = max(res,1+dist(t))
    dp[s] = res
    return res

ans = 0
for i in range(N):
    ans = max(ans,dist(i))

print(ans)
l, r, d = map(int, input().split())

for i in range(l, r+1):
  if i % d == 0:
    minimum = i
    break

for i in range(r, l-1, -1):
  if i % d == 0:
    maximum = i
    break

print(int((maximum - minimum) / d + 1))

### FIXED CODE ###

l, r, d = map(int, input().split())

count = 0
for i in range(l, r+1):
  if i % d == 0:
    count += 1

print(count)
def funcion():
    n = int(input())
    indice_anterior = -1
    total = 0
    
    

    for i in range(n):
        mayor = 0
        cadena = input()
        lista = cadena.split()
        for j in lista:
            jnum = int(j)
            indice_actual = lista.index(j)
            if (jnum > mayor) and indice_actual != indice_anterior:
                mayor = jnum
        indice_anterior = lista.index(str(mayor))     
        total = total + mayor
    print(total)

def main():
    return(funcion())

if __name__ == "__main__":
    main()


### FIXED CODE ###

N = int(input())
vacation = []
for i in range(N):
    vacation.append(list(map(int, input().split())))

activities = 3
schedules = [[None for _ in range(activities)] for _ in range(N)]
schedules[0] = vacation[0]

for i in range(1, N):
    for j in range(activities):
        schedules[i][j] = max(schedules[i - 1][(j + 1) % 3], schedules[i - 1][(j + 2) % 3]) + vacation[i][j]

print(max(schedules[N - 1]))
a=int(input())
b=int(a**(1/2))
m=a
for i in range (2,b+1):
  if a%i==0:
    m=i
c=a/m
print(int(m+c-2))

### FIXED CODE ###

a, b = map(int, input().split()) 
if a<=9 and b<=9:
  print(a*b)
else:
  print(-1)
x=input()
if x==1 print(1)
 else print(x**3)



### FIXED CODE ###

x=input()
y=int(x)
y=y**3
print(y)
import math
import functools

input()
a = list(map(int, input().split()))
l = a[0]
for i in a[1:]:
    l = math.gcd(l,i)
print(i)


### FIXED CODE ###

from fractions import gcd

input()
a = list(map(int, input().split()))
l = a[0]
for i in a[1:]:
    l = gcd(l,i)
print(l)
a = input()
s = input() if a < 3200 else 'red'
print(s)

### FIXED CODE ###

a = int(input())
s = input() if a >= 3200 else 'red'
print(s)
def fun(N,V):
    cnt = 0

    for i in range(5):
        cnt += V // (5-i)
        V = V % 5
        if V == 0:
            break

    if cnt<=N:
        flag = False
        print(1)
    
    return flag

def main():
    X = int(input())

    flag = True
    N = X//100
    V = X-N*100

    while flag:
        if N >= V/5:
            flag = fun(N,V)
            N -= 1
            V += 100
        else:
            flag = False
            print(0)

if __name__=='__main__':
    main()

### FIXED CODE ###

def fun(N,V):
    cnt = 0

    for i in range(5):
        cnt += V // (5-i)
        V = V % (5-i)
        if V == 0:
            break

    if cnt<=N and V==0:
        flag = False
        print(1)
    else:
        flag = True
    
    return flag

def main():
    X = int(input())

    flag = True
    N = X//100
    V = X-N*100

    while flag:
        if N >= V/5:
            flag = fun(N,V)
            N -= 1
            V += 100
        else:
            flag = False
            print(0)

if __name__=='__main__':
    main()
N = int(input().strip())
A = list(map(int, input().strip().split(' ')))

def gcd(a,b):
  if a < b: a,b = b,a
  return b if a % b == 0 else gcd(b, a%b)

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

now_lcm = A[0]
for a in set(A[1:]):
  now_lcm = lcm(now_lcm, a)

MOD = 1000000000 + 7
ans = 0
for a in A:
  ans = (ans + (now_lcm//a)) % MOD
print(ans)



### FIXED CODE ###

N = int(input().strip())

ans = 0

table = [[0 for i in range(10)] for j in range(10)]
for n in range(1,N+1):
  strn = str(n)
  table[int(strn[0])][int(strn[-1])] += 1

for i in range(1,10):
  for j in range(1,10):
    ans += table[i][j] * table[j][i]

print(ans)
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

int main(){
    double x1,y1,x2,y2,x3,y3,xp,yp;
    while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){
        if (((x2-x1)*(y2-y3))-((y1-y3)*(x2-x3))>0 && ((x3-x2)*(y3-yp))-((y1-yp)*(x3-xp))>0) {
        //if(((x2-x1)*(y2-yp)-(y2-y1)*(x2-xp)>0)&&((x3-x2)*(y3-yp)-(y3-y2)*(x3-xp)>0)&&((x1-x3)*(y1-yp)-(y1-y3)*(x1-xp)>0)){
            printf("YES\n");
        //}else if(((x2-x1)*(y2-yp)-(y2-y1)*(x2-xp)<0)&&((x3-x2)*(y3-yp)-(y3-y2)*(x3-xp)<0)&&((x1-x3)*(y1-yp)-(y1-y3)*(x1-xp)<0)){
        //    printf("YES\n");
        }else{
            printf("NO\n");
        }

    }
    return 0;
}

### FIXED CODE ###

while 1:
    try:
        x1,y1,x2,y2,x3,y3,xp,yp=map(float,raw_input().split())
        print 'YES' if ((x2-x1)*(y2-yp)-(y2-y1)*(x2-xp)>0)==((x3-x2)*(y3-yp)-(y3-y2)*(x3-xp)>0)==((x1-x3)*(y1-yp)-(y1-y3)*(x1-xp)>0) else 'NO'
    except:
        break
s={}
for i in range(3):
    s[chr(97+i)]=input()
turn="a"
while True:
    if not s[turn]:
        break
    else:
        turn=s[turn][0]
        s[turn]=s[turn][1:]
print(turn.upper())


### FIXED CODE ###

a=int(input())
b=int(input())
h=int(input())
print((a+b)*h//2)
def sq(a, b, mod):  # aのb乗を剰余
    if b == 0:
        return 1
    elif b % 2 == 0:
        return sq(a, b // 2, mod)**2 % mod
    else:
        return sq(a, b - 1, mod) * a % mod
  
def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

def nCk(n,k,mod):
  prev=1
  for i in range(1,min(k,n-k)+1):
    v=(prev * (n+1-i) % mod * modinv(i, mod) % mod)
    prev=v
  return prev

x,y=map(int,input().split())
mod=10**9+7

if (x+y)%3!=0:
  print(0)
else:
  n=int((x+y)/3)
  k=int((2*x-y)/3)
  print(nCk(n,k,mod))

### FIXED CODE ###

def sq(a, b, mod):  # aのb乗を剰余
    if b == 0:
        return 1
    elif b % 2 == 0:
        return sq(a, b // 2, mod)**2 % mod
    else:
        return sq(a, b - 1, mod) * a % mod
  
def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

def nCk(n,k,mod):
  prev=1
  for i in range(1,min(k,n-k)+1):
    v=(prev * (n+1-i) % mod * modinv(i, mod) % mod)
    prev=v
  return prev

x,y=map(int,input().split())
mod=10**9+7

if (x+y)%3!=0:
  print(0)
else:
  n=(x+y)//3
  k=(2*x-y)//3
  if k<0 or k>n:
    print(0)
  else:
    print(nCk(n,k,mod))
import numpy as np

N = int(input())

listX =[]
while True:
    try:
        listX.append(list(map(int,input().split())))
    except:
        break;

table = np.zeros((N,N))
point = np.zeros(N)
for i in range(N-1):
    x = listX[i][0]
    y = listX[i][1]
    table[x-1,y-1] = listX[i][2]
    table[y-1,x-1] = listX[i][2]

for j in range(0,N):
    for k in range(j+1,N):
        point[k] += table[j,k]

output = (point%2==0)
output = list(map(int,output))

outstr = str(output[0])

for i in range(1,N):
    outstr += "\n"+str(output[i])

print(outstr)

### FIXED CODE ###

N = int(input())
G = [[] for i in range(N)]
for i in range(N-1):
    A,B,C = list(map(int,input().split()))
    G[A-1].append([C,B-1]) #重み、向かう先の順番
    G[B-1].append([C,A-1])

from collections import deque
dist = [None]*N
que = deque([0])
dist[0] = 0
while que:
    v = que.popleft()
    d = dist[v]
    for c,w in G[v]:
        if dist[w] is not None:
            continue
        dist[w] = d + c
        que.append(w)
for i in range(N):
    print(dist[i]%2)
n = int(input().split())
if n % 2 == 0:
  print(n)
else:
  print(n*2)

### FIXED CODE ###

n = int(input())
if n % 2 == 0:
  print(n)
else:
  print(n*2)
n = int(input())
a = list(map(int, input().split()))
x = 1
if 0 in a:
    x = 0
else:
    for j in a:
        x = j*x
        if x > 10**18:
            x = -1
            break
print(x)

### FIXED CODE ###

A, B = map(int, input().split())
print(A*B)
N = int(input()) #入力する整数
A = list(map(int,input().split())) #入力する数列A
SUMA = sum(A) #数列の和
MOD = 10**9 + 7 # mod
C = [0] * (N-1) #累積和数列
for i in range(N-1): #\sum_{j = i+1}^{N}を求めて数列に代入する
  SUMA -= A[i]
  C[i] = SUMA
ans = 0 #求める答え
for i in range(N-1):
  ans += A[i]*C[i]
  ans %= MOD #その都度modで割った余りにする
print(ans) #答えを出力する

### FIXED CODE ###

d, t, s = map(int, input().split())
if d/s <= t:
    print("Yes")
else:
    print("No")
import numpy as np
def f(nums, a):
  return 0  if nums.size<=1 else (np.searchsorted(nums, a//nums, side='right').sum()-np.searchsorted(nums, int(pow(a, 1/2)), side='right'))//2

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

p=np.sum(A>0)
q=np.sum(A<0)
Z=N-p-q
AP=A[-p:] if p>0 else np.array([])
AN=A[:q] if q>0 else np.array([])

b=(N-Z)*Z+Z*(Z-1)//2
a=p*q

if K<=a:
  x=AP[-1]*AN[0]-1
  y=AP[0]*AN[-1]
  while y-x>1:
    tmp=(y+x)//2
    counter=np.searchsorted(AN, tmp//AP, side='right').sum()
    if counter<K:
      x=tmp
    else:
      y=tmp
  print(y)
elif K<=a+b:
  print(0)
else:
  if q>1:
    AN=-AN[::-1]
  x=0
  y=max(AN[-2]*AN[-1], AP[-2]*AP[-1])
  K=K-a-b
  while y-x>1:
    tmp=(y+x)//2
    if f(AP, tmp)+f(AN, tmp)<K:
      x=tmp
    else:
      y=tmp
  print(y)

### FIXED CODE ###

import numpy as np

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

p=np.sum(A>0)
q=np.sum(A<0)
Z=N-p-q
if p>0:
  AP=A[-p:]
else:
  AP=[]
if q>0:
  AN=A[:q]
else:
  AN=[]

b=(N-Z)*Z+Z*(Z-1)//2
a=p*q

if K<=a:
  x=AP[-1]*AN[0]-1
  y=AP[0]*AN[-1]
  while y-x>1:
    tmp=(y+x)//2
    counter=np.searchsorted(AN, tmp//AP, side='right').sum()
    if counter<K:
      x=tmp
    else:
      y=tmp
  print(y)
elif K<=a+b:
  print(0)
else:
  x=0
  y=10**18
  K=K-a-b
  if q<=1:
    while y-x>1:
      tmp=(y+x)//2
      counter=(np.searchsorted(AP, tmp//AP, side='right').sum()-np.searchsorted(AP, int(pow(tmp, 1/2)), side='right'))//2
      if counter<K:
        x=tmp
      else:
        y=tmp
    print(y)
    exit()
    
  AN=AN[::-1]
  AN=-AN
  
  if p<=1:
    while y-x>1:
      tmp=(y+x)//2
      counter=(np.searchsorted(AN, tmp//AN, side='right').sum()-np.searchsorted(AN, int(pow(tmp, 1/2)), side='right'))//2
      if counter<K:
        x=tmp
      else:
        y=tmp
    print(y)
    exit()
    
  while y-x>1:
    tmp=(y+x)//2
    counter1=(np.searchsorted(AP, tmp//AP, side='right').sum()-np.searchsorted(AP, int(pow(tmp, 1/2)), side='right'))//2
    counter2=(np.searchsorted(AN, tmp//AN, side='right').sum()-np.searchsorted(AN, int(pow(tmp, 1/2)), side='right'))//2
    counter=counter1+counter2
    if counter<K:
      x=tmp
    else:
      y=tmp
  print(y)
while True:
    m = sum(map(int, input().split()))
    n = int(input())
    fixed = [2] * m
    failures = []
    for _ in range(n):
        i, j, k, r = map(int, input().split())
        i, j, k = (x - 1 for x in (i, j, k))
        if r:
            fixed[i] = fixed[j] = fixed[k] = 1
        else:
            failures.append((i, j, k))

    for i, j, k in failures:
        fi, fj, fk = (fixed[x] for x in (i, j, k))
        if fi == 1:
            if fj == 1:
                fixed[k] = 0
            elif fk == 1:
                fixed[j] = 0
        elif fj == 1 and fk == 1:
            fi = 0

    print('\n'.join(str(x) for x in fixed) + '\n')

### FIXED CODE ###

while True:
    m = sum(map(int, input().split()))
    if not m:
        break
    n = int(input())
    fixed = [2] * m
    failures = []
    for _ in range(n):
        i, j, k, r = map(int, input().split())
        i, j, k = (x - 1 for x in (i, j, k))
        if r:
            fixed[i] = fixed[j] = fixed[k] = 1
        else:
            failures.append((i, j, k))

    for i, j, k in failures:
        fi, fj, fk = (fixed[x] for x in (i, j, k))
        if fi == 1:
            if fj == 1:
                fixed[k] = 0
            elif fk == 1:
                fixed[j] = 0
        elif fj == 1 and fk == 1:
            fixed[i] = 0

    print('\n'.join(str(x) for x in fixed))
import math
N,K = [int(x) for x in input().split()]
inf = 10**9+7
for i in range(1,K+1):
  k = i-1
  kumi = math.factorial(K-i+k)//(math.factorial(K-i)*math.factorial(k))%inf
  a = math.factorial(N-K+1)
  b = math.factorial(i)
  c = math.factorial(N-K+1-i)
  a = a//b
  a = a//c%inf
  ans = kumi*a
  print(int(ans%inf))
  
  

### FIXED CODE ###

import math
N,K = [int(x) for x in input().split()]
inf = 10**9+7
for i in range(1,K+1):
  k = i-1
  kumi = math.factorial(K-i+k)//(math.factorial(K-i)*math.factorial(k))%inf
  a = math.factorial(N-K+1)
  b = math.factorial(i)
  if (N-K+1-i)<0:
    print(0)
    continue
  c = math.factorial(N-K+1-i)
  a = a//b
  a = a//c%inf
  ans = kumi*a
  print(int(ans%inf))
import math
chou, tan, ji, hun = map(int,input().split())

kakudo = abs(((ji*30 + hun*.5) - (hun*6)))

if kakudo > 180:
    kakudo = kakudo-360
kakudo = abs(math.cos(math.radians(kakudo)))
ans =( chou**2 + tan**2 - 2*chou*tan*kakudo)**.5
print(ans)

### FIXED CODE ###

n = int(input())%10
if n in {2, 4, 5, 7, 9}:
    print("hon") 
elif(n == 3):
    print("bon") 
else:
    print("pon")
s=input()
if "F" in s[s.index("C"):]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s=input()
try: 
  if "F" in s[s.index("C"):]:
    print("Yes")
  else:
    print("No")
 
except:
  print("No")
N, M = list(map(int, input().split()))
X = list(map(int, input().split()))

if M == 1:
    ans = max(X) - min(X)
    print(ans)
    exit()

Xs = sorted(X)

diff = []
for i in range(M - 1):
    tmp = Xs[i + 1] - Xs[i]
    diff.append(tmp)

rest = N - 2
for _ in range(rest):
    if diff[0] > diff[len(diff) - 1]:
        diff.pop(0)
    else:
        diff.pop()

ans = 0

for _ in range(len(diff) - 1):
    if diff[0] > diff[len(diff) - 1]:
        ans += diff[len(diff) - 1]
        diff.pop()
    else:
        ans += diff[0]
        diff.pop(0)

print(ans)



### FIXED CODE ###

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

if N == 1:
    ans = max(X) - min(X)
    print(ans)
    exit()

if ((M == 1) or (N >= M)):
    ans = 0
    print(ans)
    exit()

Xs = sorted(X)

diff = []
for i in range(M - 1):
    tmp = Xs[i + 1] - Xs[i]
    diff.append(tmp)

diffs = sorted(diff)
print(sum(diffs[:(M - 1) - (N - 1)]))
x:int = input()
if x in (7, 5, 3):
    print('YES')
else:
    print('NO')


### FIXED CODE ###

x = int(input())
if x in (7, 5, 3):
    print('YES')
else:
    print('NO')
from collections import defaultdict
MOD = 10**9+7
N, K = map(int, input().split())
es = defaultdict(list)

for i in range(N-1):
  a, b = map(int, input().split())
  es[a-1] += [b-1]
  es[b-1] += [a-1]
  
def dfs(now, par):
  if par==-1:
    can_use = K-1
  else:
    can_use = K-2
  if K<len(es[now]):
    return 0
  else:
    case_num = 1
    for e in es[now]:
      if e==par:
        continue
      case_num *= can_use
      can_use -= 1
      case_num %= MOD
    for e in es[now]:
      if e==par:
        continue
      case_num *= dfs(e, now)
      case_num %= MOD
  return case_num

ans = K*dfs(0,-1)
ans %= MOD
print(ans)

### FIXED CODE ###

from collections import defaultdict, deque
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    return g1[n] * g2[r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N, K = map(int, input().split())
dic = defaultdict(list)
for i in range(N-1):
  a, b = map(int, input().split())
  dic[a-1] += [b-1]
  dic[b-1] += [a-1]

log = [float('inf')]*N
log[0] = 0
q = deque([0])
ans = K
while q:
  p = q.popleft()
  if log[p]<1:
    ans *= cmb(K-1,K-1-len(dic[p]),mod)
  else:
    ans *= cmb(K-2,K-1-len(dic[p]),mod)
  ans %= mod
  for e in dic[p]:
    if log[e]>log[p]+1:
      q += [e]
      log[e] = log[p]+1
print(ans)
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
  a[n]-=i
x=sum(a)//n
ans=0
for i in a:
  ans+=abs(i-x)
print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[0]
c=[0]
d=[0]
e=[0]
count=0
count2=0
count3=0
count4=0
for i in range(n):
  a[i]-=i
a.sort()
for i in range(n-1):
  count+=a[i+1]-a[i]
  count3+=a[n-i-1]-a[n-i-2]
  b.append(count)
  d.append(count3)
for i in range(n-1):
  count2+=b[i+1]
  count4+=d[i+1]
  c.append(count2)
  e.append(count4)
ans=10**18
for i in range(n):
  ans=min(ans,c[-1]-c[i]-b[i]*(n-i-1)+e[-1]-e[n-i-1]-d[n-i-1]*i)
print(ans)