peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
import numpy as np
import scipy.sparse
N,X,Y = (int(x) for x in input().split())
lil = scipy.sparse.lil_matrix((N, N))
for i in range(N-1):
    lil[i, i+1] = 1
lil[X-1, Y-1] = 1
lil2 = scipy.sparse.csgraph.dijkstra(lil)
for i in range(1,N):
    print(np.count_nonzero(lil2 == i))
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))

if len(a)%2==0:
    b=a[::-2]+a[::2]
else:
    b=a[::-2] + a[1::2]

print(' '.join(list(map(str,b))))
# Judge status: Accepted
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    A=list(map(int,readline().split()))

    S=0
    min_number=10**9
    minus_count=0
    for i in range(N):
        if A[i]<0:
            minus_count+=1
        a=abs(A[i])
        S+=a
        min_number=min(min_number,a)

    S=S if minus_count%2==0 else S-2*min_number
    print(S)
    
if __name__=="__main__":
    main()
# Judge status: Accepted
import bisect
import math
n, c, k = list(map(int, input().split()))
t = [0] * n
for i in range(n):
    t[i] = int(input())
t.sort()
bus_count = 0
pre_index = 0
index = 0
while index < n:
    #indexを乗せるバスが発車する時間
    leave = t[index] + k
    count = 0
    bus_count += 1
    while index < n and count < c and leave >= t[index]:
        count += 1
        index += 1
print(bus_count)
# Judge status: Wrong Answer
def factorial(x, mod=10**9+7):
    # x!
    # 階乗
    # ex) factorial(5) = 120
    tmp = 1
    for i in range(1, x+1):
        tmp = (tmp * i) % mod
    return tmp


N ,M = map(int, input().split())
mod = 1000000007

if N==M:
    print((2*factorial(N)**2) % mod )
elif abs(N-M==1):
    print((factorial(N)*factorial(M))%mod)
else:
    print(0)
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
k=int(input())
c=0
while a>=b:
	b*=2
	c+=1
while b>=c:
	c*=2
	c+=1
if c<=k:
	print('Yes')
else:print('No')
# Judge status: Wrong Answer
from math import gcd
sum = 0
K = int(input())
for k in range(1,K+1):
  for j in range(1,K+1):
    t = gcd(k,j)
    for i in range(1,K+1):
      sum += gcd(t,i+1)
print(sum)
# Judge status: Accepted
r, g, b = input().split()

number = int(r+g+b)
if number % 4 ==0:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
dice = np.arange(1, N+1, dtype=np.int32)
need = np.zeros(N, np.int32)

for i in range(20):
    target = dice < K
    need[target] += 1
    dice[target] <<= 1 #2倍

power = (.5) ** need
answer = power.sum() / N
print(answer)
# 58
# Judge status: Accepted
S = list(input())
k = int(input())

alp = list('abcdefghijklmnopqrstuvwxyz')
s2a = {alp[i]: 26-i for i in range(26)}
s2a['a'] = 0

for i in range(len(S)):
    s = S[i]
    if s2a[s] <= k:
        k -= s2a[s]
        S[i] = 'a'

k %= 26
idx = alp.index(S[-1])
S[-1] = alp[k+idx]

print(*S, sep='')
# Judge status: Accepted
s=input()
ans=0
if s[0]!='A':
    print("WA")
    exit()
for i in range(1,int(len(s))):
    if s[i].isupper():
        if i==1 or i==int(len(s))-1 or s[i]!='C':
            print("WA")
            exit()
        ans+=1
if ans !=1:
    print("WA")
    exit()
print("AC")
# Judge status: Accepted
from collections import defaultdict
n = int(input())
a_list = list(map(int,input().split()))
q = int(input())
d = defaultdict(lambda: 0)
ans = sum(a_list)
for i in a_list:
    d[i] += 1
    
