Harryxun/stf_run huggingface dataset:
import numpy as np


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

    w = []
    v = []
    for i in range(N):
        wi, vi = map(int, input().split())
        w.append(wi)
        v.append(vi)

    dp = [[0] * (W+1) for i in range(N)]
    for i in range(N):
        for j in range(W + 1):
            if j - w[i] >= 0:
                dp[i][j] = max(dp[i - 1][j - w[i]] + v[i], dp[i - 1][j])
            else:
                dp[i][j] = dp[i - 1][j]

    print(dp[-1][-1])
    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

# メイン関数
def main():
    # 入力データ
    N, W = map(int, input().split())
    w = []
    v = []
    for i in range(N):
        wi, vi = map(int, input().split())
        w.append(wi)
        v.append(vi)

    # dpテーブルの作成
    dp = [[0] * (W+1) for i in range(N)]
    for i in range(N):
        for j in range(W + 1):
            if j - w[i] >= 0:
                dp[i][j] = max(dp[i - 1][j - w[i]] + v[i], dp[i - 1][j])
            else:
                dp[i][j] = dp[i - 1][j]

    # 解答の出力
    print(dp[-1][-1])
    return

# 実行
if __name__ == '__main__':
    main()
import math
from intertools import accumulate

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

g = []
gcd = []
gcd_u = np.frompyfunc(gcd, 2, 1)

for i in range(n):
  r = a[i]
  a.remove(r)
  gcd = accmulate(a, math.gcd)
  g.append(min(gcd))
  a.insert(i, r)

print(max(g))


### FIXED CODE ###

import math
from itertools import accumulate

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

fromright = list(accumulate(a, math.gcd))
a.reverse()
fromleft = list(accumulate(a, math.gcd))
fromleft.reverse()

gcd = []

gcd.append(fromleft[1])

for i in range(1, n-1):
  gcd.append(math.gcd(fromright[i-1], fromleft[i+1]))

gcd.append(fromright[n-2])

if n == 2:
  print(max(a))
else:
  print(max(gcd))
dp=[0 for i in range(100001)]
dp[0]=1
a=[i for i in range(100,106)]
for i in range(100001):
  if dp[i]==1:
    for j in a:
      dp[i+j]=1
print(dp[int(input())])

### FIXED CODE ###

dp=[0 for i in range(100110)]
dp[0]=1
a=[i for i in range(100,106)]
for i in range(100000):
  if dp[i]==1:
    for j in a:
      dp[i+j]=1
print(dp[int(input())])
#C - Build Stairs
N=int(input())
H=list(map(int, input().split()))
t=True
for i in range(1,N+1):
    M=max(H[:i])
    if M>min(H[i:])+1:
        print("No")
        t=False
        break
if t:
    print("Yes")

### FIXED CODE ###

#C - Build Stairs
N=int(input())
H=list(map(int, input().split()))
t=True
M=H[0]
for i in range(1,N):
    if M<H[i]:
        M=H[i]
    if M>H[i]+1:
        print("No")
        t=False
        break
if t:
    print("Yes")
from collections import deque
import itertools
import copy
import numpy as np

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

def solve(S, s, g):
    M = copy.deepcopy(S)
    d = [[1, 0], [-1, 0], [0, -1], [0, 1]]
    queue = deque([s])
    steps = [[np.max for _ in range(W)] for _ in range(H)]
    steps[s[0]][s[1]] = 0

    while len(queue) > 0:
        current = queue.popleft()
        cy = current[0]
        cx = current[1]
        # if cy == g[0] and cx == g[1]:
        #     return steps[cy][cx]
        # else:
        M[cy][cx] = '#'
        for i in d:
            next = [cy+i[0], cx+i[1]]
            # はみ出さないかつ通ってない
            if (0<=next[0]<H and 0<=next[1]<W) and M[next[0]][next[1]]!='#':
                queue.append(next)
                steps[next[0]][next[1]] = steps[cy][cx] + 1
        
    return max([max(i) for i in steps])
