Harryxun/stf_run huggingface dataset:
import bisect


def CumulativeSum(l):
    a = [0]
    for i in l:
        a.append(a[-1] + i)
    return a[1:]


def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    b = CumulativeSum(a)
    s = b[-1]
    h = s // 2
    x = bisect.bisect_left(b, h)
    m1, m2 = b[x], b[x + 1]
    if s % 2 == 0 and h in (m1, m2):
        print(0)
        return
    a1 = abs(m1 * 2 - s)
    a2 = abs(m2 * 2 - s)
    print(min(a1, a2))


if __name__ == '__main__':
    resolve()


### FIXED CODE ###

import bisect


def CumulativeSum(l):
    a = [0]
    for i in l:
        a.append(a[-1] + i)
    return a[1:]


def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    b = CumulativeSum(a)
    s = b[-1]
    h = s // 2
    x = bisect.bisect_left(b, h)
    try:
        m = (b[x], b[x + 1], b[x - 1])
    except:
        m = (b[x], b[x - 1])
    if s % 2 == 0 and h in m:
        print(0)
        return

    print(min([abs(x * 2 - s) for x in m]))


if __name__ == '__main__':
    resolve()
n = int(input())
 
l = []
for i in range(n):
    l.append(input())

if len(set(l)) != n :
    print("No")
    exit()

for i in range(n-1) :
    if l[i][-1] != l[i+1][0]:
        print("No")
        exit()

print("Yes")

### FIXED CODE ###

hh, ww = map(int, input().split())
h, w = map(int, input().split())

print(int((hh-h)*(ww-w)))
N = int(input())
S1 = list(input())
S2 = list(input())

if len(S1) == 1:
    print(3)
else:
    if S1[0] != S2[0]:
        t = 2
        i = 2
        a = 6
    else:
        t = 1
        i = 1
        a = 3
    while True:
        if S1[i] != S2[i]:
            if t == 2:
                a *= 3
            else:
                a *= 2
            i += 2
            t = 2
        else:
            if t == 2:
                a *= 1
            else:
                a *= 2
            i += 1
            t = 1
        a %= 1000000007
        if i == len(S1):
            print(a)
            break


### FIXED CODE ###

N = int(input())
S1 = list(input())
S2 = list(input())

if len(S1) == 1:
    print(3)
elif len(S1) == 2:
    print(6)
else:
    if S1[0] != S2[0]:
        t = 2
        i = 2
        a = 6
    else:
        t = 1
        i = 1
        a = 3
    while True:
        if S1[i] != S2[i]:
            if t == 2:
                a *= 3
            else:
                a *= 2
            i += 2
            t = 2
        else:
            if t == 2:
                a *= 1
            else:
                a *= 2
            i += 1
            t = 1
        a %= 1000000007
        if i == len(S1):
            print(a)
            break
N,K = map(int,input().split())
l = list(map(int,input().split()))
ans = 0
sorted(l)
for i in range(K):
  ans += l[n-i+1]
print(ans)

### FIXED CODE ###

A,B = map(int,input().split())
if A%3 == 0:
  print("Possible")
elif B%3 == 0:
  print("Possible")
elif (A+B)%3 == 0:
  print("Possible")
else:
  print("Impossible")
INF = float('inf')
H,W = map(int,input().split())
s = [input() for _ in range(H)]
cost = [[INF]*W for _ in range(H)]
cost[0][0] = 1

def bfs(h,w):
    for dh,dw in [[1,0],[-1,0],[0,1],[0,-1]]:
        if 0<=h+dh<H and 0<=w+dw<W:
            if s[h+dh][w+dw] == '.' and cost[h+dh][w+dw] == INF:
                cost[h+dh][w+dw] = cost[h][w]+1
                return bfs(h+dh,w+dw)

bfs(0,0)
if cost[-1][-1] == INF:
    print(-1)
else:
    ans = H*W-cost[-1][-1]
    for h in range(H):
        ans -= s[h].count('#')
    print(ans)

### FIXED CODE ###

import queue
H,W = map(int,input().split())
maze = [0]*H
for i in range(H):
    maze[i] = input()
inf = float('inf')
d = [[inf for i in range(W)] for i in range(H)]
dx = [1,0,-1,0]
dy = [0,1,0,-1]