ans = sum(a_list)
for i in range(q):
    a,b = map(int,input().split())
    ans = ans + b*d[a] - a*d[a]
    d[b] += d[a]
    d[a] -= d[a]
    print(ans)
# Judge status: Wrong Answer
n = int(input())
x = list(map(int,input().split()))
S = sum(x)
Ave = sum(x) // n
m = 10**6
score = 0
count = 0

for p in range(Ave-100,Ave+101): 
    for i in range(n):
        score += (x[i]-p)**2
    if score < m:
        m = score
        score = 0
print(m,p)
# Judge status: Accepted
from math import sqrt
n=int(input())
ans=n+1
for i in range(1,int(sqrt(n))+1):
	if n%i==0:
		ans = i+n//i
print(ans-2)
# Judge status: Wrong Answer
n,m = map(int, input().split())
seq = []
for _ in range(m):
    seq.append(0)

for i in range(n):
    liked = list(map(int, input().split()))
    for j in range(liked[0]):
        liked[j+1] += 1
seq.count(n)
# Judge status: Wrong Answer
n = input() 
print(n)
sum = 0
for i in range(len(n)):
  sum += int(i)
if(sum%9 == 0):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n=int(input())
s=input()
list1=[0]*(n+1)
ans=0
for i in range(n):
    if s[i]=='I':
        ans+=1
    else:
        ans-=1
    list1[i]=ans
print(max(list1))
# Judge status: Accepted
x,y=map(int,input().split())
ans=0
while x<=y:
  x*=2
  ans+=1
print(ans)
# Judge status: Accepted
n = int(input())
a= list(map(int, input().split()))
from collections import Counter
c=Counter(a)
dic={}
for k,v in c.items():
    dic[k]=v*(v-1)//2
su=0
for k in dic.values():
    su+=k
for i in a:
    print(su-dic[i]+(c[i]-1)*(c[i]-2)//2)
# Judge status: Wrong Answer
n = int(input())
s = input()
len1 = len(s)
print(len1)
if(len1>=n):
    print(s[0:n]+"...")
else:
    print(s)
# Judge status: Wrong Answer
x = int(input())

a = 100
ans = 0

while a <= x:
  a = a * 1.01
  ans += 1

print(ans)
# Judge status: Accepted
# -*- coding: utf-8 -*-

def main():

    a = int(input())
    s = input()

    if a >= 3200:
        ans = s

    else:
        ans = 'red'

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
a = int(input())
print("Yes" if a % 9 == 0 else "No")
# Judge status: Accepted
import math
x = int(input())

x_cnt = 100
cnt = 0
while(x_cnt < x):
    x_cnt = math.floor(x_cnt * 1.01)
    cnt += 1

print(cnt)
# Judge status: Accepted
S=input()
N=int(S)
k=len(S)

dp = [[-1] * 2 for _ in range(k+1)]
dp[0][0] = 0
for i in range(k):
    c = int(S[i])
    dp[i+1][0] = dp[i][0] + c
    dp[i+1][1] = dp[i][1]
    if dp[i][1] >= 0:
        dp[i+1][1] = max(dp[i+1][1], dp[i][1] + 9)
    if c >= 1:
        dp[i+1][1] = max(dp[i+1][1], dp[i][0] + c-1)

print(max(dp[k][0], dp[k][1]))
# Judge status: Accepted
N,M=map(int,input().split())
ship=[list(map(int,input().split())) for _ in range(M)]
port1=[]
port2=[]
for i in range(M):
    if ship[i][0]==1:
        port1.append(ship[i][1])
    if ship[i][1]==N:
        port2.append(ship[i][0])

port1=set(port1)
port2=set(port2)
if len(port1&port2)>0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
# Judge status: Accepted
a,b=map(int,input().split())
n=list(map(int,input().split()))
if a<=sum(n):
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline


N = int(input().rstrip())
a_dict = {}
for i in range(N):
  a_dict[i+1] = int(input().rstrip())

target = 1
next_target = a_dict[target]
cont = True
ans = 0

while cont:
  target = next_target
  next_target = a_dict[target]
  ans += 1
  del a_dict[target]
  if next_target not in a_dict:
    ans = -1
    cont = False
  elif next_target == 2:
    ans += 1
    cont = False

print(ans)
# Judge status: Wrong Answer
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))