# print(solve(S, [0, 0], [0, 1]))
# print(solve(S, [2, 0], [0, 4]))

# print(S)
maxStep = 0
for s in itertools.product(range(H), range(W)):
    for g in itertools.product(range(H), range(W)):
        if S[s[0]][s[1]] == '.' and S[g[0]][g[1]] == '.':
            # print(s, g)
            # print(solve(S, [s[0], s[1]], [g[0], g[1]]))
            maxStep = max(solve(S, [s[0], s[1]], [g[0], g[1]]), maxStep)

print(maxStep)

### FIXED CODE ###

from collections import deque
import itertools
import copy

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

def solve(s):
    M = copy.deepcopy(S)
    d = ((1, 0), (-1, 0), (0, -1), (0, 1))
    queue = deque([s])
    steps = [[-1 for _ in range(W)] for _ in range(H)]
    steps[s[0]][s[1]] = 0

    while len(queue) > 0:
        current = queue.popleft()
        cy = current[0]
        cx = current[1]
        # M[cy][cx] = '#'
        for i in d:
            ny = cy+i[0]
            nx = cx+i[1]
            # はみ出さないかつ通ってない
            if (0<=ny<H and 0<=nx<W) and M[ny][nx]=='.' and steps[ny][nx] < 0:
            # if (0<=ny<H and 0<=nx<W) and M[ny][nx]!='#':
                queue.append([ny, nx])
                steps[ny][nx] = steps[cy][cx] + 1
        
    return max([max(i) for i in steps])

maxStep = 0
for s in itertools.product(range(H), range(W)):
    if S[s[0]][s[1]] == '.':
        maxStep = max(solve([s[0], s[1]]), maxStep)

print(maxStep)
import sys

S = list(map(int, list(sys.stdin.readline())))
len_S = len(S)
ans = 0
for i in range(2 ** (len_S - 1)):
  sum_ = S[len_S - 1]
  cursor = len_S - 1
  power = 0
  while cursor > 0:
    cursor -= 1 
    if i % 2 == 1:
      power += 1
    else:
      power = 0
    sum_ += S[cursor] * (10 ** power)
    i >>= 1
  ans += sum_
      
print(ans)
    

### FIXED CODE ###

import sys

S = list(map(int, sys.stdin.readline().strip()))
len_S = len(S)
ans = 0
for i in range(2 ** (len_S - 1)):
  sum_ = S[len_S - 1]
  cursor = len_S - 1
  power = 0
  while cursor > 0:
    cursor -= 1 
    if i % 2 == 1:
      power += 1
    else:
      power = 0
    sum_ += S[cursor] * (10 ** power)
    i >>= 1
  ans += sum_
print(ans)
def distance(a,b):
    return ((a[0]-b[0])**2+(a[1]-b[1])**2)**0.5
n = int(input())
a = [tuple(map(int,input().split())) for _ in range(n)]
l = []
for m in list(itertools.permutations(a)):
    d = 0
    for i in range(n-1):
        d += distance(m[i],m[i+1])
    l.append(d)
print(sum(l)/len(l))

### FIXED CODE ###

import itertools
def distance(a,b):
    return ((a[0]-b[0])**2+(a[1]-b[1])**2)**0.5
n = int(input())
a = [tuple(map(int,input().split())) for _ in range(n)]
l = []
for m in list(itertools.permutations(a)):
    d = 0
    for i in range(n-1):
        d += distance(m[i],m[i+1])
    l.append(d)
print(sum(l)/len(l))
n = int(input())
s = input()
c = 0
list_s = [sorted(list(set(s[:i]))) for i in range(1,n)]
list_l = [sorted(list(set(s[i:]))) for i in range(1,n)]
print(max([sum([1 if list_s[j][i] in list_l[j] else 0 for i in range(len(list_s[j]))]) for j in range(n-1)]))

### FIXED CODE ###