def bfs():
    que = queue.Queue()
    que.put((0,0))
    d[0][0] = 0
    while que.qsize():
        p = que.get()
        if p == (H-1,W-1):
            break
        for i in range(4):
            nx = p[0]+dx[i]
            ny = p[1]+dy[i]
            if 0 <= nx and nx <= H-1 and 0 <= ny and ny <= W-1 \
            and maze[nx][ny] != '#' and d[nx][ny] == inf:
                d[nx][ny] = d[p[0]][p[1]] + 1
                que.put((nx,ny))

bfs()

count = 0
for i in range(H):
    for j in range(W):
        if maze[i][j] == '#':
            count += 1

ans = -1
if d[H-1][W-1] != inf:
    ans = H*W-count-1-d[H-1][W-1]
print(ans)
from collections import Counter
M=10**7
_,*l=map(int,open(0).read().split())
d=[1]*(M)
C=Counter(sorted(l)
s=0
for a,b in C.items():
    if b != 1:d[a]=0
    elif d[a]:s+=1
    for j in range(a,M,a):d[j]=0
print(s)


### FIXED CODE ###

from collections import Counter
def i(): return int(input())
def l(): return list(map(int,input().split()))
N = i();A = l();A.sort();dp = [1]*(10**6+1);C = Counter(A);ans = 0
for a,b in C.items():
    if b != 1:dp[a] = 0
    elif dp[a]:ans += 1
    for j in range(a,10**6+1,a):dp[j] = 0
print(ans)
N = int(input())
S = input()
K = int(input())

for i in range(N):
  if S[i] != S[K]:
    S[i] = *
    
print(S)

### FIXED CODE ###

N = int(input())
S = list(input())
K = int(input())

for i in range(N):
  if S[i] != S[K-1]:
    S[i] = "*"
    
print(*S, sep="")
a = input()
print(a + a*a + a*a*a)

### FIXED CODE ###

def main():
    a = int(input())
    print(a + a*a + a*a*a)
    
if __name__ == "__main__":
    main()
N,M=map(int,input().split())
slist=[]
for i in range(M):
    slist.append(list(map(int,input().split())))

ans=["0"]*N

for i in range(N):
    if ans[slist[i][0]-1]=="0":
        ans[slist[i][0]-1]=slist[i][1]
    elif ans[slist[i][0]-1]!=slist[i][1]:
        ans=["-1"]
        break



if N>1:
    if ans[0]=="0":
        ans[0]=1
    elif ans[0]==0:
        ans=["-1"]
if ans !=["-1"]:
    for i in range(N):
        if ans[i]=="0":
            ans[i]=0

print(*ans,sep=(""))

### FIXED CODE ###


N,M=map(int,input().split())
slist=[]
for i in range(M):
    slist.append(list(map(int,input().split())))
ans=["0"]*N


for i in range(len(slist)):
    #print("i",i)
    if ans[slist[i][0]-1] == "0":
        ans[slist[i][0]-1] = slist[i][1]
    elif ans[slist[i][0]-1] == slist[i][1]:
        continue
    else:
        ans=["-1"]
        break

#print(ans)

if N>=2:
    if ans[0]=="0":
        ans[0]=1
    elif ans[0]==0:
        ans=["-1"]


    
for i in range(len(ans)):
    if ans[i]=="0":
        ans[i]=0

print(*ans,sep=(""))
s=list(int(input()))
s=s.sorted()
print(s[1]-s[0])

### FIXED CODE ###

s=list(map(int,input().split()))
s.sort()
print(s[2]-s[0])
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

ans = sum(a[1:2*n+1:2])
print(ans)


### FIXED CODE ###

x = int(input())
x += 1

ans = 9 * (len(str(x))-1) + int(str(x)[0])-1
print(ans)
N, K = map(int, input().split())
items = []
neta = {}
for _ in range(N):
    t, d = tuple(map(int, input().split()))
    items.append((t, d))

    if t not in neta:
        neta[t] = d
    else:
        tmp = neta[t]
        if d > tmp:
            neta[t] = d

neta = sorted(neta.items(), key=lambda x: -x[1])
items = sorted(items, key=lambda x: -x[1])

ans1 = 0
select1 = set()
for i in range(K):
    t, d = items[i]
    select1.add(t)
    ans1 += d
ans1 += len(select1) ** 2

ans2 = 0
select2 = set()
cnt = 0
for k, v in neta:
    cnt += 1
    select2.add(k)
    ans2 += v
    if cnt == K:
        ans2 += cnt ** 2
        print(max(ans1, ans2))
        exit()
ans2 += cnt ** 2
remain = K - cnt
i = 1
sel = set()
while remain != 0:
    t, d = items[i]
    if t not in sel:
        ans2 += d
        sel.add(t)
        remain -= 1
    else:
        i += 1
        sel.add(t)
print(max(ans1, ans2))


### FIXED CODE ###

N, K = map(int, input().split())
umai = {}
mazui = []
for _ in range(N):
    t, d = map(int, input().split())
    if t not in umai:
        umai[t] = d
    else:
        tmp = umai[t]
        if tmp < d:
            umai[t] = d
            mazui.append((t, tmp))
        else:
            mazui.append((t, d))

umai = sorted(umai.items(), key=lambda x: -x[1])
mazui = sorted(mazui, key=lambda x: -x[1])


umai_len = len(umai)
mazui_len = len(mazui)

acc_umai = [0 for _ in range(umai_len)]
acc_umai[0] = umai[0][1]
for i in range(umai_len - 1):
    acc_umai[i + 1] = acc_umai[i] + umai[i + 1][1]

acc_mazui = [0 for _ in range(mazui_len)]
if mazui_len > 0:

    acc_mazui[0] = mazui[0][1]
    for i in range(mazui_len - 1):
        acc_mazui[i + 1] = acc_mazui[i] + mazui[i + 1][1]
acc_mazui.insert(0, 0)

ans = []
for i in range(1, K + 1):
    if umai_len < i or mazui_len < K - i:
        continue
    ans.append(acc_umai[i - 1] + acc_mazui[K - i] + i ** 2)
print(max(ans))
import numpy as np
H,W = map(int,input().split())
S=np.array([list(input().rstrip("\n")) for _ in range(H)]) == '.'
D = np.zeros((H,W),dtype=int)
U = np.zeros((H,W),dtype=int)
L = np.zeros((H,W),dtype=int)
R = np.zeros((H,W),dtype=int)
for i in range(H):# 上下
  U[i] = (U[i-1] + 1) * S[i]
  D[-i-1] = (D[-i] + 1) * S[-i-1]
for i in range(W):# 左右
  L[:,i] = (L[:,i-1] + 1) * S[:,i]
  '''print(L[:,i-1] + 1)
  print(S[:,i])
  print(L[:,i])'''
  R[:,-i-1] = (R[:,-i] + 1) * S[:,-i-1]
print(np.max(U+D+L+R)-3)

### FIXED CODE ###

import numpy as np
H,W = map(int,input().split())
S=np.array([list(input().rstrip("\n")) for _ in range(H)]) == '.'
D = np.zeros((H,W),dtype=int)
U = np.zeros((H,W),dtype=int)
L = np.zeros((H,W),dtype=int)
R = np.zeros((H,W),dtype=int)
for i in range(H):# 上下
  U[i] = (U[i-1] + 1) * S[i]
  D[-i-1] = (D[-i] + 1) * S[-i-1]
for i in range(W):# 左右
  L[:,i] = (L[:,i-1] + 1) * S[:,i]
  R[:,-i-1] = (R[:,-i] + 1) * S[:,-i-1]
print(np.max(U+D+L+R)-3)
a, b, h = [int(input()) for _ in range(3)]
  print((a+b)*h / 2)


### FIXED CODE ###

a, b, h= (int(input()) for _ in range(3))
print((a+b)*h // 2)
def sup(A, j):
	if A[0] >= j:
		return 0
	l = 0
	r = len(A) - 1
	while True:
		i = (l+r) // 2
		if i == len(A) - 1 and A[i] < j:
			return len(A)
		elif A[i]<j and A[i+1]>=j:
			return i+1
		else:
			if A[i] >= j:
				r = i-1
			else: # A[i+1] < j
				l = i+1		
​
def inf(A, j): 
    if A[-1] <= j:
        return 0
    l = 0
    r = len(A) - 1
    while True:
        i = (l+r) // 2
        if i == 0 and A[i]>j:
            return len(A)
        elif A[i]>j and A[i-1]<=j:
            return len(A)-i
        else:
            if A[i] <= j:
                l = i+1
            else: # A[i-1] > j
                r = i-1		

N = int(input())
[A, B, C] = [sorted([int(i) for i in input().split()]) for j in range(3)]
ans = 0
for j in B:
	ans += sup(A, j) * inf(C, j)
print(ans)

### FIXED CODE ###

import sys
input=sys.stdin.readline
from bisect import bisect_right, bisect_left
n=int(input())
a = [list(map(int, input().split())) for _ in range(3)]
a[0].sort()
a[2].sort()



cnt=0
for i in range(n):
    index_1 = bisect_left(a[0],a[1][i])
    index_2 = n-bisect_right(a[2],a[1][i])
    cnt+=index_1*index_2
print(cnt)
input_str = row_input()

translate_num = int("input_str")**

print("translate_num\n")

### FIXED CODE ###

input_str = input()

translate_num = (int(input_str))**3

print(translate_num)
a=int(input())
b=str(input())
if a>=3200:
	print(s)
else:
	print('red')

### FIXED CODE ###

a=int(input())
s=str(input())
if a>=3200:
	print(s)
else:
	print('red')
args = input().split(" ")
if args[0]*args[1]%2 == 0:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

args = input().split()
if ( int(args[0]) * int(args[1]) ) % 2 == 0:
  print("No")
else:
  print("Yes")
n,h=map(int, input().split())
a=[]
b=[]
for i in range(n):
    ai,bi=map(int, input().split())
    a.append(ai)
    b.append(bi)
b=sorted(b,reverse=True)
amax=max(a)
newb=[b[i] for i in range(n) if b[i]>amax]
from itertools import accumulate
newb=list(accumulate(newb))
ans=0
for i in range(len(newb)):
    if newb[i]>=h:
        ans=i+1
        break
if ans==0:
    ans+=len(newb)
    ans+=(h-max(newb))//amax
    if (h-max(newb))%amax>0:
        ans+=1
print(ans)

### FIXED CODE ###

n,h=map(int, input().split())
a=[]
b=[]
for i in range(n):
    ai,bi=map(int, input().split())
    a.append(ai)
    b.append(bi)
b=sorted(b,reverse=True)
amax=max(a)
newb=[0]
for i in range(n):
    if b[i]>amax:
        newb.append(b[i])
from itertools import accumulate
newb=list(accumulate(newb))
ans=0
for i in range(len(newb)):
    if newb[i]>=h:
        ans=i
        break
if ans==0:
    ans+=len(newb)-1
    ans+=(h-max(newb))//amax
    if (h-max(newb))%amax>0:
        ans+=1
print(ans)
# input
A = int(input())
B = int(input())

ans = (A - 1) * (B - 1)
print(ans)

### FIXED CODE ###

# input
A, B = map(int, input().split())

ans = (A - 1) * (B - 1)
print(ans)
H, N = input().split(" ")
A = input()
A = [int(a) for a in A]
if sum(A) < H:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

H, N = input().split(" ")
A = list(map(int, input().split()))
if sum(A) < int(H):
  print("No")
else:
  print("Yes")
a = int(input())
print(a + a ** 2 + a *** 3)

### FIXED CODE ###

a = int(input())
print(a + a ** 2 + a ** 3)
N=int(input())
S=str(input())
K=int(input())
s=list(S)
t=s[K]
a=''
for i in range(N):
  if s[i]!=t:
    s[i]='*'
  a+=s[i]
print(a)

### FIXED CODE ###

N=int(input())
S=str(input())
K=int(input())
s=list(S)
t=s[K-1]
a=''
for i in range(N):
  if s[i]!=t:
    s[i]='*'
  a+=s[i]
print(a)
N, T = map(int,input().split())
cost=float('inf')
for i in range(N):
  c,t=map(int,input().split())
  if T>=t:
    cost = min(cost,c)
  if cost==float('inf'):
    cost='TLE'
print(cost)

### FIXED CODE ###

N, T = map(int,input().split())
cost=float('inf')
for i in range(N):
  c,t=map(int,input().split())
  if T>=t:
    cost = min(cost,c)
  if i==N-1 and cost==float('inf'):
    cost='TLE'
print(cost)
X,A = map(int,imput().split())
if X <A:
  print("0")
else:
  print("10")
  


### FIXED CODE ###

X,A = map(int,input().split())
if X <A:
  print("0")
else:
  print("10")
x = input()
print(3 * x ** 2)

### FIXED CODE ###

x = int(input())
print(3 * x ** 2)
a, b, c = input().split()
if a[len(a)] == b[0] and b[len(b)] == c[0]:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

a, b, c = input().split()
if a[len(a)-1] == b[0] and b[len(b)-1] == c[0]:
    print("YES")
else:
    print("NO")
a, b = input().split()


if a > b:
    print('>')
elif a < b:
    print('<')
else: print('=')

### FIXED CODE ###

a, b = input().split()

if a > b:
    print('>')
elif a < b:
    print('<')
else:
    print('=')
N = int(input())
H = list(map(int, input().split()))
L = []
a = 0
for i in range(a,N-1):
    n = 0
    for j in range(i,N):
        if j == N-1:
            L.append(n)
            break
        elif H[j] >= H[j+1]:
            n += 1
        else:
            L.append(n)
            a += n+1
            break
print(max(L))

### FIXED CODE ###

N = int(input())
H = list(map(int, input().split()))
c = 0
ans = 0
for i in range(N-1):
    if H[i] >= H[i+1]:
        c += 1
    else:
        c = 0
    ans = max(ans,c)
print(ans)
import sys
input = sys.stdin.readline
from functools import reduce
from itertools import starmap
from operator import xor, mul
N = int(input())
A = list(map(int ,input().strip()))

def solve(A):
    A = [abs(x-y) for x,y in zip(A,A[1:])]
    n = len(A)
    coef = 1
    for i in range(n-1):
        coef = coef ^ (coef << 1)
    coef = map(int, bin(coef)[2:])
    if 1 in A:
        B = [x % 2 for x in A]
        ans = reduce(xor, starmap(mul, zip(B,coef)))
    else:
        B = [x // 2 for x in A]
        coef = [nCr(n-1,i) for i in range(n)]
        ans *= 2
    return ans 

print(solve(A))


### FIXED CODE ###

import sys
input = sys.stdin.readline
from functools import reduce
from itertools import starmap
from operator import xor, mul
N = int(input())
A = list(map(int ,input().strip()))

A = [abs(x-y) for x,y in zip(A,A[1:])]
n = len(A)
# Lucas
coef = [((n-1)&k)==k for k in range(n)]
if 1 in A:
    B = [x % 2 for x in A]
    ans = reduce(xor, starmap(mul, zip(B,coef)))
else:
    B = [x // 2 for x in A]
    ans = reduce(xor, starmap(mul, zip(B,coef)))*2

print(ans)
R=input()
import math
r=2*math.pi*R
print(R)

### FIXED CODE ###

R=int(input())
r=2*3.14159265358979*R
print(r)
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0

for i in range(A + 1):
  for j in range(B + 1):
    if X - i * 500 - j * 100 % 50 == 0 and X - i * 500 - j * 100 <= 50 * C
        cnt += 1
        
print(cnt)

### FIXED CODE ###

A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0

workX = X

for i in range(A + 1):
    if workX > 500 * i:
        workX -= 500 * i
    elif workX == 500 * i:
        cnt += 1
        continue
    else:
        break

    for j in range(B + 1):
        if workX > 100 * j:
            workX -= 100 * j
        elif workX == 100 * j:
            cnt += 1
            break
        else:
            break

        if workX % 50 == 0 and workX <= 50 * C:
            cnt += 1
            workX += 100 * j
            continue
        else:
            workX += 100 * j

    workX = X


print(cnt)
import math
from functools import reduce
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n=int(input())
l=list(map(int,input().split()))
a=lcm_list(l)
ans_l = []
for i in l:
    ans_l.append(a/i)
print(int(sum(ans_l)%(10**9+7)))

### FIXED CODE ###

import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n=int(input())
l=list(map(int,input().split()))
a=lcm_list(l)
ans_l = []
for i in l:
    ans_l.append(a//i)
print(int(sum(ans_l)%(10**9+7)))
s = input()
if s == "Sunny":
    print("Cloudy")
else if s == "Cloudy":
    print("Rainy"):
else:
    print("Sunny")

### FIXED CODE ###

s = input()
d = {"Sunny": "Cloudy", "Cloudy": "Rainy",  "Rainy": "Sunny"}
print(d[s])
for i in range(10000):
    j = (int)input()
    if j == 0:
        break
    print("Case {0}: {1}".format(i, j))

### FIXED CODE ###


for i in range(1,100000):
    str = input()
    if str is "0":
        break
    print("Case {0}: {1}".format(i, str))
    i += 1
def main():
    N,K=map(int,input().split())
    h=list(map(int,input().split()))
    ans=[0]*N
    ans[1]=ans(h[1]-h[0])
    for i in range(2,N):
        ans[i]= min(abs(h[i]-h[j])+ans[j] for j in range(max(0,i-K),i))
    print(ans[-1])
main()

### FIXED CODE ###

def main():
    N,K = map(int,input().split())
    h = list(map(int,input().split()))
    dp = [0]*N
    for i in range(1,N):
        dp[i]= min(abs(h[i]-h[j])+dp[j] for j in range(max(0,i-K),i))
    print(dp[-1])
main()
n = int(input())
h = list(map(int,input().split(" ")))

plsl = []
plsn = 0
for i in range(n-1):
    if h[i]>= h[i+1] and i == n-2:
        plsn += 1
        # print(plsn)
        plsl.append(plsn)
        # print(plsl)
    elif h[i]>= h[i+1] and i < n-2:
        plsn += 1
        # print(plsn)
    else:
        plsl.append(plsn)
        # print(plsl)
        plsn = 0
        # print(plsn)
plsl.sort(reverse = True)
print(plsl[0])

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
answer = -1#これなに
m = 0#カウントするやつやね
for i in range(n-1):
    if h[i] >= h[i+1]:
        m += 1
    else:
        answer = max(answer,m)
        m = 0
answer = max(answer,m)
print(answer)
n = int(input())

a = [i for in range(1, n+1)]
b = sum(a)
  
print(a)
  

### FIXED CODE ###

n = int(input())

a = []
a = [i for i in range(1, n+1)]
print(sum(a))
n,a = map(int,input().split())
print(n*n-a)

### FIXED CODE ###

n=int(input())
a=int(input())
print(n**2-a)
v, c=list(map(int, input().split()))
n=int(input())
s=0
for i in range(n):
  if v[i]-c[i]>0:
    s=s+v[i]-c[i]
print(s)

### FIXED CODE ###

n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

s = 0
for i in range(n):
  if v[i] - c[i] >= 0:
    s += v[i] - c[i]
  else:
    continue
print(s)
H = int(input())
W = int(input())
h = int(input())
w = int(input())
print((H-h)*(W-w))

### FIXED CODE ###

import numpy as np
H,W = map(int, input().split())
h,w = map(int, input().split())
print((H-h)*(W-w))
a = list(map(int, input().split()))
n = []
for i in range(len(a)):
  if a[i] % 2 == 0: n.append(i+1)
if len(n) == 3:
  a.sort()
  ans = (a[2] - a[0]) // 2 + (a[2] - a[1]) // 2
elif len(n) == 2:
  N = 3 - sum(n) - 1 #奇数のインデックス
  ans = 0
  if a[N] != max(a):
    while a[N] < max(a):
      a[N] += 2
      ans += 
  a.sort()
  ans += (a[1] - a[0]) // 2 + a[2] - a[1]
else:
  a.sort()
  ans = (a[2] - a[0]) // 2 + (a[2] - a[1]) // 2
print(ans)

### FIXED CODE ###

a = list(map(int, input().split()))
n = []
for i in range(len(a)):
  if a[i] % 2 == 0: n.append(i+1)
if len(n) == 3:
  a.sort()
  ans = (a[2] - a[0]) // 2 + (a[2] - a[1]) // 2
elif len(n) == 2:
  N = 3 - sum(n) - 1 #奇数のインデックス
  ans = 0
  if a[N] != max(a):
    while a[N] < max(a):
      a[N] += 2
      ans += 1
  a.sort()
  ans += (a[1] - a[0]) // 2 + a[2] - a[1]
elif len(n) == 1:
  for i in range(len(a)):
    if a[i] % 2 != 0:
      a[i] += 1
  a.sort()
  ans = (a[2] - a[0]) // 2 + (a[2] - a[1]) // 2 + 1
else:
  a.sort()
  ans = (a[2] - a[0]) // 2 + (a[2] - a[1]) // 2
print(ans)
N,S = [int(x) for x in input().split()]
a=max(N,S)
b=min(N,S)
c=0
for i in range(min): c+=a*10**i
print(c)

### FIXED CODE ###

N,S = [int(x) for x in input().split()]
a=max(N,S)
b=min(N,S)
c=0
for i in range(a): c+=b*10**i
print(c)
a = list(map(int,input().split()))

print(np.max(a) * 9 + np.sum(a))

### FIXED CODE ###

import numpy as np

a = list(map(int,input().split()))
print(np.max(a) * 9 + np.sum(a))
import itertools
n=int(input())
a=tuple(map(int,input().split()))
b=tuple(map(int,input().split()))
lst=[i for i in itertools.permutations(range(1,n+1))]
cnt=0
for i in lst:
  if a==i:
    a=cnt
  elif b==i:
    b=cnt
  cnt+=1
print(abs(a-b))

### FIXED CODE ###

import itertools
n=int(input())
a=tuple(map(int,input().split()))
b=tuple(map(int,input().split()))
lst=[i for i in itertools.permutations(range(1,n+1))]
cnt=0
for i in lst:
  if a==i:
    a=cnt
  if b==i:
    b=cnt
  cnt+=1
print(abs(a-b))
import sys
while True:
 h,w=map(int,raw_input().split())
 for i in range(0,h):
  for j in range(0,w):
  
   if (i+j)%2==0:sys.stdout.write("#")
   else :sys.stdout.write(".")
  
  print ""
 print ""

### FIXED CODE ###

import sys
while True:
 h,w=map(int,raw_input().split())
 if h==0 and w==0:break
 for i in range(0,h):
  for j in range(0,w):
  
   if (i+j)%2==0:sys.stdout.write("#")
   else :sys.stdout.write(".")
  
  print ""
 print ""
N=input()
A=input()
B=input()
i=((A+B)*(10**100)//N)*A
if ((A+B)*(10**100))%N>A:
    i=i+A
else:
    i=i+((A+B)*(10**100)%N)
print(i)


### FIXED CODE ###

N,A,B=map(int,input().split())
i=(N//(A+B))*A
if N%(A+B)>A:
    i=i+A
else:
    i=i+(N%(A+B))
print(i)
from sys import stdin
S = stdin.readline().rstrip()
n = len(S)
def dfs(i, f):
    if i = n-1:
        return sum(list(map(int, f.split('+'))))
    return dfs(i+1, f + S[i + 1]) + dfs(i + 1, f + '+' + s[i-1])
print(dfs(0, S[0]))


### FIXED CODE ###

from sys import stdin
S = stdin.readline().rstrip()
n = len(S)
def dfs(i, f):
    if i == n-1:
        return sum(list(map(int, f.split('+'))))
    return dfs(i+1, f + S[i + 1]) + dfs(i + 1, f + '+' + S[i+1])
print(dfs(0, S[0]))
N, K = map(int, input().split())
Pn = list(map(int, input().split()))

Pn.sort()
sum = 0
for i in range(K):
	sum += Pn[K]

print(sum)

### FIXED CODE ###

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

P.sort()
s = 0
for i in range(K):
	s += P[i]

print(s)
s = rawinput()
res = 0
cur = 0
for i in s:
  if i =='S':
    cur = 0
  else:
    cur += 1
  res = max(cur, res)
print(res)

### FIXED CODE ###

s = input()
res = 0
cur = 0
for i in s:
  if i =='S':
    cur = 0
  else:
    cur += 1
  res = max(cur, res)
print(res)
N = int(input())
line1 = list(map(int, input().split()))
line2 =[]

for i in range(len(line1) - 1):
    #print(str(i)+ "番目")
    a = 0
    for j in range(len(line1) - i - 1):
        #print(str(j)+"ばんめ")
        #print(line1[i+j],line1[i+j+1])
        if line1[i+j] >= line1[i+j+1]:
            a += 1
        else:
          #  print( "a=" + str(a))
         #   print()
            line2.append(a)
            break
        #print( "a=" + str(a))
       # print()
        line2.append(a)

print(max(line2))

### FIXED CODE ###

N = int(input())
line1 = list(map(int, input().split()))
a,max = 0,0
for i in range(len(line1) - 1):
    if line1[i] >= line1[i+1]:
        a += 1
        if max < a:
            max = a
            
    else:
        a = 0
        
print(max)