visited = set()
count = 0
next = 1
while True:
  count += 1
  visited.add(next)
  next = a[next-1]
  if next == 1:
    print(count)
    exit(0)
  if next in visited:
    print(-1)
    exit(0)
# Judge status: Accepted
import sys
import copy
import math
import itertools
import numpy as np
import re

S = input()
s = "keyence"
for i in range(len(S)):
    if re.fullmatch(s[:i]+".*"+s[i:],S):
        print("YES")
        sys.exit(0)

print("NO")
# Judge status: Accepted
n = int(input())
a = [int(i) for i in input().split()]
m = a[0]
sum = 0
for i in a[1:]:
    if i <= m:
        sum += m - i
    else:
        m = i
print(sum)
# Judge status: Wrong Answer
n = int(input())
a = sorted([int(i) for i in input().split()])
b = list(range(a[0], a[-1] + 1))
l = len(b)
if l == 0:
    print(0)
else:
    m1 = b[l // 2]
    m2 = b[l // 2 - 1]
    c1, c2 = 0, 0
    for i in range(n):
        c1 += (a[i] - m1) ** 2
        c2 += (a[i] - m2) ** 2
    print(min(c1, c2))
# Judge status: Accepted
a = input()
if a[-1] == 's':
  print(a + 'es')
else:
  print(a + 's')
# Judge status: Accepted
s ,c = map(int,input().split())

ans = 0
if s*2 <= c:
    ans += s
    c -= s*2 # sと組んだ後の残り
    ans += c // 4
else: # sが余るパターン
    ans += c // 2


print(ans)
# Judge status: Accepted
N = int(input())
S = ""
while N!=0:
  if N&1:
    S = "1"+S
    N = (N-1)//(-2)
  else:
    S = "0"+S
    N = N//(-2)
print(0 if S=="" else S)
# Judge status: Accepted
a=[int(i) for i in input().split()]
res=False
for i in range(3):
    if a[i]*2==sum(a):res=True
print("Yes"if res else"No")
# Judge status: Wrong Answer
rx, uy, n = map(int, input().split())

dy = 0
lx = 0

for idx1 in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        if lx < x:
            lx = x
    elif a == 2:
        if rx > x:
            rx = x
    elif a == 3:
        if dy < y:
            dy = y
    else:
        if uy > y:
            uy = y

mul = (uy - dy) * (rx - lx)
if mul < 0:
    print(0)
else:
    print(mul)
# Judge status: Wrong Answer
import numpy as np

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

b=np.zeros(N)

for i in range(N):
  b=np.zeros(N)
  b[i]=A.count(i+1)
  tmp=0
  for j in range(N):
    if(i==j):
      tmp=tmp+(b[j]-1)*(b[j]-2)/2
    else:
      tmp=tmp+b[j]*(b[j]-1)/2
  print(int(tmp))
# Judge status: Wrong Answer
sx,sy,tx,ty = map(int, input().split( ))
u = ty-sy
r = tx-sx
print("R"* r+ "U"*u + "L"*r + "D"*u + "D" 
            + "R"* (r+1)+ "U"*(u+1) + "L" + "U" + "L"*r + "D"*(u+1) +"R")
# Judge status: Accepted
# import bisect
# from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

    for i in range(1, 1000):
        x_min = 100 * i
        x_max = 105 * i

        if x_min <= x <= x_max:
            print(1)
            sys.exit()

    print(0)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
n = 0
can = True

while can:
    for i in range(N):
        if A[i]%2 != 0:
            can = False
            break

        if A[i]%2 == 0:         
            A[i] = A[i] // 2
            n += 1
        else:
            can = False
            break

print(n)
# Judge status: Accepted
a,s,c = input().split()
print(a[0]+s[0]+c[0])
# Judge status: Accepted
N = int(input())

print((N-1)*N // 2)
# Judge status: Accepted
page = int(input())

paper = page // 2
a = page % 2
if a != 0:
  paper += 1

print(paper)
# Judge status: Wrong Answer
def lcm(x,y):
    for i in range(1,10**5+1):
        if i%x==0:
            if i%y==0:
                return(i)
                break

A,B=map(int,input().split())
print(lcm(A,B))
# Judge status: Accepted
n = int(input())  # nは入力回数
num_list = [list(map(int, input().split())) for _ in range(n)]
ans = "No"

for i in range(n-2):
    if num_list[i][0] == num_list[i][1] and num_list[i+1][0] == num_list[i+1][1] and num_list[i+2][0] == num_list[i+2][1]:
        ans = "Yes"

print(ans)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split(" ")))
countlist=[0 for i in range(n)]
for j in range(n-1):
  countlist[a[j]-1]+=1
for i in range(n):
	print(countlist[i])
# Judge status: Wrong Answer
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

exist = False
for i in range(N-M+1):
    for j in range(N-M+1):
        match = True
        for k in range(M):
            for l in range(M):
                if A[i][j] != B[k][l]:
                    match = False
        if match:
            exist = True

if exist:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
x, y = map(int, input().split())
count = abs(abs(x) - abs(y))

if x*y >= 0 and y > x:
    print(y - x)
elif (0<y and 0<x) or (0>x and 0>y):
    print(count+2)
else:
    print(count+1)
# Judge status: Accepted
S, T = input(), input()
d = dict()
count = 0
S_list = []
for c in S:
    try:
        n = d[c]
    except:
        d[c] = n = count
        count += 1
    S_list.append(n)
d = dict()
count = 0
for m, c in zip(S_list, T):
    try:
        n = d[c]
    except:
        d[c] = n = count
        count += 1
    if n != m:
        print("No")
        break
else:
    print("Yes")
# Judge status: Wrong Answer
a, b, c, d=map(int, input().split())

if (a+b)%2 ==1 and (c+d)%2==0 or (a+b)%2==(c+d)%2:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
N = int(input())
upper = [1]

for cnt in [6, 9]:
    tmp = cnt
    while tmp <= 10 ** 5:
        upper.append(tmp)
        tmp *= cnt

dp = [float("inf")] * (10 ** 5 + 1)
dp[0] = 0
for u in upper:
    dp[u] = 1

for i in range(2, N + 1):
    for u in upper:
        if i - u > 0:
            tmp = dp[i - u] + 1
            if tmp < dp[i]:
                dp[i] = tmp

print(dp[N])
# Judge status: Wrong Answer
s=input()
for i in range(len(s)-2,0,-2):
    s1=s[:i:]
    #print(s1,s1[:i//2],s1[i//2:])
    if s1[:i//2]==s1[i//2:]:print(i)
# Judge status: Wrong Answer
N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

d=[]
for i in range(N):
    d.append(a[i]-b[i])

cnt=-sum(d)
p=0
n=0
for j in range(N):
    if d[j]>0:
        p+=d[j]
    if d[j]<0:
        n+=-d[j]//2
if p<=cnt and n<=cnt:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N, P = map(int, input().split())
A = list(map(lambda x: int(x)%2, input().split()))
print(2**(N-1))
# Judge status: Wrong Answer
n, m = map(int, input().split())
if n == 1 or m == 1:
    print(n*m - 2)
else:
    print(n*m - (n*2+m*2-4))
# Judge status: Accepted
import sys
read_=sys.stdin.buffer.readline
N=int(read_())
A=input().split()
if len(A)==1:
    print(A[0])
    exit()
if N%2==0:
    ans=A[1::2][::-1]
    ans.extend(A[::2])
else:
    ans=A[::2][::-1]
    ans.extend(A[1::2])
print(' '.join(ans))
# Judge status: Accepted
N = int(input())
a_array = list(map(int, input().split()))

P = 10 ** 9 + 7
mod_array = [0] * 60
digit_array = [0] * 60
p = 1
for i in range(60):
    mod_array[i] = p
    p = (p * 2) % P

for a in a_array:
    for i in range(60):
        digit_array[i] += (a & (1 << i)) >> i
# print(digit_array)
ans = 0

for i in range(60):
    ans = (ans + mod_array[i] * digit_array[i] * (N - digit_array[i]) % P) % P

print(ans)
# Judge status: Wrong Answer
N=int(input())
d=list(map(int, input().split()))

d=sorted(d)
ans=0

for i in range(10**5):
    if d[int(N/2-1)] < i and i <= d[int(N/2)]:
        ans +=1

print(ans)
# Judge status: Accepted
from math import factorial
n = int(input())
print(factorial(n)%(10**9+7))
# Judge status: Accepted
# coding: utf-8
"""this is python work script"""

def solver(word):
    """solve this problem"""
    check_result = word.replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', '')

    answer = 'YES'
    if check_result:
        answer = 'NO'

    return answer

def main():
    """main function"""
    input_word = input().rstrip()
    answer = solver(input_word)
    print(answer)

if __name__ == '__main__':
    main()
# Judge status: Accepted
from collections import defaultdict

dic = defaultdict(int)

N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
for i in s:
    dic[i] += 1

for i in t:
    dic[i] -= 1

ans = 0
for k, v in dic.items():
    ans = max(ans, v)
print(ans)
# Judge status: Accepted
sx,sy,tx,ty=map(int,input().split())

dx=tx-sx
dy=ty-sy

ans =      "U"*dy +          "R"*dx+"D"*dy+"L"*dx
ans+="L" + "U"*dy + "U"+"R"+"R"*dx+"D"
ans+="R"+"D"*dy+"D"+"L"+"L"*dx+"U"

print(ans)
# Judge status: Accepted

alpha = "abcdefghijklmnopqrstuvwxyz"
C = input()
print(alpha[alpha.index(C)+1])
# Judge status: Wrong Answer
l=int(input())

ans=0
for i in range(l):
  for j in range(l-i):
    ans=max(ans,i*j*(l-i-j))
print(ans)
# Judge status: Accepted
import math
a=int(input())
ans=0
for i in range(1,int(math.sqrt(a)),1):
  if a%i==0 and not i==1:
    cnt=0
    while a%i==0:
      cnt+=1
      a=a/i
    ans+=(math.sqrt(2*cnt+0.25)-0.5)//1
if not a==1:
  print(int(ans+1))
else:
  print(int(ans))
# Judge status: Accepted
import sys, math
from itertools import combinations
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    x = ii()
    a = x//11
    b = x%11
    if b > 6:
        print(2*a+2)
    elif b > 0:
        print(2*a+1)
    else:
        print(2*a)

if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
s = list(input())
ans = 0
for i in range(1, n):
    x = s[:i]
    y = s[i:]
    temp = 0
    for ch in range(26):
        if chr(ch + 97) in x and chr(ch + 97) in y:
            temp += 1
    ans = max(ans, temp)
print(ans)
# Judge status: Accepted
s = input()
l = [s.count("a"), s.count("b"), s.count("c")]
print ("NO") if max(l) - min(l) >= 2 else print ("YES")
# Judge status: Accepted
from math import factorial

mod = 10 ** 9 + 7
n, m = map(int, input().split())
print(
    ((factorial(n) % mod) ** 2 % mod) * 2 % mod
    if n == m
    else (factorial(n) % mod) * (factorial(m) % mod) % mod
    if abs(n - m) == 1
    else 0
)
# Judge status: Accepted
N = int(input())
a = [int(input()) for _ in range(N)] + [0]
ans = 0

for i in range(N):
    if a[i] != 0:
        add, mod = divmod(a[i], 2)
        ans += add
        if a[i + 1] != 0:
            a[i + 1] += mod

print(ans)
# Judge status: Accepted
s = input()
pre = s[0]
for a in s[1:]:
  if pre != a:
    print("Yes")
    exit()
  pre = a
print("No")
# Judge status: Accepted
n = int(input())
h = list(map(int,input().split()))

dp=[10**10]*(n+2)

dp[0]=0
dp[1]=0
dp[2]=abs(h[1]-h[0])

for i in range(3,n+1):
  dp[i]=min(dp[i],dp[i-1]+abs(h[i-1]-h[i-2]),dp[i-2]+abs(h[i-1]-h[i-3]))

print(dp[n])
# Judge status: Accepted
S,T = input().split()
A,B = map(int,input().split())
U = input()
ans1 = A
ans2 = B
if S==U:
    ans1 -= 1
else:
    ans2 -= 1
print(ans1, ans2)
# Judge status: Accepted
N, M = map(int, input().split())
A = [''] * N
B = [''] * M
for i in range(N):
    A[i] = input()
for i in range(M):
    B[i] = input()

match_cnt = 0
for i in range(N - M + 1):
    for j in range(N - M + 1):
        flag = True
        for y in range(M):
            if A[y + i][j:j + M] != B[y]:
                flag = False
        if flag:
            match_cnt += 1

if match_cnt > 0:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
N = int(input())
mlist = list(map(int,input().split()))

s = 1
for i in range(N):
    if mlist[i] == 0:
        print(0)
        break
    elif s > 0:
        s *= mlist[i]

    if s >= 10**18:
        s = -1
if i == N-1:
    print(s)
# Judge status: Accepted
N,D = map(int,input().split())

# 2次元配列
x = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    x.append(array)
    
ans = 0

for i in range(N):
  for j in range(i+1,N):
    distance = 0
    for y,z in zip(x[i],x[j]):
      distance += (y-z)**2
    d = distance**0.5
    if d.is_integer():
      ans += 1

print(ans)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
A = [x-i-1 for i, x in enumerate(A)]
R = round(sum(A)//N)
print(sum(abs(a-R) for a in A))
# Judge status: Accepted
n=int(input())
s=list(map(int,input().split()))
f=False
c=0
while True:
    for x in range(n):
        if s[x]%2==0:s[x]=s[x]//2
        else:f=True
    if f:
        print(c)
        break
    c+=1
# Judge status: Accepted
# https://atcoder.jp/contests/abc047/tasks/abc047_b

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

left = 0
right = w
bottom = 0
top = h

for _ in range(n):
    x, y, a = [int(i) for i in input().split()]
    if a == 1:
        left = max(left, x)
    elif a == 2:
        right = min(right, x)
    elif a == 3:
        bottom = max(bottom, y)
    elif a == 4:
        top = min(top, y)

if top <= bottom or right <= left:
    print(0)
else:
    print((right - left) * (top - bottom))
# Judge status: Wrong Answer
n,m=map(int,input().split())
if 10<=n:
  print(m)
else:
  m=m-(10-n)*100
  print(m)
# Judge status: Accepted
N = int(input())
A = [int(i) for i in input().split()]

for i in range(N):
    A[i] -= i + 1

A.sort()

if N % 2 == 0:
    ans1 = 0
    ans2 = 0
    for a in A:
        ans1 += abs(a - A[N//2])
        ans2 += abs(a - A[N//2 - 1])
    ans = min(ans1, ans2)
else:
    ans = 0
    for a in A:
        ans += abs(a - A[(N - 1) // 2])

print(ans)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
AS = sum(A) - A[0]
BS = sum(B) - B[-1]
ame = A[0]

for i in range(N-1):
  if AS >= BS:
    ame += A[i+1]
    AS -= A[i+1]
    BS -= B[i]
  else:
    ans = ame + sum(B[i:])
    print(ans)
    exit()
print(ame + B[-1])
# Judge status: Accepted
S = input()
S1 = S[0:(len(S)-1)//2]
S2 = S[(len(S)-1)//2+1:len(S)]

def discrimination(S):
    N = len(S)
    if N%2==0:
        return all(S[i]==S[N-1-i] for i in range(N//2))
    else:
        return all(S[i]==S[N-1-i] for i in range((N-1)//2))

if discrimination(S) and discrimination(S1) and discrimination(S2):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
A,B,C=map(int,input().split())
mod=set()
tmp=0
D=A
while tmp not in mod:
    mod.add(tmp)
    tmp=D%B
    if tmp==C:
        print('YES')
        exit()
    D+=A
print('NO')
# Judge status: Wrong Answer
a,b = map(int,input().split())
t = 0
for i in range(a,b+1):
    if i % 100 == i // 1000 or i % 100 * 10 == i // 1000:
        t += 1

print(t)
# Judge status: Accepted
S = input()
ansA = 0
ansB = 0
for i in range(len(S)):
    N = int(S[i])
    if N == 1:
        ansA += 1
    elif N % 2 == 0:
        ansA += N//2
        ansB += N//2
    else:
        N -= 1
        ansA += N//2+1
        ansB += N//2
if ansA == 1 and ansB == 0:
    ans = 10
else:
    ans = ansA+ansB
print(ans)
# Judge status: Accepted
x = input()
a, b = map(int, x.split(" "))
print(a * b)
# Judge status: Accepted
N=int(input())
ls=list(map(int,input().split()))
ls.sort()

#定数倍のやつに＋１する
M=max(ls)
A=[0]*(M+1)
for i in range(N):
  a=M//ls[i]
  for j in range(1,a+1):
    A[j*ls[i]]+=1
    
ans=0     
for i in range(len(ls)):
  if A[ls[i]]==1:
    ans+=1
print(ans)
# Judge status: Accepted
################################################
#                                              #
#   author: raghav_0901 (Raghav Dalmia)        #
#   updated on: 19-09-2020,  5:32:05 pm IST   #
#                                              #
################################################

from math import *


def _in():
    return [int(x) for x in input().split(' ')]


if __name__ == "__main__":
    s = input()
    out = s + ("es" if s[-1] == "s" else "s")
    print(out)
# Judge status: Wrong Answer
S=input()
mem_mod = [0 for i in range(0,2019,1)]
N = len(S)
counter = 0
S_num_tmp = list(S)
S_num = list(map(int, S_num_tmp))
tmp=10
# Judge status: Wrong Answer
a, b, m = map(int, input().split())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
k = []
for i in range(m):
    t1,t2,t3 = map(int, input().split())
    dis = As[t1-1] + Bs[t2-1] - t3
    k.append(dis)
print(min(k))
# Judge status: Accepted
n = int(input())
count = 0
for i in range(1,n+1):
    if len(str(i)) % 2 != 0:
        count += 1
print(count)
# Judge status: Accepted
A, B, C = map(int, input().split())
K = int(input())

count = 0
while not A < B:
  B *= 2
  count += 1
while not B < C:
  C *= 2
  count += 1

if count <= K and A < B < C:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
a,b=input().split()
l = list(map(int, input().split()))
a=int(a)
b=int(b)
if a >= sum(l):
  print('Yes')

else:
  print('No')
# Judge status: Accepted
n = int(input())

d = {}
for i in range(n):
    a = int(input())
    if a not in d:
        d[a] = 1
    else:
        if d[a]:
            d[a] = 0
        else:
            d[a] = 1

ans = 0
for v in d.values():
    ans += v
    
print(ans)