A,B = map(int,input().split())
sum = A + B
dif = A - B
pro = A * B
if sum > dif:
    if sum > pro:
        print(sum)
    else:
        print(pro)
elif dif > pro:
    print(dif)
else:
    print(pro)
D,T,S = list(int,input().split())
if D <= T * S:
  print("YES")
else:
  print("NO")


### FIXED CODE ###

D,T,S=map(int,input().split())
if D<=T*S:
    print("Yes")
else:
    print("No")
import sys

def gcd(a,b):
    if a == b:
        return a
    else:
        return gcd(b, abs(a-b))

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

if __name__ == "__main__":
    for i in sys.stdin:
        a,b = map(int, i.split())
        print gcd(a,b),lcm(a,b,gcd(a,b))

### FIXED CODE ###

import sys
for i in sys.stdin:
    m, n = map(int, i.split())
    t1, t2 = m, n
    while True:
        if m % n == 0:
            break
        m, n = n, m % n
    a = n
    b = (t1/ a) * t2
    print("{} {}".format(a, b))
import math

def main():
    A, B, K = map(int, input().split())
    
    c_list = []
    
    for i in range(1, min(A, B)+1):
        if A%i==0 and B%i==0:
            c_list.append(i)
    print(c_list[K])
main()

### FIXED CODE ###

import math

def main():
    A, B, K = map(int, input().split())
    
    c_list = []
    
    for i in range(1, min(A, B)+1):
        if A%i==0 and B%i==0:
            c_list.append(i)
    c_list.reverse()
    print(c_list[K-1])
main()
from collections import deque
plusQ = deque([]) 
minsQ = deque([])
 
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
 
for itr, val in enumerate(A):
  if itr != len(A) - 1 and val > 0:
    plusQ.append(val)
  else:
    minsQ.append(val)
    
p1 = plusQ.popleft()
 
ans = deque([])
while len(minsQ) > 0:
  if len(plusQ) > 0:
    p, m = plusQ.popleft(), minsQ.popleft()
    ans.append([m, p])
    minsQ.append(m - p)    
  else:
    m = minsQ.popleft()
    ans.append([p1, m])
    p1 = p1 - m

print(p1)
while len(ans) > 0:
  hoge = ans.popleft()
  print(hoge[0],hoge[1])

### FIXED CODE ###

from collections import deque
plusQ = deque([]) 
minsQ = deque([])
 
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
 
for itr, val in enumerate(A):
  if itr == 0:
    plusQ.append(val)
  elif itr != len(A) - 1 and val > 0:
    plusQ.append(val)
  else:
    minsQ.append(val)
    
p1 = plusQ.popleft()
 
ans = deque([])
while len(minsQ) > 0:
  if len(plusQ) > 0:
    p, m = plusQ.popleft(), minsQ.popleft()
    ans.append([m, p])
    minsQ.append(m - p)    
  else:
    m = minsQ.popleft()
    ans.append([p1, m])
    p1 = p1 - m

print(p1)
while len(ans) > 0:
  hoge = ans.popleft()
  print(hoge[0],hoge[1])
n,k = map(int,input().split())
h = list(map(int,input().split()))
cnt=0
for i in range(n):
	if k<=h[i]:
		cnt+=1
print(cnt)

### FIXED CODE ###

import math
N = int(input())
a=N//2
b=N-a

print(b/N)
n = int(input())
a = list(map(int,input().split()))

a = sorted(a)
a.append(0)

ans = 0
tmp = 0
for i in range(len(a)):
    if a[i] == 1:continue
    tmp = a[i]
    if a[i] != a[i+1]:
        ans += 1
    for j in range(len(a)):
        if a[j] % tmp == 0:
            a[j] = 1
        if all(x == 1 for x in a):
            print(ans)
            exit()

### FIXED CODE ###

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

a_max = max(a)
cnt = [0] * (max(a) + 1)
ans = 0

for ai in a:
    for multi in range(ai, a_max + 1, ai):
        cnt[multi] += 1

for ai in a:
    if cnt[ai] == 1:
        ans += 1

print(ans)
import numpy as np
n = int(input())
a = np.sort(np.array([int(x) for x in input().split()]))[::-1]
count = 0
for index,i in enumerate(a):
    a_i = i%a[index:]
    if np.count_nonzero(a_i == 0)==1:
        count+=1
        
if a[-1] == a[-2]:
    count -= 1

print(count)

### FIXED CODE ###

import numpy as np
n = int(input())
a = np.sort(np.array(list(map(int, input().split()))))
max_num = a[-1]+1
dp = np.array([0]*(max_num))

if n == 1:
    print(1)
elif np.all(a==a[0]):
    print(0)
elif np.count_nonzero(a==1)  == 1:
    print(1)
else:
    for i in a:
        for j in np.arange(i, max_num, i):
            dp[j] += 1
    print(np.count_nonzero(dp[a] == 1))
N, M = map(int, input())
From = set()
To = set()
for _ in range(M):
  a, b = map(int, input())
  if a == 1:
    From.add(b)
  if b == N:
    To.add(a)
if From.isdisjoint(To):
  print("INPOSSIBLE")
else:
  print("POOSIBLE")

### FIXED CODE ###

N, M = map(int, input().split())
From = set()
To = set()
for _ in range(M):
  a, b = map(int, input().split())
  if a == 1:
    From.add(b)
  if b == N:
    To.add(a)
if From.isdisjoint(To):
  print("IMPOSSIBLE")
else:
  print("POSSIBLE")
n=int(input())
for i in range(n):
    if i==1:
        x,y=map(int,input().split())
    else:
        t,a=map(int,input().split())
        v=t
        w=a
        while t<x or a<y:
            v+=t
            w+=a
        x=v
        y=w
print(x+y)
        

### FIXED CODE ###

n=int(input())
x=1
y=1
for i in range(n):
    t,a=map(int,input().split())
    c=max(-(-x//t),-(-y//a))
    x=t*c
    y=a*c      
print(int(x+y))
N, S = map(int, input().split())
A = list(map(int, input().split()))
MOD = 998244353

dp = [0] * (S + 1)

ans = 0
for a in A:
    dp[0] += 1
    for s in range(S + 1)[::-1]:
        if s + a <= S:
            dp[s + a] = (dp[s + a] + dp[s]) % MOD
    ans += dp[S]
    ans %= MOD

print(ans)


### FIXED CODE ###

S = input()
MOD = 10**9 + 7
lenS = len(S)

dp = [[0 for _ in range(13)] for _ in range(lenS + 1)]  # dp[digit][d] = digit桁までの mod=d の数
dp[0][0] = 1

digitMask = 1

for digit in range(1, lenS + 1) :
    if(S[-digit] == '?') :
        for d in range(13) :
            for k in range(10) :
                dp[digit][d] = (dp[digit][d] + dp[digit - 1][(d - k * digitMask) % 13]) % MOD
    else :
        a = int(S[-digit])
        for d in range(13) :
            dp[digit][d] = (dp[digit][d] + dp[digit - 1][(d - a * digitMask) % 13]) % MOD
    digitMask *= 10
    digitMask %= 13

ans = (dp[len(S)][5]) % MOD
print(ans)
N=input()
W=list(map(int, input().split()))

sum1,sum2=0,0
ans=0
dif=1000

for i in range(N):
    sum1=sum(W[0:i])
    sum2=sum(W[i:])
    now = abs(sum1-sum2)
    if dif > now:
        dif =now

print(dif)

### FIXED CODE ###

N=int(input())
W=list(map(int, input().split()))
 
sum1,sum2=0,0
ans=0
dif=1000
 
for i in range(N):
    sum1=sum(W[0:i])
    sum2=sum(W[i:])
    now = abs(sum1-sum2)
    if dif > now:
        dif =now
 
print(dif)
from math import gcd

A, B, K = map(int, input().split())
l = []

for i in range(1, min(A, B) + 1):
    if A % i == 0 and B % i == 0:
        l.append(i)

print(l[-K])

### FIXED CODE ###

A, B, K = map(int, input().split())
l = []

for i in range(1, min(A, B) + 1):
    if A % i == 0 and B % i == 0:
        l.append(i)

print(l[-K])
h,w=map(int, input().split())
s=[' '*(w+2)]
for _ in range(h):
    s.append(' '+input()+' ')
s.append(' '*(w+2))

for i in range(1,w+1):
    for j in range(1,h+1):
        if s[j][i]=='#':
            if s[i-1][j]!='#' and s[i+1][j]!='#' and s[i][j-1]!='#' and s[i][j+1]!='#' :
                    print('No')
                    exit()
print('Yes')


### FIXED CODE ###

h,w=map(int, input().split())
s=[' '*(w+2)]
for _ in range(h):
    s.append(' '+input()+' ')
s.append(' '*(w+2))

for i in range(1,w+1):
    for j in range(1,h+1):
        if s[j][i]=='#':
            if s[j-1][i]!='#' and s[j+1][i]!='#' and s[j][i-1]!='#' and s[j][i+1]!='#' :
                    print('No')
                    exit()
print('Yes')
n,m  = map(int, input().split())
A = set(int(input()) for _ in range(m))
mod = 10**9+7

dp_l = [1, 1]+[-1]*(n-1)

def dp(n):
  if n in A:
    dp_l[n] = 0
  
  if dp_l[n] == -1:
    dp_l[n] = (dp(n-1)+dp(n-2))%mod
  
  return(dp_l[n])

print(dp(n))

### FIXED CODE ###

n,m  = map(int, input().split())
A = set(int(input()) for _ in range(m))
mod = 10**9+7

if 1 in A:
  dp_l = [1, 0] + [0]*(n-1)
else:
  dp_l = [1, 1] + [0]*(n-1)

if n==1:
  print(1)
else:
  for i in range(1, len(dp_l)):
    if i in A:
      dp_l[i] = 0
    else:
      dp_l[i] = (dp_l[i-1]+dp_l[i-2])%mod 
  print(dp_l.pop())
A = list(map(int, input().split()))
print('YES' if int(A[1]+A[2])%4 ==0 else 'NO')
2 3 4

### FIXED CODE ###

A = list(map(int, input().split()))
print('YES' if (A[1]*10+A[2])%4 ==0 else 'NO')
output_word = "YES"
set_1974 = (1,9,7,4)

for i in range(4):
  if int(input()) not in set_1974:
	output_word = "NO"
    
print(output_word)

### FIXED CODE ###

l = set([int(e) for e in input().split()])
set_1974 = set([1,9,7,4])

if l == set_1974:
  print("YES")
else:
  print("NO")
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
def primes(n):#nまでの素数を列挙
    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]]
A,B = map(int,input().split())
if A == 1 or B == 1:
    print(1)
else:
    Min = min(A,B)
    print(Min)
    pr = primes(Min)
    c = 0
    for i in pr:
        if A%i == 0 and B%i == 0:
            c += 1
    print(c+1)

### FIXED CODE ###

import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
import fractions
A,B = map(int,input().split())
if A == 1 or B == 1:
    print(1)
else:
    def factorization(n): #2以上の整数n => [[素因数, 指数], ...]の2次元リストを返す
        arr = []
        temp = n
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                arr.append([i, cnt])
        if temp!=1:
            arr.append([temp, 1])
        if arr==[]:
            arr.append([n, 1])
        return arr
    c = fractions.gcd(A,B)
    arr = factorization(c)
    print(len(arr)+1)
def getlist_pattern( offset, rstr, N, step ):
  aap = []
  if(N<=0):
    return aap
  
  for i,ch in enumerate(rstr):
    if( ch == "o" ):
      ap = []
      if( len(rstr) >=i+step+1 ):
      	ap = getlist_pattern( offset+i+step+1, rstr[i+step+1:], N-1,step )
      
      if( ap==[] ):
        ap = [[offset+i]]
      else:
      	for j in range(len(ap)):
          ap[j].append(offset+i)
      aap.extend(ap)
  return aap    

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

vstr = input()

pp = getlist_pattern( 0, vstr, k, c )

#print(pp)
base = []
for p in pp:
  if(len(p) == k):
    base = p
    break

base.sort()

for ind in base:
  err_flag = 0
  for p in pp:
    if(len(p) == k):
      if( not( ind in p )):
        err_flag = 1
        break
  if( err_flag==0):
  	print( ind+1 )


    

### FIXED CODE ###

k,y,c = map( int, input().split(" "))
ss = input()

asc = []
dsc = []

cnt = 0
err_flg = 0
while( True ):
  if(len(ss) <= cnt):
    err_flg = 1
    break
  if( ss[cnt] == "o"):
    asc.append( cnt )
    cnt += c+1
  else:
    cnt += 1
    
  if( len(asc)==y ):
    break

cnt = 0
ss = ss[::-1]
while( True ):
  if(len(ss) <= cnt):
    err_flg = 1
    break
  if( ss[cnt] == "o"):
    dsc.append( cnt )
    cnt += c+1
  else:
    cnt += 1
    
  if( len(dsc)==y ):
    break
    
for i in range(len(dsc)):
  dsc[i] = len(ss) - dsc[i] - 1
  
dsc.reverse()
#print(asc)
#print(dsc)

if( err_flg == 0 ):
  for i in range(len(asc)):
    if( asc[i] == dsc[i] ):
      print(asc[i]+1)
N=int(input())
H=list(map(int,input().split()))
count=0
if len(H)==1:
    print("Yes")
if len(H)==2:
    if H[0]<=H[1]+1:
        print("Yes")
    else:
        print("No")
elif H[0]<=H[1]+1:
    for i in range(1,N-1):
        if H[i]<=H[i+1]:
            count+=1
            continue
        elif H[i]==H[i+1]+1:
            H[i]-=1
            if H[i]<H[i-1]:
                print("No")
                break
            else:
                count+=1
                continue
        else:
            print("No")
            break
else:
    print("No")
if count==N-2:
    print("Yes")

### FIXED CODE ###

n=int(input())
h=list(map(int,input().split()))
for i in range(n-1):
    if i==0:
        if h[i]>h[i+1]+1:
            print("No")
            exit(0)
        else:
          	h[i]-=1
    elif h[i]<=h[i+1]:
        if h[i]-1>=h[i-1]:
            h[i]-=1
    elif h[i]==h[i+1]+1:
        if h[i]-1>=h[i-1]:
            h[i]-=1
        else:
            print("No")
            exit(0)
    else:
        print("No")
        exit(0)

print("Yes")
a = input()
if a.ispper() == True:
    print('A')
else:
    print('a')

### FIXED CODE ###

b = input()
if b.isupper() == True:
    print('A')
else:
    print('a')
a = map(int, raw_input().spli())

Pi = 3.141592658979

print a**2*Pi, 2*a*Pi

### FIXED CODE ###

import math

a = float(input())

print("%f %f" % (a*a*math.pi, 2*a*math.pi))
from collections import deque
def main():
    N,M,*AB=map(int,open(0).read().split())
    g=[[] for _ in range(N+1)]
    for a,b in zip(*[iter(AB)]*2):
        g[a].append(b)
        g[b].append(a)
    q=deque([1])
    s=[0]*(N+1)
    s[1]=1
    while q:
        u=q.popleft()
        for v in g[u]:
            if not s[v]:
                s[v] = u
                q.append(v)
    print("Yes")
    print("\n".join(map(str, s[2:])))
if __name__ == "__main__":
    main()

### FIXED CODE ###

import math
 
N = int(input())
Prime = []
ans = 0
 
def func(n):
    while n % 2 == 0:
        n = n // 2
        Prime.append(2)
    for i in range(3, int(math.sqrt(n)) + 1, 2):
        while n % i == 0:
            n = n //i
            Prime.append(i)
    if n > 2:
        Prime.append(n)
 
func(N)
 
for i in set(Prime):
    c = i
    while N % c == 0:
        N = N // c
        ans += 1
        c = c * i
 
print(ans)
import sys

X = input()
count = 0
for num in range(X):
  if not num % 3 == 0 or num % 5 == 0:
    count = count + num
print(count)

### FIXED CODE ###

import sys
 
X = int(input())
count = 0
for num in range(1, X+1):
  if num % 3 == 0 or num % 5 == 0:
    continue
  else:
    count = count + num
print(count)
n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in a:
    ans = ans*i
    if ans > 1000000000000000000:
        print(-1)
        ans = -1
        break
if ans != -1
    print(ans)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
else:
    ans = 1
    for i in a:
        ans = ans*i
        if ans > 1000000000000000000:
            print(-1)
            ans = -1
            break
    if ans != -1:
        print(ans)
a=input()
b=input()
c=input()

sizea=len(a)
sizeb=len(b)
sizec=len(c)
print(sizea,sizeb,sizec)

flag=1
x=0
y=0
z=0
for i in range(301):
  if flag==1:
    if sizea==0:
      ans='A'
      break
    else:
      if a[x]=='a':
        flag=1
      elif a[x]=='b':
        flag=2
      elif a[x]=='c':
        flag=3
      sizea-=1
      x+=1
      print(sizea,a[x])
  elif flag==2:
    if sizeb==0:
      ans='B'
      break
    else:
      if b[y]=='a':
        flag=1
      elif b[y]=='b':
        flag=2
      elif b[y]=='c':
        flag=3
      sizeb-=1
      y+=1
      print(sizeb,b[y])
  elif flag==3:
    if sizec==0:
      ans='C'
      break
    else:
      if c[z]=='a':
        flag=1
      elif c[z]=='b':
        flag=2
      elif c[z]=='c':
        flag=3
      sizec-=1
      z+=1
      print(sizec,c[z])

print(ans)

### FIXED CODE ###

a=list(input())
b=list(input())
c=list(input())
#print(a,b,c)


card=a.pop(0)
#print(card)
flag=0
for i in range(301):
    if card=='a' and len(a)==0 and flag==0:
        ans='A'
        flag=1
    elif card=='b' and len(b)==0 and flag==0:
        ans='B'
        flag=1
    elif card=='c' and len(c)==0 and flag==0:
        ans='C'
        flag=1
    elif flag==0:
        if card=='a':
            card=a.pop(0)
        elif card=='b':
            card=b.pop(0)
        elif card=='c':
            card=c.pop(0)
    
print(ans)
n = int(input())
a = list(map(int, input().split()))
diff = []
for i, index in enumerate(a,1):
    diff.append(i-index)

diff.sort()
if n % 2 == 1:
    ans = 0
    b = diff[n // 2]
    for i in diff:
        ans += abs(i - b)
    print(ans)
else:
    ans1,ans2 = 0
    b1 = diff[n // 2 - 1]
    b2 = diff[n // 2]
    for i in diff:
        ans1 += abs(i -b1)
        ans2 += abs(i -b2)
    print(min(b1.b2))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
diff = []
for i, index in enumerate(a,1):
    diff.append(i-index)

diff.sort()
if n % 2 == 1:
    b = diff[n // 2]
    tmp = map(lambda x: x - b, diff)
    print(sum( map(abs,tmp )))
else:
    b1 = diff[n // 2 - 1]
    b2 = diff[n // 2]
    tmp1 = map(lambda x: x - b1, diff)
    tmp2 = map(lambda x: x - b2, diff)
    ans1 = sum( map(abs,tmp1 ))
    ans2 = sum( map(abs,tmp2 ))
    print(min(ans1,ans2))